/perfil/clases/dlm_muro.php
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
- <?php
- include 'conexion_publico.php';
-
- class muro{
- //constructor
- function muro(){
- include 'conexion_publico.php';
- }
- function graba_foto( $user) {
- $dml = " INSERT INTO fotos "
- ." (id_usuario"
- .", path_foto"
- .", nombre_foto_weddcam"
- .", nombre_foto"
- .", titulo)"
- ." VALUES "
- ."('".$user['id_usuario']."'"
- .",'fotos/'"
- .",'".$user['nombre_foto_weddcam']."'"
- .",'".$user['nombre_foto']."'"
- .",'".$user['titulo']."'"
- .")";
- $result=mysql_query($dml) or die("error3-altafoto".mysql_error());
- if (!$result)
- {
- return false;
- }
- $id_foto=mysql_insert_id();
- $dml = " INSERT INTO rankingfotos "
- ." (id_foto"
- .", id_categoria"
- .", fecha_voto"
- .", numero_votos)"
- ." VALUES "
- ."('".$id_foto."'"
- .",'".$user['id_categoria']."'"
- .",'".$user['fecha_voto']."'"
- .",'".$user['n_votos']."'"
- .")";
- $result=mysql_query($dml) or die("error3-altarankingfotos".mysql_error());
- if (!$result)
- {
- return false;
- }
-
-
-
- mysql_close();
- return true;
-
-
- }
- function graba_muro( $user) {
- $id_foto=0;
- if ($user['tipo_publicacion']==="f") {
- $dml = " INSERT INTO fotos "
- ." (id_usuario"
- .", path_foto"
- .", nombre_foto_weddcam"
- .", nombre_foto"
- .", titulo)"
- ." VALUES "
- ."('".$user['id_usuario']."'"
- .",'fotos/'"
- .",'".$user['nombre_foto_weddcam']."'"
- .",'".$user['nombre_foto']."'"
- .",'".$user['titulo']."'"
- .")";
- $result=mysql_query($dml) or die("error3-altafoto".mysql_error());
- if (!$result)
- {
- return false;
- }
- $id_foto=mysql_insert_id();
- }
-
- $dml = " INSERT INTO muro "
- ." (id_usuario"
- .", tipo_publicacion"
- .", titulo"
- .", id_foto"
- .", nombre_foto_weddcam"
- .", txt_publicacion)"
- ." VALUES "
- ."('".$user['id_usuario']."'"
- .",'".$user['tipo_publicacion']."'"
- .",'".$user['titulo']."'"
- .",'".$id_foto."'"
- .",'".$user['nombre_foto_weddcam']."'"
- .",'".$user['txt_publicacion']."'"
- .")";
- $result=mysql_query($dml) or die("error3-altamuro".mysql_error());
- if (!$result)
- {
- return false;
- }
- $id_publicacion=mysql_insert_id();
- $dml = " INSERT INTO muro_relaciones "
- ."(id_usuario,id_destinatario,id_publicacion) values ('" .$user['id_usuario'] ."','" .$user['id_usuario'] ."','" .$id_publicacion. "')";
- $result=mysql_query($dml) or die("error3-altamuro".mysql_error());
- if (!$result)
- {
- return false;
- }
-
-
- //Esto hace que se guarde una relacion de la publicacion en todos los amigos
- $dml = " INSERT INTO muro_relaciones "
- ."(id_usuario,id_destinatario,id_publicacion) "
- ." SELECT id_usuario,id_usuario2,'".$id_publicacion ."'"
- ." FROM relaciones_usuarios "
- ." WHERE situacion = '1' and id_usuario ='" .$user['id_usuario'] ."'" ;
-
- $result=mysql_query($dml) or die("error3-altamuro".mysql_error());
- if (!$result)
- {
- return false;
- }
-
- mysql_close();
- return $id_publicacion;
-
-
- }
- function trae_publicaciones($dato)
- {
- //return mysql_query("SELECT * from muro where id_usuario='".$dato."' order by fecha_alta desc limit 20");
- 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");
- }
- function trae_publicidad(&$banner, &$empresa_banner, &$anuncio, &$empresa_anuncio)
- {
- if (isset($_SESSION['tramo_edad'])) { // estoy logueado
- // banner primero busco si hay alguno para con el filtro de este usuario
- $dml = " SELECT id_empresa, id_ficha_empresa, nombre_foto, id_publicidad "
- ." FROM v_publicidad"
- ." WHERE (tipo_publicidad='0' and contrato_estado='0') "
- ." AND INSTR(filtro_edad,'".$_SESSION['tramo_edad']."') >0 "
- ." AND INSTR(filtro_sexo,'".$_SESSION['sexo']."') >0 "
- ." AND INSTR(filtro_comunidad,'".$_SESSION['id_comunidad']."') >0 "
- ." AND INSTR(filtro_estado,'".$_SESSION['estado_weddcam']."') >0 "
- ." order by stamp asc limit 1";
- $result = mysql_query($dml) or die("error1-coge_banner".$dml.mysql_error());
- if ($aRow = mysql_fetch_array( $result )) {
- $stamp= date("Y-m-d H:i:s");
- $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
- $banner ="publicidad/".$aRow['nombre_foto'];
- $empresa_banner =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
- } else { // no hay banners para el filtro de este usuario, cojo cualquier banner
- $dml = " SELECT id_empresa, nombre_foto, id_publicidad "
- ." FROM v_publicidad"
- ." WHERE (tipo_publicidad='0' and contrato_estado='0') "
- ." order by stamp asc limit 1"
- ;
- $result2 = mysql_query($dml) or die("error2-coge_banner".$dml.mysql_error());;
- if ($aRow = mysql_fetch_array( $result2 )) {
- $stamp= date("Y-m-d H:i:s");
- $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
- $banner = "publicidad/".$aRow['nombre_foto'];
- $empresa_banner =$aRow['id_empresa'];
- }
- }
-
- // anuncios primero busco si hay alguno para con el filtro de este usuario
- $dml = " SELECT id_empresa, id_ficha_empresa, nombre_foto, id_publicidad "
- ." FROM v_publicidad"
- ." WHERE (tipo_publicidad='1' and contrato_estado='0')"
- ." AND INSTR(filtro_edad,'".$_SESSION['tramo_edad']."') >0 "
- ." AND INSTR(filtro_sexo,'".$_SESSION['sexo']."') >0 "
- ." AND INSTR(filtro_comunidad,'".$_SESSION['id_comunidad']."') >0 "
- ." AND INSTR(filtro_estado,'".$_SESSION['estado_weddcam']."') >0 "
- ." order by stamp asc limit 1"
- ;
- $result = mysql_query($dml) or die("error1-coge_anuncio".$dml.mysql_error());;
- if ($aRow = mysql_fetch_array( $result )) {
- $stamp= date("Y-m-d H:i:s");
- $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
- $anuncio ="publicidad/".$aRow['nombre_foto'];
- $empresa_anuncio =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
- } else { // no hay banners para el filtro de este usuario, cojo cualquier banner
- $dml = " SELECT id_empresa, nombre_foto, id_publicidad "
- ." FROM v_publicidad"
- ." WHERE (tipo_publicidad='1' and contrato_estado='0') "
- ." order by stamp asc limit 1";
- $result2 = mysql_query($dml) or die("error2-coge_anuncio".$dml.mysql_error());;
- if ($aRow = mysql_fetch_array( $result2 )) {
- $stamp= date("Y-m-d H:i:s");
- $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
- $anuncio ="../publicidad/".$aRow['nombre_foto'];
- $empresa_anuncio =$aRow['id_empresa'];
- }
- }
- return true;
- } else { //acceso publico
- $dml = " SELECT id_empresa, id_ficha_empresa, nombre_foto, id_publicidad "
- ." FROM v_publicidad"
- ." WHERE (tipo_publicidad='0' and contrato_estado='0') "
- ." order by stamp asc limit 1"
- ;
- $result2 = mysql_query($dml) or die("error2-coge_banner".$dml.mysql_error());;
- if ($aRow = mysql_fetch_array( $result2 )) {
- $stamp= date("Y-m-d H:i:s");
- $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
- $banner = "publicidad/".$aRow['nombre_foto'];
- $empresa_banner =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
- }
- $dml = " SELECT id_empresa,id_ficha_empresa, nombre_foto, id_publicidad "
- ." FROM v_publicidad"
- ." WHERE (tipo_publicidad='1' and contrato_estado='0') "
- ." order by stamp asc limit 1"
- ;
- $result2 = mysql_query($dml) or die("error2-coge_anuncio".$dml.mysql_error());;
- if ($aRow = mysql_fetch_array( $result2 )) {
- $stamp= date("Y-m-d H:i:s");
- $result2 = mysql_query(" UPDATE empresas_publicidad SET stamp='".$stamp."' where id_publicidad='".$aRow['id_publicidad']."' ");
- $anuncio ="publicidad/".$aRow['nombre_foto'];
- $empresa_anuncio =$aRow['id_empresa'].",".$aRow['id_ficha_empresa'];
- }
- }
- return true;
- }
- // fin funciones
- }
-
- ?>