Просмотр файла change.php

Размер файла: 8.73Kb
<?
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</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...</p>
</card>
</wml>");
          
        $result = @mysql_query ("Select * from mafusers 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;
}               
$us=$row["user"];  


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=\"change\" title=\"Настройки\">\n";
echo "<p>\n";
echo "Время автообновления(сек):<br/>\n";
echo "<select name=\"avr\">\n";
if($row["avr"] === "100")
{
echo "<option value=\"100\">10</option>\n";
}
elseif($row["avr"] === "150")
{
echo "<option value=\"150\">15</option>\n";
}
elseif($row["avr"] === "200")
{
echo "<option value=\"200\">20</option>\n";
}
elseif($row["avr"] === "250")
{
echo "<option value=\"250\">25</option>\n";
}
elseif($row["avr"] === "300")
{
echo "<option value=\"300\">30</option>\n";
}
elseif($row["avr"] === 0) echo "<option value=\"0\">Отключить</option>\n";
echo "<option value=\"0\">Отключить</option>\n";
echo "<option value=\"100\">10</option>\n";
echo "<option value=\"150\">15</option>\n";
echo "<option value=\"200\">20</option>\n";
echo "<option value=\"250\">25</option>\n";
echo "<option value=\"300\">30</option>\n";
echo "</select><br/>\n";
echo "Кол-во сообшений:<br/>\n";
echo "<select name=\"max\">\n";
if($row["max"] === "5")
{
echo "<option value=\"5\">5</option>\n";
}
elseif($row["max"] === "8")
{
echo "<option value=\"8\">8</option>\n";
}
elseif($row["max"] === "10")
{
echo "<option value=\"10\">10</option>\n";
}
elseif($row["max"] === "12")
{
echo "<option value=\"12\">12</option>\n";
}
elseif($row["max"] === "15")
{
echo "<option value=\"15\">15</option>\n";
}
elseif($row["max"] === "20")
{
echo "<option value=\"20\">20</option>\n";
}
elseif($row["max"] === "25")
{
echo "<option value=\"25\">25</option>\n";
}
elseif($row["max"] === "30")
{
echo "<option value=\"30\">30</option>\n";
}
echo "<option value=\"5\">5</option>\n";
echo "<option value=\"8\">8</option>\n";
echo "<option value=\"10\">10</option>\n";
echo "<option value=\"12\">12</option>\n";
echo "<option value=\"15\">15</option>\n";
echo "<option value=\"20\">20</option>\n";
echo "<option value=\"25\">25</option>\n";
echo "<option value=\"30\">30</option>\n";
echo "</select><br/>\n";
echo "По умолчанию сказать:<br/>\n";
if($row["say"] === "0")
{
echo "<select name=\"say\">\n";
echo "<option value=\"0\">Приватно</option>\n";
echo "<option value=\"1\">Всем</option>\n";
echo "</select><br/>\n";
 }
 else
 {
echo "<select name=\"say\">\n";
echo "<option value=\"1\">Всем</option>\n";
echo "<option value=\"0\">Приватно</option>\n";
echo "</select><br/>\n"; 
 }

echo "Транслит:<br/>\n";
echo "<select name=\"trun\">\n";
if($row["translit"] == 0){
echo "<option value=\"0\">Отключен</option>\n";
echo "<option value=\"1\">Включен</option>\n";
} else {
echo "<option value=\"1\">Включен</option>\n";
echo "<option value=\"0\">Отключен</option>\n";
}           
echo "</select><br/>\n";
echo "Смайлы:<br/>\n";
echo "<select name=\"smls\">\n";
if ($row["smiles"]==0){
echo "<option value=\"0\">Отключены</option>\n";
echo "<option value=\"1\">Статичные</option>\n";  
echo "<option value=\"2\">Все смайлы</option>\n";
}else if ($row["smiles"]==1){     
echo "<option value=\"1\">Статичные</option>\n";
echo "<option value=\"0\">Отключены</option>\n";  
echo "<option value=\"2\">Все смайлы</option>\n";
}else{                  
echo "<option value=\"2\">Все смайлы</option>\n";
echo "<option value=\"0\">Отключены</option>\n"; 
echo "<option value=\"1\">Статичные</option>\n"; 
}
echo "</select><br/>\n"; 
if(isset($rm))echo "<anchor title=\"go\">Апдейт<go href=\"change.php?id=$id&amp;ps=$ps&amp;go=rew&amp;rm=$rm&amp;ref=$ref\" method=\"post\">\n";
else echo "<anchor title=\"go\">Апдейт<go href=\"change.php?id=$id&amp;ps=$ps&amp;go=rew&amp;ref=$ref\" method=\"post\">\n";
echo "<postfield name=\"avr\" value=\"$(avr)\"/>\n";
echo "<postfield name=\"max\" value=\"$(max)\"/>\n";
echo "<postfield name=\"say\" value=\"$(say)\"/>\n";
echo "<postfield name=\"trun\" value=\"$(trun)\"/>\n"; 
echo "<postfield name=\"smls\" value=\"$(smls)\"/>\n";
echo "</go></anchor><br/>\n";
echo "*********<br/>\n";
if(isset($rm))echo "<a href=\"maf.php?id=$id&amp;ps=$ps&amp;rm=$rm&amp;ref=$ref\">В игру</a>\n";
else echo "<a href=\"enter.php?id=$id&amp;ps=$ps&amp;ref=$ref\">На улицу</a>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close ($link);
 exit;
 }



$avr = trim(" $avr ");
$max = trim(" $max ");
$say = trim(" $say ");
$trun = trim(" $trun ");
$emp="Неправильный формат данных!";
      if(!preg_match("!^[0-9]+$!i",$avr))  {
        $error = $emp;
    } elseif(!preg_match("!^[0-9]+$!i",$max))  {
        $error = $emp;
    } elseif(!preg_match("!^[0-9]+$!i",$say))  {
        $error = $emp;
    } elseif(!preg_match("!^[0-9]+$!i",$trun))  {
        $error = $emp;
    } elseif(!preg_match("!^[0-9]+$!i",$smls))  {
        $error = $emp;
    }

             
    if (!isset($error)) {
            $result = mysql_query ("Select * mafusers where id = '".$id."'");
            if (mysql_affected_rows() == 0) {
                $error = "database error...";
            } else {
   $ins_str = "Update mafusers set avr='".$avr."', max='".$max."', say='".$say."', translit='".$trun."', smiles = '".$smls."' where id ='".$id."'";
            }
    if (mysql_query ($ins_str)) {
     $msg = "Ваши настройки изменены";

                } else {
                    $error = " ".mysql_error()." ";
                }
                }

mysql_close($link);

    if (isset($error)) {
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";
if(isset($rm))echo "<card id=\"error\" title=\"error\" ontimer=\"change.php?id=$id&amp;rm=$rm&amp;ps=$ps\"><timer value=\"10\"/>\n";
else echo "<card id=\"error\" title=\"error\" ontimer=\"change.php?id=$id&amp;ps=$ps\"><timer value=\"10\"/>\n";
echo "<do type=\"prev\" label=\"Back\"><prev/></do>\n";
echo "<p>\n";
echo "<b>$error/b>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
exit;
} 
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";
if(isset($rm))echo "<card id=\"ok\" title=\"OK\" ontimer=\"maf.php?id=$id&amp;ps=$ps&amp;rm=$rm&amp;ref=$ref\"><timer value=\"10\"/>\n";
else echo "<card id=\"ok\" title=\"OK\" ontimer=\"enter.php?id=$id&amp;ps=$ps&amp;ref=$ref\"><timer value=\"10\"/>\n";
echo "<p>\n";
echo "<b>$msg</b><br/>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
?>