Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.86 KB | None | 0 0
  1. Alguem poderia me ajudar ? veja melhor pelo link [http://158.69.166.245/reg/cadastro.php][1]
  2.  
  3. <?php
  4. class Register
  5. {
  6. private $CurrentChannel = '01';//Canal atual
  7. private $AccountDir = 'C://Users//Administrator//Desktop//Server//DBSrv//run//account';//Accounts
  8. private $AccountDir2 = 'C:UsersAdministratorDesktopServerDBSrvrunaccount';//Accounts
  9. private $Mod = true;//TRUE para release de pobre, false pra do seitbnao
  10. private $ImportUser = 'C:/Users/Administrator/Desktop/Server/Common/ImportUser';//Cadastro
  11. private $UpdateAcount = 'C://Users//Administrator//Desktop//Server//Common//UpdateUser';//Troca de Senha
  12. public $err = array(
  13. 'Usuário deve conter de 4 a 16 caracteres alfanuméricos<br>',
  14. 'Senha deve conter de 4 a 12 caracteres alfanuméricos<br>',
  15. 'Nome deve conter de 4 a 24 caracteres alfanuméricos<br>',
  16. 'Email deve ser um email válido<br>',
  17. 'Codigo de recuperacao deve conter 9 a 16 digitos numéricos<br> ',
  18. 'Digite TOW ONLINE <br>',
  19. 'Conta está em uso <br>',
  20. 'Login ou senha não podem ficar em branco <br>',
  21. 'Conta criada com sucesso <br>',
  22. 'Nova senha não pode ficar em branco <br>',
  23. 'Nova senha deve conter de 4 a 12 caracteres alfanuméricos<br>',
  24. 'Conta não existe<br>',
  25. 'Senha alterada com sucesso<br>',
  26. 'Senha não confere!<br>'
  27.  
  28. );
  29.  
  30.  
  31. function __construct($Channel = '01')
  32. {
  33. $this->CurrentChannel = $Channel;
  34. }
  35.  
  36.  
  37. public function Validar($user = 'Servidor', $pass = 'senha',$Email ='servidor@wyd.com',$RealName ='Servidor Unico',$Telephone = '12345678912345',$Address = 'São Paulo')
  38. {
  39. $user = trim($user);
  40. $pass = trim($pass);
  41. if(!preg_match('/^[0-9a-zA-Z]{4,16}$/i',$user))
  42. {
  43. echo $this->err[0];
  44. return false;
  45. }
  46. if(!preg_match('/^[0-9a-zA-Z]{4,12}$/i',$pass))
  47. {
  48. echo $this->err[1];
  49. return false;
  50. }
  51. if (!filter_var($Email, FILTER_VALIDATE_EMAIL))
  52. {
  53. echo $this->err[3];
  54. return false;
  55. }
  56. if(strlen($RealName) < 4 || strlen($RealName) >= 24)
  57. {
  58. echo $this->err[2];
  59. return false;
  60. }
  61.  
  62. include_once("config.db.site.php");
  63. try {
  64. $loginacc = ($_POST['login']);
  65. $senhaacc = ($_POST['senha']);
  66. $emailacc = ($_POST['email']);
  67. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password1);
  68. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  69. $sql = ("INSERT INTO 't_account' (`name`, `pw2`, `email') VALUES (`$loginacc`, `$senhaacc`, `$emailacc`)");
  70. $conn->exec($sql);
  71. echo '
  72. <script type="text/javascript">
  73.  
  74. alert("Cadastrado com Sucesso.");
  75.  
  76. </script>
  77. ';
  78. }
  79.  
  80. catch(PDOException $e)
  81. {
  82. echo $sql . "<br>" . $e->getMessage();
  83. }
  84.  
  85. $conn = null;
  86. return true;
  87. }
  88. public function InitialDir($Login)
  89. {
  90. $ini = substr($Login,0,1);
  91. if(is_numeric($ini))
  92. $ini = "etc";
  93. return $ini;
  94. }
  95. public function Trocar_Senha($user, $pass,$NewPass)
  96. {
  97. if(empty($user)|| empty($pass) || empty($NewPass))
  98. {
  99. if(empty($NewPass))
  100. echo $this->err[9];
  101. else
  102. echo $this->err[7];
  103.  
  104. return false;
  105. }
  106. $account = $this->AccountDir2.'\'.$this->InitialDir($user).'\'.$user;
  107.  
  108. if(!file_exists($account))
  109. {
  110. echo $this->err[11];
  111. return false;
  112. }
  113. if(!$this->Validar($user, $pass))
  114. return false;
  115.  
  116. if(!$this->Validar($user, $NewPass))
  117. return false;
  118.  
  119. $Buffer = $this->OpenAccount($account);
  120. if(!$Buffer)
  121. {
  122. echo 'Erro ao abrir conta!';
  123.  
  124. return false;
  125. }
  126.  
  127. $PwdFile = trim(hex2bin(substr($Buffer,32,28)));
  128.  
  129. if(strcmp($PwdFile,$pass))
  130. {
  131. echo $this->err[13];
  132. return false;
  133. }
  134.  
  135. if($this->Mod == false)
  136. $account2 = $this->UpdateAcount.'\'. $this->CurrentChannel.'\update\'.$user;
  137. else
  138. $account2 = $this->UpdateAcount.'\update\'.$user;
  139.  
  140. $fp = fopen($account2, "wt");
  141. $escreve = fwrite($fp, "$usern");
  142. $escreve = fwrite($fp, "$NewPassn");
  143. fclose($fp);
  144. echo $this->err[12];
  145. return true;
  146. }
  147. public function Registrar($user, $pass,$email,$Name,$tel,$Addr)
  148. {
  149. if(empty($user)|| empty($pass))
  150. {
  151. echo $this->err[7];
  152. return false;
  153. }
  154. if(!$this->Validar($user, $pass,$email,$Name,$tel,$Addr))
  155. return false;
  156. $account = $this->AccountDir.'\'.$this->InitialDir($user).'\'.$user;
  157. $account2 = $this->ImportUser.'\'.$user;
  158. if(file_exists($account))
  159. {
  160. echo $this->err[6];
  161. return false;
  162. }
  163. else
  164. {
  165. $Bonus = 0;
  166.  
  167. $ssn = rand()%1001;
  168. $ssn2 = rand()%1001;
  169. $user = strtoupper($user);
  170. $email = strtoupper($email);
  171. $Name = strtoupper($Name);
  172. $Addr = strtoupper($Addr);
  173. //id, pass, name, ssn1, ssn2, email, tel, addr, bonus
  174. $fp = fopen($account2, "wt");
  175. $escreve = fwrite($fp, "$usern");
  176. $escreve = fwrite($fp, "$passn");
  177. $escreve = fwrite($fp, "$Namen");
  178. $escreve = fwrite($fp, "$ssnn");
  179. $escreve = fwrite($fp, "$ssn2n");
  180. $escreve = fwrite($fp, "$emailn");
  181. $escreve = fwrite($fp, "$teln");
  182. $escreve = fwrite($fp, "$Addrn");
  183. $escreve = fwrite($fp, "$Bonusn");
  184. fclose($fp);
  185.  
  186. echo $this->err[8];
  187. return true;
  188.  
  189. }
  190. }
  191. public function OpenAccount($account)
  192. {
  193.  
  194. if(file_exists($account))
  195. {
  196. $open = @fopen($account,'r');
  197. $leitura = @fread($open, filesize($account));
  198. return trim(strtoupper(bin2hex($leitura)));
  199. }
  200. else
  201. return 0;
  202. }
  203. public function hexTobin($data)
  204. {
  205. return pack("H".strlen($data),$data);
  206. }
  207. public function inverterhex($data)
  208. {
  209. $tamanho=strlen($data);
  210. if(($tamanho % 2)!=0)
  211. {
  212. $data="0".$data;
  213. }
  214. $data=wordwrap($data, 2, "/", true);
  215. $explode=explode("/", $data);
  216. $a=0;
  217. for($i=(count($explode)-1); $i>=0; $i--)
  218. {
  219. $join[$a]=$explode[$i];
  220. $a++;
  221. }
  222. $data=implode("", $join);
  223. return $data;
  224. }
  225. public function hex2num($data)
  226. {
  227. return hexdec($this->inverterhex($data));
  228. }
  229. public function num2hex($data)
  230. {
  231. return $this->inverterhex(dechex($data));
  232. }
  233. }
  234.  
  235.  
  236. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement