View file ch/bind.php

File size: 5.03Kb
<?
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 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;
}           
$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=\"bind\" title=\"Клавиши\">\n";
echo "<p><small>\n";

echo "<b>Сказать:</b><br/>";
$bind1=$row['bind1'];
echo "<input name=\"bind1\" maxlength=\"1\" format=\"*N\" value=\"$bind1\"/><br/>";

echo "<b>Обновить:</b><br/>";
$bind2=$row['bind2'];
echo "<input name=\"bind2\" maxlength=\"1\" format=\"*N\" value=\"$bind2\"/><br/>";

echo "<b>История:</b><br/>";
$bind3=$row['bind3'];
echo "<input name=\"bind3\" maxlength=\"1\" format=\"*N\" value=\"$bind3\"/><br/>";

echo "<b>Прихожая:</b><br/>";
$bind4=$row['bind4'];
echo "<input name=\"bind4\" maxlength=\"1\" format=\"*N\" value=\"$bind4\"/><br/>";

echo "-<br/><anchor title=\"go\">Сохранить<go href=\"bind.php?id=$id&amp;ps=$ps&amp;go=rew&amp;ref=$ref\" method=\"post\">\n";
echo "<postfield name=\"bind1\" value=\"$(bind1)\"/>\n";
echo "<postfield name=\"bind2\" value=\"$(bind2)\"/>\n";
echo "<postfield name=\"bind3\" value=\"$(bind3)\"/>\n";
echo "<postfield name=\"bind4\" value=\"$(bind4)\"/>\n";
echo "</go></anchor><br/>-<br/>";

echo "<a href=\"cabinet.php?id=$id&amp;ps=$ps&amp;ref=$ref\">Личный кабинет</a><br/>\n";
echo "<a href=\"enter.php?id=$id&amp;ps=$ps&amp;ref=$ref\">Прихожая</a>\n";
echo "</small></p>\n";
echo "</card>\n";
echo "</wml>\n"; 
mysql_close ($link);
 exit;
 }
 
/*
$bind1=str_replace("'","",$bind1);
$bind2=str_replace("'","",$bind2);
$bind3=str_replace("'","",$bind3);
$bind4=str_replace("'","",$bind4);

$bind1=HtmlSpecialChars($bind1); 
$bind2=HtmlSpecialChars($bind2); 
$bind3=HtmlSpecialChars($bind3); 
$bind4=HtmlSpecialChars($bind4); 
*/
               
    if (!isset($error)) {
            $result = mysql_query ("Select * users where id = '".$id."'");
            if (mysql_affected_rows() == 0) {
                $error = "database error...";
            } else {
   $ins_str = "Update users set bind1 = '".$bind1."',bind2 = '".$bind2."',bind3 = '".$bind3."',bind4 = '".$bind4."' 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";
echo "<card id=\"error\" title=\"error\" ontimer=\"bind.php?id=$id&amp;ps=$ps\"><timer value=\"10\"/>\n";
echo "<do type=\"prev\" label=\"Back\"><prev/></do>\n";
echo "<p>\n";
echo "<small>$error</small>\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";
echo "<card id=\"ok\" title=\"Ok!\" ontimer=\"cabinet.php?id=$id&amp;ps=$ps&amp;ref=$ref\"><timer value=\"10\"/>\n";
echo "<p>\n";
echo "<small>$msg</small><br/>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
?>