Advertisement
Guest User

funktioncs.php

a guest
Jan 14th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 20.54 KB | None | 0 0
  1. <?php
  2.     class Functions{
  3.         public function CheckMaintenance($a){
  4.             global $db;
  5.             $result = $db->query("SELECT * FROM cms_settings WHERE id = 1 LIMIT 1");
  6.             $exp = $db->query("SELECT * FROM users WHERE username = '". $this->FilterText($_SESSION['username']) ."' LIMIT 1");
  7.             while($mant = $result->fetch_array()){
  8.                 while($mantexp = $exp->fetch_array()){
  9.                     if($mant['mantenimiento'] == 1 AND $mantexp['rank'] <= 8){
  10.                         header("LOCATION: ". PATH ."/Mantenimiento");
  11.                     }
  12.                 }
  13.             }
  14.         }
  15.         public function GetLast($a){
  16.             if(!empty($a) || !$a == ''){
  17.                 if(is_numeric($a)){
  18.                     $date = $a;
  19.                     $date_now = time();
  20.                     $difference = $date_now - $date;
  21.                     if($difference <= '59'){ $echo = 'Justo Ahora'; }
  22.                     elseif($difference <= '3599' && $difference >= '60'){
  23.                         $minutos = date('i', $difference);
  24.                         if($minutos[0] == 0) { $minutos = $minutos[1]; }
  25.                         if($minutos == 1) { $minutos_str = 'minuto'; }
  26.                         else { $minutos_str = 'minutos'; }
  27.                         $echo = 'Hace '.$minutos.' '.$minutos_str;//Minutos
  28.                     }elseif($difference <= '82799' && $difference >= '3600'){
  29.                         $horas = date('G', $difference);
  30.                         if($horas == 1) { $horas_str = 'hora'; }
  31.                         else { $horas_str = 'horas'; }
  32.                         $echo = 'Hace '.$horas.' '.$horas_str;//Minutos
  33.                     }elseif($difference <= '518399' && $difference >= '82800'){
  34.                         $dias = date('j', $difference);
  35.                         if($dias == 1) { $dias_str = 'd&iacute;a'; }
  36.                         else { $dias_str = 'd&iacute;as'; }
  37.                         $echo = 'Hace '.$dias.' '.$dias_str;//Minutos
  38.                     }elseif($difference <= '2678399' && $difference >= '518400'){
  39.                         $semana = floor(date('j', $difference) / 7).'<!-- WTF -->';
  40.                         if($semana == 1) { $semana_str = 'semana'; }
  41.                         else { $semana_str = 'semanas'; }
  42.                         $echo = 'Hace '.floor($semana).' '.$semana_str;//Minutos
  43.                     }else { $echo = 'Hace '.date('n', $difference).' mes(es)'; }
  44.                     return $echo;
  45.                 }else{ return $a; }
  46.             }else{ return 'A&uacute;n no te has conectado'; }
  47.         }
  48.        
  49.         public function Get($a){
  50.             global $db;
  51.             $result = $db->query("SELECT {$a} FROM users WHERE username = '". $this->FilterText($_SESSION['username']) ."' LIMIT 1");
  52.             $data = $result->fetch_array();
  53.             return $data[$a];
  54.         }
  55.        
  56.         public function GetCount($a){
  57.             global $db;
  58.             $userquery = $db->query("SELECT * FROM {$a}");
  59.             $cnt = $userquery->num_rows;
  60.             return $cnt;
  61.         }
  62.    
  63.         public function GetOns(){
  64.             global $db;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  65.             $ad = $db->query("SELECT * FROM users WHERE online = '1'");
  66.             $add = $ad->fetch_array();
  67.             return $add;
  68.         }
  69.  
  70.         public function GetID(){
  71.             global $db;
  72.             $result = $db->query("SELECT id FROM users WHERE username = '". $this->FilterText($_SESSION['username']) ."' LIMIT 1");
  73.             $data = $result->fetch_array();
  74.             return $data['id'];
  75.         }
  76.  
  77.         public function Logged($a){
  78.             $b = $this->CheckLogged($_SESSION['username'], $_SESSION['password']);
  79.             if($a == "allow"){
  80.                 if($b){
  81.                     $_SESSION['IS_LOGGED'] = true;     
  82.                 }else{
  83.                     $_SESSION['IS_LOGGED'] = false;
  84.                 }
  85.             }
  86.             elseif($a == "false" AND $b){
  87.                 $_SESSION['IS_LOGGED'] = true;     
  88.                 header("LOCATION: ". PATH ."/me");
  89.                 exit;  
  90.             }elseif($a == "true" AND !$b){
  91.                 header("LOCATION: ". PATH ."/index.php");
  92.                 exit;
  93.             }elseif($b){
  94.                 $_SESSION['IS_LOGGED'] = true;     
  95.             }      
  96.         }
  97.  
  98.         public function FilterText($a){
  99.             $a = stripslashes(htmlspecialchars($a));
  100.             $a = trim($a);
  101.             $a = str_replace('"','&#34;',$a);
  102.             $a = str_replace("'","&#39;",$a);
  103.             $a = str_replace("<script","",$a);
  104.             $a = str_replace("(","",$a);
  105.             $a = str_replace(")","",$a);
  106.             return $a;  
  107.         }
  108.        
  109.         public function FilterTextEmoji($a){
  110.             $a = stripslashes(htmlspecialchars($a));
  111.             $a = trim($a);
  112.             $a = str_replace('"','&#34;',$a);
  113.             $a = str_replace("'","&#39;",$a);
  114.             $a = str_replace("<script","",$a);
  115.             $a = str_replace("(","",$a);
  116.             $a = str_replace(")","",$a);
  117.             $a = str_replace(':D','<img src="/public/img/emojis/carita_sonriente.png" width="24" height="24">',$a);
  118.             $a = str_replace(':P','<img src="/public/img/emojis/carita_lengua3.png" width="24" height="24">',$a);
  119.             $a = str_replace('*guino*','<img src="/public/img/emojis/carita_guino.png" width="24" height="24">',$a);
  120.             $a = str_replace(':|','<img src="/public/img/emojis/carita_plana2.png" width="24" height="24">',$a);
  121.             $a = str_replace('x_x','<img src="/public/img/emojis/carita_xx.png" width="24" height="24">',$a);
  122.             $a = str_replace('*risa*','<img src="/public/img/emojis/carita_sonriente2.png" width="24" height="24">',$a);
  123.             $a = str_replace('*gallery*','<img src="/public/img/emojis/carita_corazon.png" width="24" height="24">',$a);
  124.             $a = str_replace('*heart*','<img src="/public/img/emojis/carita_corazon.png" width="24" height="24">',$a);
  125.             $a = str_replace('<3','<img src="/public/img/emojis/carita_corazon.png" width="24" height="24">',$a);
  126.             $a = str_replace(':poop:','<img src="/public/img/emojis/carita_poop.png" width="24" height="24">',$a);
  127.             $a = str_replace('*triste*','<img src="/public/img/emojis/carita_triste.png" width="24" height="24">',$a);
  128.             $a = str_replace('XD','<img src="/public/img/emojis/carita_sonriente3.png" width="24" height="24">',$a);
  129.             $a = str_replace('*lengua*','<img src="/public/img/emojis/carita_lengua2.png" width="24" height="24">',$a);
  130.             $a = str_replace(';P','<img src="/public/img/emojis/carita_lengua1.png" width="24" height="24">',$a);
  131.             $a = str_replace(':O','<img src="/public/img/emojis/carita_ooh.png" width="24" height="24">',$a);
  132.             $a = str_replace('*sexy*','<img src="/public/img/emojis/carita_sonriente4.png" width="24" height="24">',$a);
  133.             $a = str_replace(':*','<img src="/public/img/emojis/carita_kiss1.png" width="24" height="24">',$a);
  134.             $a = str_replace('*kiss*','<img src="/public/img/emojis/carita_kiss.png" width="24" height="24">',$a);
  135.             $a = str_replace('O_O','<img src="/public/img/emojis/carita_ooh1.png" width="24" height="24">',$a);
  136.             $a = str_replace('^_^','<img src="/public/img/emojis/carita_sonriente5.png" width="24" height="24">',$a);
  137.             $a = str_replace(':@','<img src="/public/img/emojis/carita_enojado.png" width="24" height="24">',$a);
  138.             $a = str_replace('Q.Q','<img src="/public/img/emojis/carita_triste2.png" width="24" height="24">',$a);
  139.             $a = str_replace(':/','<img src="/public/img/emojis/carita_triste1.png" width="24" height="24">',$a);
  140.             $a = str_replace('*love*','<img src="/public/img/emojis/carita_ojos.png" width="24" height="24">',$a);
  141.             $a = str_replace('-_-','<img src="/public/img/emojis/carita_plana.png" width="24" height="24">',$a);
  142.             $a = str_replace('*angel*','<img src="/public/img/emojis/carita_angel.png" width="24" height="24">',$a);
  143.             $a = str_replace('*lentes*','<img src="/public/img/emojis/carita_lentes.png" width="24" height="24">',$a);
  144.             $a = str_replace('*applause*','<img src="/public/img/emojis/carita_applause.png" width="24" height="24">',$a);
  145.             $a = str_replace('*god*','<img src="/public/img/emojis/carita_god.png" width="24" height="24">',$a);
  146.             $a = str_replace('*strong*','<img src="/public/img/emojis/carita_strong.png" width="24" height="24">',$a);
  147.             $a = str_replace('*decepcionado*','<img src="/public/img/emojis/carita_decepcion.png" width="24" height="24">',$a);
  148.             $a = str_replace('*sinpalabras*','<img src="/public/img/emojis/carita_sinpalabras.png" width="24" height="24">',$a);
  149.             $a = str_replace('*star*','<img src="/public/img/emojis/carita_star.png" width="24" height="24">',$a);
  150.             $a = str_replace('*contodo*','<img src="/public/img/emojis/carita_golpe.png" width="24" height="24">',$a);
  151.             $a = str_replace('*angelbebe*','<img src="/public/img/emojis/carita_angelbeb.png" width="24" height="24">',$a);
  152.             $a = str_replace('*boy*','<img src="/public/img/emojis/carita_boy.png" width="24" height="24">',$a);
  153.             $a = str_replace('*bebe*','<img src="/public/img/emojis/carita_bebe.png" width="24" height="24">',$a);
  154.             $a = str_replace('*hey*','<img src="/public/img/emojis/boy_hey.png" width="24" height="24">',$a);
  155.             $a = str_replace('*x*','<img src="/public/img/emojis/boy_x.png" width="24" height="24">',$a);
  156.             $a = str_replace('*girlhey*','<img src="/public/img/emojis/girl_hey.png" width="24" height="24">',$a);
  157.             $a = str_replace('*girlx*','<img src="/public/img/emojis/girl_x.png" width="24" height="24">',$a);
  158.             $a = str_replace('*viejo*','<img src="/public/img/emojis/carita_viejo.png" width="24" height="24">',$a);
  159.             $a = str_replace('*arrecho*','<img src="/public/img/emojis/carita_arrecho.png" width="24" height="24">',$a);
  160.             $a = str_replace('*choquedemanos*','<img src="/public/img/emojis/hands.png" width="24" height="24">',$a);
  161.             $a = str_replace('*hands2*','<img src="/public/img/emojis/hands2.png" width="24" height="24">',$a);
  162.             $a = str_replace('*hand*','<img src="/public/img/emojis/hand.png" width="24" height="24">',$a);
  163.             $a = str_replace('*hand2*','<img src="/public/img/emojis/hand2.png" width="24" height="24">',$a);
  164.             $a = str_replace('*fuck*','<img src="/public/img/emojis/hand3.png" width="24" height="24">',$a);
  165.             $a = str_replace('*lol*','<img src="/public/img/emojis/mecago_delarisa.png" width="24" height="24">',$a);
  166.             $a = str_replace('*fantasma*','<img src="/public/img/emojis/fantasma.png" width="24" height="24">',$a);
  167.             $a = str_replace('*lengua*','<img src="/public/img/emojis/lengua.png" width="24" height="24">',$a);
  168.             $a = str_replace('*sueño*','<img src="/public/img/emojis/carita_sueño.png" width="24" height="24">',$a);
  169.             $a = str_replace('*extra*','<img src="/public/img/emojis/carita_extra.png" width="24" height="24">',$a);
  170.             $a = str_replace('*diabla*','<img src="/public/img/emojis/carita_diabla.png" width="24" height="24">',$a);
  171.             $a = str_replace('*mongolico*','<img src="/public/img/emojis/carita_mongolico.png" width="24" height="24">',$a);
  172.  
  173.             return $a;  
  174.         }
  175.  
  176.         public function Hash($a, $b){
  177.             // $a = username || $b = password
  178.             $c = sha1(strtolower($a) . md5($b));
  179.             $c = hash('gost', $c);
  180.             $c = hash('whirlpool', $c);
  181.             $c = hash('sha512', $c);
  182.             return $c;
  183.         }
  184.  
  185.         public function CheckLogged($a, $b){
  186.             if( !empty($a) AND !empty($b)){
  187.                 $banned = $this->CheckBanned($_SESSION['username'], USER_IP);
  188.                 if($banned){
  189.                     $_SESSION['LOGIN_ERROR'] = $banned;
  190.                     $bu = $_SESSION['username'];
  191.                     unset($_SESSION['username']);
  192.                     unset($_SESSION['password']);
  193.                     header("LOCATION: ". PATH ."/?username=". $bu ."&rememberme=false&focus=login-username");
  194.                     exit;
  195.                 }else{
  196.                     global $db;
  197.                     $Checked = $db->query("SELECT null FROM users WHERE username = '{$a}' AND password = '{$b}'");
  198.                     if($Checked->num_rows > 0){
  199.                         $_SESSION['username'] = $a;
  200.                         $_SESSION['password'] = $b;
  201.                         return true;
  202.                     }else{
  203.                         return false;
  204.                     }  
  205.                 }
  206.  
  207.             }
  208.         }
  209.  
  210.         public function LoggedHk(){
  211.             global $db;
  212.             $rank = $db->query("SELECT rank FROM users WHERE username = '{$_SESSION['username']}' AND password = '{$_SESSION['password']}'");
  213.             $ranks = $rank->fetch_array();
  214.             if($ranks['rank'] >= MINRANK){
  215.             }else{
  216.                 header("LOCATION: ". PATH ."/me");
  217.                 exit;
  218.             }
  219.         }
  220.        
  221.         public function LoggedHkADMIN(){   
  222.             global $db;
  223.             $rank = $db->query("SELECT rank FROM users WHERE username = '{$_SESSION['username']}' AND password = '{$_SESSION['password']}'");
  224.             $ranks = $rank->fetch_array();
  225.             if($ranks['rank'] == MAXRANK){
  226.             }else{
  227.                 $_SESSION['ERROR_RETURN'] = "Secci&oacute;n unicamente para los Dueños";
  228.                 header("LOCATION: ". HK ." ");
  229.                 exit;
  230.             }
  231.         }
  232.  
  233.         public function Login(){
  234.             if(isset($_POST['username']) AND isset($_POST['password'])){
  235.                 $a = $this->FilterText($_POST['username']);
  236.                 $b = $this->FilterText($_POST['password']);
  237.                 if( empty($a) || empty($b) ){ $error = "Por favor, introduce tu usuario y contraseña para conectarte"; }
  238.                 elseif( $this->CheckLogged($a, $this->Hash($a, $b)) ){ header("LOCATION: ". PATH ."/me"); exit; }
  239.                 else{ $error = "La contraseña no coincide con el usuario."; }
  240.                 if( !empty($error) ){
  241.                     $_SESSION['LOGIN_ERROR']     = $error;
  242.                     $_SESSION['LOGIN_USERNAME']  = $a;
  243.                     $_SESSION['LOGIN_PASSWORD']  = $b;
  244.                 }
  245.                 header("LOCATION: ". PATH ."/index.php?username=". $a ."&rememberme=false&focus=login-username");
  246.                 exit;
  247.             }
  248.             header("LOCATION: ". PATH ."/index.php");
  249.             exit;
  250.         }
  251.  
  252.         public function GenerateCaptcha(){
  253.             $string = substr(md5(rand()*time()),0,5);
  254.             $string = strtoupper($string);
  255.             $string = str_replace("O","B", $string);
  256.             $string = str_replace("0","C", $string);
  257.             $_SESSION["captcha"] = strtoupper($string);
  258.             return $string;
  259.         }
  260.        
  261.         public function GenerateCode(){
  262.             $string = substr(md5(rand()*time()),0,50);
  263.             $string = strtoupper($string);
  264.             $string = str_replace("O","B", $string);
  265.             $string = str_replace("0","C", $string);
  266.             $_SESSION["captcha"] = strtoupper($string);
  267.             return $string;
  268.         }
  269.  
  270.         public function GenerateTicket(){
  271.             $sessionKey = 'YeezyCMS-'.rand(9,999).'-'.substr(sha1(time()).'-'.rand(9,9999999).'-'.rand(9,9999999).'-'.rand(9,9999999),0,33);
  272.             return $sessionKey;
  273.            
  274.         }
  275.        
  276.         public function AddUser($username, $email, $password, $facebook_id, $facebook){
  277.             global $db;
  278.             $dbRegister = array();
  279.             $dbRegister['username'] = $username;
  280.             $dbRegister['password'] = $password;
  281.             $dbRegister['mail'] = $email;
  282.             $dbRegister['rank'] = 1;
  283.             $dbRegister['gender'] = 'm';
  284.             $dbRegister['account_created'] = time();
  285.             $dbRegister['last_online'] = time();
  286.             $dbRegister['ip_last'] = USER_IP;
  287.             $dbRegister['ip_reg'] = USER_IP;
  288.             $dbRegister['facebook_id'] = $facebook_id;
  289.             $dbRegister['facebook'] = $facebook;
  290.             $query = $db->insertInto('users', $dbRegister);
  291.             $id = $db->insert_id();
  292.             $dbInfo = array();
  293.             $dbInfo['user_id'] = $id;
  294.             $query = $db->insertInto('user_info', $dbInfo);
  295.             return true;
  296.         }
  297.        
  298.         public function AddTicket($id,$ticket){
  299.             global $db;
  300.             $ok = $db->query("SELECT NULL FROM user_auth_ticket WHERE user_id = '{$id}'");
  301.             if($ok->num_rows > 0){
  302.                 $r1 = $db->query("DELETE FROM user_auth_ticket WHERE user_id = '{$id}' LIMIT 1");
  303.             }
  304.             $dbQuery= array();
  305.             $dbQuery['userid'] = $id;
  306.             $dbQuery['sessionticket'] = $ticket;
  307.             $dbQuery['ipaddress'] = USER_IP;
  308.             $query = $db->insertInto('user_auth_ticket', $dbQuery);
  309.             return true;
  310.         }
  311.    
  312.         public function ComprobateExist($a){
  313.             global $db;
  314.             $result = $db->query("SELECT * FROM users WHERE username = '{$a}' OR mail = '{$a}' LIMIT 1");
  315.             if($db->num_rows($result) > 0){
  316.                 return true;
  317.             }else{
  318.                 return false;
  319.             }
  320.         }
  321.        
  322.         public function ComprobateExistIP($a){
  323.             global $db;
  324.             $result = $db->query("SELECT null FROM users WHERE ip_reg = '".$_SERVER['REMOTE_ADDR']."'");
  325.             if($db->num_rows($result) > 0){
  326.                 return true;
  327.             }else{
  328.                 return false;
  329.             }
  330.         }
  331.        
  332.         public function CheckBanned($u, $ip){
  333.             $H = date('H');
  334.             $i = date('i');
  335.             $s = date('s');
  336.             $m = date('m');
  337.             $d = date('d');
  338.             $Y = date('Y');
  339.             $j = date('j');
  340.             $n = date('n');
  341.             $today = $d;
  342.             $month = $m;
  343.             $year = $Y;
  344.             global $db;
  345.             $u = $this->FilterText($u);
  346.             $ip = $this->FilterText($ip);
  347.             $checkban = $db->query("SELECT * FROM bans WHERE value = '{$u}' or value = '{$ip}' LIMIT 1");
  348.             if($checkban->num_rows < 1){ return false; } else {
  349.                 $bandata = $checkban->fetch_array();
  350.                 $reason = $bandata['reason'];
  351.                 $expire = $bandata['expire'];
  352.                 $xbits = explode(" ", $expire);
  353.                 $xtime = explode(":", $xbits[1]);
  354.                 $xdate = explode("-", $xbits[0]);
  355.                 $stamp_now = mktime(date('H'),date('i'),date('s'),$today,$month,$year);
  356.                 $datetoex = date("d-m-y",$expire);
  357.                 if(time() < $bandata['expire']){
  358.                     $login_error = "Has sido banedo por esta razón: \"".$reason."\". Tu baneo expira el: ".$datetoex.".";
  359.                     return $login_error;
  360.                 } else {
  361.                     $db->query("DELETE FROM bans WHERE value = '{$u}' OR value = '{$ip}' LIMIT 1");
  362.                     return false;
  363.                 }
  364.             }
  365.         }
  366.        
  367.         public function RegisterSubmit(){
  368.             if(isset($_POST['reg_username']) AND isset($_POST['reg_mail']) AND isset($_POST['reg_password']) AND isset($_POST['reg_password2']) AND isset($_POST['badge']) AND isset($_POST['reg_captcha'])){
  369.  
  370.                 $user = $this->FilterText($_POST['reg_username']);
  371.                 $mail = $this->FilterText($_POST['reg_mail']);
  372.                 $password = $this->FilterText($_POST['reg_password']);
  373.                 $password2 = $this->FilterText($_POST['reg_password2']);
  374.                 $dia = $this->FilterText($_POST['DD']);
  375.                 $mes = $this->FilterText($_POST['MM']);
  376.                 $ano = $this->FilterText($_POST['AAAA']);
  377.                 $badge = $this->FilterText($_POST['badge']);
  378.                 $captcha = $this->FilterText($_POST['reg_captcha']);
  379.                 $nlook = $this->FilterText($_POST['look']);
  380.  
  381.                 $_SESSION['REG_USERNAME'] = $user;
  382.                 $_SESSION['REG_MAIL'] = $mail;
  383.                 $_SESSION['REG_PASSWORD'] = $password;
  384.                 $_SESSION['REG_PASSWORD2'] = $password2;
  385.                 $_SESSION['captcha'] = $captcha;
  386.             }
  387.             header("LOCATION: ". PATH ."/index.php?&username&password");
  388.             if(empty($user) || empty($mail) || empty($password) || empty($password2) || empty($dia) || empty($mes) || empty($ano) || empty($badge) || empty($captcha)){
  389.                     $_SESSION['REG_ERROR'] = "Rellena todos los campos<br>";
  390.                 }else{
  391.                     //USERNAME CHECK
  392.                     $filter = preg_replace("/[^a-z\d\-=\?!@:\.]/i", "", $user);
  393.                     if($user !== $filter || strlen($user) < 2 || strlen($user) > 18){
  394.                         $error_1 = "Inserta un nombre valido (Min: 2 Caract. Max 18 Caract)";
  395.                     }elseif($this->ComprobateExist($user)){
  396.                         $error_1 = "Ese nombre ya est&aacute; en uso<br>";
  397.                     }
  398.                     //IP CHECK
  399.                     global $db;
  400.                     $result = $db->query("SELECT * FROM cms_settings WHERE id = '1'");
  401.                         while($data = $result->fetch_array()){
  402.                         if($data['reg_ip'] == 1){
  403.                            if($this->ComprobateExistIP($ip_reg)){
  404.                                 $error_1 = "¡Solo esta permitido 1 usuario por IP!<br>";
  405.                             }
  406.                         }
  407.                     }
  408.                     //MOD CHECK
  409.                     global $db;
  410.                     $result = $db->query("SELECT * FROM cms_settings WHERE id = '1'");
  411.                         while($data = $result->fetch_array()){
  412.                         if($data['reg_mod'] == 1){
  413.                            if(strpos($_SESSION['REG_USERNAME'], 'MOD-') !== false){
  414.                                 $error_1 = ">Nombre No Permitido. Intenta con otro Diferente<br>";
  415.                             }
  416.                         }
  417.                     }
  418.                     //MAIL CHECK
  419.                     $email_check = preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $mail);
  420.                     if($email_check !== 1){
  421.                         $error_2 = "Inserta un email v&aacute;lido<br>";
  422.                     }elseif($this->ComprobateExist($mail)){
  423.                         $error_2 = "Inserta otro email, ese ya existe<br>";
  424.                     }
  425.                     //PASSWORD CHECK
  426.                     if(strlen($password) < 6 || strlen($password) > 32){
  427.                         $error_3 = "<b>Escribe una contrase&ntilde;a v&aacute;lida (debe atener m&aacute;s de 6 caracteristicas)</b><br>";
  428.                     }elseif(strlen($password) !== strlen($password2)){
  429.                         $error_2 = "Las contrase&ntilde;as no coinciden<br>";
  430.                     }
  431.                     //CAPTCHA CHECK
  432.                     if($_SESSION['captcha'] !== strtoupper($_POST['reg_captcha'])){
  433.                     $error_4 = "El código captcha es incorrecto<br>";
  434.                     }
  435.  
  436.                     if(!empty($error_1) || !empty($error_2) || !empty($error_3) || !empty($error_4)){
  437.                         $_SESSION['REG_ERROR'] = $error_1 . $error_2 . $error_3 . $error_4;
  438.                     }else{
  439.                         $password3 = $this->Hash($user, $password);
  440.                         $this->AddUser($user, $mail, $password3, '', '');
  441.                         $_SESSION['username'] = $user;
  442.                         $_SESSION['password'] = $password3;
  443.                         global $db;
  444.                         $db->query("UPDATE users SET cms_birthday = '".$dia."/".$mes."/".$ano."', look = '".$nlook."' WHERE username = '".$_SESSION['username']."' LIMIT 1");  
  445.                         $check = $db->query("SELECT * FROM users WHERE username = '".$_SESSION['username']."' LIMIT 1");
  446.                         $row = $check->fetch_array();
  447.                         $db->query("INSERT INTO user_badges (user_id, badge_id, badge_slot) VALUES ('".$row['id']."', '".$badge."', '0')");
  448.                         //REFERIDO
  449.                         if(!empty($_SESSION['refer'])){
  450.                             $db->query("UPDATE users SET cms_refers = cms_refers + '1' WHERE ".$this->FilterText($_SESSION['refer_type'])." = '".$this->FilterText($_SESSION['refer'])."' LIMIT 1");
  451.                         }
  452.                         //HACEMOS EL LOGUEO
  453.                         $_SESSION['connection_type'] = "id";
  454.                         header("LOCATION: ". PATH ."/me");
  455.                         return true;
  456.                     }
  457.                 }
  458.             exit;
  459.         }
  460.     }
  461. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement