Author Topic: CSVEdit - Logout Button  (Read 2578 times)

0 Members and 1 Guest are viewing this topic.

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
CSVEdit - Logout Button
« on: March 22, 2007, 10:20:14 AM »
Does anyone know a hack or someway to delete out the cookie set when logged into csvedit? I would like to setup a "Logout" link or button. Any ideas?
Uniting Bands
www.unitingbands.com

Offline Paul

  • Hero Member
  • *****
  • Posts: 162
Re: CSVEdit - Logout Button
« Reply #1 on: March 22, 2007, 08:49:52 PM »
This little php script should do it Aaron,

Just link to it from your edit template & change the "Logged Out" message to reflect what you want.

(Just tested...it works. The cookie name is USER_Login)

<?php
$time = time();

if (isset($_COOKIE['USER_Login']))
 {
  setcookie ("USER_Login", "", $time - 3600);
 echo "Logged Out<br><a href=\"http://www.mysite.com\">Click here</a> to return to the Homepage";
}

?>

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: CSVEdit - Logout Button
« Reply #2 on: March 23, 2007, 07:27:57 AM »
Thanks Paul. Since my edit template is not a php page will this still work?
Uniting Bands
www.unitingbands.com

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: CSVEdit - Logout Button
« Reply #3 on: March 23, 2007, 09:57:42 AM »
I have not experimented with using a php page as a template believe it or not.  But to try it....  Just slide in Paul's code exactly how it is, where ever you want the logout link.  Then resave your template as a .php page.  Change it in the script and see if the script will accept it as a php.  I have a sneaky suspiscion it may not, but if not, there may still be a work around we could try.

Jason
Founder of www.slipdex.com

Offline Paul

  • Hero Member
  • *****
  • Posts: 162
Re: CSVEdit - Logout Button
« Reply #4 on: March 23, 2007, 06:02:03 PM »
In my test I just saved the php code in a file called "ez_edit_logout.php"

Then from the top of the edit template I created a link like this
<a href="http://www.mysite.com/ez_edit_logout.php">Logout</a>


When the php script is executed you get the message "Logged Out" with a link back to your homepage.

I'm pretty sure you cannot execute php from within the template itself (unless you are using frames / iframes).
« Last Edit: March 23, 2007, 06:21:53 PM by Paul »

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: CSVEdit - Logout Button
« Reply #5 on: March 23, 2007, 10:47:26 PM »
Geez Paul, I never even thought of using it like that!  Man you are on fire lately with the solutions!

Jason
Founder of www.slipdex.com

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: CSVEdit - Logout Button
« Reply #6 on: March 24, 2007, 12:25:55 PM »
This one is moving to tips&tricks ;)

Offline Paul

  • Hero Member
  • *****
  • Posts: 162
Re: CSVEdit - Logout Button
« Reply #7 on: March 26, 2007, 02:15:01 AM »
This would be better built directly into the perl script EZ ... maybe for a future version?

Also, at present the username & password are visible in the session cookie. Would be nice to have the password at least encrypted.

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: CSVEdit - Logout Button
« Reply #8 on: March 26, 2007, 09:24:18 AM »
Not sure what is going on, maybe some php issues but I can't get this logout script to work.

I have the php file link in my edit template and it does take me to the logged out php page when clicked. The link I have on the php page is to go right back into  my edit script for testing and it lets me back in without prompting for a password everytime.

any ideas on this?

Uniting Bands
www.unitingbands.com

Offline Paul

  • Hero Member
  • *****
  • Posts: 162
Re: CSVEdit - Logout Button
« Reply #9 on: March 27, 2007, 06:16:57 AM »
Hmmm.
maybe try the following.

1. The url back to your edit script ...make sure it is an absolute url making a new http request.

2. Don't put the php file in your cgi-bin

3. There is a chance that you are using a version of the csvedit that uses a different cookie name (I don't think so though)

A great way for checking cookies & their values is by installing the webdeveloper toolbar for firefox.
http://chrispederick.com/work/webdeveloper/

4. try this code instead

<?php
// set the expiration date to one hour ago
setcookie("USER_Login", "", time()-3600);
echo "Logged Out<br><a href=\"http://www.mysite.com\">Click here</a> to return to the Homepage";
?>




Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: CSVEdit - Logout Button
« Reply #10 on: March 27, 2007, 09:44:54 AM »
Ok, I think I got it! The php script had to be in the root directory of the server. Before I had it in another folder(not the cgi-bin). Seems to work great, thanks Paul.
Uniting Bands
www.unitingbands.com

Offline irocwebs

  • Jr. Member
  • **
  • Posts: 24
    • Iroc Web Design Services
Re: CSVEdit - Logout Button
« Reply #11 on: July 30, 2013, 03:09:45 PM »
I have the logout function implemented directly into the CSVedit script. Here is how:

HACK: Use at your own risk. Make a backup of your script(s) before making any changes.

In your CSVedit template (the one you specified in the csvedit.pl file here: my $template = "edit-template.htm"; ) between the <body></body> tags, add and adjust the path to your script. This could technically be added to the csvedit.pl file if you wanted to find a place for it.:
Code: [Select]
<a href="/cgi-bin/csvedit.pl?logoff=1">Log Off</a>
In the csvedit.pl file (around line 138ish) immediately following:
Code: [Select]
elsif($COOKIES{pass} ne $Password or $COOKIES{login} ne $Username){promt();}
Add:
Code: [Select]
elsif($FORM{logoff}){
%COOKIES = expire_cookie('USER_Login');
}

Then around line 307ish immediatly following the sub get_cookie function:
Code: [Select]
sub get_cookie{
my %COOK;
@cookies=split('; ',$ENV{HTTP_COOKIE});
foreach $line (@cookies){
($c_name, $c_value) = split(/=/,$line,2);
if ($c_name eq $_[0]){
@cook=split(/&/,$c_value);
for($a=0; $a<@cook; $a+=2){
$cook[$a+1] =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$COOK{$cook[$a]}=$cook[$a+1];
}
}
}
return %COOK;
}

Add the following sub expire_cookie function:
Code: [Select]
sub expire_cookie{
my $time = time();
$time--;
print "Set-Cookie: USER_Login=1; expires=$time; path=/\n";
print "Location: $prog_name\n\n";
exit;
}

Hope it helps. Let me know if you have any questions.