TorrentFlux.com Welcome, Guest. Please login or register.
03-19-2010, 18:02:43
Home Help Search Login Register donate
TorrentFlux Home | TorrentFlux Hosting

+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.1 Hacks
| | |-+  "Remember me"
« previous next »
Pages: [1] Go Down Print
Author Topic: "Remember me"  (Read 2929 times)
darknite
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 39






View Profile WWW
« on: 04-07-2006, 18:51:50 »

Spotted this one on the features request topic, and knew I had it here..

courtesy of ihackstuff on the old forums

in login.php
find
Code:
// 2004-12-09 PFM: ADODB support.

and add below
Code:
$check = $HTTP_COOKIE_VARS["check"];
  $password = $HTTP_COOKIE_VARS["iamhim"];
  $username = $HTTP_COOKIE_VARS["username"];

  if ($_POST['check'] == "true")
  {
   setcookie("check", "true", time()+60*60*24*30);
   if ($_POST['username'] != "")
    setcookie("username", $_POST['username'], time()+60*60*24*30);
   if ($_POST['iamhim'] != "")
           setcookie("iamhim", $_POST['iamhim'], time()+60*60*24*30);
  }

further down find
Code:
// Check for user
 if(!empty($user) && !empty($iamhim))

and add above
Code:
if(empty($user)  && empty($iamhim) && !empty($username) && !empty($password))
 {
   $user = strtolower($username);
   $iamhim = addslashes($password);
 }

next find
Code:
         <td align="right">Username: </td>
         <td><input type="text" name="username" value="" size="15" style="font-family:verdana,helvetica,sans-serif; font-size:9px; color:#000;" /></td>

and replace with
Code:
         <td align="right">Username: </td>
         <td><input type="text" name="username" value="<?PHP if ($cfg['rememberme'] == "true") echo $username; ?>" size="15" style="font-family:verdana,helvetica,sans-serif; font-size:9px; color:#000;" /></td>

and a couple lines down replace
Code:
         <td align="right">Password:</td>
         <td><input type="password" name="iamhim" value="" size="15" style="font-family:verdana,helvetica,sans-serif; font-size:9px; color:#000" /></td>
</tr>
with
Code:
         <td align="right">Password:</td>
         <td><input type="password" name="iamhim" value="<?PHP if ($cfg['rememberme'] == "true") echo $password; ?>" size="15" style="font-family:verdana,helvetica,sans-serif; font-size:9px; color:#000" /></td>
        </tr>
        <?php
        if ($cfg['rememberme'] == "true")
        {
        echo '
        <tr>
         <td align="right">Remember me:</td>
         <td><input type="checkbox" name="check" value="true"'; if ($check == "true") echo " checked "; echo'size="15" style="font-family:verdana,helvetica,sans-serif; font-size:9px; color:#000" /></td>
        </tr>';
        }
        ?>

then in logout.php change
Code:
// do the SQL
$result = $db->Execute($sql);
showError($db, $sql);
}
to
Code:
// do the SQL
$result = $db->Execute($sql);
showError($db, $sql);

setcookie("check", "", 0);
setcookie("username", "", 0);
setcookie("iamhim", "", 0);
}
Logged

SERVER: Slackware-current | AMD Athlon 1Ghz | 512MB | Apache 1.3 | PHP 4.4.1 | MySQL 4.1.14 | TF 2.1 | NAS: AMD AthlonXP 2800+ | 1024MB| 1.12TB Storage | TF: 2.1 Mod/Hacks: Realname Links/Multi-upload/multi-search/Transfer stats/Cookied Login/Ajax Details
gringo
Full Member
***
Offline Offline

TF Base: Linux 1.x
Posts: 111





View Profile WWW
« Reply #1 on: 04-08-2006, 16:56:45 »

Sounds good, but after 2 tries with 2.1 Final this doesn't seem to work as-is.  Could you double check the code and instructions when you get a chance?

EDIT:  I found the problem.  You must also edit config.php to include:
Code:
$cfg["rememberme"] = "true";

Doh!
« Last Edit: 04-08-2006, 16:59:50 by gringo » Logged

