%s. %s is ugly in raw sql query # vsprintf - replacing all %s to parameters $sql_query = vsprintf( str_replace("?","'%s'",$query), $params ); $sql_query = mysql_query($sql_query); # Perfoming escaped query } else { $sql_query = mysql_query($query); # If no params... } return ($sql_query); } function Conectarse() { if (!($link=mysql_connect("localhost","conseilfeminin","cf2388csf4f"))) { echo "Error conectando a la base de datos."; exit(); } if (!mysql_select_db("conseilfeminin",$link)) { echo "Error seleccionando la base de datos."; exit(); } return $link; } /*function Conectarse2log() { // if (!($link=mysql_connect("localhost","",""))) if (!($link=mysql_connect("formulatv.com","formulatv","ftv90d3hg"))) { echo "Error conectando a la base de datos."; exit(); } if (!mysql_select_db("formulatv",$link)) { echo "Error seleccionando la base de datos."; exit(); } return $link; } function Conectarse3log() { // if (!($link=mysql_connect("localhost","",""))) if (!($link=mysql_connect("91.121.114.189","ecartelera","ec00x6s7"))) { echo "Error conectando a la base de datos."; exit(); } if (!mysql_select_db("ecartelera",$link)) { echo "Error seleccionando la base de datos."; exit(); } return $link; }*/ function t($string) { $string = str_replace ("", "œ", $string); return utf8_encode(trim(stripslashes($string))); } function quita_gui($string){ return str_replace("-","",$string); } function Mes($Num) { $Meses=array ("Janvier","Fvrier","Mars","Avril","Mai","Juin","Juillet","Aot","Septembre","Octobre","Novembre","Dcembre"); $Num--; return "$Meses[$Num]"; } function recortar($cadena, $max) { $aspace=" "; if(strlen($cadena) > $max ) { $cadena = substr(trim($cadena),0,$max); $cadena = substr($cadena,0,strlen($cadena)-strpos(strrev($cadena),$aspace)); $cadena = $cadena.'...'; } return $cadena; } function dame_pmayus($cadena) { preg_match_all('/[A-Za-z]/', $cadena, $subs); $longitud=count($subs[0]); preg_match_all('/[A-Z]/', $cadena, $subs); $nmayus=count($subs[0]); $pmayus=round(($nmayus*100)/$longitud); return $pmayus; } function apsl($text) { $text = str_replace ("", "\"", $text); $text = str_replace ("", "\"", $text); $text = str_replace ("", "'", $text); $text = str_replace ("", "'", $text); $text = str_replace ("", "...", $text); return $text; } function seReferer($ref = false){ $SeReferer = (is_string($ref) ? $ref : $_SERVER['HTTP_REFERER']); if( //Check against Google, Yahoo, MSN, Ask and others preg_match( "/[&\?](q|p|w|searchfor|as_q|as_epq|s|query)=([^&]+)/i", $SeReferer,$pcs) ){ if(preg_match("/https?:\/\/([^\/]+)\//i",$SeReferer,$SeDomain)){ $SeDomain = trim(strtolower($SeDomain[1])); $SeQuery = $pcs[2]; if(preg_match("/[&\?](start|b|first|stq)=([0-9]*)/i",$SeReferer,$pcs)){ $SePos = (int)trim($pcs[2]); } } } if(!isset($SeQuery)){ if( //Check against DogPile preg_match( "/\/search\/web\/([^\/]+)\//i", $SeReferer,$pcs) ){ if(preg_match("/https?:\/\/([^\/]+)\//i",$SeReferer,$SeDomain)){ $SeDomain = trim(strtolower($SeDomain[1])); $SeQuery = $pcs[1]; } } } // We Do Not have a query if(!isset($SeQuery)){ return false; } $OldQ=$SeQuery; $SeQuery=urldecode($SeQuery); // The Multiple URLDecode Trick to fix DogPile %XXXX Encodes while($SeQuery != $OldQ){ $OldQ=$SeQuery; $SeQuery=urldecode($SeQuery); } //-- We have a query return array( "Se"=>$SeDomain, "Query"=>$SeQuery, "Pos"=>(int)$SePos, "Referer"=>$SeReferer ); } function contar_articulo($id) { $link=Conectarse(); $hoy = date("Y-m-d"); $result=mysql_query("SELECT Impresiones AS Imp FROM StArticulos WHERE IDArticulo=$id AND Fecha = '$hoy'",$link); $total=mysql_numrows($result); $rs =mysql_fetch_array($result); if($total!=0) { $imptot = $rs["Imp"] + 1; $sql="UPDATE StArticulos SET Impresiones=$imptot WHERE IDArticulo=$id AND Fecha = '$hoy'"; } else { $sql="INSERT INTO StArticulos(Impresiones, Fecha, IDArticulo) VALUES (1,'$hoy',$id)"; } mysql_query($sql,$link); mysql_free_result($result); } function contar_celebrity($id) { $link=Conectarse(); $hoy = date("Y-m-d"); $result=mysql_query("SELECT Impresiones AS Imp FROM StCelebrities WHERE IDCelebrity=$id AND Fecha = '$hoy'",$link); $total=mysql_numrows($result); $rs =mysql_fetch_array($result); if($total!=0) { $imptot = $rs["Imp"] + 1; $sql="UPDATE StCelebrities SET Impresiones=$imptot WHERE IDCelebrity=$id AND Fecha = '$hoy'"; } else { $sql="INSERT INTO StCelebrities(Impresiones, Fecha, IDCelebrity) VALUES (1,'$hoy',$id)"; } mysql_query($sql,$link); mysql_free_result($result); } function contar_receta($id) { $link=Conectarse(); $hoy = date("Y-m-d"); $result=mysql_query("SELECT Impresiones AS Imp FROM StRecetas WHERE IDReceta=$id AND Fecha = '$hoy'",$link); $total=mysql_numrows($result); $rs =mysql_fetch_array($result); if($total!=0) { $imptot = $rs["Imp"] + 1; $sql="UPDATE StRecetas SET Impresiones=$imptot WHERE IDReceta=$id AND Fecha = '$hoy'"; } else { $sql="INSERT INTO StRecetas(Impresiones, Fecha, IDReceta) VALUES (1,'$hoy',$id)"; } mysql_query($sql,$link); mysql_free_result($result); } function contar_foto($id) { $link=Conectarse(); $hoy = date("Y-m-d"); $result=mysql_query("SELECT Impresiones AS Imp FROM StFotos WHERE IDFoto=$id AND Fecha = '$hoy'",$link); $total=mysql_numrows($result); $rs =mysql_fetch_array($result); if($total!=0) { $imptot = $rs["Imp"] + 1; $sql="UPDATE StFotos SET Impresiones=$imptot WHERE IDFoto=$id AND Fecha = '$hoy'"; } else { $sql="INSERT INTO StFotos(Impresiones, Fecha, IDFoto) VALUES (1,'$hoy',$id)"; } mysql_query($sql,$link); mysql_free_result($result); mysql_query("UPDATE Fotos SET Vis=Vis+1 WHERE ID=$id",$link); } function contar_video($id) { $link=Conectarse(); $hoy = date("Y-m-d"); $result=mysql_query("SELECT Impresiones AS Imp FROM StVideos WHERE IDVideo=$id AND Fecha = '$hoy'",$link); $total=mysql_numrows($result); $rs =mysql_fetch_array($result); if($total!=0) { $imptot = $rs["Imp"] + 1; $sql="UPDATE StVideos SET Impresiones=$imptot WHERE IDVideo=$id AND Fecha = '$hoy'"; } else { $sql="INSERT INTO StVideos(Impresiones, Fecha, IDVideo) VALUES (1,'$hoy',$id)"; } mysql_query($sql,$link); mysql_free_result($result); mysql_query("UPDATE Videos SET TVis=TVis+1 WHERE ID=$id",$link); } function contar_breve($id) { $link=Conectarse(); $hoy = date("Y-m-d"); $result=mysql_query("SELECT Impresiones AS Imp FROM StBreves WHERE IDBreve=$id AND Fecha = '$hoy'",$link); $total=mysql_numrows($result); $rs =mysql_fetch_array($result); if($total!=0) { $imptot = $rs["Imp"] + 1; $sql="UPDATE StBreves SET Impresiones=$imptot WHERE IDBreve=$id AND Fecha = '$hoy'"; } else { $sql="INSERT INTO StBreves (Impresiones, Fecha, IDBreve) VALUES (1,'$hoy',$id)"; } mysql_query($sql,$link); } function fecha_hora($date) { $break = explode(" ", $date); $datebreak = explode("-", $break[0]); $time = explode(":", $break[1]); $dia = $datebreak[2]; $mes = $datebreak[1]; $anio = $datebreak[0]; $minuto = $time[0]; $hora = $time[1]; $diasemana=date("w", mktime(0, 0, 0, $mes, $dia, $anio)); $completa = $dia . "/" . $mes . "/" . $anio." - ". $minuto . ":" . $hora; return $completa; } function fecha_pantalla($date) { $hoy=date("Y-m-d"); $break = explode(" ", $date); $datebreak = explode("-", $break[0]); $time = explode(":", $break[1]); $dia = $datebreak[2]; $mes = $datebreak[1]; $anio = $datebreak[0]; $hora = $time[0]; $minuto = $time[1]; $segundo = $time[2]; $dianum=mktime($hora, $minuto, $segundo, $mes, $dia, $anio); $difd=time()-$dianum; $choy=$anio."-".$mes."-".$dia; $cfecha=$dia."/".$mes."/".$anio. " ".$hora.":".$minuto; $hhora=date("H"); $hminuto=date("i"); $hdia=date("d"); $hmes=date("m"); $hanio=date("Y"); $difdia=$difd/3600; if($difdia<24) { if($difdia<1){ $difmin= ($difd%3600)/60; if($difmin<1){ $dseg=ceil($difd%3600); if($dseg==1) $chora="hace 1 segundo"; else $chora="hace ".$dseg." segundos"; }else{ $dmin=ceil(($difd%3600)/60)-1; if($dmin<=1) $chora="hace 1 minuto"; else $chora="hace ".$dmin." minutos"; } } else { $dhoras=ceil($difd/3600)-1; if($dhoras==1) $chora="hace 1 hora"; else $chora="hace ".$dhoras." horas"; } return $cfecha." (".$chora.")"; } else { return $cfecha; } } function fecha_explode($date){ $break=explode(" ", $fechab); $datebreak=explode("-", $break[0]); $anyo=$datebreak[0]; $mes=$datebreak[1]; $dia=$datebreak[2]; $time=explode(":", $break[1]); $hora=$time[0]; $min=$time[1]; $seg=$time[2]; $fecha_explode=array($anyo, $mes, $dia, $hora, $min, $seg); return $fecha_explode; } function fecha($date) { $break = explode(" ", $date); $datebreak = explode("-", $break[0]); $time = explode(":", $break[1]); $dia = $datebreak[2]; $mes = $datebreak[1]; $anio = $datebreak[0]; $minuto = $time[0]; $hora = $time[1]; $diasemana=date("w", mktime(0, 0, 0, $mes, $dia, $anio)); $completa = Dia($diasemana) . ", " . $dia . " de " . Mes($mes) . " de " . $anio; return $completa; } function Dia($Num) { $Dias=array("domingo","segunda-feira","tera-feira","quarta-feira","quinta-feira","sexta-feira","sbado"); Return "$Dias[$Num]"; } function convertirFechaCorta($date) { $break = explode(" ", $date); $datebreak = explode("-", $break[0]); $time = explode(":", $break[1]); $dia = $datebreak[2]; $mes = $datebreak[1]; $anio = $datebreak[0]; $completa = $dia . "/" . $mes . "/" . $anio; return $completa; } function fecha_home($date) { // break the date and time pieces apart $break = explode(" ", $date); // break the date portion into year, month, and day $datebreak = explode("-", $break[0]); // break the time into hours, minutes, seconds $time = explode(":", $break[1]); // re-assemble the pieces so that they display nicely $dia = $datebreak[2]; $mes = $datebreak[1]; $anio = $datebreak[0]; $minuto = $time[0]; $hora = $time[1]; $fcomp=substr($date,0,10); if($fcomp==date('Y-m-d')) $completa="".$minuto.":".$hora.""; else $completa=$dia."/".$mes; return $completa; } function texturl($text) { $text = trim($text); $text = strtolower($text); $text = str_replace (" ", "-", $text); $text = str_replace ("'", "", $text); $text = str_replace (">", "", $text); $text = str_replace ("<", "", $text); $text = str_replace ("&", "and", $text); $text = str_replace ("and#39s", "", $text); $text = str_replace ("", "a", $text); $text = str_replace ("", "a", $text); $text = str_replace ("", "a", $text); $text = str_replace ("", "a", $text); $text = str_replace ("", "a", $text); $text = str_replace ("", "a", $text); $text = str_replace ("", "a", $text); $text = str_replace ("", "e", $text); $text = str_replace ("", "e", $text); $text = str_replace ("", "e", $text); $text = str_replace ("", "e", $text); $text = str_replace ("", "i", $text); $text = str_replace ("", "i", $text); $text = str_replace ("", "o", $text); $text = str_replace ("", "o", $text); $text = str_replace ("", "o", $text); $text = str_replace ("", "o", $text); $text = str_replace ("", "o", $text); $text = str_replace ("", "o", $text); $text = str_replace ("", "u", $text); $text = str_replace ("", "u", $text); $text = str_replace ("", "u", $text); $text = str_replace ("", "c", $text); $text = str_replace ("*", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("+", "", $text); $text = str_replace ("|", "", $text); $text = str_replace (",", "", $text); $text = str_replace (".", "", $text); $text = str_replace (":", "", $text); $text = str_replace (";", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("!", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("?", "", $text); $text = str_replace ("=", "", $text); $text = str_replace ("", "n", $text); $text = str_replace ("", "n", $text); $text = str_replace ("$", "s", $text); $text = str_replace ("\"", "", $text); $text = str_replace ("\\", "", $text); $text = str_replace ("[", "", $text); $text = str_replace ("]", "", $text); $text = str_replace ("/", "", $text); $text = str_replace ("(", "", $text); $text = str_replace (")", "", $text); $text = str_replace ("%", "", $text); $text = str_replace ("@", "o", $text); $text = str_replace ("", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("`", "", $text); $text = str_replace ("~", "", $text); $text = str_replace ("^", "", $text); $text = str_replace ("'", "", $text); $text = str_replace ("and#39;", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("", "", $text); $text = str_replace ("andquot", "", $text); $text = str_replace ("andquot;", "", $text); $text = str_replace ("#", "", $text); return $text; } function codigo_aleatorio ($minlength, $maxlength, $useupper, $usespecial, $usenumbers) { $charset = "abcdefghijklmnopqrstuvwxyz"; if ($useupper) $charset .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if ($usenumbers) $charset .= "0123456789"; if ($usespecial) $charset .= "~@#$%^*()_+-={}|]["; // Note: using all special characters this reads: "~!@#$%^&*()_+`-={}|\\]?[\":;'><,./"; if ($minlength > $maxlength) $length = mt_rand ($maxlength, $minlength); else $length = mt_rand ($minlength, $maxlength); for ($i=0; $i<$length; $i++) $key .= $charset[(mt_rand(0,(strlen($charset)-1)))]; return $key; } function centenas($int) { if ($int <= 99) { $int = "000"; } else { $int = floor($int/100)."00"; } return $int; } function millares($int) { if ($int <= 999) { $int = "0000"; } else { $int = floor($int/1000)."000"; } return $int; } function my_filesize($file) { if(!is_file($file)) exit("File does not exist!"); $kb = 1024; // Kilobyte $mb = 1024 * $kb; // Megabyte $gb = 1024 * $mb; // Gigabyte $tb = 1024 * $gb; // Terabyte $size = filesize($file); if($size < $kb) { return $size." b"; } else if($size < $mb) { return round($size/$kb,2)." kb"; } else if($size < $gb) { return round($size/$mb,2)." Mb"; } else if($size < $tb) { return round($size/$gb,2)." Gb"; } else { return round($size/$tb,2)." Tb"; } } function tama_mb($int) { $kb = 1024; // Kilobyte $mb = 1024 * $kb; // Megabyte return round($int/$mb,2); } function makedisplayOn($text) { $text = str_replace ("", "œ", $text); $text = trim(t($text)); $text = str_replace (chr(10), "
", $text); $text = str_replace (chr(13), "", $text); $text = str_replace ("[a/]", "", $text); $text = str_replace ("[/a]", "", $text); $text = str_replace ("[i/]", "", $text); $text = str_replace ("[/i]", "", $text); $text = str_replace ("[s/]", "", $text); $text = str_replace ("[/s]", "", $text); $text = str_replace ("[c/]", "", $text); $text = str_replace ("[/c]", "", $text); $text = str_replace ("[d]", "", $text); $text = str_replace ("[/d]", "", $text); $text = preg_replace("/\[img=(.*?)\](.*?)\[\/img\]/is","
\"$1\"
",$text); $text = str_replace ("[img]", "
", $text); $text = preg_replace("/\[imgi=(.*?)\](.*?)\[\/imgi\]/is","
\"$1\"
",$text); $text = str_replace ("[imgi]", "
", $text); $text = preg_replace("/\[imgd=(.*?)\](.*?)\[\/imgd\]/is","
\"$1\"
",$text); $text = str_replace ("[imgd]", "
", $text); $text = str_replace ("[des1]", "
", $text); $text = str_replace ("[/des1]", "
", $text); return $text; } function makedisplayComment($text) { $text = trim(stripslashes($text)); $text = str_replace (":)", ":)", $text); $text = str_replace (";)", ";)", $text); $text = str_replace (" :S", " :S", $text); $text = str_replace (":|", ":|", $text); $text = str_replace (":P", ":P", $text); $text = str_replace (" ;P", " ;P", $text); $text = str_replace (":D", ":D", $text); $text = str_replace ("xD", "xD", $text); $text = str_replace (":(", ":(", $text); $text = str_replace (":'(", ":'(", $text); $text = str_replace (":*", ":*", $text); return $text; } function pagination($act, $ptot, $path) { $resultado=""; $flag=1; if($act!=1) { $ni=$act-1; if($ni==1) { $resultado=$resultado." Anterior"; } else { $resultado=$resultado." Anterior"; } } if($ptot<=15) { for($i=1; $i<=$ptot; $i++) { if($i==$act) { $resultado=$resultado." ".$i.""; } else { if($i==1) { $resultado=$resultado." $i"; } else { $resultado=$resultado." $i"; } } } } else { for($i=1; $i<=$ptot; $i++) { if($i<=4 || $i>=($ptot-3)) { if($i==$act) { $resultado=$resultado." ".$i.""; $flag=1; } else { if($i==1) { $resultado=$resultado." $i"; } else { $resultado=$resultado." $i"; } } } else { if($i>=($act-3) && $i<=($act+3)) { if($i==$act) { $resultado=$resultado." ".$i.""; $flag=1; } else { if($i==1) { $resultado=$resultado." $i"; } else { $resultado=$resultado." $i"; } } } else { if($flag==1) { $resultado=$resultado." []"; $flag=0; } } } } } if($act!=$ptot) { $ni=$act+1; $resultado=$resultado." Siguiente"; } return $resultado; } function pagination_ajax($act, $ptot, $iddiv, $phpinc, $id, $path) { $resultado=""; $flag=1; if($act!=1) { $ni=$act-1; $resultado=$resultado." Anterior"; } if($ptot<=10) { for($i=1; $i<=$ptot; $i++) { if($i==$act) { $resultado=$resultado." ".$i.""; } else { if($i==1) { $resultado=$resultado." $i"; } else { $resultado=$resultado." $i"; } } } } else { for($i=1; $i<=$ptot; $i++) { if($i<=2 || $i>=($ptot-1)) { if($i==$act) { $resultado=$resultado." ".$i.""; $flag=1; } else { if($i==1) { $resultado=$resultado." $i"; } else { $resultado=$resultado." $i"; } } } else { if($i>=($act-1) && $i<=($act+1)) { if($i==$act) { $resultado=$resultado." ".$i.""; $flag=1; } else { if($i==1) { $resultado=$resultado." $i"; } else { $resultado=$resultado." $i"; } } } else { if($flag==1) { $resultado=$resultado." []"; $flag=0; } } } } } if($act!=$ptot) { $ni=$act+1; $resultado=$resultado." Siguiente"; } return $resultado; } function quitarh($mensaje) { $mensaje = str_replace("<","<",$mensaje); $mensaje = str_replace(">",">",$mensaje); $mensaje = str_replace("\'","'",$mensaje); $mensaje = str_replace('\"',""",$mensaje); $mensaje = str_replace("\\\\","\",$mensaje); return $mensaje; } function birthday ($birthday) { list($year,$month,$day) = explode("-",$birthday); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($month_diff < 0) $year_diff--; elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--; return $year_diff; } function deathage ($birthday, $death) { list($year,$month,$day) = explode("-",$birthday); list($yeard,$monthd,$dayd) = explode("-",$death); $year_diff = $yeard - $year; $month_diff = $monthd - $month; $day_diff = $dayd - $day; if ($month_diff < 0) $year_diff--; elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--; return $year_diff; } function dame_pais($id) { $link=Conectarse(); $result=mysql_query("SELECT Nombre FROM Paises WHERE ID=$id",$link); $rs =mysql_fetch_array($result); return t($rs['Nombre']); } function dame_profesion($id, $idg) { $link=Conectarse(); $result=mysql_query("SELECT Profesion, Genero FROM Profesiones WHERE ID=$id",$link); $rs =mysql_fetch_array($result); if($idg==0) return t($rs['Profesion']); else return t($rs['Genero']); } function dame_profesion_url($id) { $link=Conectarse(); $result=mysql_query("SELECT URL FROM Profesiones WHERE ID=$id",$link); $rs =mysql_fetch_array($result); return $rs['URL']; } function contar_articulos_nuevos($date1, $date2){ $link=Conectarse(); $resulta=mysql_query("SELECT Articulos FROM Historico WHERE Fecha LIKE '$date1'", $link); $rsa=mysql_fetch_array($resulta); $tota=$rsa['Articulos']; $resulth=mysql_query("SELECT Articulos FROM Historico WHERE Fecha LIKE '$date2'", $link); $rsh=mysql_fetch_array($resulth); $toth=$rsh['Articulos']; $diff=$toth-$tota; return $diff; } function contar_breves_nuevos($date1, $date2){ $link=Conectarse(); $resulta=mysql_query("SELECT Breves FROM Historico WHERE Fecha LIKE '$date1'", $link); $rsa=mysql_fetch_array($resulta); $tota=$rsa['Breves']; $resulth=mysql_query("SELECT Breves FROM Historico WHERE Fecha LIKE '$date2'", $link); $rsh=mysql_fetch_array($resulth); $toth=$rsh['Breves']; $diff=$toth-$tota; return $diff; } function contar_videos_nuevos($date1, $date2){ $link=Conectarse(); $resulta=mysql_query("SELECT Videos FROM Historico WHERE Fecha LIKE '$date1'", $link); $rsa=mysql_fetch_array($resulta); $tota=$rsa['Videos']; $resulth=mysql_query("SELECT Videos FROM Historico WHERE Fecha LIKE '$date2'", $link); $rsh=mysql_fetch_array($resulth); $toth=$rsh['Videos']; $diff=$toth-$tota; return $diff; } ?>