Просмотр файла banners.ru/www/admin/index.php

Размер файла: 16.09Kb
<?session_start();
require ('../data/config.php');
require ('../data/mysql.php');
require ('../data/functions.php');
require ('../data/mail.php');
if ($cookie_user<>$admin_login and $cookie_passwd<>$admin_passw)
        {
        header("Location:/index.php?err=falce");
        exit();
        }



?>
<html>
<head> <meta http-equiv="Content-Type" content="application/vnd.wap.xhtml+xml" charset="utf-8"/>
<title>Администраторская - <?print "$site_title";?></title>
<?require ('../html/style.php');?>
</head>

<BODY BGCOLOR=#D3DDF4 LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<center>
<?require ('../html/up_admin.php');?>
<?
if ($action=="offaccount")
        {
        $result= mysql_query("SELECT * FROM accounts WHERE id=$id");
        $row = mysql_fetch_array($result);
        $text_mail="
		Vash akkaunt otkliuchen, vozmozhno Vi narushili odno iz pravil!";
        send_mail($row[email],"RBS- -   ",$text_mail,$admin_email,$site_title,$http_address);

        $result= mysql_query("UPDATE accounts SET status='0' WHERE id='$id'");
       print "<li> выключен";
        }
if ($action=="onaccount")
        {
        $result= mysql_query("SELECT * FROM accounts WHERE id=$id");
        $row = mysql_fetch_array($result);
        $text_mail="...";
        send_mail($row[email],"RealBannSystem",$text_mail,$admin_email,$site_title,$http_address);
        $result= mysql_query("UPDATE accounts SET status='1' WHERE id='$id'");
        print "<li> включен";
        }
if ($action=="delaccount")
        {
        $result= mysql_query("SELECT * FROM accounts WHERE id=$id");
        $row = mysql_fetch_array($result);
        $text_mail="...";
        send_mail($row[email],"RealBannSystem",$text_mail,$admin_email,$site_title,$http_address);

        $result= mysql_query("DELETE FROM accounts WHERE id='$id'");
        $result= mysql_query("DELETE FROM view WHERE id_account='$id'");
     print "<li> удален";
        }
if ($action=="addview")
        {
        $result= mysql_query("SELECT * FROM accounts WHERE id=$id");
        $row = mysql_fetch_array($result);
        $text_mail="$view ";
        send_mail($row[email],"RealBannSystem",$text_mail,$admin_email,$site_title,$http_address);

        for ($i=1;$i<=$view;$i++)
                {
                $result= mysql_query("INSERT INTO view (id_account) VALUES ('$id')");
                }
        print "<li> добавлено";
        }
if ($action=="delview")
        {
        $result= mysql_query("DELETE FROM view WHERE id_account='$id' LIMIT $view");
        print "<li> удалено";
        }
if ($action=="offbanner")
        {
        $result= mysql_query("UPDATE banners SET status='3' WHERE id='$id'");
        print "<li> выключен";
        }
if ($action=="delbanner")
        {
        $resu= mysql_query("SELECT * FROM banners WHERE id='$id'");
        $ro = mysql_fetch_array($resu);
                $file="$http_abs_address/images/$ro[file_banner]";
                $delete = @unlink($file);
                if (@file_exists($file))
                        {
                        $filesys = eregi_replace("/","\\",$file);
                        $delete = @system("del $filesys");
                        if (@file_exists($file))
                                {
                                $delete = @chmod ($file, 0777);
                                $delete = @unlink($file);
                                $delete = @system("del $filesys");
                                }
                       }
        $result= mysql_query("DELETE FROM banners WHERE id='$id'");
        print "<li> удален";
        }
if ($action=="onbanner")
        {
        $result= mysql_query("UPDATE banners SET status='1' WHERE id='$id'");
        print "<li> включен";
        }

