SESSION?

If you've downloaded the FAF sourcecode, and have question, please leave them here.
Post Reply
alexandarciric
Member
Posts: 16
Joined: Mon Mar 19, 2007 9:43 pm

Post by alexandarciric »

I need help to instal chat in the game....

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);
}

?>
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

That seems to be a completely unrelated bit of code, not to mention it uses flat files to store user info...
:wq
alexandarciric
Member
Posts: 16
Joined: Mon Mar 19, 2007 9:43 pm

Post by alexandarciric »

thenx
Post Reply
  • Members connected in real time

    🔒 Close the panel of connected members