106 lines
2.8 KiB
PHP
106 lines
2.8 KiB
PHP
<?php
|
|
$ini = parse_ini_file("conf.ini", true);
|
|
|
|
mysql_connect($ini['db']['host'],$ini['db']['user'],$ini['db']['pass']);
|
|
mysql_select_db($ini['db']['db']);
|
|
|
|
if ($ini['db']['log']=="1"){
|
|
$arrival_time=microtime(true);
|
|
$filename=basename(__FILE__);
|
|
$filename="log_".$filename.".txt";
|
|
$chunck=strval($arrival_time)." ".$_SERVER['REQUEST_URI']."\r\n";
|
|
file_put_contents($filename,$chunck,FILE_APPEND);
|
|
}
|
|
|
|
$user_id=$_REQUEST['u_id'];
|
|
$nick=$_REQUEST['nick'];
|
|
$password=$_REQUEST['password'];
|
|
$password_ban=$_REQUEST['password_ban'];
|
|
$user_toban_code=$_REQUEST['user_code'];
|
|
|
|
if (!empty($_REQUEST['postfix'])){
|
|
$postfix=$_REQUEST['postfix'];
|
|
}
|
|
else{
|
|
$postfix="no_postfix";
|
|
}
|
|
|
|
$sql=mysql_query("select * from banned where user_id=$user_id");
|
|
if (mysql_num_rows($sql)){
|
|
$banned=1;
|
|
$output="wrong";
|
|
}
|
|
else{
|
|
$banned=0;
|
|
}
|
|
|
|
if($banned==0 and $user_id<>862046030418099){
|
|
$sql=mysql_query("select moderator from contest_nick where nick='$nick' and pwd='$password' limit 1");
|
|
if (mysql_num_rows($sql)){
|
|
$moderator=mysql_result($sql,0,"moderator");
|
|
}
|
|
else{
|
|
$moderator=0;
|
|
}
|
|
|
|
if ($moderator==1){
|
|
if ($password_ban==91280){
|
|
$sql=mysql_query("select last_known_user_id,canbemoderator,nick from contest_nick where user_code=$user_toban_code limit 1");
|
|
if (mysql_num_rows($sql)){
|
|
$user_toban_id=mysql_result($sql,0,"last_known_user_id");
|
|
$user_toban_nick=mysql_result($sql,0,"nick");
|
|
$canbemoderator=mysql_result($sql,0,"canbemoderator");
|
|
$sql=mysql_query("select ID from banned where user_id=$user_toban_id");
|
|
if (mysql_num_rows($sql)){
|
|
$output="already";
|
|
}
|
|
else{
|
|
if ($user_toban_id<>0 && $canbemoderator==0){
|
|
$sql=mysql_query("insert into banned (user_id,banned_by) values ($user_toban_id,'$nick')");
|
|
|
|
if (strcmp($postfix,"no_postfix")==0){
|
|
$output="ok";
|
|
}
|
|
else{
|
|
$text=$user_toban_nick.' blocked by '.$nick;
|
|
|
|
$url = 'http://www.earthquakenetwork.it/mysql/distquake_upload_chat3.php';
|
|
|
|
$chat_data = array('u_id'=>'1','nick' => 'Robot', 'password' => 'h7k32fw9','postfix' =>$postfix,'u_code'=>'1','msg_code'=>'1234','message'=>$text);
|
|
$options = array(
|
|
'http' => array(
|
|
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
|
'method' => 'POST',
|
|
'content' => http_build_query($chat_data)
|
|
)
|
|
);
|
|
$context = stream_context_create($options);
|
|
$result = file_get_contents($url, false, $context);
|
|
|
|
$output="ok";
|
|
}
|
|
}
|
|
else{
|
|
$output="wrong";
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
$output="wrong";
|
|
}
|
|
}
|
|
else{
|
|
$output="wrongpwd";
|
|
}
|
|
}
|
|
else{
|
|
$output="nomod";
|
|
}
|
|
}
|
|
else{
|
|
$output="nomod";
|
|
}
|
|
print($output);
|
|
mysql_close();
|
|
?>
|