Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Registro extends CI_Controller {
  5.  
  6. public function checksession(){
  7. if($this->session->has_userdata('logado') AND $this->session->userdata('username') == "[facebook]")
  8. redirect(base_url("registro/usuario"));
  9. }
  10.  
  11. public function index()
  12. {
  13. $this->checksession();
  14. $data['titulo'] = 'Habbinx Hotel: Registre-se!';
  15. $this->load->view('registro', $data);
  16. }
  17. public function usuario()
  18. {
  19. if($this->session->has_userdata('logado') AND $this->session->userdata('username') == "[facebook]") {
  20. $data['titulo'] = 'Habbinx Hotel: Escolha seu nome de usuário!';
  21. $this->load->view('players/nameuser', $data);
  22. }else {
  23. redirect(base_url());
  24. }
  25. }
  26.  
  27. public function checkemail($email = "", $json = 1)
  28. {
  29. $response = array('valid'=>'false');
  30.  
  31. if($this->input->post('email')){
  32. $email = $this->input->post('email');
  33. }
  34.  
  35. $result = $this->players->checkemail($email);
  36. if ($result OR fc_checkemail($email)) {
  37. $response = array('valid' => 'false');
  38. } else {
  39. $response = array('valid' => 'true');
  40. }
  41.  
  42. return jreturn($response, $json);
  43. }
  44.  
  45. public function checkname($username = "", $json = 1)
  46. {
  47. $response = array('valid'=>'false');
  48.  
  49. if($this->input->post('username')){
  50. $username = $this->input->post('username');
  51. }
  52.  
  53. $result = $this->players->checkname($username);
  54. if ($result OR fc_checkusername($username)) {
  55. $response = array('valid' => 'false');
  56. } else {
  57. $response = array('valid' => 'true');
  58. }
  59.  
  60. return jreturn($response, $json);
  61. }
  62.  
  63. public function checkpassword($pass = "", $json = 1)
  64. {
  65. $response = array('valid'=>'false');
  66.  
  67. if($this->input->post('password')){
  68. $pass = $this->input->post('password');
  69. }
  70.  
  71. if (fc_checkpass($pass)) {
  72. $response = array('valid' => 'false');
  73. } else {
  74. $response = array('valid' => 'true');
  75. }
  76.  
  77. return jreturn($response, $json);
  78. }
  79.  
  80. public function registrar()
  81. {
  82. $this->checksession();
  83. if($this->input->post() AND $this->input->post('g-recaptcha-response')){
  84.  
  85. $resposta = googlecaptcha($this->input->post('g-recaptcha-response'));
  86.  
  87. if($resposta["success"]){
  88. $username = $this->input->post('username');
  89. $email = $this->input->post('email');
  90. $passwd = $this->input->post('senha');
  91. $passwdTwo = $this->input->post('senhaTwo');
  92.  
  93. $check = array(
  94. $this->checkemail($email, 0),
  95. $this->checkpassword($passwd, 0),
  96. $this->checkname($username, 0),
  97. );
  98. if(fc_checkalltrue($check) == "true" AND
  99. fc_checkequal($passwd, $passwdTwo)){
  100. $this->players->registeruser();
  101. $result = $this->players->getbyname($username);
  102.  
  103. foreach ($result as $row)
  104. {
  105. $array = array(
  106. 'player_id' => $row->id,
  107. 'logado' => TRUE
  108. );
  109. }
  110. //$this->players->insertpsettings($array['player_id']);
  111. $this->session->set_userdata($array);
  112. return redirect(base_url());
  113. }
  114. else
  115. return redirect(base_url('registro'));
  116. }
  117.  
  118. //die('por acaso caiu aqui...');
  119. } else {
  120. return redirect(base_url('registro'));
  121. }
  122. }
  123.  
  124. public function regusuario()
  125. {
  126. if($this->input->post()){
  127. $player_id = $this->session->userdata('player_id');
  128. $username = $this->input->post('username');
  129.  
  130. $check = array(
  131. $this->checkname($username, 0),
  132. );
  133. if(fc_checkalltrue($check) == "true"){
  134. $this->players->updateusername($player_id, $username);
  135.  
  136. $this->session->unset_userdata('username');
  137. return redirect(base_url());
  138. }
  139. else
  140. return redirect(base_url('registro/usuario'));
  141. } else {
  142. return redirect(base_url('registro/usuario'));
  143. }
  144. }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement