Protege
18-04-2008, 01:01 PM
It's really the one area I'm not so sure in so I want to post my way, and then you can express your ways and how you do it, then what I can do to improve on mine.
Setting sessions;
function setSession($username, $host, $ip, $id) {
$time = date("dmogi");
$_SESSION["x"] = $username;
$_SESSION["xx"] = encrypt($username);
$_SESSION["xxx"] = $host;
$_SESSION["xxxx"] = encrypt($host);
$_SESSION["xxxxx"] = $ip;
$_SESSION["xxxxxx"] = encrypt($ip);
$_SESSION["xxxxxxx"] = $time;
$_SESSION["xxxxxxxx"] = encrypt($time);
mysql_query("UPDATE `users` SET `host` = '".$host."',
`hoste` = '".encrypt($host)."',
`ip` = '".$ip."',
`ipe` = '".encrypt($ip)."',
`time` = '".$time."',
`timee` = '".encrypt($time)."' WHERE `users`.`id` = '".$id.'" LIMIT 1;");
}
To check the Session;
function checkSession($id) {
$time_plus = $_SESSION["xxxxxxx"];
$time_expire = date("dmogi");
$time_new = $time_plus - $time_expire;
if($time_new < 30) {
if(encrypt($_SESSION["x"]) == $_SESSION["xx"]) {
if(encrypt($_SESSION["xxx"]) == $_SESSION["xxxx"]) {
if(encrypt($_SESSION["xxxxx"]) == $_SESSION["xxxxxx"]) {
if(encrypt($_SESSION["xxxxxxx"]) == $_SESSION["xxxxxxxx"]) {
$query = mysql_query(" SELECT * FROM `users` WHERE `username` = CONVERT( _utf8 '".$_SESSION["x"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `host` = CONVERT( _utf8 '".$_SESSION["xxx"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `hoste` = CONVERT( _utf8 '".$_SESSION["xxxx"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `ip` = CONVERT( _utf8 '".$_SESSION["xxxxx"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `ipe` = CONVERT( _utf8 '".$_SESSION["xxxxxx"]."' USING latin1 ) COLLATE latin1_swedish_ci LIMIT 0 , 30");
$rows = mysql_num_rows($query);
if($rows == 0) {
return false;
} elseif($rows > 0) {
$time = date("dmogi");
$_SESSION["xxxxxxx"] = $time;
$_SESSION["xxxxxxxx"] = encrypt($time);
mysql_query("UPDATE `users` SET `time` = '".$time."',
`timee` = '".encrypt($time)."' WHERE `users`.`id` = '".$id."' LIMIT 1;");
return true; }
} else { return false; }
} else { return false; }
} else { return false; }
} else { return false; }
} else { return false; }
}
Your views and comments are appreciated & your way be nice to see too.
Thread moved from Website Staff by --ss-- (Forum Super Moderator): Moved to the correct location :).
Setting sessions;
function setSession($username, $host, $ip, $id) {
$time = date("dmogi");
$_SESSION["x"] = $username;
$_SESSION["xx"] = encrypt($username);
$_SESSION["xxx"] = $host;
$_SESSION["xxxx"] = encrypt($host);
$_SESSION["xxxxx"] = $ip;
$_SESSION["xxxxxx"] = encrypt($ip);
$_SESSION["xxxxxxx"] = $time;
$_SESSION["xxxxxxxx"] = encrypt($time);
mysql_query("UPDATE `users` SET `host` = '".$host."',
`hoste` = '".encrypt($host)."',
`ip` = '".$ip."',
`ipe` = '".encrypt($ip)."',
`time` = '".$time."',
`timee` = '".encrypt($time)."' WHERE `users`.`id` = '".$id.'" LIMIT 1;");
}
To check the Session;
function checkSession($id) {
$time_plus = $_SESSION["xxxxxxx"];
$time_expire = date("dmogi");
$time_new = $time_plus - $time_expire;
if($time_new < 30) {
if(encrypt($_SESSION["x"]) == $_SESSION["xx"]) {
if(encrypt($_SESSION["xxx"]) == $_SESSION["xxxx"]) {
if(encrypt($_SESSION["xxxxx"]) == $_SESSION["xxxxxx"]) {
if(encrypt($_SESSION["xxxxxxx"]) == $_SESSION["xxxxxxxx"]) {
$query = mysql_query(" SELECT * FROM `users` WHERE `username` = CONVERT( _utf8 '".$_SESSION["x"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `host` = CONVERT( _utf8 '".$_SESSION["xxx"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `hoste` = CONVERT( _utf8 '".$_SESSION["xxxx"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `ip` = CONVERT( _utf8 '".$_SESSION["xxxxx"]."' USING latin1 ) COLLATE latin1_swedish_ci AND `ipe` = CONVERT( _utf8 '".$_SESSION["xxxxxx"]."' USING latin1 ) COLLATE latin1_swedish_ci LIMIT 0 , 30");
$rows = mysql_num_rows($query);
if($rows == 0) {
return false;
} elseif($rows > 0) {
$time = date("dmogi");
$_SESSION["xxxxxxx"] = $time;
$_SESSION["xxxxxxxx"] = encrypt($time);
mysql_query("UPDATE `users` SET `time` = '".$time."',
`timee` = '".encrypt($time)."' WHERE `users`.`id` = '".$id."' LIMIT 1;");
return true; }
} else { return false; }
} else { return false; }
} else { return false; }
} else { return false; }
} else { return false; }
}
Your views and comments are appreciated & your way be nice to see too.
Thread moved from Website Staff by --ss-- (Forum Super Moderator): Moved to the correct location :).