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

Размер файла: 7.45Kb
<?
require ('data/config.php');
require ('data/mysql.php');
if (!$id)
        {   $im = imagecreatefromgif('images/bb.gif');  $sx = imagesx($im);   $sy = imagesy($im);    $img = imagecreate(68,30);    imageCopyResized($img, $im, 0, 0, 0, 0, 68, 30, $sx, $sy);   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");    header("Cache-Control: no-store, no-cache, must-revalidate");    header("Cache-Control: post-check=0, pre-check=0", false);    header("Pragma: no-cache");    header("Content-type: image/gif");    imageGIF($img);    ImageDestroy($img);
        }
else
        {

        $date=time();$action="view";
        $ip=$REMOTE_ADDR;
        $resultt= mysql_query("SELECT `onoff` FROM `accounts` WHERE `id`='$id' AND `status`='1' ;");
        $rowt = mysql_fetch_array($resultt);
        $result= mysql_query("SELECT * FROM `accounts` WHERE `id`='$id' AND `status`='1' ;");
        $row = mysql_fetch_array($result);
                  $onip=$rowt['onoff'];
          if($onip=='2') { $tt=mysql_query("UPDATE `view` SET `onoff`='2' WHERE `id_account`='".$id."'");   }

        if (mysql_num_rows($result)==0)
                {  $im = imagecreatefromgif('images/bb.gif');  $sx = imagesx($im);   $sy = imagesy($im);    $img = imagecreate(68,30);    imageCopyResized($img, $im, 0, 0, 0, 0, 68, 30, $sx, $sy);   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");    header("Cache-Control: no-store, no-cache, must-revalidate");    header("Cache-Control: post-check=0, pre-check=0", false);    header("Pragma: no-cache");    header("Content-type: image/gif");    imageGIF($img);    ImageDestroy($img);  exit();}


       ////////////// if (!strstr($HTTP_REFERER,$row[host]))
      /*  if ($HTTP_REFERER!=$row[host])
                {  $im = imagecreatefromgif('images/bb.gif');  $sx = imagesx($im);   $sy = imagesy($im);    $img = imagecreate(68,30);    imageCopyResized($img, $im, 0, 0, 0, 0, 68, 30, $sx, $sy);   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");    header("Cache-Control: no-store, no-cache, must-revalidate");    header("Cache-Control: post-check=0, pre-check=0", false);    header("Pragma: no-cache");    header("Content-type: image/gif");    imageGIF($img);    ImageDestroy($img);  exit();}  */

       // $result= mysql_query("SELECT view.id_account FROM view.id_account,banners.status WHERE (view.id_account<>'$id',banners.status='1' or view.id_account<>'$id',banners.status='2') and view.onoff='1',banners.onoff='1'  LIMIT 1;");  //ORDER BY rand()
         $result= mysql_query("SELECT * FROM `view` WHERE `id_account`<>'$id' and `onoff`='1' ORDER BY rand() LIMIT 1;");
       $row = mysql_fetch_array($result);


        $result2= mysql_query("SELECT * FROM `accounts` WHERE `id`='$row[id_account]' and `onoff`='1' LIMIT 1");
       $row2 = mysql_fetch_array($result2);
        if (mysql_num_rows($result2)==0)
                {  $im = imagecreatefromgif('images/bb.gif');  $sx = imagesx($im);   $sy = imagesy($im);    $img = imagecreate(68,30);    imageCopyResized($img, $im, 0, 0, 0, 0, 68, 30, $sx, $sy);   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");    header("Cache-Control: no-store, no-cache, must-revalidate");    header("Cache-Control: post-check=0, pre-check=0", false);    header("Pragma: no-cache");    header("Content-type: image/gif");    imageGIF($img);    ImageDestroy($img); exit();}
          $result3= mysql_query("SELECT * FROM banners WHERE `id_account`='$row2[id]' AND `status`='2' AND `onoff`='1' LIMIT 1");
              if (mysql_num_rows($result3)==0)
                {

                     $result4= mysql_query("UPDATE banners SET `status`='2' WHERE `id_account`='$row2[id]' AND `status`='1' AND `onoff`='1'");

                $result3= mysql_query("SELECT * FROM banners WHERE `id_account`='$row2[id]' AND `status`='2' AND `onoff`='1' LIMIT 1");
                $result3= mysql_query("SELECT * FROM banners WHERE `id_account`='$row2[id]' AND `status`='2' LIMIT 1");

if (mysql_num_rows($result3)==0) {  $im = @imagecreatefromgif("/images/bb.gif");
                 $sx = @imagesx($im);
                $sy = @imagesy($im);
                $img = @imagecreate(68,30);    @imageCopyResized($img, $im, 0, 0, 0, 0, 68, 30, $sx, $sy);   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");    header("Cache-Control: no-store, no-cache, must-revalidate");    header("Cache-Control: post-check=0, pre-check=0", false);    header("Pragma: no-cache");    header("Content-type: image/gif");    imageGIF($img);    ImageDestroy($img); exit();}
              }
        $row3 = @mysql_fetch_array($result3);
        $result4= mysql_query("UPDATE banners SET `status`='1' WHERE `id`='$row3[id]' LIMIT 1");


     //  $im = imagecreatefromgif('images/'.$row3[file_banner]);
     //  if($row3[file_banner]=='22.gif')  $im = imagecreatefromgif('22.gif');
  /* $sx = imagesx($im);
   $sy = imagesy($im); */
   $iii="images/$row3[file_banner]";
     if($row3[file_banner]=='22.gif') $iii = '22.gif';
    /*  $im = ImageCreateFromgif("$iii");


header("Content-type: image/gif");
imagegif($im); */
//$im2=ImageCreateFromgif("$iii");
//$im2=readfile();
//imagecopyresized($im2, $im1, 0,0,0,0,$neww,$newh, imagesx($im1), imagesy($im1));
header("Content-type: image/gif");
//imagegif($im2);
readfile($iii);
   /*$img = @imagecreate(95,35);
   imageCopyResized($img, $im, 0, 0, 0, 0, 95, 35, $sx, $sy);
   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
  header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");
   header("Content-type: image/gif");
   imageGIF($img);
   ImageDestroy($img);  */
        $result= mysql_query("INSERT INTO stat_acc (id_account,date,action,ip) VALUES ('$row2[id]','$date','$action','$ip')");
     //   $result= mysql_query("DELETE FROM view WHERE id_account='$row2[id]' LIMIT 1");
        $result= mysql_query("DELETE FROM view WHERE id_account='$row2[id]' LIMIT 1");
        $result2= mysql_query("SELECT * FROM komissia WHERE id_account='$id' LIMIT 1");
        $row2 = mysql_fetch_array($result2);
        if ($row2[view]<=9)
                {
                $result= mysql_query("UPDATE komissia SET view=view+1 WHERE id_account='$id'");
//                $result= mysql_query("INSERT INTO view (id_account) VALUES ('$id')");
 /*$result7= mysql_query("SELECT * FROM accounts WHERE `id`='$id' limit 1;");
        $row7 = mysql_fetch_array($result7);
        $oni=$row7[onoff];    */
                  $result45= mysql_query("SELECT * FROM `accounts` WHERE `id`='$id' AND `status`='1'");
        $row45 = mysql_fetch_array($result45);
         $result64= mysql_query("SELECT * FROM accounts WHERE id='$id'");
$row64 = mysql_fetch_array($result64);
 $oni4=$row45[11];
       // if($row7[onoff]=='2') {$result9= mysql_query("UPDATE `view` SET `onoff`='2' WHERE `onoff`='1' and `id_account`='$id'");}
  $result= mysql_query("INSERT INTO `view` (id_account,onoff) VALUES ('$id','$oni4')");
                }
        else
                {
                $result= mysql_query("UPDATE komissia SET view='0' WHERE id_account='$id'");
                }
        $result= mysql_query("INSERT INTO stat (id_account,date,action,ip) VALUES ('$id','$date','$action','$ip')");
        }

?>