Просмотр файла admin.php

Размер файла: 7.06Kb
<?php
#  Сщетчик переходов с статистикой по операторам ver 1.0
#  Автор скрипта Корнилов Александр aka GrOb
#  e-mail: [email protected]; [email protected]
#  ICQ: 191-171
#  WAP: http://o5wap.ru


 include('config.php');
 include('header.php');
 if (empty($_SESSION['pass'])) $_SESSION['pass']=$_GET['pass'];
 if ($_SESSION['pass']!=$admin)
 {
 echo $div['header'].'ОШИБКА!'.$div['end'];
 echo $div["div"]."Доступ запрещен!<br/>Или истекла сессия";
 echo $div['end'].$div['news'];
 echo "Пароль:";
 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="GET">';
 echo '<input name="pass" type="password"/><br/>';
 echo '<input class="ibutton" type="submit" value="Войти"/></form>';
 include ("footer.php");
 unset($_SESSION['pass']);
 exit();
 }

 if(isset($_GET['add'])){
 $name_link = htmlspecialchars(stripslashes(trim($_POST['name'])));
 $url_link = htmlspecialchars(stripslashes(trim($_POST['url'])));
 @mysql_query("INSERT INTO `click_user` (`name_link`,`url`) values ('".revconv($name_link)."','".revconv($url_link)."')");
 }

 if(isset($_GET['edit'])){
 $go_link=preg_replace("/[^0-9]/","",$_POST['go']);
 $new_name = htmlspecialchars(stripslashes(trim($_POST['name'])));
 $new_url = htmlspecialchars(stripslashes(trim($_POST['url'])));
 @mysql_query("DELETE FROM `click_opsos` WHERE `uid` = '".$go."'");
 @mysql_query("DELETE FROM `click_opsos_mes` WHERE `uid` = '".$go."'");
 @mysql_query("DELETE FROM `click_opsos_total` WHERE `uid` = '".$go."'");
 $tt=@mysql_query("UPDATE `click_user` SET `name_link`='".revconv($new_name)."',`url`='".revconv($new_url)."',`segodnya`='0',`vchera`='0' WHERE `id`='".$go_link."'");
  if(!$tt){
  header("Location: ./".$_SERVER['PHP_SELF']."?add&name_link=".$new_name."&url_link=".$new_url."");
  exit;}
 @mysql_query("UPDATE `click_opsos` SET `1`='0',`2`='0',`3`='0',`4`='0',`5`='0',`6`='0',`7`='0',`9`='0',`10`='0',`11`='0',`12`='0',`13`='0',`14`='0',`15`='0',`16`='0',`17`='0',`18`='0',`19`='0',`20`='0',`21`='0',`22`='0',`23`='0',`24`='0',`25`='0',`26`='0',`27`='0',`28`='0',`29`='0',`30`='0',`31`='0',`32`='0' WHERE `uid`='".$go_link."'");
 }

 $sql = @mysql_query("SELECT * FROM `click_user` WHERE `id`!='0' Order By `id`");
 $total_users = @mysql_num_rows($sql);


 echo $div['news'];
 echo '<b>Статистика рекламных ссылок</b>';
 echo $div['end'];
 echo $div['header'];
 echo '<b><a href="'.$_SERVER['PHP_SELF'].'?'.session_name().'='.session_id().'">Обновить статистику</a></b><br/>';
 echo $div['end'];
 echo $div['news'];
  $ww=md5(rand(1,1000));

 if($total_users>0){

    echo '<small><table border="0" cellpadding="3" bgcolor="#CCCCCC">';
    echo '
     <tr>
    <td align="center" class="p" bgcolor="#E8E8FF"><b>№</b></td>
    <td align="center" class="p" bgcolor="#E8E8FF"><b>Ссылка</b></td>
    <td align="center" class="p" bgcolor="#E8E8FF"><b>Сегодня</b></td>
    <td align="center" class="p" bgcolor="#E8E8FF"><b>Вчера</b></td>
    <td align="center" class="p" bgcolor="#E8E8FF"><b>'.whatMonth(date('m')).'</b></td>
    <td align="center" class="p" bgcolor="#E8E8FF"><b>Всего кликов</b></td>
    <td align="center" class="p" bgcolor="#E8E8FF"><b>Операторы Сегодня</b></td>
     </tr>
    ';



  for($i=0;$i<$total_users;$i++){
  $d=date('d');
  $m=date('m');
  $y=date('Y');
  $row = @mysql_fetch_array($sql);
  $id = $row['id'];
  $name = conv($row['name_link']);
  $url = conv($row['url']);
  $today = $row['segodnya'];
  if($today=='')$today=0;
  $yesterday = $row['vchera'];
  if($yesterday=='')$yesterday=0;

  $sql_mes = @mysql_query("SELECT `hits` FROM `click_opsos_mes` WHERE `uid`='".$id."' AND `m`='".$m."' AND `y`='".$y."'");
  $sql_total = @mysql_query("SELECT `hits` FROM `click_opsos_total` WHERE `uid`='".$id."'");
  $row2 = @mysql_fetch_array($sql_mes);
  $row3 = @mysql_fetch_array($sql_total);
  $mes = $row2['hits'];
  if($mes=='')$mes=0;
  $total = $row3['hits'];
  if($total=='')$total=0;



  $q = @mysql_query("select * from `click_opsos` where `uid`='".$id."' and `d`='".$d."' and `m`='".$m."' and `y`='".$y."';");
  $reg=@mysql_num_rows($q);
  $field=@mysql_fetch_array($q);
  $hits=$field['hits'];
  $opsos_=$field['0'];
  $all=$hits-$opsos_;
  $op_procent=@ceil($all/($hits/100));
  $url = str_replace("http://", "", $url);
  $url = str_replace("4e1.ru", "", $url);


     echo '<tr><td align="center" class="p" bgcolor="#E0E0E0">'.$id.'</td>';
     echo '<td align="center" class="p" bgcolor="#E0E0E0">'.$name.'<br/><small><small>'.$url.'</small></small></td>';
     echo '<td align="center" class="p" bgcolor="#E0E0E0">'.$today.'</td>';
     echo '<td align="center" class="p" bgcolor="#E0E0E0">'.$yesterday.'</td>';
     echo '<td align="center" class="p" bgcolor="#E0E0E0">'.$mes.'</td>';
     echo '<td align="center" class="p" bgcolor="#E0E0E0">'.$total.'</td>';
     echo '<td align="center" class="p" bgcolor="#E0E0E0"><a href="opsos.php?go='.$id.'&amp;'.session_name().'='.session_id().'">'.$op_procent.'%</a></td></tr>';



  }

 echo '</table></small>';

 }


