Просмотр файла sgb/index.php

Размер файла: 12.72Kb
<?

list($msec,$sec)=explode(chr(32),microtime()); 

$HeadTime=$sec+$msec;

header("Cache-Control: no-cache");

header("Content-type:text/vnd.wap.wml; charset=utf-8");   

$ref=rand(10000,1000000);   

require("conf.inc.php");

$link = @mysql_connect ($MySQL_Hostname, $MySQL_Username, $MySQL_Password)

                or die ("<wml>

<card id=\"error\" title=\"error\">

<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">Can not connect to MySQL<br/>".mysql_error()."</p>

</card>

</wml>");     

     @mysql_select_db($MySQLDatabasename) or die ("<wml>

<card id=\"error\" title=\"error\">

<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">error select the database...<br/>".mysql_error()."</p>

</card>

</wml>"); 



//configs

//??????????

$timeoutseconds 	= 60480000; 

$timestamp=time();                                                                                            

$timeout=$timestamp-$timeoutseconds; 

//?-?? ???? ???? ????

$tol = 60*15;                                                                                          

$timeb=$timestamp-$tol; 

//online

$timeoutnline 	= 60*5; 

$timekik=$timestamp-$timeoutnline; 

@mysql_query("DELETE FROM nline WHERE time<$timekik");

//





$id = intval($id);

$id=@mysql_escape_string($id);

$result=@mysql_query("select * from users where id='$id' limit 1;");



			if (mysql_affected_rows() == 0) {

			echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";

echo "<wml>";

echo "<card id=\"error\" title=\"&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;\" ontimer=\"http://wap.gsm.az\"><timer value=\"15\"/>";

echo "<p align=\"center\"><small>";

echo "&#x418;&#x437;&#x432;&#x438;&#x43D;&#x438;&#x442;&#x435;, &#x43D;&#x43E; &#x433;&#x43E;&#x441;&#x442;&#x435;&#x432;&#x43E;&#x439; &#x43A;&#x43D;&#x438;&#x433;&#x438; &#x43D;&#x435; &#x441;&#x443;&#x449;&#x435;&#x441;&#x442;&#x432;&#x443;&#x435;&#x442;!";

echo "</small></p></card></wml>";

exit;

mysql_close($link);

}



require "functions.php";

$data=mysql_fetch_array($result);

$num_msgs=$data['msgs'];

$title=$data['title'];

$id=$data['id'];

$razdel=$data['razdel'];

$link=$data['link'];

$sitename=$data['sitename'];

$komp=$data['komp'];

$verh=$data['verh'];

$niz=$data['niz'];



$agent = $HTTP_USER_AGENT;

$addr = $REMOTE_ADDR;



if (empty($sitename)) $sitename="&#x41D;&#x430; &#x433;&#x43B;&#x430;&#x432;&#x43D;&#x443;&#x44E;";

if (empty($num_msgs)) $num_msgs="9";

if (empty($title)) $title="&#x413;&#x43E;&#x441;&#x442;&#x435;&#x432;&#x430;&#x44F;";



if ($komp==1) {

if (((strpos ($agent,"M3Gate") !== false)||(strpos ($agent,"Opera") !== false)||(strpos ($agent,"emulator") !== false)||(strpos ($agent,"WinWAP") !== false)||(strpos ($agent,"Wapsilon") !== false)||(strpos ($agent,"M3GATE") !== false))&&($row["level"]<4)&&($rm==0))

{

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";

echo "<wml>";

echo "<card id=\"error\" title=\"&#x41E;&#x448;&#x438;&#x431;&#x43A;&#x430;!\" ontimer=\"http://wap.gsm.az\"><timer value=\"15\"/>";

echo "<p align=\"center\"><small>";

echo "&#x418;&#x437;&#x432;&#x438;&#x43D;&#x438;&#x442;&#x435;, &#x43D;&#x43E; &#x432; &#x434;&#x430;&#x43D;&#x43D;&#x443;&#x44E; &#x433;&#x43E;&#x441;&#x442;&#x435;&#x432;&#x443;&#x44E; &#x434;&#x43E;&#x441;&#x442;&#x443;&#x43F; &#x441; &#x43A;&#x43E;&#x43C;&#x43F;&#x44C;&#x44E;&#x442;&#x435;&#x440;&#x430; &#x437;&#x430;&#x43A;&#x440;&#x44B;&#x442;!";

echo "</small></p></card></wml>"; 

exit;

mysql_close($link);

}

}



//??? ?? ip+soft

mysql_query ("Select * from ban WHERE gid='".$id."' and ip='".$addr."' and brows='".$agent."' LIMIT 1;");

if (mysql_affected_rows()!=0)

{

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";

echo "<wml>";

echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>";

echo "<card id=\"ban\" title=\"&#x041E;&#x0431;&#x043B;&#x043E;&#x043C;!\" ontimer=\"http://wap.waup.ru\"><timer value=\"30\"/>";

echo "<p align=\"center\"><small>";

echo "&#x412;&#x44B; &#x437;&#x430;&#x431;&#x430;&#x43D;&#x435;&#x43D;&#x44B; &#x43F;&#x43E; &#x441;&#x432;&#x44F;&#x437;&#x43A;&#x435; ip+soft!!!<br/>";

echo "</small></p></card></wml>";

exit;

mysql_close($link);

}

//End ip+soft







echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";

echo "<wml>";

echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>";

echo "<card id=\"main\" title=\"$title\">";



echo "

<do type=\"options\" name=\"update\" label=\"&#x041E;&#x0431;&#x043D;&#x043E;&#x0432;&#x0438;&#x0442;&#x044C;\"><go href=\"index.php?id=$id&amp;ref=$ref\" method=\"get\"/></do>

<do type=\"options\" name=\"say\" label=\"&#x41D;&#x430;&#x43F;&#x438;&#x441;&#x430;&#x442;&#x44C;\"><go href=\"#say\" method=\"get\"/></do>

<do type=\"options\" name=\"home\" label=\"$sitename\"><go href=\"$link\" method=\"get\"/></do>



<do type=\"options\" name=\"trans\" label=\"&#x422;&#x440;&#x430;&#x43D;&#x441;&#x43B;&#x438;&#x442;\"><go href=\"translit.php?id=$id\" method=\"get\"/></do>";




$onco=mysql_query ("SELECT id FROM nline WHERE (gid='$id' and ip='$REMOTE_ADDR' and brows='$HTTP_USER_AGENT' and time>=$timekik) LIMIT 1"); 

if(mysql_affected_rows()==0)

{                                                                            

mysql_query("Insert into nline set gid='".$id."', ip='".$addr."', brows='".$agent."', time='".time()."'");

}

$r = mysql_query ("select count(id) as num from nline WHERE (gid = '".$id."')and(time >= '".$timekik."')");

$a = mysql_fetch_array($r);

$inb = $a["num"]; 





if (!empty($verh)) 

{

echo "<p align=\"center\">";

echo "$verh";

echo "</p>";

}

echo "<p align=\"left\">"; 



$id=htmlspecialchars(stripslashes(trim($id)));

$msg=htmlspecialchars(stripslashes(trim($msg)));

$login=htmlspecialchars(stripslashes(trim($login)));

$email=htmlspecialchars(stripslashes(trim($email)));



if(!empty($msg) && !empty($login)) {

$r = mysql_query("SELECT msg FROM recs order by id desc LIMIT 1");

$a = mysql_fetch_array($r);

$msgearch = array ("'\t'i",                                               

                 "'([\n])[\s]+'",                                       

                 "'\s{2,}'",                                                                                

                 "'&(nbsp|#160);'i",                            

                 "'&#(\d+);'i");                                        

//               "'&#(\d+);'e");                                

$replace = array ("",

                  "\n",

                  " ",

                  " ",

                  "-");

//                "chr(\\1)");

$msg = preg_replace ($msgearch, $replace, $msg);

$msg=str_replace('$','$$',$msg);

$msg=preg_replace("/\[!\[/","<",$msg);                

$msg=preg_replace("/\]!\]/",">",$msg);  

$msg = eregi_replace("((http://))((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z;]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:;\?\.-]*)*)", "<a href=\"\\0\">\\3</a>", $msg);

if ($translit=="") require "convert_to_smiles.php";

if($translit=="toall") $msg=latrus($msg);

if ($id==1) {

$msg=str_replace('???','wowap',$msg);

$msg=str_replace('?????','wowap',$msg);

}



if ($a["msg"] !== $msg)

{

$daten=date("d M H:i");



$login = preg_replace ($msgearch, $replace, $login);

$login=str_replace('$','$$',$login);           

$login=preg_replace("/\[!\[/","<",$login);

$login=preg_replace("/\]!\]/",">",$login);

$email = preg_replace ($msgearch, $replace, $email);

$email=str_replace('$','$$',$email);

$email=preg_replace("/\[!\[/","<",$email);

$email=preg_replace("/\]!\]/",">",$email);



@mysql_query ("Insert into recs set gid='".$id."', login='".$login."', msg='".$msg."', email='".$email."', ip='".$REMOTE_ADDR."', brows='".$HTTP_USER_AGENT."', time='".$daten."', time2='".time()."'");

}

}



$r = mysql_query("select count(*) as num from recs where gid = '".$id."'");

$a = mysql_fetch_array($r);

$num = $a["num"];



if(!isset($s))$s=1;

$mx=round(($num/$num_msgs)+0.45);

if($s>$mx)$s=$mx;

if($s==0)$s=1;



$ot=(($s-1)*$num_msgs)+1;

$do=$s*$num_msgs;

if($do>$num)$do=$num;

$o=$ot-1;

$n=$ot;

if($do==0)$n=$o;





echo "<small>&#x041F;&#x043E;&#x0441;&#x0442;&#x044B; &#x0441; $n-$do &#x0432;&#x0441;&#x0435;&#x0433;&#x043E; $num</small><br/>\n";



if($data['fsize'] == "small") { $fsize1 = "<small>"; $fsize2 = "</small>"; }

elseif($data['fsize'] == "big") { $fsize1 = "<big>"; $fsize2 = "</big>"; }

else { $fsize1 = ""; $fsize2 = ""; }

echo $fsize1; 





echo "<anchor>&#x41D;&#x430;&#x43F;&#x438;&#x441;&#x430;&#x442;&#x44C;<go href=\"#say\" method=\"get\"/></anchor><br/>";

echo "<a href=\"index.php?id=$id&amp;ref=$ref\">&#x0412; &#x0433;&#x043E;&#x0441;&#x0442;&#x0435;&#x0432;&#x0443;&#x044E;</a>";

$r = mysql_query ("Select * from recs WHERE gid = '".$id."' order by id desc LIMIT $o,$do");

for ($i=$ot;$i<=$do;$i++){

$a = mysql_fetch_array($r);



$gid=$a['gid'];

$email=$a['email'];

$login=$a['login'];

$dbmsg=$a['msg'];

$dbotvet=$a['otvet'];

$dbtime=$a['time'];

$dbbrows=$a['brows'];

$kdbb = substr($dbbrows,0,strpos($dbbrows,"/")); 

if (empty($kdbb)) $kdbb="UnKnown";



echo "<br/><a href=\"index.php?id=$id&amp;lgn=$login,&amp;ref=$ref#say\">$login</a> $dbtime<br/>$dbmsg";


if (!empty($email)) echo "<br/><small>email:$email</small>";

echo "<br/><small><u>$kdbb</u></small>\n";

if (!empty($dbotvet)) echo "<br/><b>&#x41E;&#x442;&#x432;&#x435;&#x442;: $dbotvet </b>";

echo "<br/>$razdel";

}    



$next=$s+1;

$prev=$s-1;

if ($num>$do) {

$ot=(($next-1)*$num_msgs)+1;

$do=$next*$num_msgs;

if($do>$num)$do=$num;

echo "<br/><a href=\"index.php?id=$id&amp;s=$next&amp;ref=$ref\">$ot-$do&#8594;</a>\n";

}

if($s>1) {

$ot=(($prev-1)*$num_msgs)+1;

$do=$prev*$num_msgs;

echo "<br/><a href=\"index.php?id=$id&amp;s=$prev&amp;ref=$ref\">&#8592;$ot-$do</a><br/>\n";

}



echo $fsize2;

echo "</p>";

echo "<p align=\"center\">";

if (!empty($niz)) echo "$niz<br/>";
echo "<small>";
echo "<br/>OnLine: $inb";

echo "<br/><a href=\"$link\">$sitename</a>";

echo "<br/><a href=\"smiles.php?id=$id&amp;ref=$ref\">&#8594;&#x421;&#x43C;&#x430;&#x439;&#x43B;&#x44B;</a>";

echo "<br/><a href=\"translit.php?id=$id\">&#8594;&#x422;&#x440;&#x430;&#x43D;&#x441;&#x43B;&#x438;&#x442;</a>";


list($msec,$sec)=explode(chr(32),microtime());

echo "<br/>[". round(($sec+$msec)-$HeadTime,4)."]";
echo "</small>";

?>



</p>

</card>



<card id="say" title="&#x41D;&#x430;&#x43F;&#x438;&#x441;&#x430;&#x442;&#x44C;">

<p align="left">

&#x41D;&#x438;&#x43A;

<br/>

<?

$l = mysql_query("SELECT login FROM recs where ip='".$REMOTE_ADDR."' and brows='".$HTTP_USER_AGENT."' and time2>'".$timeb."' order by id desc");

$lf = mysql_fetch_array($l);

$entered=$lf["login"];



?>

<input name="login<? echo $ref; ?>" value="<? echo $entered; ?>" maxlength="16" emptyok="false"/><br/>

&#x421;&#x43E;&#x43E;&#x431;&#x449;&#x435;&#x43D;&#x438;&#x435;

<br/>

<input name="msg<? echo $ref; ?>" value="<? echo $lgn; ?>" maxlength="200"  emptyok="false"/><br/>

Email

<br/>

<input name="email" maxlength="32" emptyok="true"/><br/>

&#x422;&#x440;&#x430;&#x43D;&#x441;&#x43B;&#x438;&#x442;:

<br/>

<select multiple="true" name="translit">

<option value="toall">&#x412;&#x43A;&#x43B;&#x44E;&#x447;&#x438;&#x442;&#x44C;</option>

</select>

<br/>



<anchor>&#x41D;&#x430;&#x43F;&#x438;&#x441;&#x430;&#x442;&#x44C;<go href="index.php?id=<? echo htmlspecialchars(stripslashes(trim($id))); ?>&amp;ref=<? echo $ref; ?>" method="post">

<postfield name="id" value="<? echo htmlspecialchars(stripslashes(trim($id))); ?>"/>

<postfield name="login" value="$(login<? echo $ref; ?>)"/>

<postfield name="email" value="$(email)"/>

<postfield name="msg" value="$(msg<? echo $ref; ?>)"/>

<postfield name="translit" value="$(translit)"/>

</go></anchor>

<? 

echo "<br/><a href=\"index.php?id=$id&amp;ref=$ref\">&#x412; &#x433;&#x43E;&#x441;&#x442;&#x435;&#x432;&#x443;&#x44E;</a><br/>"; 

?>

</p>

</card>

</wml>

<?

exit;

mysql_close($link);

?>