Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Sep 9th, 2010 | Syntax: None | Size: 8.30 KB | Hits: 22 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. <?php
  2. // Load JsHttpRequest backend.
  3. require_once "inc/JsHttpRequest.php";
  4. include ("inc/smiles.php");
  5. // Create main library object. You MUST specify page encoding!
  6. $JsHttpRequest =& new JsHttpRequest("windows-1251");
  7. // Store resulting data in $_RESULT array (will appear in req.responseJs).
  8.  
  9. // Below is unparsed stream data (will appear in req.responseText).
  10.  
  11. $a=$_REQUEST['a'];
  12. $body=htmlspecialchars($_REQUEST['body']);
  13. $foto_num=$_REQUEST['foto_num']-1;
  14. $id=$_REQUEST['id'];
  15. $user_id=$_REQUEST['user_id'];
  16. $col=$_REQUEST['col'];
  17. $ball=$_REQUEST['ball'];
  18. $GLOBALS['_RESULT'] = 0;
  19.  
  20.  
  21.  
  22.  
  23. switch ($a)
  24. {
  25. case "vote":
  26.         if($fa_userid!=$user_id && $fa_userid!=0)
  27.         {
  28.  
  29.                 $voted=execsqlone("select count(*) from vote where mod_id='13' and source_id='$user_id' and  user_id='$fa_userid'");
  30.                
  31.  
  32.                 if($voted==0)
  33.                 {
  34.                 $res=sql_query("select rating,votes,balls,showns from gallery_info  where user_id='$user_id'",$dbi);
  35.                 $row=sql_fetch_object($res,$dbi);
  36.                 $b=$row->balls+$ball;
  37.                
  38.                 $rating=round(($b)/($row->votes+1),2);
  39.                 $votes=$row->votes+1;
  40.                
  41.                 sql_query("update gallery_info set rating='$rating',balls='$b',votes=votes+1 where user_id='$user_id'",$dbi);
  42.                 sql_query("insert into vote set mod_id='13',source_id='$user_id',user_id='$fa_userid',ball='$ball'",$dbi);
  43.                 echo 'Голос учтен!';
  44.                
  45.                                 $GLOBALS['_RESULT'] = array(
  46.  
  47.                       "stat"   =>"текущий рейтинг: $rating<br>кол-во голосов: $votes баллы: $b кол-во просмотров: $row->showns");
  48.                 }
  49.                 else
  50.                 {
  51.                 echo 'Вы уже голосовали!';
  52.                 }
  53.  
  54.                
  55.         }      
  56.         else
  57.                 {echo 'За свое фото голосовать нельзя!';}
  58. break; 
  59.        
  60.        
  61. case "getInfo":
  62.                 $res=sql_query("select a.*,b.name from gallery_info a LEFT JOIN sys_users b ON b.id=a.user_id where user_id='$user_id'",$dbi);
  63.                 $row_o=sql_fetch_object($res,$dbi);
  64.                 $res=sql_query("select * from gallery_img  where author_id='$user_id' and is_active=1 order by sort_id asc limit 1999",$dbi);
  65.                 $row_img=sql_fetch_object($res,$dbi);
  66.                 if($row_o->fotos==0){$row_img->file="img/gallery/empty.jpg";}
  67.                 elseif($row_o->fotos>0 && !$row_img->file){$row_img->file="img/gallery/wait.jpg";}
  68.                 else {$img=$row_img->file;$row_img->file="img/gallery/small/small_$row_img->file";}
  69.                 $nick=nick($row_o->name);
  70.                 if($row_o->name_real) {$name_real="Имя:$row_o->name_real";}
  71.                 if($row_o->pol=="m") {$pol="Пол:муж.";} else {$pol="Пол:жен.";}
  72.                 if($row_o->age){$age="Возраст:$row_o->age";}
  73.                 if($row_o->city){$city="Город:$row_o->city";}
  74.                 sql_query("update  gallery_info set showns=showns+1  where user_id='$user_id'",$dbi);
  75.                 $v=execsqlone("select count(*) from vote where mod_id='13' and source_id='$user_id' and  user_id='$fa_userid'");
  76.                 if($v==0 && $fa_userid!=$user_id && $fa_userid!=0){
  77.                 $vote="<table><tr align=center><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td><input class='pole1' name=ball type='radio'  value='1'></td><td><input class='pole1' name=ball type='radio'  value='2'></td>
  78.                 <td><input class='pole1' name=ball type='radio'  value='3'></td><td><input class='pole1' name=ball type='radio'  value='4'></td><td><input class='pole1' name=ball type='radio'  value='5' checked></td></tr><tr align=center><td colspan=5><input type=button value='Голосовать' onclick=vote('$user_id') class=pole1></td></tr></table>";
  79.                 }else {$vote="";}
  80. $sql = "SELECT * FROM gallery_img WHERE author_id = '$user_id' limit 10";
  81. $res = sql_query($sql,$dbi);
  82. $sortik = 1;
  83.  
  84. while($row12 = sql_fetch_array($res,$dbi)){
  85. $mycarousel .= "<li class='jcarousel-item jcarousel-item-horizontal jcarousel-item-$sortik jcarousel-item-$sortik-horizontal' style='float: left; list-style-position: outside; list-style-type: none; list-style-image: none' jcarouselindex='$sortik'><img src='http://tzserv.ru/img/gallery/orig/".$row12['file']."' width='80' height='80' alt='$user_id'></li>";
  86. $sortik++;
  87. }
  88.        
  89.                 $GLOBALS['_RESULT'] = array(
  90.                           "carousel_count"=>($sortik-1),
  91.                           "vote"   => $vote,
  92.                           "link"   => "Ссылка на фотографии: <a href='/?mod=gallery&n=".str_replace("+", "%20",urlencode($row_o->name))."'>http://tzapocalipsys.ru/?mod=gallery&n=$row_o->name",
  93.                       "nick"   => $nick,
  94.                       "info"   => "$name_real $pol $age $city",
  95.                       "foto"   =>"<a href=/img/gallery/orig/$img target=_blank><img src=$row_img->file border=0></a><br><br>$row_img->comment",
  96.                       "pages"  => $mycarousel,
  97.                       "stat"   =>"текущий рейтинг: $row_o->rating<br>кол-во голосов: $row_o->votes баллы: $row_o->balls кол-во просмотров: $row_o->showns",
  98.                       "col_com"=>"<a href='javascript:{}' onclick=activateCom('$user_id')>комментарии [$row_o->comments]</a>");
  99. /*              $GLOBALS['_RESULT']['nick'] =   $nick;
  100.                 $GLOBALS['_RESULT']['info'] ="$name_real $pol $age $city";
  101.                 $GLOBALS['_RESULT']['foto'] ="<img src=$row_img->file border=1><br><br>$row_img->comment";    
  102.                 $GLOBALS['_RESULT']['pages'] =$p_arr;
  103.                 $GLOBALS['_RESULT']['stat'] ="текущий рейтинг: $row_o->rating<br>кол-во голосов: $row_o->votes баллы: $row_o->balls кол-во просмотров: $row_o->showns";
  104.                 $GLOBALS['_RESULT']['col_com'] ="<span class=hand onclick=activateCom('$user_id')>комментарии [$row_o->comments]</span>";
  105. */
  106. #echo "<pre>";
  107. #print_r($GLOBALS['_RESULT']);
  108. break; 
  109.        
  110.        
  111. case "getFoto":
  112.         sql_query("update  gallery_info set showns=showns+1  where user_id='$user_id'",$dbi);
  113.         $sql="select * from gallery_img where author_id='$user_id' order by sort_id asc limit $foto_num,1";
  114.         $res=sql_query($sql,$dbi);
  115.         $row=sql_fetch_object($res,$dbi);
  116.         echo "<a href=/img/gallery/orig/$row->file target=_blank><img src=img/gallery/small/small_$row->file border=0></a><br><br>$row->comment";
  117.         $p_arr="";
  118.                 for($i=1;$i<=$col;$i++)
  119.                 {
  120.                         if($i!=$foto_num+1){$p_arr.=" <a href='javascript:{}' onclick=goToFoto('$i','$user_id','$col') class=hand>$i</a> ";}
  121.                         else {$p_arr.=" <b>[$i]</b> ";}
  122.                 }
  123.                 $GLOBALS['_RESULT'] = $p_arr;
  124. break; 
  125.  
  126. case "OkeyFoto":
  127.                
  128.         if($fa_userid && $fa_isadmin==1)
  129.         {
  130.  
  131.  
  132.        
  133.                 $post_date=time();
  134.                 $cnt=execsqlone("select count(*) from gallery_img   where id='$id' and is_active=0");
  135.                 if($cnt>0){
  136.                 $sql="update gallery_img set is_active=1 where id='$id'";
  137.                 sql_query($sql,$dbi);
  138.                 $sql="update gallery_info  set fotos=fotos+1,last_update='".time()."' where user_id='$user_id'";
  139.                 sql_query($sql,$dbi);
  140.  
  141.                 echo "<font color=blue>Успешно промодерирована</font>";
  142.                 }
  143.                 else {echo "<font color=blue>Данное фото уже промодерировал другой модератор</font>";}
  144.                
  145.         }
  146. break; 
  147. case "DelFoto":
  148.                
  149.         if($fa_userid && $fa_isadmin==1)
  150.         {
  151.  
  152.  
  153.         $cnt=execsqlone("select count(*) from gallery_img   where id='$id' and is_active=0");
  154.         if($cnt>0){
  155.                 $file=execsqlone("select file from gallery_img where id='$id'");
  156.                
  157.                 unlink("img/gallery/orig/$file");
  158.                 unlink("img/gallery/small/small_$file");
  159.                 $sql="delete from gallery_img  where id='$id'";
  160.                 sql_query($sql,$dbi);
  161.  
  162.  
  163.                 echo "<font color=blue>Успешно удалена</font>";
  164.         }
  165.         else
  166.         {"<font color=blue>Данное фото уже удалил другой модератор</font>";}
  167.                
  168.         }
  169. break; 
  170.  
  171. case "DelFotoUser":
  172.                
  173.         if($fa_userid)
  174.         {
  175.  
  176.  
  177.        
  178.                 $res=sql_query("select * from gallery_img where id='$id' and author_id='$fa_userid'",$dbi);
  179.                 $row=sql_fetch_object($res,$dbi);
  180.                 if($row->file)
  181.                 {
  182.                 unlink("img/gallery/orig/$row->file");
  183.                 unlink("img/gallery/small/small_$row->file");
  184.                 if($row->is_active==1)
  185.                 {
  186.                 $sql="update gallery_info  set fotos=fotos-1 where user_id='$fa_userid'";
  187.                 sql_query($sql,$dbi);
  188.                 }
  189.                 $sql="delete from gallery_img  where id='$id'";
  190.                 sql_query($sql,$dbi);
  191.  
  192.  
  193.                 echo "<font color=blue>Успешно удалена</font>";
  194.                 }
  195.                
  196.         }
  197. break;
  198.  
  199. case "getCom":
  200.                
  201.         if($fa_userid)
  202.         {
  203.  
  204.  
  205.        
  206.                 $res=sql_query("select comment from gallery_img where id='$id' and author_id='$fa_userid'",$dbi);
  207.                 $row=sql_fetch_object($res,$dbi);
  208.                 echo $row->comment;
  209.                
  210.         }
  211. break;
  212.  
  213. case "saveCom":
  214.                
  215.         if($fa_userid)
  216.         {
  217.  
  218.  
  219.        
  220.                 sql_query("update  gallery_img set comment='$body' where id='$id' and author_id='$fa_userid'",$dbi);
  221.                
  222.                 echo "Коммент:$body";
  223.                
  224.         }
  225. break;
  226.  
  227.        
  228.  
  229.  
  230.  
  231. }
  232. ?>