View file ch/topic.php

File size: 6.2Kb
<?
header("Cache-Control: no-cache");
header("Content-type:text/vnd.wap.wml");  
$ref=rand(10000,1000000);
require("inc.php");

$link = @mysql_pconnect ($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>"); 

$result = @mysql_query ("Select * from users where id='".$id."'");
         
         if (mysql_affected_rows() == 0) {
          echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;\" ontimer=\"index.php?ref=$ref\"><timer value=\"15\"/>\n";
echo "<p align=\"center\">\n";
echo "User was not found\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close($link);
exit;
}
                
$row = mysql_fetch_array ($result);
if ($ps !== $row["pass"]){
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;\" ontimer=\"index.php?ref=$ref\"><timer value=\"15\"/>\n";
echo "<p align=\"center\">\n";
echo "Your login failed\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close($link);   
exit;
}       
if($row["level"] < 4)
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"error\">\n";
echo "<p align=\"center\">\n";
echo "У вас нет прав доступа!\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close ($link);
exit;
}

if($row['fsize'] == "small") { $fsize1 = "<small>"; $fsize2 = "</small>"; }
elseif($row['fsize'] == "big") { $fsize1 = "<big>"; $fsize2 = "</big>"; }
else { $fsize1 = ""; $fsize2 = ""; }

if(!isset($go))
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";  
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"topic\" title=\"&#x0421;&#x043C;&#x0435;&#x043D;&#x0438;&#x0442;&#x044C; &#x0442;&#x043E;&#x043F;&#x0438;&#x043A;\">\n";
echo "<p>\n";     
//echo $fsize1;
echo "Новый топик:<br/>\n";
echo "<input name=\"newtopic$ref\" maxlength=\"30\" value=\"\" title=\"change\"/><br/>\n"; 
echo "<anchor title=\"go\">Изменить!<go href=\"topic.php?go=nt&amp;id=$id&amp;ps=$ps&amp;rm=$rm&amp;ref=$ref\" method=\"post\">\n";    echo "<postfield name=\"newtop\" value=\"$(newtopic$ref)\"/>\n";
echo "</go></anchor><br/><br/>\n";        
//echo $fsize2;
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close ($link);
exit;
}

function trun_to_rus($str){
                $str=str_replace("ch","ч",$str);
                $str=str_replace("sc","щ",$str); 
                $str=str_replace("ye","э",$str);
                $str=str_replace("yu","ю",$str);
                $str=str_replace("ya","я",$str);
                $str=str_replace("CH","Ч",$str);
                $str=str_replace("SC","Щ",$str); 
                $str=str_replace("\"\"","Ъ",$str);
                $str=str_replace("\"","ъ",$str);
                $str=str_replace("''","Ь",$str);
                $str=str_replace("'","ь",$str);
                $str=str_replace("YE","Э",$str);
                $str=str_replace("YU","Ю",$str);
                $str=str_replace("YA","Я",$str);
$str=strtr($str,array("a"=>"а","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"е","j"=>"ж","z"=>"з","i"=>"и","y"=>"й","k"=>"к","l"=>"л","m"=>"м","n"=>"н","o"=>"о","p"=>"п","r"=>"р","s"=>"с","t"=>"т","u"=>"у","f"=>"ф","h"=>"х","c"=>"ц","w"=>"ш","x"=>"ы","A"=>"А","B"=>"Б","V"=>"В","G"=>"Г","D"=>"Д","E"=>"Е","J"=>"Ж","Z"=>"З","I"=>"И","Y"=>"Й","K"=>"К","L"=>"Л","M"=>"М","N"=>"Н","O"=>"О","P"=>"П","R"=>"Р","S"=>"С","T"=>"Т","U"=>"У","F"=>"Ф","H"=>"Х","C"=>"Ц","W"=>"Ш","X"=>"Ы"));
                return $str;
                }
				
if($row["translit"]==1) {$newtop=trun_to_rus($newtop);}	

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n"; 
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"changed\" title=\"Топик сменен\" ontimer=\"chat.php?id=$id&amp;ps=$ps&amp;rm=$rm&amp;ref=$ref\"><timer value=\"10\"/>\n";
echo "<p>";                                                        
echo $fsize1;
echo "Топик был изменен!<br/>\n";
echo $fsize2;
@$newtop = str_replace(chr("13"), " ", $newtop);
@$newtop = str_replace(chr("10"), " ", $newtop);
@$newtop = str_replace("\\n", " ", $newtop);
@$newtop = trim(" $newtop ");
@$newtop = ereg_replace(" +"," ",$newtop);
@$newtop=substr($newtop,0,60);
@$newtop = str_replace("$", "$$", $newtop);     
@$newtop = str_replace("", "", $newtop);
@$newtop = str_replace("", "", $newtop); 
@$newtop = str_replace("", "", $newtop); 
@$newtop = str_replace("", "", $newtop); 
@$newtop = str_replace("", "", $newtop); 
@$newtop = str_replace("", "", $newtop); 
@$newtop = HtmlSpecialChars($newtop); 
@$newtop = str_replace("|", "&#0166;", $newtop); 
@$newtop = str_replace("'", "&#8216;", $newtop); 
@$newtop = str_replace("\\", "", $newtop); 
$room="room".$rm;
mysql_query ("UPDATE $room SET message = '".$newtop."' WHERE klu4 = 1");
mysql_query ("UPDATE rooms SET topic = '".$newtop."' WHERE rm = '".$rm."'");
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
?>