<?php
## BY CroWn (c) 2016 ##
defined('_IN_JOHNADM') or die('Error: restricted access');
if ($rights < 7)
    die('Error: restricted access');
echo '<div class="phdr">Bosh sahifaga chiqarish</div>';
$m = mysql_query("SELECT * FROM `main`;");
$set = array();
while ($res = mysql_fetch_row($m)) $set[$res[0]] = $res[1];
mysql_result($m);

if (isset($_POST['set'])) {
	if (empty($_POST['notfound'])) $error.= 'Iltimos rasm manzili maydonini to`ldiring';
	if ($error) {
	    echo '<div class="menu">'.$error.'</div>';
		include '../incfiles/end.php';
		exit();
		}
	$status = intval($_POST['status']);
	$amatn = intval($_POST['amatn']);
    $ulimit = intval($_POST['ulimit']);
	$onid = intval($_POST['onid']);
	$oncat = intval($_POST['oncat']);
	$cat = intval($_POST['cat']);
	$cuser = intval($_POST['cuser']);
    $notfound = mysql_real_escape_string($_POST['notfound']);
	
	mysql_query("UPDATE `main` SET `val`='".$status."' WHERE `key` = 'status'");
	mysql_query("UPDATE `main` SET `val`='".$amatn."' WHERE `key` = 'amatn'");
    mysql_query("UPDATE `main` SET `val`='".$ulimit."' WHERE `key` = 'ulimit'");
   	mysql_query("UPDATE `main` SET `val`='".$notfound."' WHERE `key` = 'notfound'");
	mysql_query("UPDATE `main` SET `val`='".$onid."' WHERE `key` = 'onid'");
	mysql_query("UPDATE `main` SET `val`='".$oncat."' WHERE `key` = 'oncat'");
	mysql_query("UPDATE `main` SET `val`='".$cat."' WHERE `key` = 'cat'");
	mysql_query("UPDATE `main` SET `val`='".$cuser."' WHERE `key` = 'cuser'");
    $req = mysql_query("SELECT * FROM `main`");
    $set = array();
    while ($res = mysql_fetch_row($req)) $set[$res[0]] = $res[1];
    echo '<div class="menu"><font color="red">Ma`lumotlar saqlandi!</font></div>';}
echo '<form action="?act=main&set" method="post" name="main">';
echo '<div class="menu">';
echo 'Yangilikni bosh sahifaga chiqarish :<br/>
<input type="radio" value="1" name="status" ' . ($set['status'] ? 'checked="checked"' : '') . ' />Yoqish<br />
<input type="radio" value="0" name="status" ' . (!$set['status'] ? 'checked="checked"' : '') . '/>O`chirish<br />
Yangilikda rasm bo`lmasa :<br/>
<input name="notfound" type="text" value="'.$set['notfound'].'"><br/>
Anons dagi harflar soni :<br/>
<input name="amatn" type="text" value="'.$set['amatn'].'"><br/>
Bosh sahifadagi yangilik soni :<br/>
<input name="ulimit" type="text" value="'.$set['ulimit'].'"><br/>
Muallif orqali :<br/>
<input type="radio" value="1" name="onid" ' . ($set['onid'] ? 'checked="checked"' : '') . ' />Yoqish<br />
<input type="radio" value="0" name="onid" ' . (!$set['onid'] ? 'checked="checked"' : '') . '/>O`chirish<br />
Muallif id raqami:<br /> <input name="cuser" type="text" value="'.$set['cuser'].'"><br/>
Bo`lim bo`yicha :<br/>
<input type="radio" value="1" name="oncat" ' . ($set['oncat'] ? 'checked="checked"' : '') . ' />Yoqish<br />
<input type="radio" value="0" name="oncat" ' . (!$set['oncat'] ? 'checked="checked"' : '') . '/>O`chirish<br />
Bo`lim: <br />
 <select name="cat">';
 $bcat = mysql_query("SELECT * FROM `cms_news_cat`;");
while (($okcat = mysql_fetch_assoc($bcat)) !== false) {
echo '<option value="'.$okcat['realid'].'">'.$okcat['name'].'</option>';
}
echo '</select> <br />';
echo '<input name="set" type="submit" value="Saqlash"/>
</form>';
echo '</div>';

?>