/perfil/clases/dlm_evento.php
PHP | 322 lines | 293 code | 27 blank | 2 comment | 33 complexity | 9041e63109d58fd2c224826adf53d5ed 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 evento{
- //constructor
- function evento(){
- include 'conexion_publico.php';
- }
-
- function trae_publicidad(&$banner, &$empresa_banner, &$anuncio, &$empresa_anuncio)
- {
- $dml = " SELECT id_empresa, nombre_foto, id_publicidad "
- ." FROM v_empresas_publicidad"
- ." WHERE (tipo='banner' and estado='1') "
- ." 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'];
- }
- $dml = " SELECT id_empresa, nombre_foto, id_publicidad "
- ." FROM v_empresas_publicidad"
- ." WHERE (tipo='anuncio' and estado='1') "
- ." 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;
- }
- function trae_paises()
- {
- return mysql_query("SELECT * from paises order by pais");
- }
- function trae_provincias()
- {
- return mysql_query("SELECT * from provincias order by provincia");
- }
- function dame_apellidos($dato)
- {
- $total=mysql_query("SELECT nombre, apellidos from usuarios where id_usuario='".$dato."'") or die("error2-comprueba_email".mysql_error());
- $aRow = mysql_fetch_array( $total );
- if(!$aRow)
- {
- $respuesta="";
- }
- else
- {
- $respuesta=trim($aRow['nombre'])." ".trim($aRow['apellidos']);
- }
- return $respuesta;
- }
- function comprueba_email($dato,$dato2)
- {
- $total=mysql_query("SELECT nick,nombre_foto_perfil,id_usuario from usuarios where e_mail='".$dato."'") or die("error2-comprueba_email".mysql_error());
- $aRow = mysql_fetch_array( $total );
- if(!$aRow)
- {
- $respuesta="NO@";
- }
- else
- {
- $apellidos1=$this->dame_apellidos($dato2);
- $apellidos2=$this->dame_apellidos($aRow['id_usuario']);
- $respuesta="SI@".$aRow['nick']."@".$aRow['id_usuario']."@".$aRow['nombre_foto_perfil']."@".$apellidos1.", ".$apellidos2;
- }
- mysql_close();
- return $respuesta;
- }
- function get_plantilla($plantilla)
- {
-
- $dml = "SELECT cabecera,cuerpo,pie FROM plantillas WHERE nombre='". $plantilla ."'";
- $result = mysql_query($dml) or die("error-leer_plantilla".mysql_error());
- if($row = mysql_fetch_array($result)) {
- return $row;
- }
- else {
- return 0;
- }
-
- }
- function graba_evento_con_id( $user, &$id_evento)
-
- {
- $result=true;
- $campos=""; $valores="";
- foreach ($user as $key=>$value){
- $campos .= "" .$key .",";
- $valores .= "'" .$user[$key] ."'," ;
- }
-
-
- $dml = " INSERT INTO eventos (" .substr($campos,0,-1) .") VALUES (". substr($valores,0,-1) .")" ;
-
-
-
- $result=mysql_query($dml) or die("error3-altaEventos".mysql_error());
- if (!$result)
- {
- return false;
- }
-
- $id_evento=mysql_insert_id();
- if (strlen($user['nombre_foto_evento'])>0) {
- $nombre_foto_evento="evento_".$id_evento.".jpg";
- $dml = " UPDATE eventos SET nombre_foto_evento='".$nombre_foto_evento."' where id_evento='".$id_evento."' ";
- $result=mysql_query($dml) or die("error4-altaEventos".mysql_error());
- }
- $dml = " UPDATE usuarios SET id_evento='".$id_evento."' where id_usuario='".$user['id_usuario1']."' ";
- $result=mysql_query($dml) or die("error5-altaEventos".mysql_error());
- $dml = " UPDATE usuarios SET id_evento='".$id_evento."' where id_usuario='".$user['id_usuario2']."' ";
- $result=mysql_query($dml) or die("error6-altaEventos".mysql_error());
- mysql_close();
- return true;
-
- }
- function borra_evento( $id_evento,$id_usuario)
- {
- $result=true;
- $result=mysql_query("DELETE from eventos WHERE id_evento='".$id_evento."'") or die("error-borrar-evento".mysql_error());
- if (!$result)
- {
- return false;
- }
-
- $dml = " UPDATE usuarios SET id_evento='0' where id_usuario='".$id_usuario."' ";
- $result=mysql_query($dml) or die("error3-altaEventos".mysql_error());
- mysql_close();
- return true;
-
- }
- function trae_evento($dato)
- {
- return mysql_query("SELECT * from eventos where id_evento='".$dato."' ");
- }
- function trae_usuario2($dato)
- {
- return mysql_query("SELECT nombre_foto_perfil,nick from usuarios where id_usuario='".$dato."' ");
- }
- function activa($clave1, &$clave2) {
- $pass=$clave2;
- $nick="I=P/(1.73*U*cosfi)=610/(";
- $nick = $this->desencriptar(base64_decode($clave2), $nick);
- $clave2=$nick;
- $result=mysql_query("SELECT estado from eventos where id_evento='".$nick."'") or die("error3-ActivaUsuarios".mysql_error());
- if (!$result) { return false; }
- if($row = mysql_fetch_array($result)) {
- if ($row['estado']=='1') return false; // SI VUELVEN A ACTIVAR DEVUELVE FALSE
- }
- return true;
- }
- function activa_evento($id_evento,&$phpid) {
- $result=mysql_query("SELECT * from eventos where id_evento='".$id_evento."'") or die("error4-ActivaUsuarios".mysql_error());
- if (!$result) { return false; }
- if($row = mysql_fetch_array($result)) {
- if ($row['estado']=='1') return false; // SI VUELVEN A ACTIVAR DEVUELVE FALSE
- $result1=mysql_query("SELECT * from usuarios where id_usuario='".$row['id_usuario1']."' ") or die("error5-ActivaUsuarios".mysql_error());
- if(!$user1 = mysql_fetch_array($result1)) { return false;}
- $result2=mysql_query("SELECT * from usuarios where id_usuario='".$row['id_usuario2']."' ") or die("error6-ActivaUsuarios".mysql_error());
- if(!$user2 = mysql_fetch_array($result2)) { return false;}
- $user=array();
- $user['nick']=$user1['nick']."-".$user2['nick'];
- $user['e_mail']="evento".$id_evento."@weddcam.es";
- $user['password']=md5("evento".$id_evento);
- $user['nombre_foto_perfil']=$row['nombre_foto_evento'];
- $user['nombre']=$row['nombre_pareja'];
- $user['apellidos']= $user1['apellidos'];
- $user['estado_weddcam']= $user1['estado_weddcam'];
- $user['sexo']= $user1['sexo'];
- $user['id_pais']= $user1['id_pais'];
- $user['id_provincia']= $row['id_provincia'];
- $user['id_poblacion']= "0";
- $user['poblacion']= $row['poblacion'];
- $user['cp']= $row['cp'];
- $user['fecha_nacimiento']=$user1['fecha_nacimiento'];
- $user['tipo_usuario']=0;
- $user['estado']=3; // estado 0-ok, 1-bloqueado, 2-inactivo 3-usuario evento
- $user['id_perfil']="0";
- $id_usuario="";
- $campos=""; $valores="";
- foreach ($user as $key=>$value){
- $campos .= "" .$key .",";
- $valores .= "'" .$user[$key] ."'," ;
- }
- $dml = " INSERT INTO usuarios (" .substr($campos,0,-1) .") VALUES (". substr($valores,0,-1) .")" ;
- $result4=mysql_query($dml) or die("error3-altausuario".$dml.mysql_error());
- if (!$result4)
- {
- return false;
- }
- $id_usuario=mysql_insert_id();
- $result5=mysql_query("UPDATE usuarios SET id_usuario_evento='".$id_usuario."' where id_usuario='".$row['id_usuario1']."'") or die("error8-ActivaUsuarios".mysql_error());
- if (!$result5) { return false; }
- $result6=mysql_query("UPDATE usuarios SET id_evento='".$id_evento."', id_usuario_evento='".$id_usuario."' where id_usuario='".$row['id_usuario2']."'") or die("erro9-ActivaUsuarios".mysql_error());
- if (!$result6) { return false; }
- $result7=mysql_query("UPDATE eventos SET estado='1', nick='".$user['nick']."', id_usuario_evento='".$id_usuario."' where id_evento='".$id_evento."'") or die("erro10-ActivaUsuarios".mysql_error());
- if (!$result7) { return false; }
- $phpid = $id_usuario.md5(chr(rand(97,122)).uniqid());
- session_name($phpid);
- session_start();
- $_SESSION['tipo_usuario'] = '1';
- $_SESSION['nick'] = $user1['nick'];
- $_SESSION['id_usuario'] = $id_usuario;
- $_SESSION['nombre'] = $user1['nombre'];
- $_SESSION['id_empresa'] = '0';
- $_SESSION['nombre_foto_perfil'] = $row['nombre_foto_evento'];
- $_SESSION['modo']="privado";
- $_SESSION['que_te_pires']=time() + 1200; //20 minutitos
- $tramo=$this->dame_edad($user1['fecha_nacimiento']);
- $_SESSION['edad']=$tramo;
- $_SESSION['tramo_edad']=$this->dame_tramo($tramo);
- $_SESSION['modalidad_contratacion'] = 0;
- $_SESSION['id_provincia'] =$row['id_provincia'];
- $_SESSION['id_comunidad'] = 0;
- $_SESSION['sexo'] = $user['sexo'];
- $_SESSION['estado_weddcam'] = $user['estado_weddcam'];
- $_SESSION['id_evento'] = $id_evento;
- $_SESSION['estado_evento'] = "1";
- session_commit();
- return true;
- }
- return false;
- }
- function actualiza_evento($user,$id_evento)
- {
- $result=true;
- $campos=""; $valores="";
- foreach ($user as $key=>$value){
- $campos .= "" . $key ."= '". $user[$key] ."'," ;
-
- }
-
- $dml = " UPDATE eventos SET " .substr($campos,0,-1) ." WHERE id_evento='" . $id_evento."'";
- $result=true;
-
- $result=mysql_query($dml) or die("error-actualizando-evento".mysql_error());
- if (!$result)
- return false;
- return true;
-
- }
- function graba_agenda_con_id( $user, &$id_agenda)
-
- {
- $result=true;
- $campos=""; $valores="";
- foreach ($user as $key=>$value){
- $campos .= "" .$key .",";
- $valores .= "'" .$user[$key] ."'," ;
- }
-
-
- $dml = " INSERT INTO eventos_agenda (" .substr($campos,0,-1) .") VALUES (". substr($valores,0,-1) .")" ;
- $result=mysql_query($dml) or die("error3-altaEventos_agenda".mysql_error());
- if (!$result)
- {
- return false;
- }
-
- $id_agenda=mysql_insert_id();
- if (isset($user['album'])) { // si han chequeado album, creamos un album
- $dml = " INSERT INTO eventos_album (id_evento, id_evento_agenda,titulo) VALUES ('".$user['id_evento']."','".$id_agenda."', '".$user['titulo_album']."')" ;
- $result=mysql_query($dml) or die("error4-altaEventos_agenda".mysql_error());
- if (!$result)
- {
- return false;
- }
-
- }
- mysql_close();
- return true;
-
- }
- function desencriptar($cadena, $clave)
- {
- $cifrado = MCRYPT_RIJNDAEL_256;
- $modo = MCRYPT_MODE_ECB;
- return mcrypt_decrypt($cifrado, $clave, $cadena, $modo, mcrypt_create_iv(mcrypt_get_iv_size($cifrado, $modo), MCRYPT_RAND));
- }
- function dame_edad($date)
- {
- $fecha=strftime('%d/%m/%Y',strtotime($date));
- $part=explode("/",$fecha);
- $b_day=$part[0];
- $b_month=$part[1];
- $b_year=$part[2];
- $time=time();
- $day=date("d",$time);
- $month=date("m",$time);
- $year=date("Y",$time);
- if ( $month >= $b_month AND $day >= $b_day ) $age = $year-$b_year;
- else $age = $year-$b_year-1;
- return $age;
- }
- function dame_tramo($tramo) {
- $rango=0;
- $edad=(int)$tramo;
- $consulta2 =mysql_query("SELECT * from rango_edad");
- if (!$consulta2) return $rango;
- while ( $aRow = mysql_fetch_array( $consulta2 ) )
- {
-
- if ( ($edad >= (int) $aRow['min']) && ($edad <= (int) $aRow['max'])) {
- $rango=$aRow['id_rango_edad'];
- break;
- }
-
- }
- return $rango;
- }
- // fin funciones
- }
-
- ?>