Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: araque615 en 25 Octubre 2015, 16:14 pm



Título: Alguien me ayuda?
Publicado por: araque615 en 25 Octubre 2015, 16:14 pm
Muy buenas, quisiera que alguien me ayudase con esto, quisiera modificar los datos de un tabla, pero los códigos que uso no hacen nada, si alguien fuera tan amable, acá os paso el archivo conexion y el function.

Código
  1. <?php
  2. ###################################################
  3. // SQL Config
  4. ###################################################
  5. $info = array (
  6. 'hostname' => 'localhost', // Host
  7. 'username' => 'root', // User
  8. 'password' => '', // Password
  9. 'database' => 'apk', // Database Name
  10. 'path' => '', // URL
  11. 'path_images' => 'http://localhost/styles/beta', // URL of Styles And Images
  12. 'path_hk' => 'http://localhost/housekeeping',
  13. 'badges_image' => 'http://habboo-a.akamaihd.net/c_images/album1584/',
  14. 'name' => 'xd', // Hotel Name
  15. 'Me_Ad' => 'xd', // Text me
  16. 'footer' => 'xd'
  17. );
  18. ###################################################
  19. // SQL Connect
  20. ###################################################
  21. mysql_connect ($info['hostname'], $info['username'], $info['password']) or die(mysql_error());
  22. mysql_select_db($info['database']) or die(mysql_error());
  23. mysql_query("SET NAMES 'utf8'");
  24. ###################################################
  25. ini_set('display_errors', 0);
  26. require_once 'functions.php';
  27. $function=new functions();
  28. ###################################################
  29. // Usuarios Online
  30. ###################################################
  31. $ons = mysql_fetch_assoc(mysql_query("SELECT * FROM server_status"));
  32. ###################################################
  33. // Definiciones
  34. ###################################################
  35. $H = date('H');
  36. $i = date('i');
  37. $s = date('s');
  38. $m = date('m');
  39. $d = date('d');
  40. $Y = date('Y');
  41. $j = date('j');
  42. $n = date('n');
  43. $today = $d;
  44. $month = $m;
  45. $year = $Y;
  46. $getmoney_date = date('d.m.Y',mktime($m,$d,$Y));
  47. $birthday_date = date('d.m', mktime($m,$d));
  48. $date_normal = date('d.m.Y',mktime($m,$d,$Y));
  49. $date_full = date('d.m.Y H:i:s',mktime($H,$i,$s,$m,$d,$Y));
  50. define("KrCMS", TRUE);
  51. define("PATH", $info['path']);
  52. define("PATH_I", $info['path_images']);
  53. define("PATH_HK", $info['path_hk']);
  54. define("AvatarI", "http://www.habbo.nl/habbo-imaging/avatarimage?figure=");
  55. define("Name", $info['name']);
  56. define("BETA", TRUE);
  57. define('CHARSET','UTF-8');
  58. define('UsersOnline', $ons['users_online']);
  59. ###################################################
  60. header('Content-type: text/html; charset='.CHARSET);
  61. ###################################################
  62. if($html == true){
  63. if(isset($_POST) || isset($_GET) || isset($_REQUEST) || isset($_COOKIE)){
  64. foreach($_POST as $key => $p){
  65. $_POST[$key] = htmlentities($function->filternews($p));
  66. $_POST[$key] = mysql_real_escape_string($function->filternews($p));
  67. $_POST[$key] = $function->filternews(html_entity_decode($p));
  68. }
  69. //Filtro las entradas vía GET
  70. foreach($_GET as $key => $g){
  71. $_GET[$key] = mysql_real_escape_string($function->filternews($g));
  72. }
  73. foreach($_COOKIE as $key => $s){
  74. $_COOKIE[$key] = mysql_real_escape_string($function->filternews($s));
  75. }
  76. //Filtro las entradas vía REQUEST
  77. foreach($_REQUEST as $key => $k){
  78. $_REQUEST[$key] = mysql_real_escape_string($function->filternews($k));
  79. }
  80. }if(isset($_GET)){
  81. //Filtro las entradas vía GET
  82. foreach($_GET as $key => $f){
  83. $_GET[$key] = strip_tags(htmlentities($function->filternews($f)));
  84. }
  85. }
  86. }else{
  87. if(isset($_POST) || isset($_GET) || isset($_REQUEST) || isset($_COOKIE)){
  88. foreach($_POST as $key => $p){
  89. $_POST[$key] = htmlentities($function->filter($p));
  90. $_POST[$key] = mysql_real_escape_string($function->filter($p));
  91. $_POST[$key] = $function->filter(html_entity_decode($p));
  92. }
  93. //Filtro las entradas vía GET
  94. foreach($_GET as $key => $g){
  95. $_GET[$key] = mysql_real_escape_string($function->filter($g));
  96. }
  97. foreach($_COOKIE as $key => $s){
  98. $_COOKIE[$key] = mysql_real_escape_string($function->filter($s));
  99. }
  100. //Filtro las entradas vía REQUEST
  101. foreach($_REQUEST as $key => $k){
  102. $_REQUEST[$key] = mysql_real_escape_string($function->filter($k));
  103. }
  104. }if(isset($_GET)){
  105. //Filtro las entradas vía GET
  106. foreach($_GET as $key => $f){
  107. $_GET[$key] = strip_tags(htmlentities($function->filter($f)));
  108. }
  109. }
  110. }
  111.  
  112. if($function->checkLogin($_SESSION['username'], $_SESSION['password'])){
  113. $u = $function->filter($_SESSION['username']);
  114. //$a = mysql_query("SELECT username, motto, password, look, id, last_online, online, rank, credits FROM users WHERE username = '{$u}' LIMIT 1");
  115. $a = mysql_query("SELECT * FROM users WHERE username = '{$u}' LIMIT 1");
  116. $myrow = mysql_fetch_assoc($a);
  117. if($function->CheckBanned($_SESSION['username'], $function->GetIP())){
  118. $error = $_SESSION['BAN_LOGIN_ERROR'];
  119. $_SESSION['W_LOGIN_ERROR'] = $error;
  120. $bu = $_SESSION['username'];
  121. unset($_SESSION['BAN_LOGIN_ERROR']);
  122. unset($_SESSION['username']);
  123. unset($_SESSION['password']);
  124.  
  125. header("LOCATION: ". PATH ."/?username=". $bu ."&rememberme=false&focus=login-username");
  126. }
  127. if($myrow['rank'] > '5'){
  128. mysql_query("INSERT INTO private_logs (id,user,time,description,ip) VALUES (NULL,'{$myrow['username']}','{$date_full}','En el archivo: {$_SERVER['PHP_SELF']} con rango: {$myrow['rank']}','{$function->GetIP()}')");
  129. }
  130. }else{
  131. $myrow['username'] = "Guest";
  132. }
  133. ###################################################
  134. ?>

