<?php
error_reporting(0);
//----------
include ('inc/config.inc.php.php');
//----------
session_name('sid');
session_start();
//----------
connect_to_db();
include ('inc/autorize.php.php');
include ('inc/online.php.php');
//----------
// Удаляем IP и UA старее недели
@mysql_query("DELETE FROM `love_golos` WHERE `time` < ".(time() - 7 * 24 * 3600).";");
//----------
$partner = intval($_GET['partner']); if ($partner == 0) $partner = 1;
//----------
$arr = mysql_query("SELECT COUNT(*) FROM `love_partner`;");
$part_users = mysql_result($arr, 0);
if($partner > $part_users) $partner = 1;
//----------
$partner_arr = @mysql_query("SELECT * FROM `love_partner` WHERE `partner` = ".$partner." LIMIT 1;");
$row = @mysql_fetch_array($partner_arr);
$partner_site = $row['site'];
$partner_name = $row['name'];
//----------
$id = intval($_GET['user_id']);
//----------
function gen_sid($length) 
{ 
$sid = ""; 
$length = intval($length); 
$symbols = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 
for($i = 0; $i <= $length; $i++) 
{ 
$symbol = array_rand($symbols); 
$sid .= $symbols[$symbol]; 
}
return $sid; 
}
//----------
session_id();
session_start();
//-----------
$_SESSION['remote_addr'] = $REMOTE_ADDR;
$_SESSION['user_agent'] = $HTTP_USER_AGENT;
$_SESSION['uid'] = $id;
//----------
$sid = gen_sid(rand(8, 12));
//----------
$title = 'Голосовать';
include ('header.php');
echo $header;
if($mod == '1') echo '<p align="center"><small>';
if (!$autorize) {
echo $class_d2;
echo 'Ограничения...<br/>';
echo $class_divz.$class_d0;
if($mod == '1') {
echo '</small></p><p align="left"><small>';
echo '<u>Вы не можете общаться с другими пользователями, голосовать, смотреть и устанавливать фото!</u><br/>';
}
else
{
echo '<span style="color:#000000">Вы не можете общаться с другими пользователями, голосовать, смотреть и устанавливать фото!</span><br/>';
}
echo 'Возможные причины:<br/>';
echo '- Вы не зарегистрированы - <a href="http://'.$_SERVER['HTTP_HOST'].'/reg.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Регистрируйтесь</a><br/>';
echo '- Вы не вошли в систему - <a href="http://'.$_SERVER['HTTP_HOST'].'/auth.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Войти</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d0;
echo '&#171;- <a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Назад</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[7] <a href="http://'.$_SERVER['HTTP_HOST'].'/index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="7">Поиск</a> [8] <a href="http://'.$_SERVER['HTTP_HOST'].'/auth.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Вход</a> [9] <a href="http://'.$_SERVER['HTTP_HOST'].'/reg.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="9">Регистрация</a><br/>';
if($mod == '1') echo '</small></p><p align="center"><small>';
echo $class_divz.$class_d2;
echo $class_divz.$class_d2.$class_version.$class_divz.$class_div;
echo $class_endpage;
exit();
}

$sql = @mysql_query("SELECT * FROM `love_user` WHERE `id` = '".$id."' limit 1;");
if(mysql_affected_rows() == 0)
{
echo $class_d2;
echo 'Ошибка!<br/>';
echo $class_divz.$class_d0;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo 'Такой пользователь на сайте не зарегистрирован!<br/>';
echo $class_divz.$class_d0;
if($mod == '1') echo '---<br/>';
echo '&#171;- <a href="index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Назад</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[7] <a href="http://'.$_SERVER['HTTP_HOST'].'/index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="7">Поиск</a> [8] <a href="http://'.$_SERVER['HTTP_HOST'].'/auth.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Вход</a> [9] <a href="http://'.$_SERVER['HTTP_HOST'].'/reg.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="9">Регистрация</a><br/>';
if($mod == '1') echo '</small></p><p align="center"><small>';
echo $class_divz.$class_d2;
echo $class_divz.$class_d2.$class_version.$class_divz.$class_div;
echo $class_endpage;
exit();
}

if(!empty($sql)) {
$sql_ip = mysql_query("SELECT * FROM `love_golos` WHERE `uid` = '".$id."' && `ip` = '".$REMOTE_ADDR."'");
$sql_bw = mysql_query("SELECT * FROM `love_golos` WHERE `uid` = '".$id."' && `ua` = '".$HTTP_USER_AGENT."'");
if(mysql_num_rows($sql_ip) == false && mysql_num_rows($sql_bw) == false)
{
if($_SESSION['remote_addr'] == getenv("REMOTE_ADDR") && $_SESSION['user_agent'] == getenv("HTTP_USER_AGENT") && $_SESSION['uid'] == $id && $sid)
{
@mysql_query("UPDATE `love_user` SET `golos` = `golos` + 1 WHERE `id` = ".$id.";");
@mysql_query("INSERT INTO `love_golos` VALUES ('".$id."', '".$REMOTE_ADDR."', '".time()."', '".$HTTP_USER_AGENT."');");
//----------
echo $class_d2;
echo 'Голосовать<br/>';
echo $class_divz.$class_d0;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo 'Ваш голос учтён!<br/>';
echo $class_divz;
}
}
else
{
echo $class_d2;
echo 'Ошибка!<br/>';
echo $class_divz.$class_d0;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo 'Ваш голос учтён ранее!<br/>';
echo $class_divz;
}
}
echo $class_d0;
if($mod == '1') echo '---<br/>';
echo '&#171;- <a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Назад</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[7] <a href="http://'.$_SERVER['HTTP_HOST'].'/index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="7">Поиск</a> [8] <a href="http://'.$_SERVER['HTTP_HOST'].'/menu.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Личное меню</a> [9] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="9">Выход</a><br/>';
if($mod == '1') echo '</small></p><p align="center"><small>';
echo $class_divz.$class_d2;
echo $class_divz.$class_d2.$class_version.$class_divz.$class_div;
echo $class_endpage;
?>