View file journal/admin.php

File size: 35.17Kb
<?php
///////////////////////////////////////////////////////////////////////////////////////////////
header('Cache-Control: no-store, no-cache, must-revalidate');                                //
if ($ver=="wml")header ("Content-type:text/vnd.wap.wml; charset=utf-8");                     //
else header("Content-Type:text/html; charset=UTF-8");                                        //
                                                                                             //
require("../inc.php");                                                                       //
$link = connect_db();                                                                        //
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);                                 //
require("../version.php");                                                                   //
                                                                                             //
if ($ver=="wml"){                                                                            //
print $xml;                                                                                  //
print $dtd;                                                                                  //
print "<wml>";                                                                               //
print "<card id=\"index\" title=\"Журнал чата | Админка\">";                               //
print "<p align=\"center\">";                                                                //
}else{                                                                                       //
print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"";                    //
print "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";                        //
print "<html xmlns=\"http://www.w3.org/1999/xhtml\">";                                       //
if($row["skin"]=="0")
{print "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"../css/css.css\"/>";}
if($row["skin"]=="1")
{print "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"../css/css1.css\"/>";}
if($row["skin"]=="2")
{print "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"../css/css2.css\"/>";}
if($row["skin"]=="3")
{print "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"../css/css3.css\"/>";}          //
print "<title>Журнал чата | Админка</title>";                                              //
print"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";//
print "<div align=\"center\">";                                                              //
}                                                                                            //
$config_bookpost = 5;                                                                       //
///////////////////////////////////////////////////////////////////////////////////////////////

$day=date("d.m.y");
$timer=date("H:i");

$idsd = $_GET['id'];

echo'<b>Управление журналом</b><br/><br/>';

if($action=="") {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

echo'<a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Обновить</a> | ';
echo '<a href="admin.php?action=add&amp;'.$ses.'&amp;ref='.$ref.'">Новая категория</a><br/><hr/>';

$resultx=mysql_query("SELECT `id`,`name`,`about`,`type`,`down_type`,`realid` FROM `journal` WHERE `type`='r' order by realid;");
$count_users_on_pagex = mysql_num_rows($resultx);

for($i = 0; $i < $count_users_on_pagex; $i++)
{
$row = mysql_fetch_array($resultx);
$uid = $row[0];
$name = $row[1];
$about = $row[2];
$type = $row[3];
$downtype = $row[4];
$realid = $row[5];

if($downtype==1){echo'<a href="admin.php?action=cat&amp;uid='.$uid.'&amp;'.$ses.'&amp;ref='.$ref.'">'.$name.'</a><br/><small>'.$about.'</small><br/>';}
if($downtype==0){echo''.$name.'<br/><small>'.$about.'</small><br/>[Без подкатегорий]<br/>';}

echo'<a href="admin.php?action=edit&amp;uid='.$uid.'&amp;'.$ses.'&amp;ref='.$ref.'">[Изменить]</a> <a href="admin.php?action=del&amp;uid='.$uid.'&amp;'.$ses.'&amp;ref='.$ref.'">[Удалить]</a><br/><br/>';

}
echo"<br/>";
}
else { echo"Вы не редактор журнала!<br/><br/>"; }
}
//---------------------------------------- РЕДАКТИРОВАНИЕ -------------------------------------------//
if($action=="edit") {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{
$uid = intval(check($_GET['uid']));
if (eregi("[^0-9]", $uid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['uid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $uid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "r")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}

echo "Изменить название:<br/><form action='admin.php?action=editgo&amp;uid=".$uid."&amp;".$ses."&amp;ref=".$ref."' method='post'><input type='text' name='nf' value='" . $ms[name] . "'/><br/>Изменить описание:<br/><input type='text' name='ab' value='" . $ms[about] . "'/><br/><input type='submit' name='submit' value='Ok!'/><br/></form>";

}else { echo"Вы не админ журнала!<br/><br/>"; }
}

if($action=="cat") {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

$uid = intval(check($_GET['uid']));
if (eregi("[^0-9]", $uid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['uid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $uid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "r")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}
if ($ms[down_type] != "1")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}

echo'<a href="admin.php?action=cat&amp;uid='.$uid.'&amp;'.$ses.'&amp;ref='.$ref.'">Обновить</a> | ';
echo '<a href="admin.php?action=addf&amp;fid='.$uid.'&amp;'.$ses.'&amp;ref='.$ref.'">Новая категория</a><br/><br/>';

$resultx=mysql_query("SELECT `id`,`name`,`about`,`type`,`down_type`,`realid`,`refid` FROM `journal` WHERE `type`='f' AND `refid`='".$uid."' order by realid;");
$count_users_on_pagex = mysql_num_rows($resultx);

for($i = 0; $i < $count_users_on_pagex; $i++)
{
$row = mysql_fetch_array($resultx);
$uid = $row[0];
$name = $row[1];
$about = $row[2];
$type = $row[3];
$downtype = $row[4];
$realid = $row[5];
$refid = $row[6];

echo''.$name.'<br/><small>'.$about.'</small><br/>';

echo'<a href="admin.php?action=editf&amp;uid='.$uid.'&amp;'.$ses.'&amp;ref='.$ref.'">[Изменить]</a> <a href="admin.php?action=delf&amp;uid='.$uid.'&amp;'.$ses.'&amp;ref='.$ref.'">[Удалить]</a><br/><br/>';

}
echo"<br/>";
}
else { echo"Вы не редактор журнала!<br/><br/>"; }

}

//---------------------------------------- ИЗМЕНЕНИЕ СООБЩЕНИЯ -------------------------------------------//
if($action=="editgo") {



$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

$nf = check(trim($_POST['nf']));
$ab = check(trim($_POST['ab']));

$uid = intval(check($_GET['uid']));
if (eregi("[^0-9]", $uid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['uid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $uid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "r")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}

mysql_query("update `journal` set  name='" . $nf . "', about='" . $ab . "' where id='" . $uid . "';");

echo"Категория изменена!<br/><br/>";
}
else { echo"Вы не админ журнала!<br/><br/>"; }
}

//---------------------------------------- УДАЛЕНИЕ СООБЩЕНИЯ -------------------------------------------//
if($action=="del") {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{
$uid = intval(check($_GET['uid']));
if (eregi("[^0-9]", $uid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['uid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $uid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "r")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}

if ($ms[down_type] == "0")
{

$raz = mysql_query("select * from `journal` where refid='" . $uid . "' and type='a' ;");
                        while ($raz1 = mysql_fetch_array($raz))
                        {
                            $tem = mysql_query("select * from `journal` where refid='" . $raz1[id] . "' and type='k';");
                            while ($tem1 = mysql_fetch_array($tem))
                            {
                            mysql_query("delete from `journal` where `id`='" . $tem1[id] . "';");
                            }
                            mysql_query("delete from `journal` where `id`='" . $raz1[id] . "';");
                        }
                        mysql_query("delete from `journal` where `id`='" . $uid . "';");

}
if ($ms[down_type] == "1")
{

$raz = mysql_query("select * from `journal` where refid='" . $uid . "' and type='f' ;");
                        while ($raz1 = mysql_fetch_array($raz))
                        {
                            $tem = mysql_query("select * from `journal` where refid='" . $raz1[id] . "' and type='a';");
                            while ($tem1 = mysql_fetch_array($tem))
                            {

                               $temk = mysql_query("select * from `journal` where refid='" . $tem[id] . "' and type='k';");
                                while ($tem1k = mysql_fetch_array($temk))
                                {mysql_query("delete from `journal` where `id`='" . $tem1k[id] . "';");}

                            mysql_query("delete from `journal` where `id`='" . $tem1[id] . "';");

                            }

                        mysql_query("delete from `journal` where `id`='" . $raz1[id] . "';");

                        }
mysql_query("delete from `journal` where `id`='" . $uid . "';");

}

}else { echo"Вы не админ журнала!<br/><br/>"; }

}


if($action=="editf") {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{
$uid = intval(check($_GET['uid']));
if (eregi("[^0-9]", $uid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['uid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $uid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "f")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}

echo "Изменить название:<br/><form action='admin.php?action=editfgo&amp;uid=".$uid."&amp;".$ses."&amp;ref=".$ref."' method='post'><input type='text' name='nf' value='" . $ms[name] . "'/><br/>Изменить описание:<br/><input type='text' name='ab' value='" . $ms[about] . "'/><br/><input type='submit' name='submit' value='Ok!'/><br/></form>";

}else { echo"Вы не админ журнала!<br/><br/>"; }
}
//---------------------------------------- ИЗМЕНЕНИЕ СООБЩЕНИЯ -------------------------------------------//
if($action=="editfgo") {



$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

$nf = check(trim($_POST['nf']));
$ab = check(trim($_POST['ab']));

$uid = intval(check($_GET['uid']));
if (eregi("[^0-9]", $uid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['uid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $uid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "f")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}

mysql_query("update `journal` set  name='" . $nf . "', about='" . $ab . "' where id='" . $uid . "';");

echo"Категория изменена!<br/><br/>";
}
else { echo"Вы не админ журнала!<br/><br/>"; }
}

//---------------------------------------- УДАЛЕНИЕ СООБЩЕНИЯ -------------------------------------------//
if($action=="delf") {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{
$uid = intval(check($_GET['uid']));
if (eregi("[^0-9]", $uid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['uid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $uid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "f")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}


$raz = mysql_query("select * from `journal` where refid='" . $uid . "' and type='a' ;");
                        while ($raz1 = mysql_fetch_array($raz))
                        {
                            $tem = mysql_query("select * from `journal` where refid='" . $raz1[id] . "' and type='k';");
                            while ($tem1 = mysql_fetch_array($tem))
                            {
                            mysql_query("delete from `journal` where `id`='" . $tem1[id] . "';");
                            }
                            mysql_query("delete from `journal` where `id`='" . $raz1[id] . "';");
                        }
                        mysql_query("delete from `journal` where `id`='" . $uid . "';");


echo"Готово!<br/><br/>";

}else { echo"Вы не админ журнала!<br/><br/>"; }

}



if($action=="add") {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

if($ver!="wml"){
echo'<form action="admin.php?action=addn&amp;'.$ses.'&amp;ref='.$ref.'" method="post">';
echo'<b>Название:</b> <br/><input type="text" name="name"/><br/>';
echo'<b>Описание:</b><br/>';
echo'<textarea cols="25" rows="3" name="msg"></textarea><br/>';
echo'<b>Будем в данной папке делать подпапки? *</b><br/><b>Да</b> <input name="trans" type="checkbox" value="y" /><br/>';
echo'<br/><input type="submit" value="Старт!" /></form><hr/>';}else{

echo 'Название:<br/>';
echo '<input name="name"/><br/>';

echo 'Описание:<br/>';
echo '<input name="msg"/><br/>';


echo 'Будем в данной папке делать подпапки? *<select name="trans"><option value="0">Нет</option>';
echo '<option value="y">Да</option></select><br/>';

echo '<anchor>Создать!';
echo '<go href="admin.php?action=addn&amp;'.$ses.'&amp;ref='.$ref.'" method="post">';
echo '<postfield name="msg" value="$(msg)"/>';
echo '<postfield name="name" value="$(name)"/>';
echo '<postfield name="trans" value="$(trans)"/>';
echo '</go></anchor><br/>--------------------<br/>';
}
echo"* Выбрать тип категории (с подпапками или нет) можно выбрать один раз! И изменить данную опцию потом уже нельзя.<br/><br/>";
}
else { echo"Вы не редактор журнала<br/><br/>"; }
}

if($action=="addn") {


$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

$dates=date("d.m.y");
$times=date("H:i");
$time=time();

$name = $_POST['name'];
$msg = $_POST['msg'];
$id = $_GET['id'];
$name = check ($name);
$msg = check ($msg);

if (empty($msg)){echo"ЗЫ. Введите описание папки!!!";
echo'<br/><br/><a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Назад</a><br/>';
echo'<a href="../apanel.php?'.$ses.'&amp;ref='.$ref.'">В админку</a><br/>';
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($name)){echo"ЗЫ. Введите название папки!!!";
echo'<br/><br/><a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Назад</a><br/>';
echo'<a href="../apanel.php?'.$ses.'&amp;ref='.$ref.'">В админку</a><br/>';
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}


if($trans=="y"){$type=1;}
if($trans!="y"){$type=0;}

$r = mysql_query ("select id,user from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];

$q = mysql_query("select * from `journal` where type='r' order by realid desc ;");
$q1 = mysql_num_rows($q);
if ($q1 == 0)
{
$rid = 1;
} else
{
while ($arr = mysql_fetch_array($q))
{
$arr1[] = $arr[realid];
}
$rid = $arr1[0] + 1;
}

mysql_query("insert into `journal` values(0,'','".$name."','" . $msg . "','','r','','','','','','".$type."','','".$rid."','','','');");

echo"Папка создана!<br/><br/>";

if($type==1){echo"Вы выбрали тип папки - подпапочный. По-этому вы должны создать подпапки в данном разделе.<br/><br/>";}
if($type==0){echo"Вы выбрали тип папки - для статей. Теперь в данной категории можно сразу писать статьи.<br/><br/>";}

}
else { echo"Вы не админ выборов!<br/><br/>"; }
}

if($action=="addf") {

$fid = intval(check($_GET['fid']));
if (eregi("[^0-9]", $fid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['fid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $fid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "r")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

if($ver!="wml"){
echo'<form action="admin.php?action=addnf&amp;'.$ses.'&amp;ref='.$ref.'&amp;fid='.$fid.'" method="post">';
echo'<b>Название:</b> <br/><input type="text" name="name"/><br/>';
echo'<b>Описание:</b><br/>';
echo'<textarea cols="25" rows="3" name="msg"></textarea><br/>';
echo'<br/><input type="submit" value="Старт!" /></form><hr/>';}else{
echo 'Название:<br/>';
echo '<input name="name"/><br/>';
echo 'Описание:<br/>';
echo '<input name="msg"/><br/>';
echo '<anchor>Создать!';
echo '<go href="admin.php?action=addnf&amp;'.$ses.'&amp;ref='.$ref.'&amp;fid='.$fid.'" method="post">';
echo '<postfield name="msg" value="$(msg)"/>';
echo '<postfield name="name" value="$(name)"/>';
echo '<postfield name="trans" value="$(trans)"/>';
echo '</go></anchor><br/>--------------------<br/>';
}
}
else { echo"Вы не редактор журнала<br/><br/>"; }
}

if($action=="addnf") {

$fid = intval(check($_GET['fid']));
if (eregi("[^0-9]", $fid))
{echo"ЗЫ. Попытка взлома!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($_GET['fid'])){echo "Ошибка!";include_once"../foot3.php"; ob_end_flush(); exit;}
$typ = mysql_query("select * from `journal` where id='" . $fid . "';");
$ms = mysql_fetch_array($typ);
if ($ms[type] != "r")
{echo "Ошибка!"; include_once"../foot3.php"; ob_end_flush(); exit;}


$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$idsd";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{

$dates=date("d.m.y");
$times=date("H:i");
$time=time();

$name = $_POST['name'];
$msg = $_POST['msg'];
$fid = $_GET['fid'];
$name = check ($name);
$msg = check ($msg);
$fid = check ($fid);

if (empty($msg)){echo"ЗЫ. Введите описание папки!!!";
echo'<br/><br/><a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Назад</a><br/>';
echo'<a href="../apanel.php?'.$ses.'&amp;ref='.$ref.'">В админку</a><br/>';
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}
if (empty($name)){echo"ЗЫ. Введите название папки!!!";
echo'<br/><br/><a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Назад</a><br/>';
echo'<a href="../apanel.php?'.$ses.'&amp;ref='.$ref.'">В админку</a><br/>';
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}

$r = mysql_query ("select id,user from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];

$q = mysql_query("select * from `journal` where type='f' and refid='".$fid."' order by realid desc ;");
$q1 = mysql_num_rows($q);
if ($q1 == 0)
{
$rid = 1;
} else
{
while ($arr = mysql_fetch_array($q))
{
$arr1[] = $arr[realid];
}
$rid = $arr1[0] + 1;
}

mysql_query("insert into `journal` values(0,'".$fid."','".$name."','" . $msg . "','','f','','','','','','','','".$rid."','','','');");

echo"Папка создана!<br/><br/>";

}
else { echo"Вы не редатор журнала!<br/><br/>"; }
}

if($action=="addadmin") {
$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];

if($lev > 7) {

if($ver!="wml"){
echo'<form action="admin.php?action=addadminok&amp;'.$ses.'&amp;ref='.$ref.'" method="post">';
echo'<b>ID Юзера:</b> <br/><input type="text" name="uid"/><br/>';
echo'<br/><input type="submit" value="Назначить!" /></form><hr/>';}else{

echo 'ID Юзера:<br/>';
echo '<input name="uid"/><br/>';

echo '<anchor>Создать!';
echo '<go href="admin.php?action=addadminok&amp;'.$ses.'&amp;ref='.$ref.'" method="post">';
echo '<postfield name="uid" value="$(uid)"/>';
echo '</go></anchor><br/>--------------------<br/>';
}
 }
}
if($action=="addadminok") {

$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];
$uid = $_POST['uid'];
$uid = check ($uid);

if (eregi("[^0-9]", $uid))
{echo"ЗЫ. ТОЛЬКО ШД ЮЗЕРА! ЦИФРЫ!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}

if (empty($uid)){echo"ЗЫ. Введите ID юзера!!!";
echo'<br/><br/><a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Назад</a><br/>';
echo'<a href="../apanel.php?'.$ses.'&amp;ref='.$ref.'">В админку</a><br/>';
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}

if($lev > 7) {

$filex=file("editors.dat");
$countx=count($filex);
$switchx=0;
$wordx="$uid";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{
echo"Данный юзер уже добавлен в список редакторов!";
}
else {

$tex="$uid";
$fp=fopen("editors.dat","a+");
flock
($fp,LOCK_EX);
fputs($fp,"$tex\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
@chmod("$fp", 0777);
@chmod("editors.dat", 0777);
echo"Теперь пользователь с ID $uid сможет полностью администрировать журнал!<br/>";
}
}
}

if($action=="addadmin2") {
$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];

if($lev > 7) {

if($ver!="wml"){
echo'<form action="admin.php?action=addadminok2&amp;'.$ses.'&amp;ref='.$ref.'" method="post">';
echo'<b>ID Юзера:</b> <br/><input type="text" name="uid"/><br/>';
echo'<br/><input type="submit" value="Назначить!" /></form><hr/>';}else{

echo 'ID Юзера:<br/>';
echo '<input name="uid"/><br/>';

echo '<anchor>Создать!';
echo '<go href="admin.php?action=addadminok2&amp;'.$ses.'&amp;ref='.$ref.'" method="post">';
echo '<postfield name="uid" value="$(uid)"/>';
echo '</go></anchor><br/>--------------------<br/>';
}
 }
}
if($action=="addadminok2") {

$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];
$uid = $_POST['uid'];
$uid = check ($uid);

if (eregi("[^0-9]", $uid))
{echo"ЗЫ. ТОЛЬКО ЦИФРЫ!!!";
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}

if (empty($uid)){echo"ЗЫ. Введите ID юзера!!!";
echo'<br/><br/><a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Назад</a><br/>';
echo'<a href="../apanel.php?'.$ses.'&amp;ref='.$ref.'">В админку</a><br/>';
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php"; ob_end_flush(); exit;}

if($lev > 7) {

$filex=file("journalist.dat");
$countx=count($filex);
$switchx=0;
$wordx="$uid";
for ($ix=0;$ix<$countx;$ix++){
if (trim($filex[$ix])==$wordx){$switchx=1;}}
if($switchx==1)
{
echo"Данный юзер уже добавлен в список журналистов!";
}
else {

$tex="$uid";
$fp=fopen("journalist.dat","a+");
flock
($fp,LOCK_EX);
fputs($fp,"$tex\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
@chmod("$fp", 0777);
@chmod("journalist.dat", 0777);
echo"Теперь пользователь с ID $uid может добавлять статьи в журнал!<br/>";
}
}
}

if($action=="readlist") {
	$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];
if($lev > 7) {
echo"<br/>Список редакторов:<br/>";

$file = file("editors.dat");
$total = count($file);
if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + $config_bookpost){ $end = $total;}
else {$end = $start + $config_bookpost; }
for ($fm = $start; $fm < $end; $fm++){

$file = file("editors.dat");
$file = array_reverse($file);
$dt = explode("|",$file[$fm]);

$num=$total-$fm-1;

if($fm>=0){

$r = mysql_query ("select id,user from users where id='$dt[0]';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];

echo'<br/>';
echo"<b><a href='../info.php?$ses&amp;nk=$usid&amp;ref=$ref'> $login </a></b>";
echo'<a href="admin.php?action=deluser&amp;rd='.$num.'&amp;start='.$start.'&amp;uz='.$dt[0].'&amp;nm='.$dt[0].'&amp;'.$ses.'&amp;ref='.$ref.'">[Удалить]</a> ';}
}
if($total<1){echo'<br/>Редакторов пока нет!<br/>';}

echo'<hr>';
if ($start != 0) {echo '<a href="admin.php?action=readlist&amp;start='.($start - $config_bookpost).'&amp;'.$ses.'&amp;ref='.$ref.'">&lt;-Назад </a> ';}else{echo'&lt;-Назад ';}
echo'|';
if ($total > $start + $config_bookpost) {echo ' <a href="admin.php?action=readlist&amp;start='.($start + $config_bookpost).'&amp;'.$ses.'&amp;ref='.$ref.'">Далее-&gt;</a>';}else{echo' Далее-&gt;';}

$ba=ceil($total/$config_bookpost);
$ba2=$ba*$config_bookpost-$config_bookpost;

echo '<br/><hr>Страницы:';
$asd=$start-($config_bookpost*3);
$asd2=$start+($config_bookpost*4);

if($asd<$total && $asd>0){echo ' <a href="admin.php?action=readlist&amp;start=0&amp;'.$ses.'&amp;ref='.$ref.'">1</a> ... ';}

for($i=$asd; $i<$asd2;)
{
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_bookpost);

if ($start==$i) {
echo ' <b>'.$ii.'</b>';
               }
                else {
echo ' <a href="admin.php?action=readlist&amp;start='.$i.'&amp;'.$ses.'&amp;ref='.$ref.'">'.$ii.'</a>';
                     }}


$i=$i+$config_bookpost;}
if($asd2<$total){echo ' ... <a href="admin.php?action=readlist&amp;start='.$ba2.'&amp;'.$ses.'&amp;ref='.$ref.'">'.$ba.'</a>';}

echo '<br/><br/>Всего редакторов: '.$total.' <br/>';
echo'<br/><a href="admin.php?action=addadmin&amp;'.$ses.'&amp;ref='.$ref.'">Добавить редактора</a><br/>';
}
}
///////////////////////////// Удаление юзера из списка читателей \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

if($action=="deluser") {
	$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];
	if($lev > 7) {
if (isset($rd))  {
$file=file("editors.dat");
$fp=fopen("editors.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$rd) {unset($file[$i]);} }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
}
echo"Теперь пользователь не может администрировать журнал!<br/>";
}
}

if($action=="readlist2") {
	$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];
if($lev > 7) {
echo"<br/>Список журналистов:<br/>";

$file = file("journalist.dat");
$total = count($file);
if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + $config_bookpost){ $end = $total;}
else {$end = $start + $config_bookpost; }
for ($fm = $start; $fm < $end; $fm++){

$file = file("journalist.dat");
$file = array_reverse($file);
$dt = explode("|",$file[$fm]);

$num=$total-$fm-1;

if($fm>=0){

$r = mysql_query ("select id,user from users where id='$dt[0]';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];

echo'<br/>';
echo"<b><a href='../info.php?$ses&amp;nk=$usid&amp;ref=$ref'> $login </a></b>";
echo'<a href="admin.php?action=deluser2&amp;rd='.$num.'&amp;start='.$start.'&amp;uz='.$dt[0].'&amp;nm='.$dt[0].'&amp;'.$ses.'&amp;ref='.$ref.'">[Удалить]</a> ';}
}
if($total<1){echo'<br/>Журналистов пока нет!<br/>';}

echo'<hr>';
if ($start != 0) {echo '<a href="admin.php?action=readlist&amp;start='.($start - $config_bookpost).'&amp;'.$ses.'&amp;ref='.$ref.'">&lt;-Назад </a> ';}else{echo'&lt;-Назад ';}
echo'|';
if ($total > $start + $config_bookpost) {echo ' <a href="admin.php?action=readlist&amp;start='.($start + $config_bookpost).'&amp;'.$ses.'&amp;ref='.$ref.'">Далее-&gt;</a>';}else{echo' Далее-&gt;';}

$ba=ceil($total/$config_bookpost);
$ba2=$ba*$config_bookpost-$config_bookpost;

echo '<br/><hr>Страницы:';
$asd=$start-($config_bookpost*3);
$asd2=$start+($config_bookpost*4);

if($asd<$total && $asd>0){echo ' <a href="admin.php?action=readlist&amp;start=0&amp;'.$ses.'&amp;ref='.$ref.'">1</a> ... ';}

for($i=$asd; $i<$asd2;)
{
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_bookpost);

if ($start==$i) {
echo ' <b>'.$ii.'</b>';
               }
                else {
echo ' <a href="admin.php?action=readlist&amp;start='.$i.'&amp;'.$ses.'&amp;ref='.$ref.'">'.$ii.'</a>';
                     }}


$i=$i+$config_bookpost;}
if($asd2<$total){echo ' ... <a href="admin.php?action=readlist&amp;start='.$ba2.'&amp;'.$ses.'&amp;ref='.$ref.'">'.$ba.'</a>';}

echo '<br/><br/>Всего журналистов: '.$total.' <br/>';
echo'<br/><a href="admin.php?action=addadmin2&amp;'.$ses.'&amp;ref='.$ref.'">Добавить журналиста</a><br/>';
}
}
///////////////////////////// Удаление юзера из списка читателей \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

if($action=="deluser2") {
	$id = $_GET['id'];
$r = mysql_query ("select id,user,level from users where id='$id';");
$arr = mysql_fetch_array($r);
$login=$arr['user'];
$usid=$arr['id'];
$lev=$arr['level'];
	if($lev > 7) {
if (isset($rd))  {
$file=file("journalist.dat");
$fp=fopen("journalist.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$rd) {unset($file[$i]);} }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
}
echo"Теперь пользователь не является журналистом!<br/>";
}
}

echo'<a href="admin.php?'.$ses.'&amp;ref='.$ref.'">Главная журнала</a><br/>';
$r = mysql_query ("select id,user,level from users where id='$idsd';");
$arr = mysql_fetch_array($r);
$lev=$arr['level'];
if($lev > 7) {
echo'<a href="admin.php?action=readlist&amp;'.$ses.'&amp;ref='.$ref.'">Список редакторов</a><br/>';
echo'<a href="admin.php?action=readlist2&amp;'.$ses.'&amp;ref='.$ref.'">Список журналистов</a><br/>';
echo'<a href="../apanel.php?'.$ses.'&amp;ref='.$ref.'">В админку</a><br/>';}
echo'<a href="../journal/index.php?'.$ses.'&amp;ref='.$ref.'">Обзор журнала / Упр.статьями</a><br/>';
echo'<a href="../enter.php?'.$ses.'&amp;ref='.$ref.'">В прихожую</a><br/>';
include_once"../foot3.php";
ob_end_flush();
exit;
?>