<?php
error_reporting(0);
//----------
include ('../inc/config.inc.php.php');
//----------
session_name('sid');
session_start();
//----------
connect_to_db();
include ('inc_pt/autorize.php.php');
include ('../inc/pages.php.php');
// Зар. сегодня
$arr_user = @mysql_query("select * from `love_user` where ((`user_reg` = '".$autorize_partner['partner']."') and (`regdata` = '".date('j-m-y')."'));");
$arr_reg_day = mysql_num_rows($arr_user);
// Зар. вчера
$date = date('j') - 1;
$arr_yesterday = @mysql_query("select * from `love_user` where ((`user_reg` = '".$autorize_partner['partner']."') and (`regdata` = '".$date.date('-m-y')."'));");
$arr_reg_yesterday = mysql_num_rows($arr_yesterday);
// Зар. всего
$arr_all = @mysql_query("select * from `love_user` where `user_reg` = '".$autorize_partner['partner']."';");
$arr_reg_all = mysql_num_rows($arr_all);
//----------
$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'];
//----------
if (!$autorize_partner) {
header('Location: index.php?partner='.$partner.'&mod='.$mod.'&'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id());
exit();
}
//-----------
$title = 'Панель управления';
include ('../header.php');
echo $header;
if($mod == '1') echo '<p align="center"><small>';

if(isset($_GET['up'])) $up = $_GET['up']; else $up = "0";
switch ($up) {

case "0":
echo $class_d2;
echo 'Панель управления<br/>';
echo $class_divz.$class_d0;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo 'Ссылка для размещения на сайте:<br/>';
echo '<b>'.htmlspecialchars('<a href="http://'.$_SERVER['HTTP_HOST'].'/?partner='.$autorize_partner['partner'].'">WAP Знакомства</a><br/>').'</b><br/>';
echo $class_divz.$class_d1;
if($mod == '1') echo '---<br/>';
echo 'Зарегистрированных пользователей:<br/>';
echo '-&#187; <a href="'.$PHP_SELF.'?up=1&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Сегодня</a> ('.$arr_reg_day.')<br/>';
echo '-&#187; <a href="'.$PHP_SELF.'?up=2&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Вчера</a> ('.$arr_reg_yesterday.')<br/>';
echo '-&#187; <a href="'.$PHP_SELF.'?up=3&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Всего</a> ('.$arr_reg_all.')<br/>';
echo $class_divz.$class_d0;
echo '-&#187; <a href="'.$PHP_SELF.'?up=4&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Профиль</a><br/>';
echo $class_divz;
break;

case "1":
$sql = @mysql_query("select * from `love_user` where ((`user_reg` = '".$autorize_partner['partner']."') and (`regdata` = '".date('j-m-y')."'));");
echo $class_d2;
echo 'Сегодня<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if(mysql_affected_rows() == 0) {
echo $class_d3;
echo 'Сегодня регистраций нет!<br/>';
echo $class_divz;
}
else
{
$url = ''.$PHP_SELF.'?up=1&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'&amp;';
$wf = ONPAGE_USER;
$tp = mysql_num_rows($sql);
$mp = ceil($tp/$wf);
$page = (int)$_GET['page'];
if($page < 1) $page = 1;
if($page > $mp) $page = $mp;
$start = $page * $wf - $wf;
if(!preg_match('#^[0-9]{1,3}$#i',$page)) $page = 1;
//----------
$arr = @mysql_query("select * from `love_user` where ((`user_reg` = '".$autorize_partner['partner']."') and (`regdata` = '".date('j-m-y')."')) ORDER BY `regdata` DESC LIMIT ".intval($start).",".intval($wf).";");
while($info_user = mysql_fetch_array($arr)) {
$id = $info_user['id'];
$name = $info_user['name'];
$vozrast = $info_user['vozrast'];
$pol = $info_user['pol'];
if ($pol == 1) $pol = '[М]'; else $pol = '[Ж]';
echo $class_d1;
echo '<b><a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">'.$name.'</a></b> '.$vozrast.', '.$pol.'<br/>';
echo $class_divz;
}
if ($tp > ONPAGE_USER) {
if($mod == '1') echo '---<br/>';
echo $class_d0;
page($tp, $page, $wf, $url);
echo $class_divz;
if($mod == '1') echo '<br/>';
}
}
break;

