<?php include('header.php');?>
<div class="menucenter">
<?if(!isset($_SESSION["username"]) && !isset($_SESSION["password"])){
	echo '<div class=error>Ошибка! Для доступа к данной странице необходимо зарегистрироваться!</div>';
	include('footer.php');
	exit();
}else{
	$username = text($_SESSION["username"]);


	if(!isset($_GET["id"])){

			require('stat_task.php');
			echo "<BR>";
	}

if($_GET["page"]!="")
      { $page=intval($_GET["page"]); } else { $page='1'; }
      $p1=8*($page-1);
	$id=intval($_GET["id"]);
	if(isset($_GET["id"])){

			$checkid = mysql_query("SELECT id FROM seelf_task WHERE id='$id' AND credits>0");
			$id_exist = mysql_num_rows($checkid);

			if ($id_exist<1){
					echo '<div class=error>Ошибка такого задания нет!</div>';
					include('footer.php');
					exit();
			}

			$ban_task = mysql_query("SELECT id FROM seelf_task_ban WHERE nameuser='$username'");
			if(mysql_num_rows($ban_task)>9)
				{
					echo '<div class=error>Ошибка! Вы не можете выполнять задания. На вас поданы жалобы от пользователей.<br />Если вы считаете жалобы не обоснованными напишите администрации в тех поддержку!<br /><a href="ban_task.php">Подробнее &gt;&gt;</a></div>';
					include('footer.php');
					exit();
				}


			$sql = mysql_query("SELECT * FROM seelf_task WHERE id='$id'");
			$row = mysql_fetch_assoc($sql);

				$id = $row["id"];
				$namep = $row["namep"];
				$type = $row["type"];
				$title = $row["title"];
				$text = $row["text"];
				$url = $row["url"];
				$credits = $row["credits"];
				$pay = $row["pay"];
				$active = $row["active"];
				$good = $row["good"];
				$bad = $row["bad"];
				$inprogress = $row["inprogress"];
$reyt_r = $row["good"];

if($reyt_r  >=0){

  $taskstat="<img src=images/rating0.png>";

if($reyt_r >=3){

  $taskstat="<img src=images/rating1.png>";


if($reyt_r >=6){

  $taskstat="<img src=images/rating2.png>";


if($reyt_r >=9){

  $taskstat="<img src=images/rating3.png>";

if($reyt_r >=12){

 $taskstat="<img src=images/rating4.png>";

if($reyt_r >=15){

  $taskstat="<img src=images/rating5.png>";

}}}}}
}

				$vip = $row["vip"];

require('stat_task.php');
require_once('bbcode.php');

$rest=mysql_query("select * from tb_users where username='$namep'");
$rowt=mysql_fetch_assoc($rest);
?>
<div class='menucenter' style='padding:0px;'>
<div class="name" style='margin:0px;margin-bottom:3px;padding:0px;'><b>Название: <?php echo $title;?></b></div>
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td align="center" rowspan="5" width="80px"  style='border-bottom:none;'>
<div align='center' style='background: url(../images/avbg.png) no-repeat; padding: 2px 0px 0px 0px; width: 78px; height:78px;'>
<img src="avp/<?=$rowt['avatar'];?>" class='avatar' width='62px' height='62px' title='Нажми для увеличения картинки'><br />
<div style='padding-top:10px;'>
<b><font color='red'><?=round($rowt['ball'],2);?> балл.</font></b>
</div>
</div></td>
<td class='value' align='left' >
<font color=#696969><b> <b>Рекламодатель:</b></font></td>
<td class='value' align='left' ><span style="font-size: 12px; font-weight: bold"><?php echo $namep;?><a class='tsk-mail' href="mailnew.php?name=<?php echo $namep;?>"></a></span>
Рейтинг рекламодателя: <span style="font-size: 12px; color: green; font-weight: bold">
     <?
      $sql="select sum(reyt_rek) from tb_users WHERE username='$namep'";
      $res=mysql_query($sql);
      $ret=mysql_result($res,0,0);
      echo $ret;
      ?></span>
</td>
</tr>
<tr>
<td class='value' align='left' ><span style="font-size: 12px; font-weight: bold">Тип задания:</span></td>
<td class='value' align='left' ><? echo $type;?></td>
</tr>
<tr>
<td class='value' align='left' ><font color=#696969><b> <b>Рейтинг задания:</b></font></td>
<td class='value' align='left' ><? echo $taskstat;?></td>
</tr>
<tr>
<td class='value' align='left' ><font color=#696969><b> <b>Оплата:</b></font></td>
<td class='value' align='left' ><font color=red><?php echo $pay;?></font>&nbsp; руб.</td>
</tr>
<tr>
<td class='value' align='left' style='border:none;'><span style="font-size: 12px; color: green; font-weight: bold">Одобрено: <?php echo $good;?></span></td>
<td class='value' align='left' style='border:none;'><span style="font-size: 12px; color: red; font-weight: bold">Отклонено: <?php echo $bad;?></span></td>
</tr>
</tbody>
</table>
</div>
<div class='menucenter'>
<div class="name">Описание:</div>
<span class='taskdescription'><?php echo $text;?></span>
</div>
<div class='menucenter'>
<center>
<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
                            <tr>
                                <td width='50%' aling='center'>
                                <a href="<?php echo $row["url"];?>" target="_blank" class="ads_dates" style="color:#4F4F4F;">Начать выполнение</a>
                                </td>
                                <td width='50%' aling='center'>
                                <a href="ctask.php?id=<?php echo $id;?>" class="ads_date" style="color:#4F4F4F;">Подтвердить задание</a>
                                </td>
                            </tr>
                        </table>
</center>
</div>
    <table width="100%">
        <tr>
            <td class="td_user" width="50%">
<?
require('config.php');
$username=text($_SESSION["username"]);
$newid=intval($_GET["id"]);
if($newid=="")
  {
function str_count($str,$col)
      {
if (strlen($str) > $col)
          {
$str = substr($str,0,$col);
          }
return ($str);
         }

$sql="select * from seelf_task order by id desc";
$res=mysql_query($sql);
while ($row=mysql_fetch_assoc($res))

$neew=mysql_query("SELECT * FROM seelf_task WHERE id='$newid'");
$neew=mysql_fetch_assoc($neew);

     }
if(isset($_POST["delete"]))
  {
$delid=intval($_POST["id"]);
$username=text($_SESSION["username"]);
$ob=mysql_fetch_assoc(mysql_query("SELECT user_status FROM tb_users WHERE username='$username'"));
$ussst=$ob["user_status"];
if($ussst=='admin')
{
mysql_query("DELETE FROM seelf_comments where id='$delid'");
      }else{
     }
  }
if(isset($_POST["comment"]))
{
require_once('bbcode.php');
$comment = bbcod($_POST["comment"], true, true);
$reyt_rek=text($_POST["reyt_rek"]);
if ($reyt_rek!=0 and $reyt_rek!=1 and $reyt_rek!=2 and $reyt_rek!=3 and $reyt_rek!=4 and $reyt_rek!=5 )
{
echo '<div class=error>Не дури систему</div>'; include('footer.php'); exit;
}
if($comment!='')
   {
$date=time();
mysql_query("INSERT INTO seelf_comments (idnew, data, user, comment, reyt_rek) VALUES ('$newid', '$date', '$username', '$comment', '$reyt_rek')");
mysql_query("UPDATE seelf_task SET reyt_rek=reyt_rek+$reyt_rek WHERE id='$newid'");
?>
				<script type="text/javascript">
				location.replace("task.php?id=<?=$newid ?>");
				</script>
				<noscript>
				<meta http-equiv="refresh" content="0; url=task.php?id=<?=$newid ?>">
				</noscript>
<?
   }
      }else{
     }
?>
<?
$nameus=$_SESSION["username"];
$sql=mysql_query("SELECT * FROM seelf_comments WHERE idnew='$newid' and user='$nameus'");
if(mysql_num_rows($sql)==0)
{
?>
<script type="text/javascript" language="JavaScript">
function LoginClick() {
document.getElementById('logfrm').style.display = '';
document.getElementById('logbtn').style.display = 'none';
}
</script>
<center>
<form name="mailform" action="" id="logbtn" class="btnlogin" href="#login" >
<input type=submit class="ok_wm" onClick="javascript:LoginClick(); return false;" value="Оставить отзыв">
</form>
</center>
<div id="logfrm" class="formlogin" style="display: none;">
<?
include("copilca/css.php");
include('task_form.php');?>
</div>
<? } ?>
<?
$num = 10;
$upag = "task.php?id=".$id."&";
$page = (isset($_GET['n']))? intval($_GET['n']) : 1 ;
$numpag = mysql_num_rows(mysql_query("SELECT `data` FROM `seelf_comments` WHERE idnew='$newid'"));
$np =$numpag;
$obpag = intval(($np - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $obpag) $page = $obpag;
$nach = $page * $num - $num;

$result="SELECT * from seelf_comments WHERE idnew='$newid' order by data desc LIMIT $nach, $num";
$myrow1=mysql_query($result) or die(mysql_error());
include("navi.php");
while ($rowe=mysql_fetch_assoc($myrow1))
{
  $usernapisal=$rowe["user"];
  $sqlz=mysql_query("SELECT * FROM tb_users WHERE username='$usernapisal'");
  $vivod=mysql_fetch_assoc($sqlz);
  $avabla=$vivod["avatar"];
  $yourcomment=$rowe["comment"];
  $your=$rowe["reyt_rek"];
  $yourdata=$rowe["data"];
  $normdate=date("H:i в d.m.y", $yourdata);

$ret = mysql_fetch_assoc(mysql_query("SELECT sum(reyt_user) as reyt_t FROM seelf_task_pay WHERE nameuser='$usernapisal'"));
?>

<table align='center' width='100%' border='0' cellpadding='0' cellspacing='0'>
<thead style='background:#f5f5b5;'>
<tr>
<td colspan='4' align='left' style='color:red; font:11px Tahoma; border-bottom:solid 1px #F2C0A6; border-top:solid 1px #F2C0A6; padding:4px; padding-left:15px;'><font color='#696969'>Пользователь:&nbsp;<font color="green"><?=$usernapisal; ?></font>
<small> (Репутация: <font color='red'><?echo round($ret['reyt_t'], 2);?></font> баллов)</font></small>
<td align='right' style='font:10px Tahoma; border-bottom:solid 1px #F2C0A6; border-top:solid 1px #F2C0A6; padding:4px; padding-right:5px;'>
&nbsp;<font color="red"><?=$normdate; ?>
</td>
<?
$username=text($_SESSION["username"]);
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if($whois["user_status"]=='admin')
{
?><td align='right' style='color:red; font:13px Tahoma; border-bottom:solid 1px #F2C0A6; border-top:solid 1px #F2C0A6; '>
<form action="" method="POST">
<input type=hidden name="delete">
<input type=hidden name="id" value="<?=$rowe["id"];?>"><input type="image" img src="images/delete.png" alt="" style="border:none;padding:0px;" title="Удалить"></form>
</td>
<? } ?>
            </tr>
          </thead>
<td width='80px' valign='top' style='padding:5px;'>
<a href='avp/$avabla' onclick='return hs.expand(this)'>
<div align='center' style='background: url(../images/avbg.png) no-repeat; padding: 2px 0px 0px 0px; width: 78px; height:78px;'>
<a href='wall.php?user=<? echo $usernapisal; ?>'><img src='avp/<?=$avabla;?>' a class='avatar' width='62px' height='62px' title='Перейти на стену пользователя'></a>
<div>
</a><b>
</td>
<td align='left' valign='top' colspan='3' style='padding:5px;padding-top:15px;'>
<?=$yourcomment; ?>
<div style='padding-top:20px; color:green; font: 12px Arial, Verdana, sans-serif, Tahoma;font-style: italic;font-weight: bold;'>
Оценка:&nbsp;<?=$your; ?>
</div>
</td><td></td>
<? $username=text($_SESSION["username"]);
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if($whois["user_status"]=='admin')
{
?>
<td></td>
<? } ?>
</table>
<? } ?>
<div class="menucenter">
* - Запрещено размещение в комментариях информации, полученной при выполнении задания. Например, ссылки, по которым были совершены переходы, ответы, пароли и т.п. Также, запрещено размещение комментариев оскорбительного характера, нецензурных высказываний и т.п. Аккаунты пользователей, нарушающих данные условия, будут оштрафованы/заблокированы администрацией проекта!
</div>
</tr>
</td>
</table>
<?
		}else{

if(isset($_GET["sort"])){$tr_s = "sort=".$_GET["sort"]."&amp;";}
echo'
<div class="menucenter" style="padding:0px;margin:0px;">
<div class="name" style="padding:0px;margin:0px;">Сортировать задание по:</div>
<table class="reyt" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td><a href="'.$_SERVER['PHP_SELF'].'?'.$tr_s.'page='.$page.'" class="tabl">Все</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?'.$tr_s.'tr=1&amp;" class="tabl">Новые</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?'.$tr_s.'tr=2&amp;" class="tabl">Клики</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?'.$tr_s.'tr=3&amp;" class="tabl">Регистрация с активностью</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?'.$tr_s.'tr=4&amp;" class="tabl">Регистрация без активности</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?'.$tr_s.'tr=5&amp;" class="tabl">Прочее</a></td>
</tr>
<tr>
';
if(isset($_GET["tr"])){$s_tr = "&amp;tr=".$_GET["tr"];}
			echo'
<td><a href="'.$_SERVER['PHP_SELF'].'?sort=1'.$s_tr.'&amp;" class="tabl" title="Сортировать по номеру">№</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?sort=2'.$s_tr.'&amp;" class="tabl" title="Сортировать по названию">Названию</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?sort=5'.$s_tr.'&amp;" class="tabl" title="Сортировать по цене">Стоимости</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?sort=6'.$s_tr.'&amp;" class="tabl" title="Сортировать по рейтингу">Рейтингу</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?sort=7'.$s_tr.'&amp;" class="tabl" title="Сортировать по типу задания">Типу задания</a></td>
<td><a href="'.$_SERVER['PHP_SELF'].'?sort=8'.$s_tr.'&amp;" class="tabl" title="Сортировать по остатку">Остатку</a></td>
</tr>
<tr>
<td colspan="6" align="center" style="border-bottom:0px;"><font color="red">Автоподтверждение заданий в течение 14 дней.</font></td>
</tr>
</table>
</div>
';
			echo "<BR>";
			if(isset($_GET["sort"])) {
				if(preg_match("|^[\d]*$|",$_GET["sort"])) {
					$sort = intval($_GET["sort"]);
					if($sort==1) $s_tab = "id";
					elseif ($sort==2) $s_tab = "title";
					elseif ($sort==3) $s_tab = "namep";
					elseif ($sort==4) $s_tab = "date";
					elseif ($sort==5) $s_tab = "pay";
					elseif ($sort==6) $s_tab = "good";
					elseif ($sort==7) $s_tab = "type";
					elseif ($sort==8) $s_tab = "credits";
                                        else $s_tab = "date";
				}else{
					$s_tab = "date";
					$sort = "1";
				}
			}else{
				$s_tab = "date";
				$sort = "1";
			}

switch ($_GET["tr"]) {
case 1: $task_raz = 'AND date > '.time().'-43200';break;
case 2: $task_raz = 'AND type =\'клики\'';break;
case 3: $task_raz = 'AND type =\'регистрация с активностью\'';break;
case 4: $task_raz = 'AND type =\'регистрация без активности\'';break;
case 5: $task_raz = 'AND type =\'прочее\'';break;
default: $task_raz = '';
}

echo '<table class="reyt" width=" 100%" border="0"  cellpadding="0" cellspacing="0" >';
echo '<thead><tr>';
                                        echo '<th width="5%" align="center" class="top"><a class=link_head href="'.$_SERVER['PHP_SELF'].'?sort=1'.$s_tr.'&amp;page='.$page.'" class="tabl" title="Сортировать по номеру" style="color:#fff;"><font color=white>№</font></a></th>';
      					echo '<th width="50%" align="left" class="top"><a class=link_head href="'.$_SERVER['PHP_SELF'].'?sort=2'.$s_tr.'&amp;page='.$page.'" class="tabl" title="Сортировать по названию" style="color:#fff;"><font color=white>Название</font></a></th>';
                                        echo '<th width="5%" align="center" class="top"></th>';
                                        echo '<th width="5%" align="center" class="top"></th>';
                                        echo '<th width="10%" align="center" class="top"><a class=link_head href="'.$_SERVER['PHP_SELF'].'?sort=5'.$s_tr.'&amp;page='.$page.'" class="tabl" title="Сортировать по цене" style="color:#fff;"><font color=white>Стоимость</font></a></th>';
                                        echo '<th width="20%" align="center" class="top"><a class=link_head href="'.$_SERVER['PHP_SELF'].'?sort=6'.$s_tr.'&amp;page='.$page.'" class="tabl" title="Сортировать по Рейтингу" style="color:#fff;"><font color=white>Рейтинг</font></a></th>';
$sql = mysql_query("SELECT * FROM seelf_task WHERE credits>0 AND active='1' AND vip='1' ".$task_raz." ORDER BY  $s_tab DESC limit 10");
			if(mysql_num_rows($sql)>0) {
					while ($row = mysql_fetch_assoc($sql)) {

$reyt_r = $row["good"];

if($reyt_r >=0){

  $taskstat="<img src=images/rating0.png>";


if($reyt_r >=3){

  $taskstat="<img src=images/rating1.png>";


if($reyt_r >=6){

  $taskstat="<img src=images/rating2.png>";


if($reyt_r >=9){

  $taskstat="<img src=images/rating3.png>";

if($reyt_r >=12){

 $taskstat="<img src=images/rating4.png>";

if($reyt_r >=15){

  $taskstat="<img src=images/rating5.png>";

}}}}
}}
						$color = $row["color"];
$n_t = "";
if($row["date"] > time()-43200 and $row["verx"]!=1){$n_t = "<font style=\"font-size:11px;color:#D50000;\"> ( New )</font>";}
$v_t = "";
if($row["24h"]==1){$v_t = "<font style=\"font-size:10px;color:#D50000;\"><img src='images/date.png' title='Многоразовое' align='absmiddle' /></font>";}
$domen=$row["url"];
$domen = str_replace("//","/",$domen);
$domen = str_replace("www.","",$domen);
$domen = explode("/", $domen);
$domen=$domen[1];
if (strlen($domen) > 20) { $domen=substr($domen,0,20)."..."; }
 					echo '
                                        <tbody><tr>';
					echo '<tr bgcolor="'.$color.'">';
					echo '<td class="value" align="left"><img src="images/user_task.png" align="absmiddle" /></td>';
					echo '<td class="value" align="left"><span class="desctext3"><a href="'.$_SERVER['PHP_SELF'].'?id='.$row["id"].'">'.$row["title"].'</a>'.$n_t.'</span><br><span class="desctext">http://'.$domen.'</span><br>
                                        <span class="desctext2">№ '.$row["id"].' - '.$row["type"].'</span></td>';
                                        echo '<td align="center"><span class="vip">VIP</span></td>';
                                        echo '<td align="center">'.$v_t.'</td>';
                                        echo '<td align="center"><span class="desctext4" style="font-size:13px;"><font color=red><b>'.$row["pay"].' </b></font>&nbsp;руб.</span></td>';
					echo '<td class="value" align="center"><span class="desctext4"><font color="green">'.$row["good"].'</font> - <font color="red">'.$row["bad"].'</font> - '.$row["inprogress"].'</span><br />'.$taskstat.'</td>';
					}
					echo '</tbody>';
}


			$sql = mysql_query("SELECT * FROM seelf_task WHERE credits>0 AND active='1' AND vip='0' ".$task_raz." ORDER BY $s_tab DESC limit $p1,20");
			if(mysql_num_rows($sql)>0) {

					while ($row = mysql_fetch_assoc($sql)) {
$reyt_r = $row["good"];

if($reyt_r >=0){

  $taskstat="<img src=images/rating0.png>";

if($reyt_r >=3){

  $taskstat="<img src=images/rating1.png>";


if($reyt_r >=6){

  $taskstat="<img src=images/rating2.png>";


if($reyt_r >=9){

  $taskstat="<img src=images/rating3.png>";

if($reyt_r >=12){

 $taskstat="<img src=images/rating4.png>";

if($reyt_r >=15){

  $taskstat="<img src=images/rating5.png>";

}}}}}
}
						$color = $row["color"];
                                        $n_t = "";
if($row["date"] > time()-43200 and $row["verx"]!=1){$n_t = "<font style=\"font-size:11px;color:#D50000;\">( New )</font>";}
$v_t = "";
if($row["24h"]==1){$v_t = "<font style=\"font-size:10px;color:#D50000;\"><img src='images/date.png' title='Многоразовое' align='absmiddle' /></font>";}
$domen=$row["url"];
$domen = str_replace("//","/",$domen);
$domen = str_replace("www.","",$domen);
$domen = explode("/", $domen);
$domen=$domen[1];
if (strlen($domen) > 20) { $domen=substr($domen,0,20)."..."; }
 					echo '<tr>';
					echo '<tr bgcolor="'.$color.'">';
					echo '<td class="value" align="left"><img src="images/user_task.png" align="absmiddle" /></td>';
					echo '<td class="value" align="left"><span class="desctext3"><a href="'.$_SERVER['PHP_SELF'].'?id='.$row["id"].'">
                                        '.$row["title"].' </a>'.$n_t.'</span><br><span class="desctext">http://'.$domen.'</span><br>
                                        <span class="desctext2">№ '.$row["id"].' - '.$row["type"].'</span></td>';
                                        echo '<td align="center"></td>';
                                        echo '<td align="center">'.$v_t.'</td>';
                                        echo '<td align="center"><span class="desctext4" style="font-size:13px;"><font color="red"><b>'.$row["pay"].' </b></font>&nbsp;руб.</span></td>';
					echo '<td align="center"><span class="desctext4"><font color=green>'.$row["good"].'</font> - <font color=red>'.$row["bad"].'</font> - '.$row["inprogress"].'</span><br />'.$taskstat.'</td>';
					}
					echo '</table><br><center>';


			}else{
				if($kolvo>0) {echo '<font color="red"><b>Ошибка такой страницы не существует!</b></font>'; include('footer.php'); exit();}
			}

switch ($_GET["tr"]) {
case 1: $t_raz = 'WHERE date > '.time().'-43200';break;
case 2: $t_raz = 'WHERE type =\'клики\'';break;
case 3: $t_raz = 'WHERE type =\'регистрация с активностью\'';break;
case 4: $t_raz = 'WHERE type =\'регистрация без активности\'';break;
case 5: $t_raz = 'WHERE type =\'прочее\'';break;
default: $t_raz = '';
}

$result=mysql_query("SELECT * FROM seelf_task ".$t_raz." order by id desc limit $p1,20");
$res=mysql_query("select count(*) from seelf_task ".$t_raz." ");
$all=mysql_result($res,0,0);
if($all>0)
{
$pages=$all/20;
$pages1=floor($pages);
if($pages>$pages1)
{
$pages=$pages1+1;
}
include("copilca/css.php");
?><div class="navil"><center>
<?
for($i=1;$i<=$pages;$i++)
{
echo '&nbsp;<a class="selpage" href="'.$_SERVER['PHP_SELF'].'?'.$tr_s.'page='.$i.$s_tr.'">'.$i.'</a>&nbsp;';
}
echo "</center></div></center>";

}
}
}
include('footer.php');?>