echo $div['end'];
echo $div['header'];
echo "<b>Управление ссылками</b><br/>";
echo $div['end'];
echo $div['news'];

    echo '<form action="'.$_SERVER['PHP_SELF'].'?add&amp;'.session_name().'='.session_id().'" method="POST">';
    echo '
     <tr>
    <td align="center" class="p" bgcolor="#80FFFF">Название</td>
    <td align="center" class="p" bgcolor="#80FFFF">Адрес</td>
    <td align="center" class="p" bgcolor="#80FFFF">Действие</td>
     </tr>
     <tr>
    <td align="center" class="p" bgcolor="#80FFFF"><input name="name" type="text"/></td>
    <td align="center" class="p" bgcolor="#80FFFF"><input name="url" type="text" value="http://"/></td>
    <td align="center" class="p" bgcolor="#80FFFF"><input class="ibutton" type="submit" value="Добавить"/></td>
     </tr></form>
    ';


    echo "<small><b>*Внимание при изменении ссылки все счетчики будут сброшены!!!</b></small>";
    echo '<form action="'.$_SERVER['PHP_SELF'].'?edit&amp;'.session_name().'='.session_id().'" method="POST">';
    echo '
     <tr>
    <td align="center" class="p" bgcolor="#80FFFF">id</td>
    <td align="center" class="p" bgcolor="#80FFFF">Название</td>
    <td align="center" class="p" bgcolor="#80FFFF">Адрес</td>
    <td align="center" class="p" bgcolor="#80FFFF">Действие</td>
     </tr>
     <tr>
    <td align="center" class="p" bgcolor="#80FFFF"><input name="go" format="*N" size="5"/></td>
    <td align="center" class="p" bgcolor="#80FFFF"><input name="name" type="text"/></td>
    <td align="center" class="p" bgcolor="#80FFFF"><input name="url" type="text" value="http://"/></td>
    <td align="center" class="p" bgcolor="#80FFFF"><input class="ibutton" type="submit" value="Изменить"/></td>
     </tr></form>
    ';


 include('footer.php');
 @mysql_close($sesDB);

?>