Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Registro extends CI_Controller {
- public function checksession(){
- if($this->session->has_userdata('logado') AND $this->session->userdata('username') == "[facebook]")
- redirect(base_url("registro/usuario"));
- }
- public function index()
- {
- $this->checksession();
- $data['titulo'] = 'Habbinx Hotel: Registre-se!';
- $this->load->view('registro', $data);
- }
- public function usuario()
- {
- if($this->session->has_userdata('logado') AND $this->session->userdata('username') == "[facebook]") {
- $data['titulo'] = 'Habbinx Hotel: Escolha seu nome de usuário!';
- $this->load->view('players/nameuser', $data);
- }else {
- redirect(base_url());
- }
- }
- public function checkemail($email = "", $json = 1)
- {
- $response = array('valid'=>'false');
- if($this->input->post('email')){
- $email = $this->input->post('email');
- }
- $result = $this->players->checkemail($email);
- if ($result OR fc_checkemail($email)) {
- $response = array('valid' => 'false');
- } else {
- $response = array('valid' => 'true');
- }
- return jreturn($response, $json);
- }
- public function checkname($username = "", $json = 1)
- {
- $response = array('valid'=>'false');
- if($this->input->post('username')){
- $username = $this->input->post('username');
- }
- $result = $this->players->checkname($username);
- if ($result OR fc_checkusername($username)) {
- $response = array('valid' => 'false');
- } else {
- $response = array('valid' => 'true');
- }
- return jreturn($response, $json);
- }
- public function checkpassword($pass = "", $json = 1)
- {
- $response = array('valid'=>'false');
- if($this->input->post('password')){
- $pass = $this->input->post('password');
- }
- if (fc_checkpass($pass)) {
- $response = array('valid' => 'false');
- } else {
- $response = array('valid' => 'true');
- }
- return jreturn($response, $json);
- }
- public function registrar()
- {
- $this->checksession();
- if($this->input->post() AND $this->input->post('g-recaptcha-response')){
- $resposta = googlecaptcha($this->input->post('g-recaptcha-response'));
- if($resposta["success"]){
- $username = $this->input->post('username');
- $email = $this->input->post('email');
- $passwd = $this->input->post('senha');
- $passwdTwo = $this->input->post('senhaTwo');
- $check = array(
- $this->checkemail($email, 0),
- $this->checkpassword($passwd, 0),
- $this->checkname($username, 0),
- );
- if(fc_checkalltrue($check) == "true" AND
- fc_checkequal($passwd, $passwdTwo)){
- $this->players->registeruser();
- $result = $this->players->getbyname($username);
- foreach ($result as $row)
- {
- $array = array(
- 'player_id' => $row->id,
- 'logado' => TRUE
- );
- }
- //$this->players->insertpsettings($array['player_id']);
- $this->session->set_userdata($array);
- return redirect(base_url());
- }
- else
- return redirect(base_url('registro'));
- }
- //die('por acaso caiu aqui...');
- } else {
- return redirect(base_url('registro'));
- }
- }
- public function regusuario()
- {
- if($this->input->post()){
- $player_id = $this->session->userdata('player_id');
- $username = $this->input->post('username');
- $check = array(
- $this->checkname($username, 0),
- );
- if(fc_checkalltrue($check) == "true"){
- $this->players->updateusername($player_id, $username);
- $this->session->unset_userdata('username');
- return redirect(base_url());
- }
- else
- return redirect(base_url('registro/usuario'));
- } else {
- return redirect(base_url('registro/usuario'));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement