View file nwchat/chat/moder.php

File size: 9.62Kb
<?php
//посылаем заголовки
header ("Content-type:text/vnd.wap.wml; charset=utf-8");
//вывод в браузер
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
print '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"'.
' "http://www.wapforum.org/DTD/wml_1.1.xml">'.
'<wml><head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>';
//конфигурационный файл
include "./ini.php";
//авторизация
$login = autorize();
print '<card title="'.$lang['modering'].'">'.
'<p align="center">';
if($login&&$login['moder']) {
	//выбираем режим
	switch($mod) {
	//०Ё¬ гбв ­®ўЄЁ бв вгб 
	case 'setstatus':
	if(empty($act)) {
	print $lang['who'].":<br/><input name=\"who\" value=\"$who\"/><br/>
	".$lang['status'].":<br/><input name=\"status\" value=\"".$data['status']."\"/><br/>
	<anchor>".$lang['ok']."<go href=\"moder.php?id=$id&amp;pass=$pass&amp;mod=$mod\" method=\"post\">
	<postfield name=\"act\" value=\"set\"/>
	<postfield name=\"who\" value=\"$(who)\"/>
	<postfield name=\"status\" value=\"$(status)\"/>
	</go></anchor><br/>"; } else {
	//§ Їа®б ў Ў §г
	if(@mysql_query("update `".$px.$utable."` set status='$status' where login='$who'")) print $lang['done'];
	else print $lang['error'];
	}
	break;
	//०Ё¬ зЁбвЄЁ Є®¬­ в
	case 'delmsgs':
	if(@mysql_query("TRUNCATE TABLE `".$px.$mtable."`")&&@mysql_query("TRUNCATE TABLE `".$px.$vtable."`")) print $lang['done'];
	else print $lang['error'];
	break;
	//। ЄвЁа㥬 ­ЁЄ
	case 'editnik':
	if(empty($act)) {
	print $lang['old_nick']."<br/><input type=\"text\" name=\"old\"/><br/>";
	print $lang['new_nick']."<br/><input type=\"text\" name=\"new\"/><br/>";
	print "<anchor>".$lang['ok']."<go href=\"moder.php?act=update&amp;id=$id&amp;pass=$pass&amp;mod=$mod\" method=\"post\"><postfield name=\"old\" value=\"$(old)\"/><postfield name=\"new\" value=\"$(new)\"/></go></anchor><br/>";
	} else {
	$q = @mysql_query("select * from `".$px.$utable."` where login='$new' limit 1;");
	$ud = @mysql_fetch_array($q);
	if($ud['id']) { print $lang['such_nick_exist']; } else {
	if(@mysql_query("update `".$px.$utable."` set login='$new' where login='$old';")) print $lang['done'];
	else print $lang['user_not_exist']; }
	}
	break;
	//режим убить
	case 'kill';
	if($login['moder']>=2) {
	$q = @mysql_query("select * from `".$px.$utable."` where id='$whoid';");
	$dbuser = @mysql_fetch_array($q);
	if(@mysql_query("update `".$px.$utable."` set ban='kill' where id='".$whoid."';"))
		print "<b><u>".$dbuser['login']."</u>".$lang['killed']."</b><br/>"; }
	else print $lang['access_denied'];
	break;
	//режим убить
	case 'agent';
	if($login['moder']>=3) {
	$q = @mysql_query("select * from `".$px.$utable."` where id='$whoid';");
	$dbuser = @mysql_fetch_array($q);
	print "<b>Ip:</b><br/>".$dbuser['ip']."<br/>";
	print "<b>Браузер:</b><br/>".$dbuser['soft']."<br/>"; }
	else print $lang['access_denied'];
	break;
	//режим восстановить
	case 'restore';
	if($login['moder']>1) {
	//проверяем какое нам совершать действие
	if(empty($act)) {
		print $lang['login'].":<br/><input type=\"text\" name=\"who\"/><br/>";
		print "<anchor>".$lang['ok']."<go href=\"moder.php?id=$id&amp;pass=$pass&amp;room=$room&amp;mod=$mod\" method=\"post\"><postfield name=\"act\" value=\"kick\"/><postfield name=\"who\" value=\"$(who)\"/></go></anchor><br/>";
	} else {
		$q = @mysql_query("select * from `".$px.$utable."` where login='$who';");
		$dbuser = @mysql_fetch_array($q);
		if(@mysql_query("update `".$px.$utable."` set ban='', btime='', breason='' where login='".$who."';"))
			print "<b><u>".$who."</u>".$lang['restored']."</b><br/>";
		}
	}
	else print $lang['access_denied'];
	break;
	//режим пнуть
	case 'kick':
	//проверяем какое нам совершать действие
	if(empty($act)) {
		print $lang['reason'].":<br/><input type=\"text\" name=\"pr\"/><br/>
		<select name=\"len\">
		<option value=\"30\">30".$lang['s']."</option>
		<option value=\"60\">60".$lang['s']."</option>
		<option value=\"90\">1".$lang['m']." 30".$lang['s']."</option>
		<option value=\"120\">2".$lang['m']."</option>
		<option value=\"300\">5".$lang['m']."</option>
		<option value=\"600\">10".$lang['m']."</option>";
		if($login['moder']>=2)
		print "<option value=\"1800\">30".$lang['m']."</option><option value=\"3600\">1".$lang['h']."</option><option value=\"86400\">24".$lang['h']."</option>";
		print "</select><br/>
		<anchor>".$lang['kick']."<go href=\"moder.php?id=$id&amp;pass=$pass&amp;room=$room&amp;mod=$mod\" method=\"post\"><postfield name=\"len\" value=\"$(len)\"/><postfield name=\"act\" value=\"kick\"/><postfield name=\"whoid\" value=\"$whoid\"/><postfield name=\"pr\" value=\"$(pr)\"/></go></anchor><br/>";
	} else {
		if($login['moder']>=1 && $len<=600 || $login['moder']>=2 && $len<=86400) {
		$q = @mysql_query("select * from `".$px.$utable."` where id='$whoid';");
		$dbuser = @mysql_fetch_array($q);
		if(@mysql_query("update `".$px.$utable."` set ban='".$login['login']."', btime='".(time() + $len)."', breason='$pr' where id='".$whoid."';"))
			print "<b><u>".$dbuser['login']."</u>".$lang['kicked']."</b><br/>"; }
		}
	break;
	//добавление встреч
	case 'addmeet':
	$q = @mysql_query("select * from `".$px.$meettable."` where login='".$login['id']."' order by id desc;");
	$last_meet = @mysql_fetch_array($q);
	if(empty($act)) {
		print $lang['title'].":<br/><input name=\"t\"/><br/>
			".$lang['content'].":<br/><input name=\"content\"/><br/>
			".$lang['organizators'].":<br/><input name=\"organizatory\"/><br/>
			<anchor>".$lang['ok']."<go href=\"moder.php?id=$id&amp;pass=$pass&amp;mod=$mod\" method=\"post\">
			<postfield name=\"act\" value=\"add\"/>
			<postfield name=\"t\" value=\"$(t)\"/>
			<postfield name=\"content\" value=\"$(content)\"/>
			<postfield name=\"organizatory\" value=\"$(organizatory)\"/></go></anchor><br/>";
	} else { if(empty($error)) { //если ошибок нет
	//если такой встечи нет в бд
	if($t!=$last_meet['title']) {
	//запрос на добавление новой встечи
	if(@mysql_query("insert into `".$px.$meettable."` values(0,'".$login['login']."','$t','$content','$organizatory');")) { print $lang['done']; } else { print $lang['error']; } } else { print $lang['meet_exist']; }
	} else { print $error; } }
	break;
	//удаление встречи
	case 'delmeet':
	$q = @mysql_query("select * from `".$px.$meettable."` order by id desc;");
	if(empty($act)) {
	while($arr = @mysql_fetch_array($q)) {
	print "<a href=\"moder.php?act=del&amp;id=$id&amp;pass=$pass&amp;delid=".$arr['id']."&amp;mod=$mod\">".$arr['title']."</a><br/>";  }
	} else {
	if(mysql_query("delete from `".$px.$meettable."` where id='$delid' limit 1;")) print $lang['done'];
	}
	break;
	//изменение заголовка
	case 'title':
	if(empty($act)) {
	print $lang['head']."<br/><input type=\"text\" name=\"t\"/><br/>".$lang['room']."<br/><select name=\"name\">";
	$q = @mysql_query("select * from `".$px.$stable."` where mod='room';");
	while ($dbdata = @mysql_fetch_array($q)) {
	print "<option value=\"".$dbdata['var']."\">".$dbdata['val1']."</option>"; }
	print "</select><br/>
	<anchor>Изменить<go href=\"moder.php?act=update&amp;id=$id&amp;pass=$pass&amp;mod=$mod\" method=\"post\"><postfield name=\"name\" value=\"$(name)\"/><postfield name=\"t\" value=\"$(t)\"/></go></anchor><br/>";
	} else {
	$t=htmlspecialchars(stripslashes(trim(substr($t,0,25))));
	if(@mysql_query("update `".$px.$stable."` set val2='$t' where var='$name' and mod='room';")) print $lang['done'];
	}
	break;
	//по умолчанию
	default:
	print "<a href=\"./moder.php?id=$id&amp;pass=$pass&amp;mod=addmeet\">".$lang['add_meet']."</a><br/>";
	print "<a href=\"./moder.php?id=$id&amp;pass=$pass&amp;mod=delmeet\">".$lang['del_meet']."</a><br/>";
	print "<a href=\"./moder.php?id=$id&amp;pass=$pass&amp;mod=title\">".$lang['change_head']."</a><br/>";
	if($login['moder']>=2)
	print "<a href=\"./moder.php?id=$id&amp;pass=$pass&amp;mod=restore\">".$lang['restore_login']."</a><br/>";
	if($login['moder']>=4) {
	print "<a href=\"$PHP_SELF?id=$id&amp;pass=$pass&amp;mod=editnik\">".$lang['change_login']."</a><br/>";
	print "<a href=\"$PHP_SELF?id=$id&amp;pass=$pass&amp;mod=setstatus\">".$lang['change_status']."</a><br/>";
	print "<a href=\"$PHP_SELF?id=$id&amp;pass=$pass&amp;mod=delmsgs\">".$lang['empty_rooms']."</a><br/>";
	}
	break;
	}
	if($mod)
	print "<a href=\"./moder.php?id=$id&amp;pass=$pass\">".$lang['modering']."</a><br/>";
	if($room)
	print "<a href=\"./room.php?id=$id&amp;pass=$pass&amp;room=$room\">".$lang['to_chat']."</a><br/>";
	else
	print "<a href=\"./enter.php?id=$id&amp;pass=$pass\">".$lang['holl']."</a><br/>";
		} else { $lang['access_denied']; }
mysql_close();
ob_end_flush();
?>
</p>
</card>
</wml>