if ($action=="editaccountyes")
        {
        $result= mysql_query("UPDATE accounts SET
                                name='$name',
                                email='$email',
                                user_login='$user',
                                user_pass='$password',
                                url='$url',
                                host='$host',
                                name_site='$name_site'
                                WHERE id='$id'");
       print "<br><font color=green><b>изменения внесены</b><br>";

        }

if ($action=="editaccount")
        {
        $result= mysql_query("SELECT * FROM accounts WHERE id=$id");
        $row = mysql_fetch_array($result);
        print "
        <center>
        <TABLE WIDTH=600 BORDER=0 CELLPADDING=2 CELLSPACING=2>
        <form action=$PHP_SELF method=post>
                <tr>
                        <td width=35% align=left valign=top class=p>
                        <b>Ваше имя:</td>
                        <td width=65% align=left valign=top class=p>
                        <input type=text name=name size=40 class=p value=\"$row[name]\"></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>Ваш e-mail:</td>
                        <td align=left valign=top class=p>
                        <input type=text name=email size=40 class=p value=\"$row[email]\"></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>Ваш логин:</td>
                        <td align=left valign=top class=p>
                        <input type=text name=user size=40 class=p value=\"$row[user_login]\"></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>пароль:</td>
                        <td align=left valign=top class=p>
                        <input type=text name=password size=40 class=p value=\"$row[user_pass]\"></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>Название веб-сайта:</td>
                        <td align=left valign=top class=p>
                        <input type=text name=name_site size=40 class=p value=\"$row[name_site]\"></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>адрес веб-сайта:</td>
                        <td align=left valign=top class=p>
                        <input type=text name=url size=40 class=p value=\"$row[url]\"></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>хост:</td>
                        <td align=left valign=top class=p>
                        <input type=text name=host size=40 class=p value=\"$row[host]\"></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <input type=hidden name=id value=$id>
                        <input type=hidden name=action value=editaccountyes></td>
                        <td align=left valign=top class=p><br><br>
                        <input type=submit value=\"изменить\" class=p></td>
                </tr>
        </form>
        </table>
        </center>";
        }
              ////////////////////////////////////////////////////


                     $arr=mysql_query("select * from accounts WHERE status='1' order by id desc;");

$it=mysql_num_rows($arr);
///////////////////////////////
while ($data=mysql_fetch_array($arr))
{
if($id==$data['id']) $start=count($chid);
$chid[] = $data['id'];
$name[] = $data['link'];
$today[] = $data['today'];
$allday[] = $data['allday'];
}

$count=$it;
$count1=$count;
if(empty($start))
$start=0;
$start=intval($start);
if($start<0)
$start=0;
if($count>$start+10) $count=$start+10;
$name=str_replace("http://","",$name);
for($it=$start;$it<$count;$it++)
/*$result= mysql_query("SELECT * FROM accounts WHERE status='1' ORDER BY id DESC");
while ($row = mysql_fetch_array($result))  */
        {
        $result= mysql_query("SELECT * FROM accounts WHERE status='1' and id='$chid[$it]' ORDER BY id DESC");
 $row = mysql_fetch_array($result);




        print " <br>
        <TABLE WIDTH=720 BORDER=1 CELLPADDING=10 CELLSPACING=0 BGCOLOR=white>

            <form action=$PHP_SELF>
            <td align=left width=60% valign=top CLASS=P>
            <b>$row[name_site]</b><bR>
            <a href=$row[url] class=p target=_blank>$row[url]</a><bR>
            $row[email] - $row[name]<br>
            host: $row[host] <br><br>&#x0420;&#x0435;&#x0444;&#x0435;&#x0440;&#x0430;&#x043B;&#x044B;:<br>";
             $result7= mysql_query("SELECT * FROM accounts WHERE referal='$row[id]'");
while ($row7 = mysql_fetch_array($result7))
        {
        print "$i. <a href=\"$row7[url]\" target=\"_blank\">$row7[name_site]</a> [" ;
        $resul7= mysql_query("SELECT * FROM stat WHERE id_account='$row7[id]' AND action='view' AND date>='$today'");
        print mysql_num_rows($resul7);
        print "]<br/>";
        $i++;
        }
            print "<br>
            накоплено: ";
            $result3= mysql_query("SELECT * FROM view WHERE id_account=$row[id]");
            print mysql_num_rows($result3);
            print "
            <br>
            <input type=text name=view class=p size=7 value=1000><input type=hidden name=action value=delview>
            <input type=hidden name=id value=$row[id]>
            <input type=submit value=\" убрать показы\" class=p>

            </form>
            <form action=$PHP_SELF>
            <td align=left width=40% valign=top CLASS=P>
            <a href=$PHP_SELF?id=$row[id]&action=editaccount class=p>изменить</a><br>";
            if ($row[status]==0) print "<a href=$PHP_SELF?id=$row[id]&action=onaccount class=p>включить</a><br><br>";
            if ($row[status]==1) print "<a href=$PHP_SELF?id=$row[id]&action=offaccount class=p>выключить</a><br><br>";
            print "
            <a href=$PHP_SELF?id=$row[id]&action=delaccount class=p>удалить</a><br><br>
            <input type=text name=view class=p size=7 value=1000><input type=hidden name=action value=addview>
            <input type=hidden name=id value=$row[id]>
            <input type=submit value=\" добавить показы\" class=p>
            </td>
            </form>
             <td align=left valign=top CLASS=P>

  <TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=white class=p>
<tr bgcolor=#E9EDF6>
        <td align=left valing=top>
        </tD>
        <td align=left valing=top>
        <b>показы</b></tD>
        <td align=left valing=top>
        <b>клики</b></tD>
        <td align=left valing=top>
        <b>CRT,%</b></tD>
</tr>
<tr>
        <td align=left valing=top>
        <b>сегодня</b></tD>
        <td align=left valing=top>";
        $mm=date("m",time());
        $dd=date("d",time());
        $yy=date("Y",time());

        $today=mktime(0,0,0,$mm,$dd,$yy);
        $r1= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='view' AND date>='$today'");
        print mysql_num_rows($r1);
        print "
        </tD>
        <td align=left valing=top>";
        $r2= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='click' AND date>='$today'");
        print mysql_num_rows($r2);
        print"
        </tD>
        <td align=left valing=top>";
        if (mysql_num_rows($r1)<>0)
        print round((mysql_num_rows($r2)/mysql_num_rows($r1))*100,1);
        print "
        </tD>
</tr>

<tr bgcolor=#E9EDF6>
        <td align=left valing=top>
        <b>вчера</b></tD>
        <td align=left valing=top>";
        $mm=date("m",time());
        $dd=date("d",time());
        $yy=date("Y",time());

        $today=mktime(0,0,0,$mm,$dd,$yy);
        $yesterday=$today-86400;
        $r1= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='view' AND date<='$today' AND date>='$yesterday'");
        print mysql_num_rows($r1);
        print "
        </tD>
        <td align=left valing=top>";
        $r2= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='click' AND date<='$today' AND date>='$yesterday'");
        print mysql_num_rows($r2);
        print"
        </tD>
        <td align=left valing=top>";
        if (mysql_num_rows($r1)<>0)
                print round((mysql_num_rows($r2)/mysql_num_rows($r1))*100,1);
        print "
        </tD>
</tr>

<tr>
        <td align=left valing=top>
        <b>за 7 дней</b></tD>
        <td align=left valing=top>";

        $week=time()-604800;
        $r1= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='view' AND date>='$week'");
        print mysql_num_rows($r1);
        print "
        </tD>
        <td align=left valing=top>";
        $r2= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='click' AND date>='$week'");
        print mysql_num_rows($r2);
        print"
        </tD>
        <td align=left valing=top>";
        if (mysql_num_rows($r1)<>0)
                print round((mysql_num_rows($r2)/mysql_num_rows($r1))*100,1);
        print "
        </tD>
</tr>
<tr bgcolor=#E9EDF6>
        <td align=left valing=top>
        <b>за 30 дней</b></tD>
        <td align=left valing=top>";

        $week=time()-2592000;
        $r1= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='view' AND date>='$week'");
        print mysql_num_rows($r1);
        print "
        </tD>
        <td align=left valing=top>";
        $r2= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='click' AND date>='$week'");
        print mysql_num_rows($r2);
        print"
        </tD>
        <td align=left valing=top>";
        if (mysql_num_rows($r1)<>0)
                print round((mysql_num_rows($r2)/mysql_num_rows($r1))*100,1);
        print "
        </tD>
</tr>
<tr>
        <td align=left valing=top>
        <b>всего</b></tD>
        <td align=left valing=top>";
        $r1= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='view'");
        print mysql_num_rows($r1);
        print "
        </tD>
        <td align=left valing=top>";
        $r2= mysql_query("SELECT * FROM stat WHERE id_account='$row[id]' AND action='click'");
        print mysql_num_rows($r2);
        print"
        </tD>
        <td align=left valing=top>";
        if (mysql_num_rows($r1)<>0)
                print round((mysql_num_rows($r2)/mysql_num_rows($r1))*100,1);
        print "
        </tD>
</tr>
</table>";

            print "
            </td>
            <td align=left valign=top CLASS=P>";

            $result2= mysql_query("SELECT * FROM banners WHERE id_account='$row[id]' AND status<>0");
             while ($row2 = mysql_fetch_array($result2))
                {
                print "<a href=/images/$row2[file_banner] target=_blank>
                <img src=/images/$row2[file_banner] border=0 width=90 height=30 align=left></a>";
                if ($row2[status]==0) print "<a href=newban.php class=p><font color=red>провреить</font></a><br>";
                if ($row2[status]==1 or $row2[status]==2) print "<a href=$PHP_SELF?id=$row2[id]&action=offbanner class=p>выключить</a><br>";
                if ($row2[status]==3) print "<a href=$PHP_SELF?id=$row2[id]&action=onbanner class=p>ВКЛЮЧИТЬ</a><br>";
                print "
                <a href=$PHP_SELF?id=$row2[id]&action=delbanner class=p>удалить</a><br>
                <br><br>";
                }
            print "
        </table>";
        }
        if($start!=0)
{
print "<br/><a href=\"?start=".($start-10)."\">&#x41D;&#x430;&#x437;&#x430;&#x434;</a>";
}
if($count1>$start+10)
{
print "<a href=\"?start=".($start+10)."\"><br/>&#x414;&#x430;&#x43B;&#x435;&#x435;</a>";
}
?>
</center>
</body>
</html>