P4 2.8 | CentOS-4.2 | 1024MB RAM | 10 mb/s Connect

Apache 2.0.52 | PHP 4.3.9 | MySQL 4.1.12 | Python 2.3.4

TF 2.1b4rt with cosmetic changes.
lysip
Jr. Member
**
Offline Offline

Posts: 53




View Profile
« Reply #2 on: 04-12-2006, 11:16:05 »

Find
Code:
        <tr>
            <td align="left" width="350" valign="top"><strong>Page Refresh (in seconds)</strong><br>
            Number of seconds before the torrent list page refreshes:
            </td>
            <td valign="top">
                <input name="page_refresh" type="Text" maxlength="3" value="<?php    echo($cfg["page_refresh"]); ?>" size="3">
            </td>
        </tr>
Add this below it
Code:
        <!-- R.D. -- nice setting for cookies -->
  <tr>
            <td align="left" width="350" valign="top"><strong>Enable Cookie Authentication</strong><br>
            When enabled, users will will stay logged in with a cookie:
            </td>
            <td valign="top">
                <select name="rememberme">
                        <option value="1">true</option>
                        <option value="0" <?php
                        if (!$cfg["rememberme"])
                        {
                            echo "selected";
                        }
                        ?>>false</option>
                </select>
            </td>
        </tr>

modify the mysql table like so:
Code:
INSERT INTO `tf_settings` VALUES ('rememberme','1');

now the setting to turn it on and off is in the config page  Grin
Logged

CentOS 4.2 (kernel: 2.6.9-22.ELsmp)
TorrentFlux version - 2.1
Python version - 2.4.1
PHP Version - 4.3.9
Webserver software and version - Apache 2.0
Add-ons/Hacks - rememberme, multiup
lysip
Jr. Member
**
Offline Offline

Posts: 53




View Profile
« Reply #3 on: 04-12-2006, 11:33:13 »

ok im having troubles:
when you say...

in login.php
find
Code:

// 2004-12-09 PFM: ADODB support.


and add below
Code:

 $check = $HTTP_COOKIE_VARS["check"];
  $password = $HTTP_COOKIE_VARS["iamhim"];
  $username = $HTTP_COOKIE_VARS["username"];

  if ($_POST['check'] == "true")
  {
   setcookie("check", "true", time()+60*60*24*30);
   if ($_POST['username'] != "")
    setcookie("username", $_POST['username'], time()+60*60*24*30);
   if ($_POST['iamhim'] != "")
           setcookie("iamhim", $_POST['iamhim'], time()+60*60*24*30);
  }


can you be more descriptive ont eh // 2004-12-09 PFM: ADODB support. part as there is nothing liek that and if you put that at the top of the page it wont work.
Logged

CentOS 4.2 (kernel: 2.6.9-22.ELsmp)
TorrentFlux version - 2.1
Python version - 2.4.1
PHP Version - 4.3.9
Webserver software and version - Apache 2.0
Add-ons/Hacks - rememberme, multiup
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile
« Reply #4 on: 04-12-2006, 11:51:22 »

here is my login.php
Logged

lysip
Jr. Member
**
Offline Offline

Posts: 53




View Profile
« Reply #5 on: 04-12-2006, 12:08:07 »

and that sets the cookie? i have yet to see my cookie set, maybe its a problem with my http server or php and not the code.

*EDIT*
Doh, i found my issue, with my addition of the mysql config and etc, all trues should be 1 and all falses be 0

work nicly now

*EDIT*
I'm not to big on the password being stored in plain text in the cookie, ill add some md5();s in there and post back later.
« Last Edit: 04-12-2006, 12:23:40 by lysip » Logged

CentOS 4.2 (kernel: 2.6.9-22.ELsmp)
TorrentFlux version - 2.1
Python version - 2.4.1
PHP Version - 4.3.9
Webserver software and version - Apache 2.0
Add-ons/Hacks - rememberme, multiup
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile
« Reply #6 on: 08-05-2006, 18:35:44 »

why doesn't this work with opera 9? it worked with 8.5x and it's working with IE:/
Logged

Pages: [1] Go Up Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Powered by PHP