PageRenderTime 47ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/perfil/clases/dlm_perfil.php

https://bitbucket.org/weddcam/develop_weddcam
PHP | 133 lines | 120 code | 11 blank | 2 comment | 14 complexity | f51d6203f0484ca5296626f02e1fac6e MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, MIT, LGPL-3.0, LGPL-2.1
  1. <?php
  2. include 'conexion.php';
  3. class perfil{
  4. //constructor
  5. var $conexion;
  6. function perfil(){
  7. include 'conexion.php';
  8. }
  9. // FUNCIONES USUARIOS PERFIL
  10. function trae_usuario($dato)
  11. {
  12. return mysql_query("SELECT * from usuarios where id_usuario='".$dato."'");
  13. }
  14. function trae_usuario_perfil($dato)
  15. {
  16. return mysql_query("SELECT * from v_user_perfil where id_usuario='".$dato."'");
  17. }
  18. function trae_fotos_usuario($dato)
  19. {
  20. return mysql_query("SELECT id_foto_usuario, nombre_foto from fotos_usuarios where id_usuario='".$dato."'");
  21. }
  22. function cambia_foto_perfil($foto, $user,$nombre_foto)
  23. {
  24. $dml="UPDATE usuarios SET nombre_foto_perfil='".$nombre_foto."', id_foto='".$foto."' WHERE id_usuario='".$user."'";
  25. $result=mysql_query($dml) or die("error3-updatefotousuario".mysql_error());
  26. if (!$result)
  27. {
  28. return false;
  29. }
  30. mysql_close();
  31. return true;
  32. }
  33. function borra_foto_perfil($foto)
  34. {
  35. $dml="DELETE FROM fotos_usuarios WHERE id_foto_usuario='".$foto."'";
  36. $result=mysql_query($dml) or die("error3-borrafotousuario".mysql_error());
  37. if (!$result)
  38. {
  39. return false;
  40. }
  41. mysql_close();
  42. return true;
  43. }
  44. function graba_foto_perfil($user, $foto, &$id_foto)
  45. {
  46. $dml = " INSERT INTO fotos_usuarios ( id_usuario, nombre_foto) VALUES ('".$user."', '".$foto."')" ;
  47. $result=mysql_query($dml) or die("error3-altausuariofotos".mysql_error());
  48. if (!$result)
  49. {
  50. return false;
  51. }
  52. $id_foto=mysql_insert_id();
  53. mysql_close();
  54. return true;
  55. }
  56. function activa_usuario($clave1, $clave2) {
  57. $pass=$clave2;
  58. $nick="I=P/(1.73*U*cosfi)=610/(";
  59. $nick = $this->desencriptar(base64_decode($clave2), $nick);
  60. $result=mysql_query("SELECT id_usuario,nick,tipo_usuario,nombre,nombre_foto_perfil,estado from usuarios where nick='".$nick."'") or die("error3-ActivaUsuarios".mysql_error());
  61. if (!$result) { return false; }
  62. if($row = mysql_fetch_array($result)) {
  63. if ($row['estado']=='0') return false; // SI VUELVEN A ACTIVAR DEVUELVE FALSE
  64. $result2=mysql_query("UPDATE usuarios SET estado='0' where id_usuario='".$row['id_usuario']."'") or die("error4-ActivaUsuarios".mysql_error());
  65. if (!$result2) { return false; }
  66. session_name('weddcam');
  67. session_start();
  68. $_SESSION['tipo_usuario'] = $row['tipo_usuario'];
  69. $_SESSION['nick'] = $row['nick'];
  70. $_SESSION['id_usuario'] = $row['id_usuario'];
  71. $_SESSION['nombre'] = $row['nombre'];
  72. $_SESSION['id_empresa'] = '0';
  73. $_SESSION['nombre_foto_perfil'] = $row['nombre_foto_perfil'];
  74. $_SESSION['modo']="privado";
  75. $_SESSION['que_te_pires']=time() + 1200; //20 minutitos
  76. session_commit();
  77. return true;
  78. }
  79. return false;
  80. }
  81. function trae_perfil_privado($dato,$cual)
  82. {
  83. if ($cual=='0') $tabla="v_user_perfil_amigos";
  84. if ($cual=='1') $tabla="v_user_perfil_contactos";
  85. if ($cual=='2') $tabla="v_user_perfil_publico";
  86. return mysql_query("SELECT * from ".$tabla." where id_usuario='".$dato."'");
  87. }
  88. function dame_edad($date)
  89. {
  90. $fecha=strftime('%d/%m/%Y',strtotime($date));
  91. $part=explode("/",$fecha);
  92. $b_day=$part[0];
  93. $b_month=$part[1];
  94. $b_year=$part[2];
  95. $time=time();
  96. $day=date("d",$time);
  97. $month=date("m",$time);
  98. $year=date("Y",$time);
  99. if ( $month >= $b_month AND $day >= $b_day ) $age = $year-$b_year;
  100. else $age = $year-$b_year-1;
  101. return $age;
  102. }
  103. function dame_provincia($dato)
  104. {
  105. $result=mysql_query("SELECT provincia from provincias where id_provincia='".$dato."'") or die("error3-dame_provinica".mysql_error());
  106. if (!$result)
  107. {
  108. return '';
  109. }
  110. if ($consulta=mysql_fetch_array($result)) {
  111. return $consulta['provincia'];
  112. }
  113. return '';
  114. }
  115. function desencriptar($cadena, $clave)
  116. {
  117. $cifrado = MCRYPT_RIJNDAEL_256;
  118. $modo = MCRYPT_MODE_ECB;
  119. return mcrypt_decrypt($cifrado, $clave, $cadena, $modo, mcrypt_create_iv(mcrypt_get_iv_size($cifrado, $modo), MCRYPT_RAND));
  120. }
  121. } // fin clase perfil
  122. ?>