<?php
/*[_X3T4_N!CK_] Muellifdir Silenin Anasin Sikim*/
define('MKTOP', 1);
require_once('../system/connect.php');
require_once('../system/core.php');
require_once('../system/function.php');
level(2);
switch($act){
default:
$title = 'Saytlari idarə etme';
require_once('../head.php');
$count = mysql_num_rows(mysql_query("SELECT * FROM `sait`"));
if($count > 0){
$total=intval(($count-1)/$page_sait)+1;
$page=abs(intval($_GET['page']));
if(empty($page) OR $page < 0) $page = 1;
if($page > $total) $page = $total;
$past=intval($count/$page_sait);
$start=$page*$page_sait-$page_sait;
if($_GET['sort'] == 'hits') $sort= 'hits';
elseif($_GET['sort'] == 'in') $sort= 'in';
elseif($_GET['sort'] == 'out') $sort= 'out';
else $sort= 'hosts';
$saits = mysql_query("SELECT * FROM `sait` ORDER BY `".$sort."` DESC LIMIT ".$start.",".$page_sait."");
echo'<div class="text"><a href="platforms.php?act=check_sait&sort='.$sort.'">Semi-avtomatik təftiş platformaları</div>';
while($row = mysql_fetch_array($saits)){
$start++;
if($row['ban'] == 1) $ban = '<a href="platforms.php?act=ban&id='.$row['id'].'">Azad Et</a>';
else $ban = '<a href="platforms.php?act=ban&id='.$row['id'].'">Ban Et</a>';
if($row['status'] == 0) $ban .= ' <a href="moderacia.php?act=activate&id='.$row['id'].'">Aktiv Et</a>';
$zabanen = ($row['ban'] == 0) ? '' : '(Ban Edilib)';
$status = $row['status'] == 1 ? '' : '(Tesdiq Edilmeyib)';
echo '<a class="link" href="/out/'.$row['id'].'.php">'.$start.') '.$row['name'].' <span class="stat">'.$row['hosts'].'/'.$row['hits'].'</span> '.$zabanen.''.$status.'</a>';
if(mb_strlen($row['about']) > 50){
$text = mb_substr($row['about'], 0, 50, 'utf-8');
echo '<a class="link" href="/infos.php?id='.$row['id'].'">'.$text.'...</a>';
}
else echo '<a class="link" href="/infos.php?id='.$row['id'].'">'.$row['about'].'</a>';
echo '<div class="text"><a href="platforms.php?act=edit_sait&id='.$row['id'].'">Deyiş</a> | <a href="platforms.php?act=del_sait&id='.$row['id'].'">Sil</a> | '.$ban.'</div>';
}
navigation($count,$page_sait,$page,'platforms.php?sort='.$sort.'&',$total);
}
else echo '<div class="text">Sayt Yoxdur!</div>';
break;
//inoy
case 'check_sait':
$title = 'Semi-avtomatik təftiş platformaları';
require_once('../head.php');
$count = mysql_num_rows(mysql_query("SELECT * FROM `sait`"));
if($count > 0){
$total=intval(($count-1)/$page_sait)+1;
$page=abs(intval($_GET['page']));
if(empty($page) OR $page < 0) $page = 1;
if($page > $total) $page = $total;
$past=intval($count/$page_sait);
$start=$page*$page_sait-$page_sait;
if($_GET['sort'] == 'hits') $sort= 'hits';
elseif($_GET['sort'] == 'in') $sort= 'in';
elseif($_GET['sort'] == 'out') $sort= 'out';
else $sort= 'hosts';
$saits = mysql_query("SELECT * FROM `sait` ORDER BY `".$sort."` DESC LIMIT ".$start.",".$page_sait."");
echo'<div class="text"><a href="platforms.php?sort='.$sort.'">Saytlari idarə etme</div>';
$rch=curl_init();
curl_setopt($rch, CURLOPT_TIMEOUT, 6);
curl_setopt($rch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($rch, CURLOPT_HEADER, 0);
curl_setopt($rch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
function curl_check($rch, $url, $pattern){
curl_setopt($rch, CURLOPT_URL, $url);
$sce=curl_exec($rch);
if($sce==FALSE)return array( 'status'=>FALSE, 'reason'=>'Сбой URL "'.curl_error($rch).'"', 'info'=>array('total_time'=>0, 'size_download'=>0) );
$aci=curl_getinfo($rch);
if($aci['http_code']<>200)return array( 'status'=>FALSE, 'reason'=>'Статус страницы '.$aci['http_code'], 'info'=>$aci );
if(!preg_match($pattern, $sce))return array( 'status'=>FALSE, 'reason'=>'Sistem Bu Saytda Bizim Saygac Kodu Tapmadi', 'info'=>$aci );
return array( 'status'=>TRUE, 'reason'=>'ok', 'info'=>$aci );
};
while($row = mysql_fetch_array($saits)){
$start++;
$check=curl_check($rch, 'http://'.$row['url'], '~<a href="http://'.$set['home'].'/in/'.$row['id'].'.php"><img src="http://'.$set['home'].'/count/(big|small)/'.$row['id'].'.gif"~' );
if($row['ban'] == 1) $ban = '<a href="platforms.php?act=ban&id='.$row['id'].'">Azad Et</a>';
else $ban = '<a href="platforms.php?act=ban&id='.$row['id'].'">Ban Et</a>';
if($row['status'] == 0) $ban .= ' <a href="moderacia.php?act=activate&id='.$row['id'].'">Aktiv Et</a>';
$zabanen = ($row['ban'] == 0) ? '' : '(Ban Edilib)';
$status = $row['status'] == 1 ? '' : '(Tesdiq Edilmeyib)';
echo '<a class="link" href="/out/'.$row['id'].'.php">'.$start.') '.$row['name'].' <span class="stat">'.$row['hosts'].'/'.$row['hits'].'</span> '.$zabanen.''.$status.'</a>';
if(mb_strlen($row['about']) > 50){
$text = mb_substr($row['about'], 0, 50, 'utf-8');
echo '<a class="link" href="/infos.php?id='.$row['id'].'">'.$text.'...</a>';
}
else echo '<a class="link" href="/infos.php?id='.$row['id'].'">'.$row['about'].'</a>';
echo '<div class="text">';
if($check['status']){
echo 'ОК ('.round($check['info']['total_time'],3).'s/'.round($check['info']['size_download']/1024,2).'kb) ';
}else{
echo '<div class="error">'.$row['url'].' '.$check['reason'].' ('.round($check['info']['total_time'],3).'s/'.round($check['info']['size_download']/1024,2).'kb)</div>';
}
echo'<a href="platforms.php?act=edit_sait&id='.$row['id'].'">Deyiş</a> | <a href="platforms.php?act=del_sait&id='.$row['id'].'">Sil</a> '.$ban.'</div>';
}
curl_close($rch);
navigation($count,$page_sait,$page,'platforms.php?act=check_sait&sort='.$sort.'&',$total);
}
else echo '<div class="text">Sayt Yoxdur!</div>';
break;
//inoy
case 'edit_sait':
$title = 'Saytlari Editle';
require_once('../head.php');
$platform = mysql_query("SELECT * FROM `sait` WHERE `id` = '".$id."' LIMIT 1");
$platform_count = mysql_num_rows($platform);
$user_platform = mysql_fetch_array($platform);
if($platform_count > 0){
$redsait = '<form action="platforms.php?act=edit_sait&id='.$id.'" method="post">
<div class="text">Saytin Adi:<br/><input type="text" class="input" name="name" maxlength="35" value="'.$user_platform['name'].'" /></div>
<div class="text">Adres (link http://):<br/><input type="text" class="input" name="url" maxlength="30" value="'.$user_platform['url'].'" /></div>
<div class="text">Sayt Haqqinda:<br/><textarea name="about" cols="38" rows="8" maxlength="100">'.$user_platform['about'].'</textarea></div>
<div class="text">Kategoriya:<br/><select name="cat">';
$cats = mysql_query("SELECT * FROM `cat` ORDER BY `id` ASC");
if(mysql_num_rows($cats) > 0){
while($cat = mysql_fetch_assoc($cats)){
$selected = ($user_platform['category'] == $cat['id']) ? ' selected="selected"' : '';
$redsait .= '<option value="'.$cat['id'].'"'.$selected.'>'.$cat['name'].'</option>';
}
$redsait .= '</select></div>';
$redsait .= '<div class="text">Saygaclar:</div>';
$redsait .= '<div class="text">Ana Sehife:<br/>';
if ($user_platform['image'] == 1)
$redsait .= '<input type="radio" name="image" value="1" checked="checked"> <img src="/images/big/1.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image" value="1"> <img src="/images/big/1.gif" alt=""><br/>';
if ($user_platform['image'] == 2)
$redsait .= '<input type="radio" name="image" value="2" checked="checked"> <img src="/images/big/2.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image" value="2"> <img src="/images/big/2.gif" alt=""><br/>';
if ($user_platform['image'] == 3)
$redsait .= '<input type="radio" name="image" value="3" checked="checked"> <img src="/images/big/3.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image" value="3"> <img src="/images/big/3.gif" alt=""><br/>';
if ($user_platform['image'] == 4)
$redsait .= '<input type="radio" name="image" value="4" checked="checked"> <img src="/images/big/4.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image" value="4"> <img src="/images/big/4.gif" alt=""><br/>';
if ($user_platform['image'] == 5)
$redsait .= '<input type="radio" name="image" value="5" checked="checked"> <img src="/images/big/5.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image" value="5"> <img src="/images/big/5.gif" alt=""><br/>';
if ($user_platform['image'] == 6)
$redsait .= '<input type="radio" name="image" value="6" checked="checked"> <img src="/images/big/6.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image" value="6"> <img src="/images/big/6.gif" alt=""><br/>';
$redsait .= '</div><div class="text">Diger Sehife:<br/>';
if ($user_platform['image_s'] == 1)
$redsait .= '<input type="radio" name="image_s" value="1" checked="checked"> <img src="/images/small/1.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image_s" value="1"> <img src="/images/small/1.gif" alt=""><br/>';
if ($user_platform['image_s'] == 2)
$redsait .= '<input type="radio" name="image_s" value="2" checked="checked"> <img src="/images/small/2.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image_s" value="2"> <img src="/images/small/2.gif" alt=""><br/>';
if ($user_platform['image_s'] == 3)
$redsait .= '<input type="radio" name="image_s" value="3" checked="checked"> <img src="/images/small/3.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image_s" value="3"> <img src="/images/small/3.gif" alt=""><br/>';
if ($user_platform['image_s'] == 4)
$redsait .= '<input type="radio" name="image_s" value="4" checked="checked"> <img src="/images/small/4.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image_s" value="4"> <img src="/images/small/4.gif" alt=""><br/>';
if ($user_platform['image_s'] == 5)
$redsait .= '<input type="radio" name="image_s" value="5" checked="checked"> <img src="/images/small/5.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image_s" value="5"> <img src="/images/small/5.gif" alt=""><br/>';
if ($user_platform['image_s'] == 6)
$redsait .= '<input type="radio" name="image_s" value="6" checked="checked"> <img src="/images/small/6.gif" alt=""><br/>';
else $redsait .= '<input type="radio" name="image_s" value="6"> <img src="/images/small/6.gif" alt=""><br/>';
$redsait .= '</div><div class="text"><input name="ok" type="submit" value="Deyiş" /></div></form>';
}
else $redsait .= '<div class="error">Bu Sayt Movcud Deyil</div>';
if(!isset($_POST['ok'])) echo $redsait;
else{
$name = filter($_POST['name']);
$url = filter($_POST['url']);
$url = str_replace("http://","",$url);
$url = str_replace("https://","",$url);
$about = filter($_POST['about']);
$cat = intval($_POST['cat']);
$image = filter($_POST['image']);
$image_s = filter($_POST['image_s']);
$error = '';
if(empty($cat) OR empty($image) OR empty($image_s) OR empty($name) OR empty($url) OR empty($about))
$error .= '<div class="text">Butun bolmeleri doldurun</span>';
else{
if($image < 1 OR $image > 6) $error .= '<div class="error">Esas sehife ucun saygac secilmedi</div>';
if($image_s < 1 OR $image_s > 6) $error .= '<div class="error">Diger sehife ucun saygac secilmedi</div>';
$isset_cat = mysql_num_rows(mysql_query("SELECT `id` FROM `cat` WHERE `id` = '".$cat."'"));
if($isset_cat == 0)
$error .= '<div class="error">Нет такой категории</div>';
$platform_isset = mysql_num_rows(mysql_query("SELECT * FROM `sait` WHERE `id` = '".$id."' LIMIT 1"));
if($platform_isset == 0)
$error .= '<div class="error">Bele sayt yoxdur</div>';
if(mb_strlen($about) > 100 OR mb_strlen($about) < 10)
$error .= '<div class="error">Saytin Ad uzunlugu az 10 və artıq 100 simvoldan cox olmamalıdır</div>';
if(mb_strlen($url) > 30 OR mb_strlen($url) < 5)
$error .= '<div class="error">Ünvan uzunlugu artıq 30 simvoldan ən azı 5 simvol olmalıdır</div>';
if(mb_strlen($name) > 35 OR mb_strlen($name) < 5)
$error .= '<div class="error">Saytın adı uzunlugu ən azı 5 və 35 simvoldan artıq olmalıdır</div>';
}
if(!empty($error)){
echo $error;
echo $redsait;
}
else{
$edit = mysql_query("UPDATE `sait` SET `category` = '".$cat."', `image` = '".$image."', `image_s` = '".$image_s."', `name` = '".$name."', `about` = '".$about."', `url` = '".$url."' WHERE `id` = '".$id."'");
if($edit) echo '<div class="text">Sayt ugurla deyişdirildi!</div>';
else echo '<div class="text">Sayt deyişilmedi</div>';
}
}
}
else echo '<div class="text">Bele sayt movcud deyil</div>';
echo '<a class="link" href="platforms.php">Saytlari idarə etme</a>';
break;
case 'del_sait':
if($user_data AND $user_data['level'] < 3 OR !$user_data){
$title = 'Sehf!';
require_once('../head.php');
echo '<div class="text">Sizin Daxil Olmaniza Icaze Yoxdur!</div>';
require_once('../foot.php');
exit;
}
$title = 'Sayti Silmek';
require_once('../head.php');
$sait_isset = mysql_query("SELECT * FROM `sait` WHERE `id` = '".$id."'LIMIT 1");
$sait_isset_c = mysql_num_rows($sait_isset);
if($sait_isset_c > 0){
$sait = mysql_fetch_array($sait_isset );
if(!isset($_GET['ok'])){
echo '<div class="text">Siz bu '.$sait['name'].' sayti silmekde eminsiniz?</div>';
echo '<a class="link" href="platforms.php?act=del_sait&id='.$id.'&ok"">Beli, silirem</a>';
echo '<a class="link" href="platforms.php">Xeyr, silmirem</a>';
}
else{
$del_hosts = mysql_query("DELETE FROM `hosts` WHERE `id_sait` = '".$id."'");
$del_hits = mysql_query("DELETE FROM `hits` WHERE `id_sait` = '".$id."'");
$del_in = mysql_query("DELETE FROM `in` WHERE `id_sait` = '".$id."'");
$del_out = mysql_query("DELETE FROM `out` WHERE `id_sait` = '".$id."'");
$del_online = mysql_query("DELETE FROM `sait_online` WHERE `id_sait` = '".$id."'");
$del_platform = mysql_query("DELETE FROM `sait` WHERE `id` = '".$id."'");
if($del_hosts AND $del_hits AND $del_in AND $del_out AND $del_online AND $del_platform)
echo '<div class="text">Sayt ugurla silindi</div>';
else echo '<div class="text">Sayt silinmedi</div>';
}
}
else echo '<div class="text">Bele sayt movcud deyil</div>';
echo '<a class="link" href="platforms.php">Saytlari idarə etme</a>';
break;
case 'ban':
$title = 'Sayt Ban Etme';
require_once('../head.php');
if($id){
$checking = mysql_query("SELECT * FROM `sait` WHERE `id` = '".$id."'");
if(mysql_num_rows($checking) > 0){
$check = mysql_fetch_array($checking);
if($check['ban'] == 0){
$blok = '<form action="platforms.php?act=ban&id='.$id.'" method="post">
<div class="text">Sebeb:<br/>
<input type="text" name="reason" maxlength="50" value=""/></div>
<div class="text"><input type="submit" name="ok" value="Ban Et"/></div>
</form>';
if(!isset($_POST['ok'])) echo $blok;
else{
$reason = filter($_POST['reason']);
$error = '';
if(empty($reason)) $error .= '<div class="error">Sebebi Yazin</div>';
else if(mb_strlen($reason) > 50 OR mb_strlen($reason) < 5 ) $error .= '<div class="error">Səbəb ən azı 5 və 50 simvoldan artıq olmalıdır</div>';
if(!empty($error)){
echo $error;
echo $blok;
}
else{
$ban = mysql_query("UPDATE `sait` SET `ban` = '1',`status` = '1', `ban_reason` = '".$reason."', `ban_who` = '".$user_data['id']."', `ban_time` = '".time()."' WHERE `id` = '".$id."'");
if($ban) echo '<div class="text">Sayt ugurla Ban edildi</div>';
else echo '<div class="text">Sayt Ban Edilmedi</div>';
}
}
}
else{
$unban = mysql_query("UPDATE `sait` SET `ban` = '0', `ban_reason` = '', `ban_who` = '' WHERE `id` = '".$id."'");
if($unban) echo '<div class="text">Sayt ugurla azad edildi</div>';
else echo '<div class="text">Sayt azad edilmedi</div>';
}
}
else echo '<div class="text">Bu sahede sayt movcud deil</div>';
}
echo '<a class="link" href="platforms.php">Saytlari idarə etme</a>';
break;
}
if($user_data['level'] == 3) echo '<a class="link" href="index.php">Admin Panel</a>';
require_once('../foot.php');
?>