case "2":
$sql = @mysql_query("select * from `love_user` where ((`user_reg` = '".$autorize_partner['partner']."') and (`regdata` = '".$date.date('-m-y')."'));");
echo $class_d2;
echo 'Вчера<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if(mysql_affected_rows() == 0) {
echo $class_d3;
echo 'Вчера никто не зарегистрировался!<br/>';
echo $class_divz;
}
else
{
$url = ''.$PHP_SELF.'?up=2&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'&amp;';
$wf = ONPAGE_USER;
$tp = mysql_num_rows($sql);
$mp = ceil($tp/$wf);
$page = (int)$_GET['page'];
if($page < 1) $page = 1;
if($page > $mp) $page = $mp;
$start = $page * $wf - $wf;
if(!preg_match('#^[0-9]{1,3}$#i',$page)) $page = 1;
//----------
$arr = @mysql_query("select * from `love_user` where ((`user_reg` = '".$autorize_partner['partner']."') and (`regdata` = '".$date.date('-m-y')."')) ORDER BY `regdata` DESC LIMIT ".intval($start).",".intval($wf).";");
while($info_user = mysql_fetch_array($arr)) {
$id = $info_user['id'];
$name = $info_user['name'];
$vozrast = $info_user['vozrast'];
$pol = $info_user['pol'];
if ($pol == 1) $pol = '[М]'; else $pol = '[Ж]';
echo $class_d1;
echo '<b><a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">'.$name.'</a></b> '.$vozrast.', '.$pol.'<br/>';
echo $class_divz;
}
if ($tp > ONPAGE_USER) {
if($mod == '1') echo '---<br/>';
echo $class_d0;
page($tp, $page, $wf, $url);
echo $class_divz;
if($mod == '1') echo '<br/>';
}
}
break;

case "3":
$sql = @mysql_query("select * from `love_user` where `user_reg` = '".$autorize_partner['partner']."';");
echo $class_d2;
echo 'Всего<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if(mysql_affected_rows() == 0) {
echo $class_d3;
echo 'Регистраций нет!<br/>';
echo $class_divz;
}
else
{
$url = ''.$PHP_SELF.'?up=3&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'&amp;';
$wf = ONPAGE_USER;
$tp = mysql_num_rows($sql);
$mp = ceil($tp/$wf);
$page = (int)$_GET['page'];
if($page < 1) $page = 1;
if($page > $mp) $page = $mp;
$start = $page * $wf - $wf;
if(!preg_match('#^[0-9]{1,3}$#i',$page)) $page = 1;
//----------
$arr = @mysql_query("select * from `love_user` where `user_reg` = '".$autorize_partner['partner']."' ORDER BY `regdata` DESC LIMIT ".intval($start).",".intval($wf).";");
while($info_user = mysql_fetch_array($arr)) {
$id = $info_user['id'];
$name = $info_user['name'];
$vozrast = $info_user['vozrast'];
$pol = $info_user['pol'];
if ($pol == 1) $pol = '[М]'; else $pol = '[Ж]';
echo $class_d1;
echo '<b><a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">'.$name.'</a></b> '.$vozrast.', '.$pol.'<br/>';
echo $class_divz;
}
if ($tp > ONPAGE_USER) {
if($mod == '1') echo '---<br/>';
echo $class_d0;
page($tp, $page, $wf, $url);
echo $class_divz;
if($mod == '1') echo '<br/>';
}
}
break;