Código
  1. <?php
  2. // Funciones
  3. ###################################################
  4. class functions {
  5. public function HoloHash($password){
  6. $password = sha1(md5($password));
  7. $password = hash('gost', $password);
  8. $password = hash('whirlpool', $password);
  9. $password = hash('sha512', $password);
  10. return $password;
  11. }
  12. public function filter($texto) {
  13. $texto = stripslashes(htmlspecialchars($texto));
  14. $texto = trim($texto); // Eliminamos espacios en blanco o caracteres al principio y final del post
  15. $texto = htmlspecialchars($texto); // funciona casi igual que htmlentities
  16. $texto = str_replace("INSERT","IN-SER-T",$texto);  // Remplazamos palabras que podrian ser usadas para alterar la BD
  17. $texto = str_replace("DELETE","DE-LE-TE",$texto);
  18. $texto = str_replace("TRUNCATE","TRUN-CA-TE",$texto);
  19. $texto = str_replace("SELECT","SE-LEC-T",$texto);
  20. $texto = str_replace("ALTER","AL-TER",$texto);
  21. $texto = str_replace("UPDATE","UP-DA-TE",$texto);
  22. $texto = str_replace("inert","IN-SER-T",$texto);  // Remplazamos palabras que podrian ser usadas para alterar la BD
  23. $texto = str_replace("delete","DE-LE-TE",$texto);
  24. $texto = str_replace("truncate","TRUN-CA-TE",$texto);
  25. $texto = str_replace("select","SE-LEC-T",$texto);
  26. $texto = str_replace("alter","AL-TER",$texto);
  27. $texto = str_replace("update","UP-DA-TE",$texto);
  28. $texto = str_replace("script","",$texto);
  29. $texto = str_replace("SCRIPT","",$texto);
  30. $texto = str_replace('"','&#38;#34;',$texto);
  31. $texto = str_replace("'","&#38;#39;",$texto);
  32. $texto = str_replace("<","&#38;#60;",$texto);
  33. $texto = str_replace(">","&#38;#62;",$texto);
  34. $texto = str_replace("(","",$texto);
  35. $texto = str_replace(")","",$texto);
  36. return $texto;
  37. }
  38. public function filternews($texto) {
  39. $texto = trim($texto); // Eliminamos espacios en blanco o caracteres al principio y final del post
  40. $texto = str_replace("INSERT","IN-SER-T",$texto);  // Remplazamos palabras que podrian ser usadas para alterar la BD
  41. $texto = str_replace("DELETE","DE-LE-TE",$texto);
  42. $texto = str_replace("TRUNCATE","TRUN-CA-TE",$texto);
  43. $texto = str_replace("SELECT","SE-LEC-T",$texto);
  44. $texto = str_replace("ALTER","AL-TER",$texto);
  45. $texto = str_replace("UPDATE","UP-DA-TE",$texto);
  46. $texto = str_replace("inert","IN-SER-T",$texto);  // Remplazamos palabras que podrian ser usadas para alterar la BD
  47. $texto = str_replace("delete","DE-LE-TE",$texto);
  48. $texto = str_replace("truncate","TRUN-CA-TE",$texto);
  49. $texto = str_replace("select","SE-LEC-T",$texto);
  50. $texto = str_replace("alter","AL-TER",$texto);
  51. $texto = str_replace("update","UP-DA-TE",$texto);
  52. $texto = str_replace("script","",$texto);
  53. $texto = str_replace("SCRIPT","",$texto);
  54. $texto = str_replace('"','',$texto);
  55. $texto = str_replace("'","",$texto);
  56. return $texto;
  57. }
  58. function GetIP() {
  59. if($_SERVER) {
  60. if($_SERVER["HTTP_X_FORWARDED_FOR"]) {
  61. $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
  62. } elseif ($_SERVER["HTTP_CLIENT_IP"]) {
  63. $realip = $_SERVER["HTTP_CLIENT_IP"];
  64. } else {
  65. $realip = $_SERVER["REMOTE_ADDR"];
  66. }
  67. } else {
  68. if(getenv("HTTP_X_FORWARDED_FOR")) {
  69. $realip = getenv("HTTP_X_FORWARDED_FOR");
  70. } elseif(getenv("HTTP_CLIENT_IP")) {
  71. $realip = getenv("HTTP_CLIENT_IP");
  72. } else {
  73. $realip = getenv("REMOTE_ADDR");
  74. }
  75. }
  76. return $realip;
  77. }
  78. public function GenerateTicket(){
  79. $data = "ST-";
  80. for ($i=1; $i<=6; $i++){
  81. $data = $data . rand(0,9);
  82. }
  83. $data = $data . "-";
  84. for ($i=1; $i<=20; $i++){
  85. $data = $data . rand(0,9);
  86. }
  87. $data = $data . "-habbo-beta-fe";
  88. $data = $data . rand(0,5);
  89. return $data;
  90. }
  91. public function checkLogin($u, $p){
  92. $u = $this->filter($u);
  93. $p = $this->filter($p);
  94. $check = mysql_query("SELECT * FROM users WHERE username = '{$u}' AND password = '{$p}' OR mail = '{$u}' AND password = '{$p}' LIMIT 1");
  95. if(mysql_num_rows($check) > 0) return true; return false;
  96.  
  97. }
  98. public function userExist($u){
  99. $u = $this->filter($u);
  100. $g = mysql_query("SELECT null FROM users WHERE username = '{$u}' OR mail = '{$u}' LIMIT 1");
  101. if(mysql_num_rows($g) > 0) return true; return false;
  102. }
  103. public function AddUser($u, $p, $m, $b){
  104. $user = $this->filter($u);
  105. $pass = $this->filter($p);
  106. $mail = $this->filter($m);
  107. $birth = $this->filter($b);
  108. $credits = "900000";
  109. $rank = "1";
  110. $look = "hr-893-42.hd-180-1.ch-225-64.lg-280-64.sh-300-64.ha-1002-64.ea-1404-62.ca-1802";
  111. $motto = "Hola, soy un usuario nuevo!";
  112.  
  113. mysql_query("INSERT INTO users(`id`, `username`, `password`, `mail`, `credits`, `rank`, `ip_reg`, `ip_last`, `look`, `account_created`, `gender`, `motto`, `birth`, `auth_ticket`)
  114. VALUES(NULL, '{$user}', '{$pass}', '{$mail}', '{$credits}', '{$rank}', '".$this->GetIP()."', '".$this->GetIP()."', '{$look}', '". time() ."', 'M', '{$motto}', '{$birth}', '" .$this->GenerateTicket()."')");
  115. $userd = mysql_query("SELECT * FROM users WHERE username = '{$user}'");
  116. $userd = mysql_fetch_assoc($userd);
  117. mysql_query("INSERT INTO `user_info` (user_id,reg_timestamp) VALUES ('".$userd['id']."','".time()."')");
  118. //mysql_query("INSERT INTO `user_stats` (id) VALUES ('".$userd['id']."')");
  119. $_SESSION['username'] = $user;
  120. $_SESSION['password'] = $pass;
  121. }
  122. function CheckBanned($u, $ip){
  123. $H = date('H');
  124. $i = date('i');
  125. $s = date('s');
  126. $m = date('m');
  127. $d = date('d');
  128. $Y = date('Y');
  129. $j = date('j');
  130. $n = date('n');
  131. $today = $d;
  132. $month = $m;
  133. $year = $Y;
  134. $u = $this->filter($u);
  135. $ip = $this->filter($ip);
  136. $checkban = mysql_query("SELECT * FROM bans WHERE value = '{$u}' or value = '{$ip}' LIMIT 1");
  137. if(mysql_num_rows($checkban) < 1){ return false;} else {
  138. $bandata = mysql_fetch_assoc($checkban);
  139. $reason = $bandata['reason'];
  140. $expire = $bandata['expire'];
  141. $xbits = explode(" ", $expire);
  142. $xtime = explode(":", $xbits[1]);
  143. $xdate = explode("-", $xbits[0]);
  144. $stamp_now = mktime(date('H'),date('i'),date('s'),$today,$month,$year);
  145. $datetoex = date("d-m-y",$expire);
  146. if($stamp_now < $expire){
  147. $login_error = "Has sido banedo por esta razón: \"".$reason."\". Tu baneo expira el: ".$datetoex.".";
  148. $_SESSION['BAN_LOGIN_ERROR'] = $login_error;
  149. return $login_error;
  150. } else {
  151. mysql_query("DELETE FROM bans WHERE value = '{$u}' OR value = '{$ip}' LIMIT 1");
  152. return false;
  153. }
  154. }
  155. }
  156. public function session($s){
  157. if($s == "no" && $this->checkLogin($_SESSION['username'], $_SESSION['password'])){
  158. header("LOCATION: ". PATH ."../dashboard");
  159. }elseif($s == "yes" && $this->checkLogin($_SESSION['username'], $_SESSION['password']) == false){
  160. header("LOCATION: ". PATH ."/index.php");
  161. }
  162. }
  163. public function hk_access(){
  164. $user = $this->filter($_SESSION['username']);
  165. $pass = $this->filter($_SESSION['password']);
  166. $r = mysql_fetch_assoc(mysql_query("SELECT rank FROM users WHERE username = '{$user}' AND password = '{$pass}' LIMIT 1"));
  167. if($r['rank'] >= "5"){}else{header("LOCATION: ". PATH ."dashboard");}
  168.  
  169. }
  170.  
  171. public function GetLast($a){
  172. $a = $this->filter($a);
  173. if(!empty($a) || !$a == ''){
  174. if(is_numeric($a)){
  175. $date = $a;
  176. $date_now = time();
  177. $difference = $date_now - $date;
  178. if($difference <= '59'){ $echo = 'Justo Ahora'; }
  179. elseif($difference <= '3599' && $difference >= '60'){
  180. $minutos = date('i', $difference);
  181. if($minutos[0] == 0) { $minutos = $minutos[1]; }
  182. if($minutos == 1) { $minutos_str = 'minuto'; }
  183. else { $minutos_str = 'minutos'; }
  184. $echo = 'Hace '.$minutos.' '.$minutos_str;//Minutos
  185. }elseif($difference <= '82799' && $difference >= '3600'){
  186. $horas = date('G', $difference);
  187. if($horas == 1) { $horas_str = 'hora'; }
  188. else { $horas_str = 'horas'; }
  189. $echo = 'Hace '.$horas.' '.$horas_str;//Minutos
  190. }elseif($difference <= '518399' && $difference >= '82800'){
  191. $dias = date('j', $difference);
  192. if($dias == 1) { $dias_str = 'd&iacute;a'; }
  193. else { $dias_str = 'd&iacute;as'; }
  194. $echo = 'Hace '.$dias.' '.$dias_str;//Minutos
  195. }elseif($difference <= '2678399' && $difference >= '518400'){
  196. $semana = floor(date('j', $difference) / 7).'<!-- WTF -->';
  197. if($semana == 1) { $semana_str = 'semana'; }
  198. else { $semana_str = 'semanas'; }
  199. $echo = 'Hace '.floor($semana).' '.$semana_str;//Minutos
  200. }else { $echo = 'Hace '.date('n', $difference).' mes(es)'; }
  201. return $echo;
  202. }else{ return $a; }
  203. }else{ return 'A&uacute;n no te has conectado'; }
  204. }
  205. public function RankName($a){
  206. $a = mysql_fetch_assoc(mysql_query("SELECT name FROM ranks WHERE id = '{$a}' LIMIT 1"));
  207. return $a['name'];
  208. }
  209. public function UpdateProfile($a, $b, $u){
  210. $a = $this->filter($a);
  211. $b = $this->filter($b);
  212. $u = $this->filter($u);
  213. mysql_query("UPDATE users SET profile_bg = '{$a}', profile_image = '{$b}' WHERE username = '{$u}'");
  214. }
  215. public function Username_check($a){
  216. $a = $this->filter($a);
  217. $filter = preg_replace("/[^a-z\d\-=\?!@:\.]/i", "", $a);
  218. # USERNAME CHECK #
  219. if($a !== $filter || strlen($a) < 2 || strlen($a) > 32){ $error = "Insertaste un nombre iv&aacute;lido</div>"; }
  220. elseif($this->userExist($a)){ $error = "Ese nombre ya esta en uso"; }
  221. return $error;
  222. }
  223. public function Emails_check($a, $b){
  224. $a = $this->filter($a); // Email 1
  225. $b = $this->filter($b); // Email 2
  226. $email_check = preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $a);
  227. # EMAIL CHECK #
  228. if($email_check !== 1){ $error = "Insertaste un email inv&aacute;lido"; }
  229. elseif($this->userExist($a)){ $error = "Ese email ya esta en uso"; }
  230. elseif($a !== $b){ $error = "Tus emails no coinciden"; }
  231. return $error;
  232. }
  233. public function Password_Check($a, $b){
  234. $a = $this->filter($a); // pass 1
  235. $b = $this->filter($b); // pass 2
  236. # PASSWORD CHECK #
  237. if(strlen($a) < 6 || strlen($a) > 32){ $error = "Escribiste una contrase&ntilde;a inv&aacute;lida (debe tener m&aacute;s de 6 caracteristicas)";}
  238. elseif($a !== $b){ $error = "Tus contraseñas no coinciden"; }
  239. return $error;
  240. }
  241.  
  242. }
  243. ?>

Mod: Obligatorio el uso de etiquetas GeSHi. Temas sobre PHP van al subforo de PHP.


Título: Re: Alguien me ayuda?
Publicado por: LaThortilla (Effort) en 27 Octubre 2015, 20:11 pm
USA ETIQUETAS GeSHi Para codigo PHP.

Te aparece algún error?


ALGÚN MOD QUE MUEVA ESTO AL FORO PHP

Mod: En vez de gritar, usa la función "Reportar al moderador" para avisar.