- <?php
- // Load JsHttpRequest backend.
- require_once "inc/JsHttpRequest.php";
- include ("inc/smiles.php");
- // Create main library object. You MUST specify page encoding!
- $JsHttpRequest =& new JsHttpRequest("windows-1251");
- // Store resulting data in $_RESULT array (will appear in req.responseJs).
- // Below is unparsed stream data (will appear in req.responseText).
- $a=$_REQUEST['a'];
- $body=htmlspecialchars($_REQUEST['body']);
- $foto_num=$_REQUEST['foto_num']-1;
- $id=$_REQUEST['id'];
- $user_id=$_REQUEST['user_id'];
- $col=$_REQUEST['col'];
- $ball=$_REQUEST['ball'];
- $GLOBALS['_RESULT'] = 0;
- switch ($a)
- {
- case "vote":
- if($fa_userid!=$user_id && $fa_userid!=0)
- {
- $voted=execsqlone("select count(*) from vote where mod_id='13' and source_id='$user_id' and user_id='$fa_userid'");
- if($voted==0)
- {
- $res=sql_query("select rating,votes,balls,showns from gallery_info where user_id='$user_id'",$dbi);
- $row=sql_fetch_object($res,$dbi);
- $b=$row->balls+$ball;
- $rating=round(($b)/($row->votes+1),2);
- $votes=$row->votes+1;
- sql_query("update gallery_info set rating='$rating',balls='$b',votes=votes+1 where user_id='$user_id'",$dbi);
- sql_query("insert into vote set mod_id='13',source_id='$user_id',user_id='$fa_userid',ball='$ball'",$dbi);
- echo 'Голос учтен!';
- $GLOBALS['_RESULT'] = array(
- "stat" =>"текущий рейтинг: $rating<br>кол-во голосов: $votes баллы: $b кол-во просмотров: $row->showns");
- }
- else
- {
- echo 'Вы уже голосовали!';
- }
- }
- else
- {echo 'За свое фото голосовать нельзя!';}
- break;
- case "getInfo":
- $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);
- $row_o=sql_fetch_object($res,$dbi);
- $res=sql_query("select * from gallery_img where author_id='$user_id' and is_active=1 order by sort_id asc limit 1999",$dbi);
- $row_img=sql_fetch_object($res,$dbi);
- if($row_o->fotos==0){$row_img->file="img/gallery/empty.jpg";}
- elseif($row_o->fotos>0 && !$row_img->file){$row_img->file="img/gallery/wait.jpg";}
- else {$img=$row_img->file;$row_img->file="img/gallery/small/small_$row_img->file";}
- $nick=nick($row_o->name);
- if($row_o->name_real) {$name_real="Имя:$row_o->name_real";}
- if($row_o->pol=="m") {$pol="Пол:муж.";} else {$pol="Пол:жен.";}
- if($row_o->age){$age="Возраст:$row_o->age";}
- if($row_o->city){$city="Город:$row_o->city";}
- sql_query("update gallery_info set showns=showns+1 where user_id='$user_id'",$dbi);
- $v=execsqlone("select count(*) from vote where mod_id='13' and source_id='$user_id' and user_id='$fa_userid'");
- if($v==0 && $fa_userid!=$user_id && $fa_userid!=0){
- $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>
- <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>";
- }else {$vote="";}
- $sql = "SELECT * FROM gallery_img WHERE author_id = '$user_id' limit 10";
- $res = sql_query($sql,$dbi);
- $sortik = 1;
- while($row12 = sql_fetch_array($res,$dbi)){
- $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>";
- $sortik++;
- }
- $GLOBALS['_RESULT'] = array(
- "carousel_count"=>($sortik-1),
- "vote" => $vote,
- "link" => "Ссылка на фотографии: <a href='/?mod=gallery&n=".str_replace("+", "%20",urlencode($row_o->name))."'>http://tzapocalipsys.ru/?mod=gallery&n=$row_o->name",
- "nick" => $nick,
- "info" => "$name_real $pol $age $city",
- "foto" =>"<a href=/img/gallery/orig/$img target=_blank><img src=$row_img->file border=0></a><br><br>$row_img->comment",
- "pages" => $mycarousel,
- "stat" =>"текущий рейтинг: $row_o->rating<br>кол-во голосов: $row_o->votes баллы: $row_o->balls кол-во просмотров: $row_o->showns",
- "col_com"=>"<a href='javascript:{}' onclick=activateCom('$user_id')>комментарии [$row_o->comments]</a>");
- /* $GLOBALS['_RESULT']['nick'] = $nick;
- $GLOBALS['_RESULT']['info'] ="$name_real $pol $age $city";
- $GLOBALS['_RESULT']['foto'] ="<img src=$row_img->file border=1><br><br>$row_img->comment";
- $GLOBALS['_RESULT']['pages'] =$p_arr;
- $GLOBALS['_RESULT']['stat'] ="текущий рейтинг: $row_o->rating<br>кол-во голосов: $row_o->votes баллы: $row_o->balls кол-во просмотров: $row_o->showns";
- $GLOBALS['_RESULT']['col_com'] ="<span class=hand onclick=activateCom('$user_id')>комментарии [$row_o->comments]</span>";
- */
- #echo "<pre>";
- #print_r($GLOBALS['_RESULT']);
- break;
- case "getFoto":
- sql_query("update gallery_info set showns=showns+1 where user_id='$user_id'",$dbi);
- $sql="select * from gallery_img where author_id='$user_id' order by sort_id asc limit $foto_num,1";
- $res=sql_query($sql,$dbi);
- $row=sql_fetch_object($res,$dbi);
- 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";
- $p_arr="";
- for($i=1;$i<=$col;$i++)
- {
- if($i!=$foto_num+1){$p_arr.=" <a href='javascript:{}' onclick=goToFoto('$i','$user_id','$col') class=hand>$i</a> ";}
- else {$p_arr.=" <b>[$i]</b> ";}
- }
- $GLOBALS['_RESULT'] = $p_arr;
- break;
- case "OkeyFoto":
- if($fa_userid && $fa_isadmin==1)
- {
- $post_date=time();
- $cnt=execsqlone("select count(*) from gallery_img where id='$id' and is_active=0");
- if($cnt>0){
- $sql="update gallery_img set is_active=1 where id='$id'";
- sql_query($sql,$dbi);
- $sql="update gallery_info set fotos=fotos+1,last_update='".time()."' where user_id='$user_id'";
- sql_query($sql,$dbi);
- echo "<font color=blue>Успешно промодерирована</font>";
- }
- else {echo "<font color=blue>Данное фото уже промодерировал другой модератор</font>";}
- }
- break;
- case "DelFoto":
- if($fa_userid && $fa_isadmin==1)
- {
- $cnt=execsqlone("select count(*) from gallery_img where id='$id' and is_active=0");
- if($cnt>0){
- $file=execsqlone("select file from gallery_img where id='$id'");
- unlink("img/gallery/orig/$file");
- unlink("img/gallery/small/small_$file");
- $sql="delete from gallery_img where id='$id'";
- sql_query($sql,$dbi);
- echo "<font color=blue>Успешно удалена</font>";
- }
- else
- {"<font color=blue>Данное фото уже удалил другой модератор</font>";}
- }
- break;
- case "DelFotoUser":
- if($fa_userid)
- {
- $res=sql_query("select * from gallery_img where id='$id' and author_id='$fa_userid'",$dbi);
- $row=sql_fetch_object($res,$dbi);
- if($row->file)
- {
- unlink("img/gallery/orig/$row->file");
- unlink("img/gallery/small/small_$row->file");
- if($row->is_active==1)
- {
- $sql="update gallery_info set fotos=fotos-1 where user_id='$fa_userid'";
- sql_query($sql,$dbi);
- }
- $sql="delete from gallery_img where id='$id'";
- sql_query($sql,$dbi);
- echo "<font color=blue>Успешно удалена</font>";
- }
- }
- break;
- case "getCom":
- if($fa_userid)
- {
- $res=sql_query("select comment from gallery_img where id='$id' and author_id='$fa_userid'",$dbi);
- $row=sql_fetch_object($res,$dbi);
- echo $row->comment;
- }
- break;
- case "saveCom":
- if($fa_userid)
- {
- sql_query("update gallery_img set comment='$body' where id='$id' and author_id='$fa_userid'",$dbi);
- echo "Коммент:$body";
- }
- break;
- }
- ?>
