<?
oB_start();
// allows you to use cookies.
include("config.php");
if (!$logged[username])
{
if (!$_POST[login])
{
echo("
<center><form method=\"POST\">
<table>
<tr>
<td align=\"right\">
Потребител: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
</td>
</tr>
<tr>
<td align=\"right\">
Парола: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
</td></tr><tr>
<td align=\"center\">
<input type=\"submit\" name=\"login\" value=\"Влез\">
</td></tr><tr>
<td align=\"center\">
<a href=\"register.php\">Регистрирай се</a>
</td></tr></table></form></center>");
}
if ($_POST[login]) {
// the form has been submitted. We continue...
$username=$_POST['username'];
$password = md5($_POST[password]);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM register WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Грешен потребител или парола!";
}else{
// the password was right!
$query = mysql_query("SELECT * FROM register WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
// gets the user's information
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=\"/>Вие успешно влязохте в акаунта си.");
// modify the above line...add in your site url instead of yoursite.com
}
}
}
else
{
// we now display the user controls.
echo ("<center>Добре дошли <b>$logged[username]</b><br /></center>
<a href=\"editprofile.php\">Промени профила си</a><br />
<a href=\"members.php\">Виж всички регистрирани потребители</a><br />
<a href=\"search.php\">Търси за потребители</a><br />
<a href=\"logout.php\">Излез от акаунта си</a>");
}
echo'<br><br>
Статистика:<br>';
$last = mysql_query("SELECT id, username FROM register ORDER BY id DESC LIMIT 1");
while($q=mysql_fetch_assoc($last)){
echo "<b>Последно регистриран:</b>
<a href='members.php?user=". $q['username'] ."'>".$q['username']."</a><br />";}
$register = mysql_query("SELECT count(id) as total FROM register");
while($c=mysql_fetch_array($register)){
echo "<b>Брой потребители:</b>" .$c['total']. ""; }
echo '<br>';
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$cutoff = 15; //online cut of time
$exists = 0;
$users = 0;
$user = "";
$fp = fopen ("online.txt","r+"); //if the file exists open it
while (!feof($fp))
{
$user[] = chop(fgets($fp,65536));
}
fseek($fp,0,SEEK_SET);
foreach ($user as $line)
{
list($oldip,$oldtime) = explode('|',$line);
if ($oldip == $ip) {$oldtime = $time;$exists = 1;} //check to see if the user is already in the text file
if ($time < $oldtime + ($cutoff * 60)) //see if the last time the user visited is past the cut off time
{
fputs($fp,"$oldip|$oldtime\n"); //write the old data to the text file
$users = $users + 1; // add one to the user count
}
}
if ($exists == 0) //if the user isn't in the text file already:
{
fputs($fp,"$ip|$time\n"); //write the new data to the text file
$users = $users + 1; //add one to the user count
}
fclose ($fp); //close the text file
print "<b>Online:</b> $users"; //display the number of users online
?>
<center>
<?PHP
$username=$logged[username];
$avatar = 'avatari/'.$username.'.gif';
if(empty($avatar)){
echo "<img src='avatari/nqma.jpg'>";
}
else {
echo "<img border=0 src=$avatar>";
} ?>
това е на логина