base_Open(); $My_db->base_Query($my_query); ... your code ... $My_db->base_Close(); or $My_db=new base_mysql($DB_HostName, $DB_user, $DB_Password, ""); $My_db->base_Open(); $My_db->base_Select_DB($DB_Name); $My_db->base_Query($my_query); ... your code ... $My_db->base_Select_DB($OtherDB_Name); etc. ********************************************/ class base_mysql { /* public variables*/ /* private variables */ var $_DB_Name; var $_DB_User; var $_DB_Pass; var $_DB_Host; var $_DB_Link; var $_query_ID; var $_row; var $_debug; var $_error_handling; var $_stop_on_error; var $script; /* private constants*/ var $_terminated; /********* CLASS CONSTRUCTOR *********/ function base_mysql ($Host_DB="localhost", $User_DB="", $Pass_DB="",$Name_DB="") { $this->base_Continue(); $this->base_errors(); $this->base_Debug(); $this->_DB_Name = $Name_DB; $this->_DB_User = $User_DB; $this->_DB_Pass = $Pass_DB; $this->_DB_Host = $Host_DB; $this->_DB_link = 0; $this->_query_ID = 0; $this->_terminated = "
!!!SCRIPT TERMINATED CAUSE ERROR!!!"; $this->script = $_SERVER['PHP_SELF']; } /********* SETTINGS *********/ function base_Debug($ON_OFF = False) /* ON_OFF = False - deactivate debug messages. ON_OFF = True - activate debug messages. */ { $this->_debug=$ON_OFF; } function base_errors($ON_OFF = True) /* ON_OFF = False - deactivate error handling. ON_OFF = True - activate error handling. */ { $this->_error_handling=$ON_OFF; } function base_Continue($ON_OFF = True) /* ON_OFF = False - stop script after an error. ON_OFF = True - don't stop script after an error. */ { $this->_stop_on_error = $ON_OFF; } /********* CLASS METHODS *********/ function base_Open() { if ($this->_debug) { echo "
Hostname: $this->_DB_Host
"; echo "User: $this->_DB_User

"; } if (($this->_DB_User=="") && ($this->_DB_Host=="")) {$this->_errors(1);} else { $this->_DB_Link = mysql_connect ($this->_DB_Host, $this->_DB_User, $this->_DB_Pass); if (!$this->_DB_Link) {$this->_errors();} else { if ($this->_debug==True) {echo "
Connection to DB server $this->_DB_Host active.
";} if ($this->_DB_Name!="") {$this->base_Select_DB($this->_DB_Name);} } } } function base_Close() { if ($this->_DB_Link) { if ($this->_debug==True) {echo "
Closing connection to DB server $this->_DB_Host.
";} if (!mysql_close($this->_DB_Link)) $this->_errors(); } } function base_Select_DB ($other_DB_Name="") { if ($other_DB_Name=="") {$this->_errors(2);} else { if ($this->_DB_Link==0) {$this->_errors(4);} else { if (mysql_select_db($other_DB_Name, $this->_DB_Link)) {$this->_DB_Name = $other_DB_Name; if ($this->_debug==True) {echo "
Database $this->_DB_Name selected.
";} } else {$this->_errors();} } } } function base_Get_DB() { /* returns the current selected DB or empty if none */ return $this->_DB_Name; } function base_Get_query_ID() { /* returns the current _query_ID */ return $this->_query_ID; } function base_Query($_sql) { /* execute a query */ if (!$this->_DB_Link) {$this->_errors(4);} else { if ($this->_debug==True) {echo"
Executing query: $_sql.
";} $this->_query_ID = mysql_query ($_sql, $this->_DB_Link); if (!$this->_query_ID) {$this->_errors(); unset ($_sql); return False;} else {unset ($_sql); return True;} } } function base_Last_Insert() { if ($this->_query_ID!=0) { $Number = mysql_insert_id(); if (is_null($Number)){return "NULL";} else {return $Number;} } else { $this->_errors(3); return False; } } function base_Num_Rows() { if ($this->_query_ID!=0) { $Number = mysql_num_rows($this->_query_ID); if (is_null($Number)){return "NULL";} else {return $Number;} } else { $this->_errors(3); return False; } } /* Devuelve el nmero de campos de una consulta */ function base_num_fields() { return mysql_num_fields($this->_query_ID); } function base_Affected_Rows() { if ($this->_DB_Link!=0) { $Number = mysql_affected_rows($this->_DB_Link); if (is_null($Number)){return "NULL";} else {return $Number;} } else { $this->_errors(4); return False; } } function base_Data_Seek($row_number=0) { if ($this->_query_ID!=0) { mysql_data_seek($this->_query_ID,$row_number);} else { $this->_errors(3); return False; } } function base_Fetch_Array() { if ($this->_query_ID!=0) { return mysql_fetch_array($this->_query_ID);} else { $this->_errors(3); return False; } } function base_field_name($id = 0) { return mysql_field_name($this->_query_ID, $id); } function base_Fetch_RArray() { // mostrarmos los registros while ($row = mysql_fetch_row($this->_query_ID)) { echo " \n"; for ($i = 0; $i < $this->base_num_fields(); $i++) { echo "".$row[$i]."\n"; } echo "\n"; } } /********* ERROR HANDLING FUNCTION *********/ function _errors ($int_err=0) {if (!$this->_error_handling) {return False;} else { switch ($int_err) { case 0: /* for My_SQL errors handling */ echo "
Error number: ".mysql_errno()."
"; echo "Error Text: ".mysql_error()."
"; break; case 1: echo "
Please specify User/Host!
"; break; case 2: echo "
Database name not set.
"; break; case 3: echo "
No valid query have been executed.
"; break; case 4: echo "
No DB connection available.
"; break; default: break; } if (!$this->_stop_on_error) die($this->_terminated); } } /********* OTHER FUNCTIONS *********/ function _is_boolean($_to_check) {/* for future use */ if (is_bool($_to_check)) {return True;} else {$this->_errors(4); return False;} } } ?> $regex) { if (preg_match($regex, $URL )) {$url=$dir_old[$k]; break;} /* Compatibilidad del viajo con el nuevo sitio */ } //echo $url; $QueryTD="SELECT * FROM tpaginas WHERE url='$url'"; $QueryK="SELECT * FROM Keywords, rel_pag_key, tpaginas WHERE rel_pag_key.codkey=Keywords.codkey AND rel_pag_key.codidio='$language' AND rel_pag_key.codtpag=tpaginas.codtpag AND tpaginas.url='$url' GROUP BY rel_pag_key.orden ORDER BY rel_pag_key.orden"; } if(isset($QueryTD)) { $Conn_Id->base_Query($QueryTD); $Result = $Conn_Id->base_Fetch_Array(); if (trim($Result["titulo"])!='' ) { $PageTitle = Show_field_text($language, $Result["titulo"], $Conn_Id); $PageDescription = strip_tags (Show_field_text($language, $Result["descripcion"], $Conn_Id)); } /* Keywords */ $Conn_Id->base_Query($QueryK); $KeywordsArray = array(); $j = 0; while($Result = $Conn_Id->base_Fetch_Array()) { if($Result['codidio']==$language || (is_null($Result['codidio']) && $Result['orden']!=$Orden) ) { $Orden = $Result['orden']; $KeywordsArray[$j] = $Result["keyword"]; $j++; } } $PageKeywords = implode(", ", $KeywordsArray); } return array($PageTitle, $PageDescription, $PageKeywords); } /* Camino de Navegaci�n */ function breadcrumb_nav($basename = "Home") { global $LANG,$CONFIG,$TPL_OUT; $LANG['NAVIGATOR'] = array_combine($CONFIG['NAVIGATOR'], $LANG['NAVIGATOR']); $CONFIG['DOMAINST'] = array_flip($CONFIG['DOMAINS']); $site = (isset($_SERVER['HTTP_HOST'])) ? "http://".$_SERVER['HTTP_HOST']."/" : "http://".$CONFIG['DOMAINST']["en_com"]."/"; $return_str = ''.$LANG['TOP_MENU'][0].''; $vd_nolinks = array('','themes', 'destinations', 'brands', 'corporate', 'segments', 'cuba-vacations', 'cuba-travel','cuba-holidays'); $vd_alias_match = array ( '/^\/dining\/([^\n\r]*)$/i', '/^(\/common\/error[^\n\r]*)$/i', '/^\/search-videos(\?q=)[^\n\r]*$/i', '/^\/hotel\/[^\r\n]*\/guest-book[-editon]*\/([^\n\r]*)$/i', '/^\/(hotel)\/[^\n\r]*$/i', '/^\/travel-professionals\/([^\n\r]*)$/i', '/^\/newsletter\/([^\n\r]*)$/i', '/^\/corporate\/survey\/?([^\n\r]*)$/i', '/^\/solwaystravel\/([^\n\r]*)$/i','/^(\/special-offers\/?)$/i'); $vd_alias_result = array ( ' ','/error/', '/', ' ', 'hotels-resorts', ' ', ' ',' ', ' ', '/special-offers/ '); $vd_alias_restore_match = array ( '/^[^\n\r]+\/(hotels-resorts)\/[^\n\r]+$/i'); $vd_alias_restore_result = array ( 'hotel'); $URL = $_SERVER['REQUEST_URI']; foreach( $vd_alias_match as $k => $regex ) { /* Para cambiar un camino ejemplo: hoteles */ if (preg_match($regex, $URL, $coincidencias)) {$URL = str_replace($coincidencias[1], $vd_alias_result[$k], $URL); /* $URL = $vd_alias_result[$k].$coincidencias[1];*/ } } $vdir = explode ('/', $URL); switch ($vdir[1]) { case 'hotel': case 'hotels-resorts': if (isset($_GET['name']) && $_GET['name']!="") { $url =$_GET['name']; fillNavigator("SELECT nomhot AS name, url FROM Hoteles WHERE Hoteles.de_solmelia=1 AND Hoteles.activo=1 AND url='".$url."'", false); } if (isset($_GET['type']) && $_GET['type']!="") { $type =$_GET['type']; if (isset($_GET['id']) && $_GET['id']!="") $url = $_GET['id']; else $url=''; switch ($type) { case 'themes': fillNavigator("SELECT nomseg AS name, url FROM Segmentos WHERE url='".$url."'" ); break; } } break; case 'themes': case 'cuba-vacations': if (isset($_GET['theme']) && $_GET['theme']!="") { $url =$_GET['theme']; fillNavigator("SELECT nomseg AS name, CONCAT(url,'-hotels') AS url FROM Segmentos WHERE url='".$url."'" ); } break; case 'destinations': case 'cuba-travel': if (isset($_GET['destiny']) && $_GET['destiny']!='' && preg_match('/^[a-z-]{1,64}$/i', $_GET['destiny']) ) { $url =$_GET['destiny']; fillNavigator("SELECT nompolo AS name, CONCAT(url,'-hotels') AS url FROM Polos WHERE url='".$url."'", false); } break; case 'brands': case 'cuba-holidays': $url =$_GET['brand']; fillNavigator("SELECT marca AS name, url FROM Marcas WHERE url='".$url."'", false); break; case 'videos': if (isset($_GET['video']) && $_GET['video']!="") { $video=$_GET['video']; fillNavigator("SELECT title AS name, url FROM Videos WHERE url='$video'"); } break; case 'photos': if (isset($_GET['url']) && $_GET['url']!="") { $url =$_GET['url']; fillNavigator("SELECT Polos.nompolo AS name , Hoteles.nomhot AS name, Polos.url, Hoteles.url FROM Polos, Hoteles WHERE (Polos.url='$url') || (Hoteles.de_solmelia=1 AND Hoteles.activo=1 AND Hoteles.url='$url')"); } break; case 'virtual-tours': if (isset($_GET['hotel']) && $_GET['hotel']!="") { $url =$_GET['hotel']; fillNavigator("SELECT nomhot AS name, url FROM Hoteles WHERE Hoteles.de_solmelia=1 AND Hoteles.activo=1 AND url='".$url."'", false); if (isset($_GET['vt']) && $_GET['vt']!="" && preg_match('/^[0-9]{1,3}$/i', $_GET['vt'])) { $cod =$_GET['vt']; fillNavigator("SELECT nomtimg AS name, imgVTour.imagen AS url FROM imgVTour, timgtour, Hoteles WHERE timgtour.codtimg=imgVTour.codtimg AND imgVTour.imagen = $cod AND Hoteles.codhot=imgVTour.codhot AND Hoteles.url='$url'"); } } break; case 'news': if (isset($_GET['url']) && $_GET['url']!="") { $url =$_GET['url']; fillNavigator("SELECT titular AS name, url FROM Noticias WHERE url='".$url."'"); } if (isset($_GET['page']) && $_GET['page']!="" && preg_match('/^[0-9]{1,3}$/i', $_GET['page'])) { $page =$_GET['page']; if (isset($LANG['NAVIGATOR']['page']))$LANG['NAVIGATOR']['page'.$page] = $LANG['NAVIGATOR']['page']. ' '.$page; } break; default: } //print_r($LANG['NAVIGATOR']); $length = count($vdir); if ($vdir[$length-1]=='') { unset($vdir[$length-1]); $length = count($vdir);} if ($length > 1 && $vdir[1] !=''){ for ($i = 1; $i < $length; $i++) { $key = $vdir[$i]; $site .= $key.'/'; foreach( $vd_alias_restore_match as $k => $regex ) { /* Para restaurar un camino ejem: hoteles*/ if (preg_match($regex, $site, $coincidencias)) { $site = str_replace($coincidencias[1], $vd_alias_restore_result[$k], $site); break;} } if (isset($LANG['NAVIGATOR'][$key])) { $name = $LANG['NAVIGATOR'][$key] ; } else { $name = ucfirst(str_replace(array('-','.php'),array(" ", ""), $key)); /* Por defecto, caso extremo */ } if (!in_array($key, $vd_nolinks) && $i < ($length - 1) ) { $return_str .= ' » '.$name.''; /* Con enlace */ } else { $return_str .= ' » '.$name; /* Sin enlace */ } } } return $return_str; } function fillNavigator($query, $translate=true) { global $Conn_Id, $language, $CONFIG, $LANG; $Conn_Id->base_Query($query); while ($Result = $Conn_Id->base_Fetch_Array()) { if ($translate) $LANG['NAVIGATOR'][$Result['url']] = Show_field_text($language, $Result['name'], $Conn_Id); else $LANG['NAVIGATOR'][$Result['url']] = $Result['name']; } } function authenticate($host,$data,$aUser, $aPass) { $sqlStr="select * from visitante where email='$aUser' and passwd='$aPass' and registro='Y'"; if ($idqlg=mysql_db_query($data,$sqlStr)) { if ($resultq=mysql_fetch_array($idqlg)) { $clientId=$resultq["bazarid"]; @setcookie("bazar", $clientId, time() + 15552000); return 1; } else { return 0; } mysql_free_result($idqlg); } else { echo $sqlStr; echo mysql_error(); } return 0; } function CountCat($host, $data, $mCatid) { $sqlStr="select * from stats where catid='" . $mCatid . "'"; $count=0; if ($idqlg=mysql_db_query($data, $sqlStr)) $count=mysql_num_rows($idqlg); else echo mysql_error(); return $count; } function CountVisitors($database) { $timeout=2; $zeit = time(); $ctime = $zeit-($timeout*60); $sqlStr="select * from visitante where online='Y' and checktime>=$ctime"; $mCount=0; echo $slqStr; if ($rsCount=mysql_db_query($database, $sqlStr)) { $mCount+=@mysql_numrows($rsCount); } else { echo $sqlStr; echo mysql_error(); exit; } return $mCount; } function mifecha() { $Dias=Array("0"=>"Domingo", "1"=>"Lunes", "2"=>"Martes", "3"=>"Miercoles", "4"=>"Jueves", "5"=>"Viernes", "6"=>"Sabado"); $Meses=Array("01"=>"Enero", "02"=>"Febrero", "03"=>"Marzo", "04"=>"Abril", "05"=>"Mayo", "06"=>"Junio", "07"=>"Julio", "08"=>"Agosto", "09"=>"Septiembre", "10"=>"Octubre", "11"=>"Noviembre", "12"=>"Diciembre"); Return $Dias[date('w')]. ". " . $Meses[date('m')] . " " . date('d') . ". ". date('Y'); } function mydate() { return date('l, M d, Y'); } function alt_colors($mColor) { if ($mColor==0) { return "#F98F00"; } else { return "#FF9900"; } } function color_degr($color, $degr) { $r=str_pad(dechex((hexdec(substr($color, 1, 2)) & floor(hexdec(substr($color, 1, 2))/100*$degr))), 2, "0", STR_PAD_LEFT); $g=str_pad(dechex((hexdec(substr($color, 3, 2)) & floor(hexdec(substr($color, 3, 2))/100*$degr))), 2, "0", STR_PAD_LEFT); $b=str_pad(dechex((hexdec(substr($color, 5, 2)) & floor(hexdec(substr($color, 5, 2))/100*$degr))), 2, "0", STR_PAD_LEFT); return "#" . $r . $b . $g; } // Conformar la url para el link a reservas de solmelia.com function MakeLink($lang) { if($lang!="es") $lan="en"; else $lan="es"; return $URL_Reserve = "http://www.solmelia.com/sol/clickzru/jsp/clickzru.jsp?idLang=".$lan."&url=http://www.solmelia.com/sol/reservations/jsp/CDisponibilidad.jsp?codigoHotel=";// Se adiciona el codigo del hotel } // Funcion que hace la coneccion con la base de datos function Connect_DB($dbHost, $dbUser, $dbPass, $dbName) { $My_db=new base_mysql($dbHost, $dbUser, $dbPass, $dbName); $My_db->base_Open(); return $My_db; } // Determina el valor del parametro en la queryestrig function Find_Query_Param($param) { $a = split('&', $_SERVER['QUERY_STRING']); $i = 0; while ($i < count($a)) { $b = split('=', $a[$i]); if($b[0]==$param) { return $b[1]; break; } $i++; } } // Funcion que muestra de la base de datos los texto en dependencia del idioma function Show_field_text($lang, $sp_text, $Conn_Id = NULL) { global $CONFIG; $OutText = $sp_text; if ($lang!="es") { $IntConn_Id = Connect_DB($CONFIG['DB_HOST'], $CONFIG['DB_USR'], $CONFIG['DB_PASS'], $CONFIG['DB_NAME']); //** Evitar los mensajes de error $IntConn_Id->base_errors(false); if (!get_magic_quotes_gpc()) { $sp_textSearch = addslashes($sp_text);} /* MGS 30/10/2006*/ //$IntConn_Id->base_Query("UPDATE Traducciones SET smc=1 WHERE (es=\"".$sp_textSearch."\")"); // Ejecutar query si existe la coneccion usando clase $sqlQuery = "select * from Traducciones where Traducciones.es=\"".$sp_textSearch."\""; $IntConn_Id->base_Query($sqlQuery); if($Result=$IntConn_Id->base_Fetch_Array()) { if(!is_null($Result[$lang]) && !$Result[$lang]=='' ) $OutText = $Result[$lang]; } } return ereg_replace("\n", "
",$OutText); } // Funcion que, en dependencia del estado del browser, mustra los objetos del mismo function SwitchBrowser($searcher, $combo, $Browser) { if($Browser!="IE") { if($searcher=="hotels" && $combo=="Ofertas") return "visibility : hidden;"; if($searcher=="offers" && $combo=="Brands") return "visibility : hidden;"; } else { if($searcher=="hotels" && $combo=="Ofertas") return "display : none;"; if($searcher=="offers" && $combo=="Brands") return "display : none;"; } } // Funcion GetFileInfo que recupera informacion de un fichero remoto // Retorna un arreglo asociativo (server, lastmod, size, type) function GetFileInfo($FullPath) { $FileSize = filesize($FullPath) / 1024; return round($FileSize,1)."Kb"; } // Recuperar las n primeras palabras de un parrafo function GetNWords($str, $n) { $j = 0; for($i=0; ($i < strlen($str) && $j < $n); $i++) { if($str[$i]==" ") $j++; } return substr($str,0,$i-1); } // Funcion que dado un char(7) en fomato binario retorna los dias de la semana function GetWeekDays($BinDays, $WeekDays) { global $LANG; $IdDays = ""; // Varificar si son todos los dias de la semana if($BinDays=="1111111") return $LANG['ALL_WEEK']; // Reemplazar los 0 por comos $BinDays = str_replace("0", ",", $BinDays); // Armar una cadena con lo indices que son 1 for($i=0; $i < strlen($BinDays); $i++) { if($BinDays[$i]=='1') $IdDays .= $i; else $IdDays .= $BinDays[$i]; } $Temp = explode(",", $IdDays); // Arreglo con los componentes del resultado final $IdDaysResult = array(); for($i=0; $i < count($Temp); $i++) { if(strlen($Temp[$i]) > 2) $IdDaysResult[$i] = $WeekDays[$Temp[$i][0]].",".$WeekDays[$Temp[$i][strlen($Temp[$i]) - 1]]; //$IdDaysResult[$i] = $WeekDays[$Temp[$i][0]]."-".$WeekDays[$Temp[$i][strlen($Temp[$i]) - 1]]; if(strlen($Temp[$i]) == 2) $IdDaysResult[$i] = $WeekDays[$Temp[$i][0]].",".$WeekDays[$Temp[$i][1]]; if(strlen($Temp[$i]) == 1) $IdDaysResult[$i] = $WeekDays[$Temp[$i]]; } return implode(",", $IdDaysResult); } // Armar la ofertas function SetTitleOffer($Titulo, $Hotel, $Precio, $Moneda) { global $LANG; $OffResult = ""; $AtLang=$LANG['OFFERS_TXT'][0]; $FromL =$LANG['OFFERS_TXT'][1]; //********************************************* if($Titulo!='') $OffResult .= $Titulo; if($Hotel!='') $OffResult .= " ".$AtLang." ".$Hotel.""; if($Precio!='') { // Modificacion del precio en dependencia del idioma if($_SESSION['language']=="es" || $_SESSION['language']=="en" || $_SESSION['language']=="") $Precio .= " ".$Moneda; if($_SESSION['language']=="fr") { $temp = explode(".", $Precio); if($temp[1]=="00") $Precio = $temp[0]; $Precio = str_replace(".", ",", $Precio); $Precio .= " ".$Moneda; } if($_SESSION['language']=="de") { $temp = explode(".", $Precio); if($temp[1]=="00") $Precio = $temp[0].",-"; $Precio = str_replace(".", ",", $Precio); $Precio = $Moneda." ".$Precio; } $OffResult .= ' '.$FromL." ".$Precio.""; } return $OffResult; } function MakeDate($today) { global $Months; $temp = explode(",", $today); settype($temp[1], "integer"); if($_SESSION['language']=="es") $today = $temp[0]." de ".$Months[$temp[1]]. " del ".$temp[2]; if($_SESSION['language']=="en" || !isset($_SESSION['language'])) $today = $Months[$temp[1]]." ".$temp[0].", ".$temp[2]; if($_SESSION['language']=="de") $today = $temp[0].". ".$Months[$temp[1]]." ".$temp[2]; if($_SESSION['language']=="fr") $today = $temp[0]." ".$Months[$temp[1]]." ".$temp[2]; return $today; } function UploadFoto($path,$name,$i) { $result = true; $uploaddir = $path; if (!@move_uploaded_file($_FILES['foto_'.$i]['tmp_name'], $uploaddir.$name)) { $result = false; } return $result; } //Para hacer el resize de las imagenes del guest book function ResizeFoto($path, $Files, $name){ $result = true; $resize = false; $file_path_name = $path.$name; $file_type = $Files['type']; $file_name = $Files['name']; $file_size = $Files['size']; $file_tmp = $file_path_name; ////////////////////////// // CREATE THE THUMBNAIL // ////////////////////////// //keep image type //echo "entra"; if($file_size){ $path_thumbs = $path; //the new width of the resized image, in pixels. $ThumbWidth = 500; $ThumbHeight = 480; if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){// || $file_type == "" $new_img = imagecreatefromjpeg($file_tmp); }elseif($file_type == "image/x-png" || $file_type == "image/png"){ $new_img = imagecreatefrompng($file_tmp); }elseif($file_type == "image/gif"){ $new_img = imagecreatefromgif($file_tmp); } else return 9;//Que la imagen no tiene ninguno de estos tipos requeridos //list the width and height and keep the height ratio. list($width, $height) = getimagesize($file_tmp); $imgratio = $height/$width; if (($width > $height) && ($width > $ThumbWidth)) //landscape Photo { $imgratio = $width/$height; $newwidth = $ThumbWidth; $newheight = abs($newwidth/$imgratio); $resize = true; } else if (($height > $width) && ($height > $ThumbWidth)) //Portrait Photo { $imgratio = $height/$width; $newheight = $ThumbHeight; $newwidth = abs($newheight/$imgratio); $resize = true; } //calculate the image ratio if ($resize == true) { //function for resize image. $resized_img = imagecreatetruecolor($newwidth,$newheight); //the resizing is going on here! imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); //finally, save the image $result = ImageJpeg ($resized_img,$file_path_name);//"$path_thumbs/$rand_name.$file_ext" ImageDestroy ($resized_img); ImageDestroy ($new_img); if($result==false) return 10; } } return $resize; } /* Valida una direccion de correo */ function is_valid_email($email) { return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email); } function selectNumber ($from, $to, $name, $id, $step=1, $pref='', $selected='') { $strSelect = "\n"; return $strSelect; } function hHorario ($name, $id, $selected='') { $strSelect = "\n"; return $strSelect; } function InterVersion() { global $CONFIG; $code=''; return $code; } function convertTxtToURL($string) { $string = strtr($string, "������", "aeioun"); /* Vocales*/ $unPretty = array('/�/','/�/','/�/','/�/','/�/','/�/','/�/','/�/','/�/','/�/','/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/\s?-\s?/', '/\s?_\s?/', '/\s?\/\s?/', '/\s?\\\s?/', '/\s/', '/"/', '/\'/','/�s/','/,/','/;/','/:/','/\./'); $pretty = array('a','e','i','o','u','A','E','I','O','U','ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss', '-', '-', '-', '-', '-', '', '','-is','-','-','-',''); $string = strtolower(preg_replace($unPretty, $pretty, $string)); if (strlen($string) > 256) $text = substr($string, 0, 256); return $string; } function getPrice ($precio,$moneda, $plus=false) { global $CONFIG; $moneda = $_SESSION['CURR_RATE']["CURRENCY"]; $precio = ceil($precio * $_SESSION['CURR_RATE']["RATE"]); if (!$plus) $precio = ereg_replace( "\.00", " ", $precio); switch ($moneda) { case 'EUR': $code = '€ '.$precio; break; default: $code = $precio.' '.$moneda; } return trim($code) ; } function getOffersbyPolo($codpolo=1, $codtofer=2, $limited=true, $limited_number=3) { global $Conn_Id, $CONFIG,$LANG; $Query = "SELECT DISTINCTROW Hoteles.nomhot, Hoteles.codfb, Hoteles.url AS urlhot, Precios.precio, Precios.moneda FROM Ofertas, Hoteles, rel_ofer_hot, Precios, Polos, tofertas, rel_ofer_tofer, titulosOfer where Ofertas.codtitulo=titulosOfer.codtitulo AND Ofertas.codofer=rel_ofer_tofer.codofer AND tofertas.codtofer=rel_ofer_tofer.codtofer AND Hoteles.codhot=rel_ofer_hot.codhot AND Precios.disponible=1 AND ((now() >= Precios.fechaini) AND (Precios.fechafin > now())) AND rel_ofer_hot.codofer=Ofertas.codofer AND (tofertas.codtofer=$codtofer OR tofertas.pertenece_a=$codtofer ) AND Ofertas.codofer=Precios.codofer AND Precios.fechafin>now() AND Hoteles.codpolo=Polos.codpolo AND Precios.disponible=1 "; if(is_array($codpolo)) { $Query .= " AND (" ; $c=0; foreach ($codpolo as $cod){$c++; $Query .= ($c>1?' OR ':'')." Polos.codpolo=$cod"; } $Query .= " ) " ; } else $Query .= " AND Polos.codpolo=$codpolo "; $Query .= " AND Ofertas.activo=1 ORDER BY RAND(), Precios.precio "; if ($limited) $Query .= " LIMIT 0, $limited_number "; $Conn_Id->base_Query($Query); $code=''; return $code; } //Tracking Code function getTrackingCode () { $tracking = ""; $vparams = explode ('/', $_SERVER['REQUEST_URI']); switch ($vparams[1]) { case 'hotel': $tracking = "QSHOTELS"; break; case 'hotels-resorts': $tracking = "QSRESORTS"; break; case 'themes': $tracking = "QSTHEMES"; break; case 'destinations': $tracking = "QSDESTS"; break; case 'brands': $tracking = "QSBRANDS"; break; case 'special-offers': $tracking = "QSOFFERS"; break; default: $tracking = "QSHOME"; break; } return $tracking; } // function hasHTMLTags($s) { if (preg_match('/(<\/?[^>]+>)|(http:\/\/)/', $s)) return true; return false; } function hasSpamWords ($s) { if (preg_match('/[bcdfghjklmopqrstvwxyz]{4,}|[aeiou]{10,}|paranoia|incoherently|convulsional|raptus|dismalness|vaporescent|clam|myalism\s+yxpme|xeeyllc-online|4u|adipex|advicer|baccarrat|blackjack|bllogspot|booker|byob|car-rental-e-site|car-rentals-e-site|carisoprodol|casino|casinos|chatroom|cialis|coolcoolhu|coolhu|credit-card-debt|credit-report-4u|cwas|cyclen|cyclobenzaprine|dating-e-site|day-trading|debt-consolidation|debt-consolidation-consultant|discreetordering|duty-free|dutyfree|equityloans|fioricet|flowers-leading-site|freenet-shopping|freenet|gambling-|hair-loss|health-insurance|deals-4u|homeequityloans|homefinance|holdem|holdempoker|holdemsoftware|holdemtexasturbowilson|hotel-dealse-site|hotele-site|hotelse-site|incest|insurance-quotesdeals-4u|insurancedeals-4u|jrcreations|levitra|macinstruct|mortgage-4-u|mortgagequotes|online-gambling|onlinegambling-4u|ottawavalleyag|ownsthis|palm-texas-holdem-game|paxil|penis|pharmacy|phentermine|poker-chip|poze|pussy|rental-car-e-site|ringtones|roulette|shemale|shoes|slot-machine|texas-holdem|thorcarlson|top-site|top-e-site|tramadol|trim-spa|ultram|valeofglamorganconservatives|viagra|vioxx|xanax|zolus|http:\/\/azhaxzi.com|rilyvfr|wrehbel|http:\/\/emvdams\.com|pzzanwi|yihh|http:\/\/anprusscah\.com|jivryo|tjdqlb|http:\/\/lrqswxuimpmo\.com/', $s)) return true; return false; } //Cragar las tarifas del XE function load_XE_rates ($curr, $curdate) { global $CONFIG; if ($curr == $CONFIG['BASE_CURR']) return 1; $archivo_XML = file_get_contents ("http://".$CONFIG['URL_SMC']."/XE/XE-rates.xml"); if ($archivo_XML == false) return -1; if (!empty($archivo_XML)){ preg_match("|(.*)|s", $archivo_XML, $name); $date = substr($name[1],0,10); if ($curdate == $date) { //$_SESSION['CURR_RATE']["DATE"] = $date; preg_match_all("|(.*)|sU", $archivo_XML, $items); foreach ($items[1] as $key => $item) { preg_match("|(.*)|s", $item, $name); if ($name[1] == $curr) { preg_match("|(.*)|s", $item, $value); return $value[1]; } } } } return -1; } /* Spiderable slides */ function getSlidesHTML ($slides) { $code=""; $c=0; global $CONFIG, $Conn_Id, $LANG; $hide ='style="display:none" '; foreach ($slides->slide as $k => $slide) { switch ($slide['type']) { case 'image': if (isset($slide['href']) && $slide['href']!="") { $code.=''.utf8_decode($slide['alt']).''; } break; } } return $code.getSlidesJS($slides); } /* Full HTML for ajax call */ function getSlidesAjax($slides) { $code=""; $c=0; global $CONFIG, $Conn_Id, $LANG; foreach ($slides->slide as $k => $slide) { $c++; if ($c >1) $hide ='style="display:none" '; else $hide=''; switch ($slide['type']) { case 'html': include_once($slide['src']); $code='
'.$slide_html.'
'.$code; break; case 'flash': $code='
'; break; case 'image': default: $onclick = ""; if (isset($slide['onClick']) && $slide['onClick']!="") { $onclick =" onClick=\"$slide[onClick]\""; } if (isset($slide['href']) && $slide['href']!="") { if (preg_match('/http:\/\//i', $slide['href'] )) $target =' target="_blank"'; else $target =''; $code=''.utf8_decode($slide['alt']).''.$code; /* Para invertir el orden */ } else { $code=''.$slide['alt'].''.$code; /* Para invertir el orden */ } break; } } return $code; } function getVideos($sqlVideo) { global $CONFIG, $Conn_Id, $LANG, $language, $video_id_play; $Conn_Id->base_Query($sqlVideo); $code=''; $i=0; $addclass=''; $page_title=''; while($Result=$Conn_Id->base_Fetch_Array()) { $i++; $titular = Show_field_text($language, $Result['title'], $Conn_Id); if (isset($video_id_play) && $video_id_play == $Result['video_id']) { $addclass='video-active'; } else $addclass=''; if ($i==1) $addclass.=' first'; else $addclass=''; $url = '/videos/'.$Result['url']; $code.='

