Advertisement
Advertisement
| 03.19.2008 at 10:43AM PDT, ID: 23254493 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: |
<?php
//login page
if (isset($_POST['submit']))
{
$uname = ($_POST['uname']);
$passwd = ($_POST['passwd']);
$remember_me = ($_POST['remember_user']);
// if form has been submitted
/* check they filled in what they were supposed to and authenticate */
$fd = fopen('/dev/urandom', 'r');
$tmp = fread($fd, 1000);
fclose($fd);
$site_uhash = md5($tmp);
if (isset($_POST['remember_user']))
{
$cookiedata = $_POST['uname']."|".md5($_POST['passwd'])."|".$site_uhash;
setcookie("autologin", $cookiedata, time() + 31536000);
}
if(!$_POST['uname'])
{
"";
}
else if(!$_POST['passwd'])
{
"";
}
// authenticate.
if (!get_magic_quotes_gpc())
{
$_POST['uname'] = addslashes($_POST['uname']);
}
$check = $db_object->query("SELECT users_id, username, password, userlevel, uhash, deluser_ FROM users WHERE username = '".$_POST['uname']."' AND deluser_ = '0'");
if (MDB2::isError($check) || $check->numRows() == 0)
{
//echo ('<span style="font-weight: bold; color: #691717;">väärä tunnus.</span>');
//echo ('<br/>');
}
$sqlquery = "select * FROM users WHERE username = '".$_POST['uname']."' AND deluser_ = '0'";
$result = mysql_query($sqlquery);
while ($row = mysql_fetch_array($result))
{
$count_float = $row['count_float'];
$float = $row['float_user'];
$count = $row['count_logons'];
}
$info = $check->fetchRow();
$count_add = $count+1;
if ($float == 1)
{
$count_float_add = $count_float + 1;
}
// check passwords match
$_POST['passwd'] = stripslashes($_POST['passwd']);
$info['password'] = stripslashes($info['password']);
$_POST['passwd'] = md5($_POST['passwd']);
if ($_POST['passwd'] != $info['password'])
{
//echo ('<span style="font-weight: bold; color: #691717;">väärä salasana.</span>');
//echo ('<br/>');
}
else
{
// if we get here username and password are correct,
//register session variables and set last login time.
$date = date('d.m.Y H.i');
// get userid from db query
$usersid_ = $info['users_id'];
$_SESSION['users_id'] = $usersid_;
$update_login = $db_object->query("UPDATE users SET count_logons='$count_add', uhash='$site_uhash', count_float='$count_float_add' WHERE username = '".$_POST['uname']."'");
$_POST['uname'] = stripslashes($_POST['uname']);
$_SESSION['site_uhash'] = $site_uhash;
$db_object->disconnect();
$goback ="http://www.toubes-page.net/td/user";
header ("Location: $goback");
}
}
?>
// Index.php page
<?php
require ('template.php');
include("db_connect.php");
include 'online_users/whosonlineupdate.php';
if (isset($_COOKIE['autologin']) && !isset($_SESSION['site_uhash']))
{
//this line checks that the cookie is set and the username session is not set (ie. the user has not yet been logged in and //they have the autologin cookie set).
$splitcookie = explode("|",$_COOKIE['autologin']);
$cookie_username = $splitcookie[0];
$cookie_password = $splitcookie[1];
$cookie_uhash = $splitcookie[2];
//the above code splits the data in the cookie so you have the user name in the first variable ($cookie_username) and the //password in the second ($cookie_password).
$query = "SELECT username, password, uhash FROM users WHERE username='$cookie_username' AND password='$cookie_password' AND uhash='$cookie_uhash' LIMIT 1;";
$logincookie = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($logincookie) < 1)
{
echo "Cookie Error - Auto Login Failed!<br>\n";
}
// $users_id = mysql_result($logincookie, 0, "users_id");
$site_uhash = mysql_result($logincookie, 0, "uhash");
$_SESSION['site_uhash'] = $site_uhash;
//$_SESSION['users_id'] = $users_id;
//In the above code you are using the results returned by the database to set the session vars up (like you would when you //handle the login normally), you may need to add some code here to set more data in sessions.
}
if ($logged_in == 0)
{
$goback ="http://www.toubes-page.net/td/index.php?id=cpanel&page=logout&logged_in=0";
header ("Location: $goback");
}
if (!isset($_SESSION['count']))
{
$_SESSION['count'] = 0;
//$count = $_SESSION['count'];
$_SESSION['session_start'] = time();
}
else
{
$_SESSION['count']++;
}
$session_timeout = 5; // 1 hr (in sec)
$session_duration = time() - $_SESSION['session_start'];
if ($session_duration > $session_timeout)
{
$goback ="http://www.toubes-page.net/td/index.php?id=cpanel&page=logout";
header ("Location: $goback");
}
$_SESSION['session_start'] = time();
require ('basepage.php');
basepage("main");
?>
|