this is code, but i not have idea, about sessions....please help me...
code: Select all
<?php
include('settings.php');
// Quote variable to make safe
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
// Connect
$link = mysql_connect($dbhost, $dbuser, $dbpass)
or die('SQL Greška!');
mysql_select_db($dbname);
mysql_query("SET NAMES 'cp1250'");
// Make a safe query
$query = sprintf("SELECT * FROM $playerdb WHERE username=%s AND password=%s",
quote_smart($_COOKIE['usernamecookie']),
quote_smart($_COOKIE['passwordcookie']));
$users = false;
if (isset($_COOKIE['passwordcookie']))
{
$users = mysql_fetch_array(mysql_query($query));
}
if (!$users['empire'])
{
die('Greška!');
}
//----------------------------------------------------------
//
$trans2 = array('&' => '&',
'<' => '<',
'>' => '>',
'"' => '"'
);
// Sebian chars in nickname.
$trans = array('æ' => '__u0107',
'è' => '__u010d',
'Å¡' => '__u0161',
'ð' => '__u0111',
'ž' => '__u017e',
'Æ' => '__u0106',
'È' => '__u010c',
'Å ' => '__u0160',
'Ã?' => '__u0110',
'Ž' => '__u017d',
);
$userid = strtr($users['empire'], $trans2);
$userid = strtr($users['empire'], $trans);
$userid = rawurlencode($userid);
$userid = str_replace('__u0', '%u0', $userid);
$password = @$_POST['p'];
$uid = rand(100000000,1000000000);
//read in userlist
$file = @file_get_contents($users_file);
if( strpos($file, ',' . $userid . "\n") === false )
{
// append the username
$fp = @fopen($users_file, 'a');
fwrite($fp, $uid . ',' . $userid . "\n");
@fclose($fp);
$temp = @fopen($path_to_chat.'posttext.php?u='.$admin_id.'&t='.$userid.'%20usao','r');
@fclose($temp);
header('Location: chat.html?'.$uid);
} else {
$f_arr = explode("\n", $file);
while(list(, $val) = each($f_arr))
{
if (($pos = strpos($val, ',' . $userid)) !== false)
{
$uid = substr($val, 0, $pos);
break;
}
}
header('Location: chat.html?'.$uid);
}
?>