'.$titular.'

'.date("i:s", $Result['length_seconds']).'
'.$Result['view_count'].'
'; } return $code; } /* Full HTML slide Javascript */ function getSlidesJS($slides) { $code = getSlidesAjax($slides); if (!get_magic_quotes_gpc()) $code = addslashes($code); return ''; } function getLinksList($name='hotel') { global $Conn_Id, $CONFIG,$LANG, $language; $prefix=$sufix=''; $Query= false; $translate_name = true; switch ($name) { case 'hotel': $Query = "SELECT DISTINCTROW Hoteles.nomhot AS name, CONCAT('cuba-hotel/', Hoteles.url,'/' ) AS url FROM Hoteles, Marcas WHERE Marcas.codmarca=Hoteles.codmarca AND Hoteles.activo =1 AND Hoteles.de_solmelia =1 ORDER BY Marcas.orden, Hoteles.orden "; $prefix ='Hotel '; $translate_name = false; break; case 'destination': $Query = "SELECT DISTINCTROW Polos.nompolo AS name, CONCAT('cuba-travel/', Polos.url,'-hotels' ) AS url FROM Polos WHERE Polos.de_solmelia =1 AND Polos.codpolo <>9 ORDER BY Polos.orden "; $sufix = array('es'=>'', 'en'=>'Hotels', 'fr'=>'', 'de'=>''); $prefix = array('es'=>'Hoteles en ', 'en'=>'', 'fr'=>'Hôtels', 'de'=>'Hotels'); break; case 'theme': $Query = "SELECT Segmentos.nomseg AS name, CONCAT('cuba-vacations/', Segmentos.url ,'-hotels' ) AS url FROM Segmentos WHERE Segmentos.activo=1 "; $sufix = array('es'=>'', 'en'=>'Hotels', 'fr'=>'', 'de'=>''); $prefix = array('es'=>'Hoteles de', 'en'=>'', 'fr'=>'Hôtels', 'de'=>'Hotels'); break; case 'tv': $menu_items =array ( "/videos/"=> $LANG["MEDIA_TITLES"][3] , "/photos/"=>$LANG["MEDIA_TITLES"][1] , "/virtual-tours/"=> $LANG["MEDIA_TITLES"][4] , "/news/"=>$LANG["MEDIA_TITLES"][0] ); $sufix = array('es'=>'de Hoteles', 'en'=>'', 'fr'=>'', 'de'=>''); $prefix = array('es'=>'', 'en'=>'Hotel', 'fr'=>'Hôtel', 'de'=>'Hotel'); break; } if (is_array($prefix)) $prefix = utf8_decode($prefix[$_SESSION['language']].' '); if (is_array($sufix)) $sufix = ' '.$sufix[$_SESSION['language']]; $code=''; return $code; } /** * Truncates +text+ to the length of +length+ and replaces the last three characters with the +truncate_string+ * if the +text+ is longer than +length+. */ function truncate_text($text, $length = 30, $truncate_string = '...', $truncate_lastspace = false) { if ($text == '') { return ''; } if (strlen($text) > $length) { $truncate_text = substr($text, 0, $length - strlen($truncate_string)); if ($truncate_lastspace) { $truncate_text = preg_replace('/\s+?(\S+)?$/', '', $truncate_text); } return $truncate_text.$truncate_string; } else { return $text; } } function truncate_text_more($text, $length = 35) { if ($text == '') { return ''; } if (strlen($text) > $length) { $text = strip_tags( $text); $truncate_text = substr($text, 0, $length).'...'; return $truncate_text; } else { return $text; } } function showHotelColumns1($Query, $addUrl="/",$textOpt='') //en un futuro tomar como parametro el No. de columnas { global $Conn_Id; global $TmpConn_Id; global $LANG; global $CONFIG; $Conn_Id->base_Query($Query); $i=0; $language =$_SESSION['language']; $video_language =($language=='es')?$language:'en'; $video_language_other = $video_language=='es'?'en':'es'; $code='
'; $j=1; $total=$Conn_Id->base_Num_Rows(); while($Result=$Conn_Id->base_Fetch_Array()) { $hint = $textOpt.'Hotel '.$Result["estrellas"]." ".$LANG['STARS']." ".$Result["nomhot"]; $nomPolo = Show_field_text($language, $Result['nompolo'], $TmpConn_Id); if ($i==0 && $code!='
') $code .='
'; if ($i==0) $code .='
'; $code.='
'; $code.='
'; $code.=''.$hint.''; $code.='

