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

/perfil/clases/dlm_muro.php

https://bitbucket.org/weddcam/develop_weddcam
PHP | 224 lines | 203 code | 15 blank | 6 comment | 17 complexity | 669a662e571c650aa7e2fc22c6c81d63 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, MIT, LGPL-3.0, LGPL-2.1
  1. <?php
  2. include 'conexion_publico.php';
  3. class muro{
  4. //constructor
  5. function muro(){
  6. include 'conexion_publico.php';
  7. }
  8. function graba_foto( $user) {
  9. $dml = " INSERT INTO fotos "
  10. ." (id_usuario"
  11. .", path_foto"
  12. .", nombre_foto_weddcam"
  13. .", nombre_foto"
  14. .", titulo)"
  15. ." VALUES "
  16. ."('".$user['id_usuario']."'"
  17. .",'fotos/'"
  18. .",'".$user['nombre_foto_weddcam']."'"
  19. .",'".$user['nombre_foto']."'"
  20. .",'".$user['titulo']."'"
  21. .")";
  22. $result=mysql_query($dml) or die("error3-altafoto".mysql_error());
  23. if (!$result)
  24. {
  25. return false;
  26. }
  27. $id_foto=mysql_insert_id();
  28. $dml = " INSERT INTO rankingfotos "
  29. ." (id_foto"
  30. .", id_categoria"
  31. .", fecha_voto"
  32. .", numero_votos)"
  33. ." VALUES "
  34. ."('".$id_foto."'"
  35. .",'".$user['id_categoria']."'"
  36. .",'".$user['fecha_voto']."'"
  37. .",'".$user['n_votos']."'"
  38. .")";
  39. $result=mysql_query($dml) or die("error3-altarankingfotos".mysql_error());
  40. if (!$result)
  41. {
  42. return false;
  43. }
  44. mysql_close();
  45. return true;
  46. }
  47. function graba_muro( $user) {
  48. $id_foto=0;
  49. if ($user['tipo_publicacion']==="f") {
  50. $dml = " INSERT INTO fotos "
  51. ." (id_usuario"
  52. .", path_foto"
  53. .", nombre_foto_weddcam"
  54. .", nombre_foto"
  55. .", titulo)"
  56. ." VALUES "
  57. ."('".$user['id_usuario']."'"
  58. .",'fotos/'"
  59. .",'".$user['nombre_foto_weddcam']."'"
  60. .",'".$user['nombre_foto']."'"
  61. .",'".$user['titulo']."'"
  62. .")";
  63. $result=mysql_query($dml) or die("error3-altafoto".mysql_error());
  64. if (!$result)
  65. {
  66. return false;
  67. }
  68. $id_foto=mysql_insert_id();
  69. }
  70. $dml = " INSERT INTO muro "
  71. ." (id_usuario"
  72. .", tipo_publicacion"
  73. .", titulo"
  74. .", id_foto"
  75. .", nombre_foto_weddcam"
  76. .", txt_publicacion)"
  77. ." VALUES "
  78. ."('".$user['id_usuario']."'"
  79. .",'".$user['tipo_publicacion']."'"
  80. .",'".$user['titulo']."'"
  81. .",'".$id_foto."'"
  82. .",'".$user['nombre_foto_weddcam']."'"
  83. .",'".$user['txt_publicacion']."'"
  84. .")";
  85. $result=mysql_query($dml) or die("error3-altamuro".mysql_error());
  86. if (!$result)
  87. {
  88. return false;
  89. }
  90. $id_publicacion=mysql_insert_id();
  91. $dml = " INSERT INTO muro_relaciones "
  92. ."(id_usuario,id_destinatario,id_publicacion) values ('" .$user['id_usuario'] ."','" .$user['id_usuario'] ."','" .$id_publicacion. "')";
  93. $result=mysql_query($dml) or die("error3-altamuro".mysql_error());
  94. if (!$result)
  95. {
  96. return false;
  97. }
  98. //Esto hace que se guarde una relacion de la publicacion en todos los amigos
  99. $dml = " INSERT INTO muro_relaciones "
  100. ."(id_usuario,id_destinatario,id_publicacion) "
  101. ." SELECT id_usuario,id_usuario2,'".$id_publicacion ."'"
  102. ." FROM relaciones_usuarios "
  103. ." WHERE situacion = '1' and id_usuario ='" .$user['id_usuario'] ."'" ;
  104. $result=mysql_query($dml) or die("error3-altamuro".mysql_error());
  105. if (!$result)
  106. {
  107. return false;
  108. }
  109. mysql_close();
  110. return $id_publicacion;
  111. }
  112. function trae_publicaciones($dato)
  113. {
  114. //return mysql_query("SELECT * from muro where id_usuario='".$dato."' order by fecha_alta desc limit 20");
  115. return mysql_query("SELECT * from muro inner join muro_relaciones on muro.id_publicacion=muro_relaciones.id_publicacion where muro_relaciones.id_destinatario='".$dato."' order by fecha_alta desc limit 20");
  116. }
  117. function trae_publicidad(&$banner, &$empresa_banner, &$anuncio, &$empresa_anuncio)
  118. {
  119. if (isset($_SESSION['tramo_edad'])) { // estoy logueado
  120. // banner primero busco si hay alguno para con el filtro de este usuario
  121. $dml = " SELECT id_empresa, id_ficha_empresa, nombre_foto, id_publicidad "
  122. ." FROM v_publicidad"
  123. ." WHERE (tipo_publicidad='0' and contrato_estado='0') "
  124. ." AND INSTR(filtro_edad,'".$_SESSION['tramo_edad']."') >0 "
  125. ." AND INSTR(filtro_sexo,'".$_SESSION['sexo']."') >0 "
  126. ." AND INSTR(filtro_comunidad,'".$_SESSION['id_comunidad']."') >0 "
  127. ." AND INSTR(filtro_estado,'".$_SESSION['estado_weddcam']."') >0 "
  128. ." order by stamp asc limit 1";
  129. $result = mysql_query($dml) or die("error1-coge_banner".$dml.mysql_error());
  130. if ($aRow = mysql_fetch_array( $result )) {
  131. $stamp= date("Y-m-d H:i:s");
  132. $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
  133. $banner ="publicidad/".$aRow['nombre_foto'];
  134. $empresa_banner =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
  135. } else { // no hay banners para el filtro de este usuario, cojo cualquier banner
  136. $dml = " SELECT id_empresa, nombre_foto, id_publicidad "
  137. ." FROM v_publicidad"
  138. ." WHERE (tipo_publicidad='0' and contrato_estado='0') "
  139. ." order by stamp asc limit 1"
  140. ;
  141. $result2 = mysql_query($dml) or die("error2-coge_banner".$dml.mysql_error());;
  142. if ($aRow = mysql_fetch_array( $result2 )) {
  143. $stamp= date("Y-m-d H:i:s");
  144. $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
  145. $banner = "publicidad/".$aRow['nombre_foto'];
  146. $empresa_banner =$aRow['id_empresa'];
  147. }
  148. }
  149. // anuncios primero busco si hay alguno para con el filtro de este usuario
  150. $dml = " SELECT id_empresa, id_ficha_empresa, nombre_foto, id_publicidad "
  151. ." FROM v_publicidad"
  152. ." WHERE (tipo_publicidad='1' and contrato_estado='0')"
  153. ." AND INSTR(filtro_edad,'".$_SESSION['tramo_edad']."') >0 "
  154. ." AND INSTR(filtro_sexo,'".$_SESSION['sexo']."') >0 "
  155. ." AND INSTR(filtro_comunidad,'".$_SESSION['id_comunidad']."') >0 "
  156. ." AND INSTR(filtro_estado,'".$_SESSION['estado_weddcam']."') >0 "
  157. ." order by stamp asc limit 1"
  158. ;
  159. $result = mysql_query($dml) or die("error1-coge_anuncio".$dml.mysql_error());;
  160. if ($aRow = mysql_fetch_array( $result )) {
  161. $stamp= date("Y-m-d H:i:s");
  162. $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
  163. $anuncio ="publicidad/".$aRow['nombre_foto'];
  164. $empresa_anuncio =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
  165. } else { // no hay banners para el filtro de este usuario, cojo cualquier banner
  166. $dml = " SELECT id_empresa, nombre_foto, id_publicidad "
  167. ." FROM v_publicidad"
  168. ." WHERE (tipo_publicidad='1' and contrato_estado='0') "
  169. ." order by stamp asc limit 1";
  170. $result2 = mysql_query($dml) or die("error2-coge_anuncio".$dml.mysql_error());;
  171. if ($aRow = mysql_fetch_array( $result2 )) {
  172. $stamp= date("Y-m-d H:i:s");
  173. $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
  174. $anuncio ="../publicidad/".$aRow['nombre_foto'];
  175. $empresa_anuncio =$aRow['id_empresa'];
  176. }
  177. }
  178. return true;
  179. } else { //acceso publico
  180. $dml = " SELECT id_empresa, id_ficha_empresa, nombre_foto, id_publicidad "
  181. ." FROM v_publicidad"
  182. ." WHERE (tipo_publicidad='0' and contrato_estado='0') "
  183. ." order by stamp asc limit 1"
  184. ;
  185. $result2 = mysql_query($dml) or die("error2-coge_banner".$dml.mysql_error());;
  186. if ($aRow = mysql_fetch_array( $result2 )) {
  187. $stamp= date("Y-m-d H:i:s");
  188. $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
  189. $banner = "publicidad/".$aRow['nombre_foto'];
  190. $empresa_banner =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
  191. }
  192. $dml = " SELECT id_empresa,id_ficha_empresa, nombre_foto, id_publicidad "
  193. ." FROM v_publicidad"
  194. ." WHERE (tipo_publicidad='1' and contrato_estado='0') "
  195. ." order by stamp asc limit 1"
  196. ;
  197. $result2 = mysql_query($dml) or die("error2-coge_anuncio".$dml.mysql_error());;
  198. if ($aRow = mysql_fetch_array( $result2 )) {
  199. $stamp= date("Y-m-d H:i:s");
  200. $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
  201. $anuncio ="publicidad/".$aRow['nombre_foto'];
  202. $empresa_anuncio =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
  203. }
  204. }
  205. return true;
  206. }
  207. // fin funciones
  208. }
  209. ?>