case "4":
if(!isset($_POST['edit'])) {
echo $class_d2;
echo 'Профиль<br/>';
echo $class_divz;
if($mod == '1') {
echo '</small></p><p align="left"><small>';
echo 'Пароль:</small><br/>';
echo '<input name="p1" type="text" maxlength="15" value="'.$autorize_partner['pass'].'" /><br/>';
echo '<small>Адрес сайта:</small><br/>';
echo '<input name="p2" type="text" maxlength="50" value="http://'.$autorize_partner['site'].'" /><br/>';
echo '<small>Название сайта:</small><br/>';
echo '<input name="p3" type="text" maxlength="50" value="'.$autorize_partner['name'].'" /><br/>';
echo '<input type="hidden" name="edit" value="edit" />';
echo '<input type="hidden" name="'.session_name().'" value="'.session_id().'" />';
echo '<small><anchor>Сохранить<go href="'.$PHP_SELF.'?up=4&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'" method="post">';
echo "<postfield name='p1' value='$(p1)' />";
echo "<postfield name='p2' value='$(p2)' />";
echo "<postfield name='p3' value='$(p3)' />";
echo "<postfield name='edit' value='edit' />";
echo "<postfield name='".session_name()."' value='".session_id()."' />";
echo '</go></anchor><br/>';
}
else
{
echo '<form method="post" action="'.$PHP_SELF.'?up=4&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">';
echo $class_d1;
echo 'Пароль:<br/>';
echo '<input name="p1" type="text" maxlength="15" value="'.$autorize_partner['pass'].'" class="button" /><br/>';
echo 'Адрес сайта:<br/>';
echo '<input name="p2" type="text" maxlength="50" value="http://'.$autorize_partner['site'].'" class="button" /><br/>';
echo 'Название сайта:<br/>';
echo '<input name="p3" type="text" maxlength="50" value="'.$autorize_partner['name'].'" class="button" /><br/>';
echo '<input type="hidden" name="edit" value="edit" />';
echo '<input type="hidden" name="'.session_name().'" value="'.session_id().'" />';
echo '<input type="submit" value="Сохранить" class="do_button" />';
echo $class_divz;
echo '</form>';
}
}
else
{
$p1 = $_POST['p1']; $p1 = substr($p1,0,15);
$p2 = strtolower(trim(htmlspecialchars($_POST['p2']))); $p2 = substr($p2,0,50);
$p2 = str_replace("http://", "", $p2);
$p3 = mysql_escape_string(htmlspecialchars($_POST['p3'])); $p3 = substr($p3,0,50);
//----------
$sql = mysql_query("SELECT * FROM `love_partner` WHERE `site` = '".$p2."' AND `partner` != '".$autorize_partner['partner']."';");
if(!$sql)
{
echo $class_d2;
echo 'Профиль<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo $class_d0;
echo 'Произошла ошибка.<br/>';
echo $class_divz.$class_d0;
echo mysql_error().'<br/>';
echo $class_divz.$class_d2;
if($mod == '1') echo '---<br/>';
echo '[7] <a href="'.$PHP_SELF.'?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'" accesskey="7">Панель управления</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[8] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Выход</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(mysql_affected_rows() != 0)
{
echo $class_d2;
echo 'Профиль<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo $class_d0;
echo 'Ошибка!<br/>';
echo $class_divz.$class_d0;
echo 'Такой сайт уже зарегистрирован!<br/>';
echo $class_divz.$class_d0;
if($mod == '1') echo '---<br/>';
echo '[7] <a href="'.$PHP_SELF.'?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'" accesskey="7">Панель управления</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[8] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Выход</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($error)) $error = '';
if(empty($p1)) $error = $error. 'Не введен пароль!<br/>';
else if(!preg_match("!^[a-z0-9]+$!i",$p1)) $error = $error. 'Неверные символы в пароле!<br/>';
if(empty($p2)) $error = $error. 'Не введен адрес сайта!<br/>';
if(empty($p3)) $error = $error. 'Не введено название сайта!<br/>';
//----------
if(!empty($error))
{
echo $class_d2;
echo 'Профиль<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo $class_d0;
echo 'Ошибка!<br/>';
echo $class_divz.$class_d0;
echo $error;
echo $class_divz.$class_d0;
if($mod == '1') echo '---<br/>';
echo '[7] <a href="'.$PHP_SELF.'?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'" accesskey="7">Панель управления</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[8] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Выход</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();
}

$reg =  mysql_query("UPDATE `love_partner` SET `pass` = '".$p1."', `site` = '".$p2."', `name` = '".$p3."' WHERE `partner` = '".$autorize_partner['partner']."';");

if($reg)
{
echo $class_d2;
echo 'Профиль<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo $class_d0;
echo 'Данные успешно сохранены!<br/>';
echo $class_divz;
}
else
{
echo $class_d0;
echo 'Ошибка!<br/>';
echo mysql_error().'<br/>';
}
}
break;
}
echo $class_d0;
if($mod == '1') echo '---<br/>';
echo '[7] <a href="'.$PHP_SELF.'?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'" accesskey="7">Панель управления</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[8] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Выход</a><br/>';
if($mod == '1') echo '</small></p><p align="center"><small>';
echo $class_divz.$class_d2;
echo 'Copyright &#169; 2008 «<a href="http://'.$partner_site.'">'.$partner_name.'</a>»<br/>';
echo $class_divz.$class_d2.$class_version.$class_divz.$class_div;
echo $class_endpage;
?>