'.$Result['nomhot'].'

'; $code.=''; $code.= str_repeat('*',$Result['estrellas']); $code.=''; $code.=$nomPolo.', '; if ($Result['allincl']=='1') $code.=$LANG['ACTIVITIES'][7]; else $code.=$LANG['CITY_HOTEL']; $code.='

'.truncate_text_more(Show_field_text($language, $Result['descripcion1'], $TmpConn_Id), 100).'

'; $code.='
'; $code.='
'; if ($language=="de") {$LANG["SEE_ALL"][4] = "Fotos";} $code.="".$LANG["SEE_ALL"][4].""; $sqlVideo = "SELECT DISTINCTROW Videos.* FROM rel_hot_fich, Ficheros, Hoteles, Idiomas , Videos WHERE Ficheros.codfich = Videos.codfich AND rel_hot_fich.codhot = Hoteles.codhot AND Ficheros.codfich = rel_hot_fich.codfich AND Ficheros.codtfich = 18 AND Videos.language=Idiomas.codidio AND Hoteles.codhot = ".$Result['codhot']." ORDER BY field(language, '$video_language', '$video_language_other')"; $TmpConn_Id->base_Query($sqlVideo); if ($row_video=$TmpConn_Id->base_Fetch_Array()) $url_video = $row_video['url']; else $url_video=''; $code.=" ".$LANG["SEE_ALL"][5].""; $code.=''.$LANG['OFFERS_TXT'][1].' '.getPrice ($Result['precio'],$Result['moneda']).''; $code.="".$LANG['CRS'][6].""; $code.='
'; $i=1-$i; $j++; } $code.='
'; return $code; } ?>