View file user_passw/window.php

File size: 3.76Kb
<?php
 include_once  '../sys/inc/start.php' ;     
 include_once  '../sys/inc/compress.php' ; 
include_once  '../sys/inc/sess.php' ;
 include_once  '../sys/inc/home.php' ;
 include_once  '../sys/inc/settings.php' ;
include '../user_passw/config.php';
include_once '../sys/inc/db_connect.php' ;
include_once  '../sys/inc/ipua.php' ;
include_once  '../sys/inc/fnc.php' ;
include_once  '../sys/inc/user.php' ;
$set['title']='Потвердить Номер'; // заголовок страницы
include_once  '../sys/inc/thead.php' ;
title ();
aut ();
$showCodeform = false;
$show_content = false;
if(!mysql_connect($db_host,$db_user,$db_pass))
	{	
		echo "Произошла ошибка доступа к базе номеров, попробуйте обновить страницу";
	}
else
	{
		if(!mysql_select_db($db_name))
			{
				echo "Произошла ошибка доступа к базе номеров, попробуйте обновить страницу еще раз";
			}
		}			
if(isset($_POST['abonent'])) 
{
      $abonent = htmlentities($_POST['abonent']);
      $now = date("YmdHis");     
		if(strlen($abonent)<>11 || substr($abonent,0,1) <> 7)
			{
				 $errMessage = "Вводите номер в формате 71231234567";
				$trueAbonent = false; 
			}
		elseif(!preg_match('/^\d+$/', $abonent)) 
			{
				 $errMessage = "Номер телефона не может содержать символов.";
				$trueAbonent = false; 
			}
		else
          $trueAbonent = true;    
    }  
    if ($trueAbonent)
    {

      $urlsend = "sub-bill.ru/http/send/send.php?srvID=".$servis."&short_num=".$short_num."&abonent=".$abonent."&now=".$now."&smstext=".urlencode($smstext)."&md5key=".md5($servis.$now.$short_num.$skey);
  $cr = curl_init($urlsend);
  curl_setopt($cr,CURLOPT_RETURNTRANSFER,true); 
  $content = curl_exec($cr);
  curl_close($cr);
		//echo $content;
if($content =="OK_STATUS")
      {	
		 for($i=0; $i<10; $i++)
		 {
			 $secretCode.=rand(0,9);
		 }
		 $from_db=mysql_query("INSERT INTO `user_passw` (`Number` ,`Pass`) VALUES ('".mysql_real_escape_string($abonent)."',  '".$secretCode."')");
         $showCodeform = true;   
      }
      else
	  {  
        $errMessage = "Проверьте правильность введенной информации";
        $showCodeform = false;    
		}
   }
if(isset($_REQUEST['code']))
 {
	 $f_db=mysql_query("SELECT * FROM user_passw where Pass=".$_REQUEST['code']);
	 $row=mysql_fetch_array($f_db);
	 if($row[Pass]!='')
	 {	 
   $show_content=true;
	 }
  elseif($_POST['code']==1)
  {
   $showCodeform = true;
  }
		else
		{
			echo "<script>";
			echo "document.location='".$incorrect."'";
			echo "</script>";
			exit();
		}
}
if($show_content ==false)
{
   if(!$showCodeform)
	   {
?>
<p><font color="red"><?=$errMessage?> </font></p><br />  
<div style="width:" "height:">
<form method="POST">
<p>Введите номер телефона в формате <b>79XXXXXXXXX</b>:</p>
<input name="abonent" value="<?=@$_POST['abonent'];?>">
<input type="submit" value=" Отправить ">
<p>Если Вы уже зарегистрированы, введите свой пароль <a href="#" onclick="document.getElementById('code').submit();return false;"><b>здесь</b></a></p>		   
</form>
<form method="POST" id="code">
<input type="hidden" name="code" value="1">
</form>		   
</div>
 <?		} else {?>
<p><font color="red"><?=$errMessage?> </font></p><br />	 
<div style="width:" "height:">
<form method="POST">
<p>Введите Ваш пароль:</p>
<input name="code" value="">
<input type="submit" value=" Отправить ">
</form>
</div>
<?	}
}
if($show_content==true)
{
			echo "<script>";
			echo "document.location='".$correct."'";
			echo "</script>";
	}
include_once '../sys/inc/tfoot.php';
?>