Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Alguem poderia me ajudar ? veja melhor pelo link [http://158.69.166.245/reg/cadastro.php][1]
- <?php
- class Register
- {
- private $CurrentChannel = '01';//Canal atual
- private $AccountDir = 'C://Users//Administrator//Desktop//Server//DBSrv//run//account';//Accounts
- private $AccountDir2 = 'C:UsersAdministratorDesktopServerDBSrvrunaccount';//Accounts
- private $Mod = true;//TRUE para release de pobre, false pra do seitbnao
- private $ImportUser = 'C:/Users/Administrator/Desktop/Server/Common/ImportUser';//Cadastro
- private $UpdateAcount = 'C://Users//Administrator//Desktop//Server//Common//UpdateUser';//Troca de Senha
- public $err = array(
- 'Usuário deve conter de 4 a 16 caracteres alfanuméricos<br>',
- 'Senha deve conter de 4 a 12 caracteres alfanuméricos<br>',
- 'Nome deve conter de 4 a 24 caracteres alfanuméricos<br>',
- 'Email deve ser um email válido<br>',
- 'Codigo de recuperacao deve conter 9 a 16 digitos numéricos<br> ',
- 'Digite TOW ONLINE <br>',
- 'Conta está em uso <br>',
- 'Login ou senha não podem ficar em branco <br>',
- 'Conta criada com sucesso <br>',
- 'Nova senha não pode ficar em branco <br>',
- 'Nova senha deve conter de 4 a 12 caracteres alfanuméricos<br>',
- 'Conta não existe<br>',
- 'Senha alterada com sucesso<br>',
- 'Senha não confere!<br>'
- );
- function __construct($Channel = '01')
- {
- $this->CurrentChannel = $Channel;
- }
- public function Validar($user = 'Servidor', $pass = 'senha',$Email ='servidor@wyd.com',$RealName ='Servidor Unico',$Telephone = '12345678912345',$Address = 'São Paulo')
- {
- $user = trim($user);
- $pass = trim($pass);
- if(!preg_match('/^[0-9a-zA-Z]{4,16}$/i',$user))
- {
- echo $this->err[0];
- return false;
- }
- if(!preg_match('/^[0-9a-zA-Z]{4,12}$/i',$pass))
- {
- echo $this->err[1];
- return false;
- }
- if (!filter_var($Email, FILTER_VALIDATE_EMAIL))
- {
- echo $this->err[3];
- return false;
- }
- if(strlen($RealName) < 4 || strlen($RealName) >= 24)
- {
- echo $this->err[2];
- return false;
- }
- include_once("config.db.site.php");
- try {
- $loginacc = ($_POST['login']);
- $senhaacc = ($_POST['senha']);
- $emailacc = ($_POST['email']);
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password1);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $sql = ("INSERT INTO 't_account' (`name`, `pw2`, `email') VALUES (`$loginacc`, `$senhaacc`, `$emailacc`)");
- $conn->exec($sql);
- echo '
- <script type="text/javascript">
- alert("Cadastrado com Sucesso.");
- </script>
- ';
- }
- catch(PDOException $e)
- {
- echo $sql . "<br>" . $e->getMessage();
- }
- $conn = null;
- return true;
- }
- public function InitialDir($Login)
- {
- $ini = substr($Login,0,1);
- if(is_numeric($ini))
- $ini = "etc";
- return $ini;
- }
- public function Trocar_Senha($user, $pass,$NewPass)
- {
- if(empty($user)|| empty($pass) || empty($NewPass))
- {
- if(empty($NewPass))
- echo $this->err[9];
- else
- echo $this->err[7];
- return false;
- }
- $account = $this->AccountDir2.'\'.$this->InitialDir($user).'\'.$user;
- if(!file_exists($account))
- {
- echo $this->err[11];
- return false;
- }
- if(!$this->Validar($user, $pass))
- return false;
- if(!$this->Validar($user, $NewPass))
- return false;
- $Buffer = $this->OpenAccount($account);
- if(!$Buffer)
- {
- echo 'Erro ao abrir conta!';
- return false;
- }
- $PwdFile = trim(hex2bin(substr($Buffer,32,28)));
- if(strcmp($PwdFile,$pass))
- {
- echo $this->err[13];
- return false;
- }
- if($this->Mod == false)
- $account2 = $this->UpdateAcount.'\'. $this->CurrentChannel.'\update\'.$user;
- else
- $account2 = $this->UpdateAcount.'\update\'.$user;
- $fp = fopen($account2, "wt");
- $escreve = fwrite($fp, "$usern");
- $escreve = fwrite($fp, "$NewPassn");
- fclose($fp);
- echo $this->err[12];
- return true;
- }
- public function Registrar($user, $pass,$email,$Name,$tel,$Addr)
- {
- if(empty($user)|| empty($pass))
- {
- echo $this->err[7];
- return false;
- }
- if(!$this->Validar($user, $pass,$email,$Name,$tel,$Addr))
- return false;
- $account = $this->AccountDir.'\'.$this->InitialDir($user).'\'.$user;
- $account2 = $this->ImportUser.'\'.$user;
- if(file_exists($account))
- {
- echo $this->err[6];
- return false;
- }
- else
- {
- $Bonus = 0;
- $ssn = rand()%1001;
- $ssn2 = rand()%1001;
- $user = strtoupper($user);
- $email = strtoupper($email);
- $Name = strtoupper($Name);
- $Addr = strtoupper($Addr);
- //id, pass, name, ssn1, ssn2, email, tel, addr, bonus
- $fp = fopen($account2, "wt");
- $escreve = fwrite($fp, "$usern");
- $escreve = fwrite($fp, "$passn");
- $escreve = fwrite($fp, "$Namen");
- $escreve = fwrite($fp, "$ssnn");
- $escreve = fwrite($fp, "$ssn2n");
- $escreve = fwrite($fp, "$emailn");
- $escreve = fwrite($fp, "$teln");
- $escreve = fwrite($fp, "$Addrn");
- $escreve = fwrite($fp, "$Bonusn");
- fclose($fp);
- echo $this->err[8];
- return true;
- }
- }
- public function OpenAccount($account)
- {
- if(file_exists($account))
- {
- $open = @fopen($account,'r');
- $leitura = @fread($open, filesize($account));
- return trim(strtoupper(bin2hex($leitura)));
- }
- else
- return 0;
- }
- public function hexTobin($data)
- {
- return pack("H".strlen($data),$data);
- }
- public function inverterhex($data)
- {
- $tamanho=strlen($data);
- if(($tamanho % 2)!=0)
- {
- $data="0".$data;
- }
- $data=wordwrap($data, 2, "/", true);
- $explode=explode("/", $data);
- $a=0;
- for($i=(count($explode)-1); $i>=0; $i--)
- {
- $join[$a]=$explode[$i];
- $a++;
- }
- $data=implode("", $join);
- return $data;
- }
- public function hex2num($data)
- {
- return hexdec($this->inverterhex($data));
- }
- public function num2hex($data)
- {
- return $this->inverterhex(dechex($data));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement