function ftime($param=null) {
echo date("h.i.s")." ".microtime().$param."
";
}
function getTemplate($tempalte) {
global $paths;
$str = file_get_contents($paths['Common'].'protected/views/'.$tempalte);
return $str;
}
function get_domain(){
return Application::getSiteInstance();
}
function get_domain_params($domain){
global $paths;
$site= Application::getSiteInstance($domain);
if (file_exists($paths['data'].'config/'.$site.'/params.php')){
return $site;
}
else{
if (APP_AMBIENTE=="BACK"){
return get_server();
}else{
header("location: ".Application::$SITE_URL_ADMIN);
die();
}
}
}
function get_domain_url(){
return "http://".$_SERVER['HTTP_HOST'];
}
function get_server(){
return "mundial_rosario3_com";
if($_SERVER["DOCUMENT_ROOT"]=="/Applications/XAMPP/htdocs" ){
return "localhostmac";
}
if($_SERVER["CONTEXT_DOCUMENT_ROOT"]=="/Applications/XAMPP/xamppfiles/htdocs"){
return "localhostmac";
}
elseif($_SERVER["CONTEXT_DOCUMENT_ROOT"]=="C:/xampp/htdocs"){
return "localhost";
}
else{
if( $_SERVER["SERVER_NAME"]=="mundial.rosario3.com"){
return "mundial_rosario3_com";
}
elseif( $_SERVER["SERVER_NAME"]=="www.tiemposur.com.ar" || $_SERVER["SERVER_NAME"]=="tiemposur.com.ar" || $_SERVER["SERVER_NAME"]=="admin.tiemposur.com.ar" ){
return "tiemposur_com_ar_v2";
}
elseif($_SERVER["SERVER_NAME"]=="testing.tiemposur.com.ar" || $_SERVER["SERVER_NAME"]=="testadmin.tiemposur.com.ar" ){
return "testing_tiemposur_com_ar";
}
else{
return "diarios-digitales_com_ar";
}
return "diarios-digitales_com_ar";
}
}
function get_paging_url($pattern, $page){
if (!isset($pattern)) $pattern="javascript:go_page(%p)";
return str_replace("%p",$page,$pattern );
}
function getPagerNew($npage,$AtFirstPage,$AtLastPage,$AbsolutePage,$LastPageNo,$cant_result=CANT_RESULTADOS,$param=""){
$cant_result=10;
//if ($LastPageNo<$cant_result) return;
if ($npage<=($cant_result/2)){
$FirstPage = 1;
$LastPage = $cant_result;
}
else{
$FirstPage = $npage-(($cant_result/2)-1);
$LastPage = $npage+($cant_result/2);
if($LastPage>$LastPageNo){
$FirstPage = $LastPageNo-$cant_result;
$LastPage=$LastPageNo;
}
}
if($LastPage>$LastPageNo){
$LastPage=$LastPageNo;
}
if($FirstPage<1){
$FirstPage=1;
}
if ($param["PAGE_CALL"]==""){
$param["PAGE_CALL"]="go_page";
}
$pager = "
";
return $pager;
}
function getPager($npage,$AtFirstPage,$AtLastPage,$AbsolutePage,$LastPageNo,$cant_result=CANT_RESULTADOS,$param=""){
$cant_result=10;
//if ($LastPageNo<$cant_result) return;
if ($npage<=($cant_result/2)){
$FirstPage = 1;
$LastPage = $cant_result;
}
else{
$FirstPage = $npage-(($cant_result/2)-1);
$LastPage = $npage+($cant_result/2);
if($LastPage>$LastPageNo){
$FirstPage = $LastPageNo-$cant_result;
$LastPage=$LastPageNo;
}
}
if($LastPage>$LastPageNo){
$LastPage=$LastPageNo;
}
if($FirstPage<1){
$FirstPage=1;
}
if ($param["PAGE_CALL"]==""){
$param["PAGE_CALL"]="go_page";
}
$pager = "";
if (!$AtFirstPage) {
//$pager .="
";
//$pager .="
";
$pager .="
";
$pager .="
";
}
if ($LastPage!=1){
for($i=$FirstPage;$i<=$LastPage;$i++) {
if($npage==$i) {
$pager .="
$i";
if ($i<$LastPage){
$pager .="
";
}
}else{
$pager .="
$i";
if ($i<$LastPage){
$pager .="
";
}
}
}
}
if (!$AtLastPage){
$pager .="
";
$pager .="
";
}
else{
$pager .="
";
$pager .="
";
}
$pager .= "
";
return $pager;
}
function filtrar2($page,$sql,$val,$param="",$cant_result=CANT_RESULTADOS) {
//if (APP_AMBIENTE=='FRONT')
if (isset($param["PAGING"]) && $param["PAGING"]==true){
return filtrar2_paging($page,$sql,$val,$param,$cant_result);
}
else{
return filtrar2_all($sql,$val,$cant_result);
}
}
function filtrar2_all($sql,$val,$cant_result=null) {
global $conn;
//echo "filtrar2_all ini ". microtime()."
";
if ($cant_result) $sql.=" limit {$cant_result}";
if ($val==null) $val = array();
$rs = $conn->getArray($sql, $val);
//$rs = $conn->getArray("select 1");
if ($val) $val=implode(",",$val);
//LogActivity::LogUserActivity($sql.$val."\n");
$filtro["element"]=$rs;
//echo "filtrar2_all end ". microtime()."
";
/*if($rs) {
$arrElements=rstToArr($rs);
$filtro["element"]=$arrElements;
return $filtro;
}*/
//var_dump($rs);
return $filtro;
}
function filtrar2_bak_paging($page,$sql,$val,$param="",$cant_result=CANT_RESULTADOS) {
global $ADODB_COUNTRECS;
$ADODB_COUNTRECS=false;
global $conn;
global $p;
$AtLastPage=false;
$AtFirstPage=false;
$pager=null;
if ($page!=""){$npage=$page;}
else{
$npage=$p;
}
if ($npage=="") $npage=1;
//echo $sql;
//var_dump($val);
echo "ex pag end ". microtime()."
";
$link = mysql_connect("marge", "root","");
mysql_select_db("promo_arcor", $link);
$sql="SELECT p.ProductId,p.CatalogId,p.DateCreated,p.VisitNumber,
(select pp.value from cla_product_properties pp where pp.ProductId=(select VALUE from cla_product_properties pp where pp.catalogpropertyId=464 AND pp.ProductId=p.ProductId) AND pp.CatalogPropertyId=452 AND pp.LanguageId=1) SUBASTA,
(select VALUE from cla_product_properties pp where pp.catalogpropertyId=464 AND pp.ProductId=p.ProductId) SUBASTA_ID,
CONCAT((select pp.value from cla_product_properties pp where pp.ProductId=(select VALUE from cla_product_properties pp where pp.catalogpropertyId=463 AND pp.ProductId=p.ProductId) AND pp.CatalogPropertyId=460 AND pp.LanguageId=1) ,' ',(select pp.value from cla_product_properties pp where pp.ProductId=(select VALUE from cla_product_properties pp where pp.catalogpropertyId=463 AND pp.ProductId=p.ProductId) AND pp.CatalogPropertyId=461 AND pp.LanguageId=1) ,' ','') USUARIO,
(select VALUE from cla_product_properties pp where pp.catalogpropertyId=463 AND pp.ProductId=p.ProductId) USUARIO_ID,
(select ROUND(IFNULL(value,0),0) from cla_product_properties pp499 where pp499.catalogpropertyId=499 AND pp499.ProductId=p.ProductId) IMPORTE,
(select pv.VALUE from cla_product_properties pp523 inner join cla_properties_values pv on pv.propertyValueId=pp523.value where pp523.catalogpropertyId=523 AND pp523.ProductId=p.ProductId) ESTADO_OFERTA,
1
from cla_product p
inner join cla_catalog c on c.catalogid=p.catalogid
where c.catalogid='75' AND 1=1
ORDER BY null";
// mysql_query($sql, $link);
//echo "ex pag end ". microtime()."
";
//echo $sql;
$rs = $conn->PageExecute($sql, $cant_result, $npage);
// var_dump($rs->RecordCount() );
// echo "ex pag end ". microtime()."
";
//die();
//LogActivity::LogUserActivity($rs->sql."\n");
$RecordCount=$rs->RecordCount();
if ($npage==""){$npage=1;}
$sql=$sql." LIMIT ".intval(((floatval($npage)-1) * floatval($cant_result))).",$cant_result";
//echo $sql;
$rs = $conn->Execute($sql, $val);
//LogActivity::LogUserActivity($rs->sql."\n");
$LastPageNo=ceil($RecordCount/$cant_result);
//echo "";
$AbsolutePage=$npage;
if ($npage==1){
$AtFirstPage=true;
}
if ($AbsolutePage==$LastPageNo){
$AtLastPage=true;
}
//var_dump($rs->sql);
$page=query_string();
if($rs) {
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
$pager=getPager($npage,$AtFirstPage,$AtLastPage,$AbsolutePage,$LastPageNo,$cant_result);
}
$arrElements=rstToArr($rs);
$filtro["pager"]=$pager;
$filtro["element"]=$arrElements;
//return $arrElements;
return $filtro;
}else return FALSE;
}
function filtrar2_paging($page,$sql,$val,$param="",$cant_result=CANT_RESULTADOS) {
global $conn;
global $p;
$AtLastPage=false;
$AtFirstPage=false;
$pager=null;
if ($page!=""){$npage=$page;}
else{
$npage=$p;
}
//echo $sql;
if ($npage=="") $npage=1;
if ($param["RecordCount"]){
$RecordCount=$param["RecordCount"];
}
else{
$sql_total= $param["sql_cant"];
//$sql_total="select count(*) total ". substr($sql, strpos($sql,"from cla_product p"), strlen($sql));
//var_dump($val);
//echo "1 ". microtime()."
";
$rs = $conn->getArray($sql_total, $val);
//$rs = $conn->getArray("SELECT count(*) total FROM cla_product_properties");
$RecordCount=$rs[0][0];
}
//echo "2 ". microtime()."
";
//die();
//LogActivity::LogUserActivity($rs->sql."\n");
//echo "3 ". microtime()."
";
//echo $RecordCount=$rs->RecordCount();
//echo "4 ". microtime()."
";
if ($npage==""){$npage=1;}
$sql=$sql." LIMIT ".intval(((floatval($npage)-1) * floatval($cant_result))).",$cant_result";
//echo $sql;
$arrElements = $conn->getArray($sql, $val);
$LastPageNo=ceil($RecordCount/$cant_result);
//echo "";
$AbsolutePage=$npage;
if ($npage==1){
$AtFirstPage=true;
}
if ($AbsolutePage==$LastPageNo){
$AtLastPage=true;
}
//var_dump($rs->sql);
$page=query_string();
if($arrElements) {
//if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
if ($LastPageNo!=1 && $LastPageNo!=0 )
$pager=getPagerNew($npage,$AtFirstPage,$AtLastPage,$AbsolutePage,$LastPageNo,$cant_result,$param);
//}
//$arrElements=rstToArr($rs);
$filtro["pager"]=$pager;
$filtro["element"]=$arrElements;
$filtro["data"]["RecordCount"]=$RecordCount;
$filtro["data"]["LastPageNro"]=$LastPageNo;
$filtro["data"]["npage"]=$npage;
//return $arrElements;
return $filtro;
}else return FALSE;
}
function filtrar2_paging_bak($page,$sql,$val,$param="",$cant_result=CANT_RESULTADOS) {
global $conn;
global $p;
$pager=null;
if ($page!=""){$npage=$page;}
else{
$npage=$p;
}
if ($npage=="") $npage=1;
echo $sql;
var_dump($val);
die();
$rs = $conn->PageExecute($sql, $cant_result, $npage,$val);
//echo "ex pag end ". microtime()."
";
//LogActivity::LogUserActivity($rs->sql."\n");
//var_dump($rs);
//die();
if($rs) {
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
$pager=getPager($npage,$rs->AtFirstPage(),$rs->AtLastPage(),$rs->AbsolutePage(),$rs->LastPageNo(),$cant_result,$param);
}
$arrElements=rstToArr($rs);
$filtro["pager"]=$pager;
$filtro["element"]=$arrElements;
//return $arrElements;
return $filtro;
}else return FALSE;
/*$LastPageNo=ceil($RecordCount/$cant_result);
//echo "";
$AbsolutePage=$npage;
if ($npage==1){
$AtFirstPage=true;
}
if ($AbsolutePage==$LastPageNo){
$AtLastPage=true;
}
//var_dump($rs->sql);
$page=query_string();
if($rs) {
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
$pager=getPager($npage,$AtFirstPage,$AtLastPage,$AbsolutePage,$LastPageNo,$cant_result);
}
$arrElements=rstToArr($rs);
$filtro["pager"]=$pager;
$filtro["element"]=$arrElements;
//return $arrElements;
return $filtro;
}else return FALSE;
*/
}
function getCbo_bak($selected=0, $name_cbo, $arrData,$Nombre,$Valor,$otro=NULL,$attr=NULL,$class="caja") {
$strCbo = "";
return $strCbo;
}
//create a Cbo with an array parameter of dim 2
function getCbo($selected=0, $name_cbo, $arrData,$attr=NULL) {
if(count($arrData)>0) {
$strCbo = "";
}else{
$strCbo = "";
}
return $strCbo;
}
function getCboDao($selected="", $name_cbo, $arrData,$Nombre,$Valor,$otro=NULL,$attr=NULL,$class="caja",$first_option=true) {
$strCbo = "";
return $strCbo;
}
function getAdjustedDate( $date_str, $difference_str, $format = 'd/m/Y' )
{
return date( $format, strtotime($difference_str, strtotime($date_str) ) );
}
function getDateFormat( $date_str,$format = 'd/m/Y' )
{
if ($date_str){
return date( $format,strtotime($date_str));
}
else{
return "";
}
}
function getDateTimeFormat( $date_str,$format = 'd/m/Y H:i:s' )
{
if ($date_str){
return date( $format,strtotime($date_str));
}
else{
return "";
}
}
function validString($str) {
if(trim($str)!='') return TRUE;
else return FALSE;
}
function redimImg($image, $newname, $maxw,$width_only=false){ // ****** como parámetros se pasan la imagen original del directorio de imágenes
// ****** y le agregamos algunas letras que la identifiquen como thumbnail
list($width,$height,$otype)=@getimagesize($image);
//Application::debug($width."<".$maxw,true);
if ($width<$maxw){
copy($image,$newname);
return;
}
if ($width_only || $width > $height) {
$newwidth = $maxw;
$newheight = round(($height*$maxw)/$width);
} else {
$newheight = $maxw;
$newwidth = round(($width*$maxw)/$height);
}
switch($otype) {
case 1: $src=imagecreatefromgif($image); break;
case 2: $src=imagecreatefromjpeg($image); break;
case 3: $src=imagecreatefrompng($image); break;
default: echo "Unkown filetype (file $image, typ $otype)"; return;
}
$im = imagecreatetruecolor($newwidth,$newheight);
if ($otype==3){
imagealphablending( $im, false );
imagesavealpha( $im, true );
}
imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
switch($otype) {
case 1: imagegif($im,$newname); break;
case 2: imagejpeg($im,$newname,95); break;
case 3: imagepng($im,$newname); break;
}
imagedestroy($im);
}
function getCboVer3($selected=0, $name_cbo, $arrData,$value_id, $value_name,$attr=NULL) {
//var_dump($arrData);
if(count($arrData)>0) {
$strCbo = "";
}else{
$strCbo = "";
}
return $strCbo;
}
function getCboVer4($selected=0, $name_cbo, $arrData,$attr=NULL) {
if(count($arrData)>0) {
$strCbo = "";
}else{
$strCbo = "";
}
return $strCbo;
}
//con paginado
function filtrar($npage,$sql,$val,$page="",$extraParam="",$ajax=false) {
global $conn;
$rs = $conn->PageExecute($sql, C_RESULT_SEARCH, $npage, $val);
//LogActivity::LogUserActivity($rs->sql."\n");
if($rs) {
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
$tag_title=str_replace(" "," ",$ajax["tag_title"]);
/// INI: PAGING Distinto para iconolab
if (!$rs->AtFirstPage()) {
if($ajax) $strPage .= "AbsolutePage()-1).",'".$ajax["page"]."','".$ajax["div_id"]."','{$tag_title}')>Anterior";
}
else{
$strPage .= "Anterior";
}
for($i=1;$i<=$rs->LastPageNo();$i++) {
if($npage==$i) {
$active=" class=\"Act\" ";
}
else{
$active="";
}
$strPage.="";
}
if (!$rs->AtLastPage()){
if($ajax) $strPage .= "AbsolutePage()+1).",'".$ajax["page"]."','".$ajax["div_id"]."','{$tag_title}')>Siguiente";
}
else{
$strPage .= "Siguiente";
}
/// END: PAGING Distinto para iconolab
$pager = "";
}
$arrElements = NULL;
while(!$rs->EOF) {
$arrElements[] = $rs->fields;
$rs->MoveNext();
}
return array($pager,$arrElements,$strPage);
}else return FALSE;
}
//con paginado
function filtrar_v2($npage,$sql,$val,$page="",$extraParam="",$ajax=false) {
global $conn;
global $p;
$npage=$p;
if ($npage=="") $npage=1;
$rs = $conn->PageExecute($sql, C_RESULT_SEARCH, $npage, $val);
//LogActivity::LogUserActivity($rs->sql."\n");
$page=query_string();
//echo "
".$rs->sql."
";
if($rs) {
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
$pager = "";
}
//var_dump($rs);
$arrElements=rstToArr($rs);
$filtro["pager"]=$pager;
$filtro["element"]=$arrElements;
//return $arrElements;
return $filtro;
}else return FALSE;
}
function query_string(){
$qs="?";
foreach ($_GET as $key=> $value) {
if ($key!="p")
$qs.="$key=$value&";
}
return $qs;
}
//sin paginado
function consultar_nova($sql,$val,$generateArr=FALSE,$dbextra=NULL) {
if($dbextra) $rs = $dbextra->Execute($sql,$val);
else{
global $conn;
$rs = $conn->getArray($sql,$val);
}
return $rs;
}
function consultar_bak($sql,$val,$generateArr=FALSE,$dbextra=NULL) {
if($dbextra) $rs = $dbextra->Execute($sql,$val);
else{
global $conn;
$rs = $conn->Execute($sql,$val);
}
$ret = NULL;
if($rs){
while(!$rs->EOF) {
$ret[] = $rs->fields;
$rs->MoveNext();
}
if(!$generateArr && count($ret)==1) $ret = $ret[0];
return $ret;
}else return FALSE;
}
/*****************************/
/* imagenes */
/*****************************/
// Funciones para genera el thumbnail y la imagen de tama�o normal
function redimImg2($image, $newname, $maxw, $ext){ // ****** como par�metros se pasan la imagen original del directorio de im�genes
list($width,$height,$otype)=@getimagesize($image);
if ($width > $height) {
$newwidth = $maxw;
$newheight = round(($height*$maxw)/$width);
} else {
$newheight = $maxw;
$newwidth = round(($width*$maxw)/$height);
}
switch($otype) {
case 1: $src=imagecreatefromgif($image); break;
case 2: $src=imagecreatefromjpeg($image); break;
case 3: $src=imagecreatefrompng($image); break;
default: echo "Unkown filetype (file $image, typ $otype)"; return;
}
$im = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
switch($otype) {
case 1: imagegif($im,$newname); break;
case 2: imagejpeg($im,$newname,90); break;
case 3: imagepng($im,$newname); break;
}
imagedestroy($im);
}
//create a Cbo with an array parameter of dim 2
function getCboVer2($selected=0, $name_cbo, $arrData,$attr=NULL) {
if(count($arrData)>0) {
$strCbo = "";
}else{
$strCbo = "";
}
return $strCbo;
}
function lineas($str){
return str_replace('\r',chr(13),str_replace('\n',chr(10),$str));
}
//create a Cbo with an array parameter of dim 2
function getCboVer1($selected=0, $name_cbo, $arrData,$attr=NULL) {
if(count($arrData)>0) {
$strCbo = "";
}else{
$strCbo = "";
}
return $strCbo;
}
//create an array from a recordset in ADODB
function rstToArr($rst) {
$arr = NULL;
if ($rst && !$rst->EOF) {
if($rst->RecordCount()>1) {
//more than one element
while (!$rst->EOF) {
$tmp_arr = $rst->FetchObject(FALSE);
foreach($tmp_arr as $k=>$val) {
if(is_string($val)) $tmp_arr->$k = $val; //encode to utf-8
}
$arr[] = ((array)$tmp_arr);
$rst->MoveNext();
}
}else{
//one element
$tmp_arr = $rst->FetchObject(FALSE);
foreach($tmp_arr as $k=>$val) {
if(is_string($val)) $tmp_arr->$k = $val; //encode to utf-8
}
$arr[] = ((array)$tmp_arr);
}
}
return $arr;
}
//create array categories
function generateArrayCategories($modulo_tag) {
global $conn;
//query database
if (CUser::getUserValue("PROFILE_COMPANY")){
$str_inner="INNER JOIN perfil_categorias PC on PC.categoriaId=C.categoriaId and perfilid=".CUser::getSecurityId();
}
$sql = "SELECT C.CategoriaId, C.Nombre, C.Destacado, C.Home FROM categoria C
".$str_inner."
WHERE C.EstadoId = ? AND C.Padre = 0 and C.CategoriaId!=110".CUser::getCompanyFilter("C")."
order by C.orden
";
//echo $sql;
//var_dump(array(ACTIVE));
$rstCat = &$conn->Execute($sql,array(ACTIVE));
$category = rstToArr($rstCat);
$arrCat=NULL;
if ($rstCat->RecordCount()>0) {
foreach($category as $cat) {
$tmp_data=array();
$tmp_data['CategoriaId'] = $cat['CategoriaId'];
$tmp_data['Destacado'] = $cat['Destacado'];
$tmp_data['level'] = 1;
$tmp_data['Home'] = $cat['Home'];
$tmp_data['Nombre'] = $cat['Nombre'];
$tmp_data['CategoriaNombre'] = $cat['Nombre'];
$arrCat[] = $tmp_data;
$sql = "SELECT C.CategoriaId, C.Nombre, C.Destacado, C.Home FROM categoria C
".$str_inner."
WHERE C.EstadoId = ".ACTIVE." AND Padre = ?
order by C.orden
";
//echo $sql;
//var_dump(array($cat['CategoriaId'],userOb::getProfileId()));
$rstSubCat = &$conn->Execute($sql,array($cat['CategoriaId']));
$subcategory = rstToArr($rstSubCat);
if ($rstSubCat->RecordCount()>0)
foreach($subcategory as $subcat) {
$tmp_data=array();
$tmp_data['CategoriaId'] = $subcat['CategoriaId'];
$tmp_data['Nombre'] = ' » '.$subcat['Nombre'];
$tmp_data['CategoriaNombre'] = $subcat['Nombre'];
$tmp_data['level'] = 2;
$tmp_data['Destacado'] = $subcat['Destacado'];
$tmp_data['Home'] = $subcat['Home'];
$arrCat[] = $tmp_data;
}
}
}
return $arrCat;
}
//validate access of user
function validateAccess(){
global $pages_access, $menu_opts_access;
//all menu opts
$continue=TRUE;
foreach($menu_opts_access as $menu=>$hasAccess) {
$pages = $pages_access[$menu];
foreach($pages as $page){
if(strpos($_SERVER['PHP_SELF'],$page)) {
if(!$hasAccess) {
$continue=FALSE;
break;
}
}
}
if($continue==FALSE) break;
}
if(!$continue) header("Location: denied.htm");
}
function array_qsort (&$array, $column, $order='SORT_ASC', $first=0, $last= -2) {
// $array - the array to be sorted
// $column - index (column) on which to sort
// can be a string if using an associative array
// $order - SORT_ASC (default) for ascending or SORT_DESC for descending
// $first - start index (row) for partial array sort
// $last - stop index (row) for partial array sort
// $keys - array of key values for hash array sort
if (is_array($array)) {
$keys = array_keys($array);
if($last == -2) $last = count($array) - 1;
if($last > $first) {
$alpha = $first;
$omega = $last;
$key_alpha = $keys[$alpha];
$key_omega = $keys[$omega];
$guess = $array[$key_alpha][$column];
while($omega >= $alpha) {
if($order == 'SORT_ASC') {
while($array[$key_alpha][$column] < $guess) {$alpha++; $key_alpha = $keys[$alpha]; }
while($array[$key_omega][$column] > $guess) {$omega--; $key_omega = $keys[$omega]; }
} else {
while($array[$key_alpha][$column] > $guess) {$alpha++; $key_alpha = $keys[$alpha]; }
while($array[$key_omega][$column] < $guess) {$omega--; $key_omega = $keys[$omega]; }
}
if($alpha > $omega) break;
$temporary = $array[$key_alpha];
$array[$key_alpha] = $array[$key_omega]; $alpha++;
$key_alpha = $keys[$alpha];
$array[$key_omega] = $temporary; $omega--;
$key_omega = $keys[$omega];
}
array_qsort ($array, $column, $order, $first, $omega);
array_qsort ($array, $column, $order, $alpha, $last);
}
}
return $array;
}
//get mail templates
function get_email_template($tempalte) {
$chars = array("}","{");
$str = utf8_encode(str_replace($chars,"",file_get_contents('templates/mails/'.$tempalte)));
return $str;
}
function php2js($a=false) {
if (is_null($a)) return 'null';
if ($a === false) return 'false';
if ($a === true) return 'true';
if (is_scalar($a)) {
if (is_float($a)) {
// Always use "." for floats.
$a = str_replace(",", ".", strval($a));
}
// All scalars are converted to strings to avoid indeterminism.
// PHP's "1" and 1 are equal for all PHP operators, but
// JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
// we should get the same result in the JS frontend (string).
// Character replacements for JSON.
static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
}
$isList = true;
for ($i = 0, reset($a); $i < count($a); $i++, next($a)) {
if (key($a) !== $i) {
$isList = false;break;
}
}
$result = array();
if ($isList) {
foreach ($a as $v) $result[] = php2js($v);
return '[ ' . join(', ', $result) . ' ]';
}else{
foreach ($a as $k => $v) $result[] = php2js($k).': '.php2js($v);
return '{ ' . join(', ', $result) . ' }';
}
}
/*****************************/
/* imagenes */
/*****************************/
function get_ip(){
if ($_SERVER) {
if ( $_SERVER[HTTP_X_FORWARDED_FOR] ) {
$realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} elseif ( $_SERVER["HTTP_CLIENT_IP"] ) {
$realip = $_SERVER["HTTP_CLIENT_IP"];
} else {
$realip = $_SERVER["REMOTE_ADDR"];
}
} else {
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
$realip = getenv( 'HTTP_X_FORWARDED_FOR' );
} elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
$realip = getenv( 'HTTP_CLIENT_IP' );
} else {
$realip = getenv( 'REMOTE_ADDR' );
}
}
if ($realip=="::1") $realip="127.0.0.1";
return $realip;
}
function myTruncate($string, $limit, $break=".", $pad="...") { // return with no change if string is shorter than $limit
if(strlen($string) <= $limit) return $string; // is $break present between $limit and the end of the string?
if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } return $string;
}
function myTruncate2($string, $limit, $break=" ", $pad="...") { // return with no change if string is shorter than $limit
if(strlen($string) <= $limit) return $string; $string = substr($string, 0, $limit); if(false !== ($breakpoint = strrpos($string, $break))) { $string = substr($string, 0, $breakpoint); } return $string . $pad; }
/** Date Combos **/
function getDayCbo($selected=0,$name_pref) {
$strCbo = "";
return $strCbo;
}
/** Date Combos **/
function getCboDELETED($DELETED="") {
$strCbo = "";
return $strCbo;
}
/** Date Combos **/
function getCboReported($Reported="") {
$strCbo = "";
return $strCbo;
}
function getMonthCbo($selected=0,$name_pref) {
$strCbo = "";
return $strCbo;
}
function getYearCbo($selected=0,$name_pref) {
$strCbo = "";
return $strCbo;
}
//generate the combos option
function getDateCbo($name_pref='',$date=NULL) {
//if previos date selected - parse date
if($date) $date= explode("-", $date);
else $date= array(0,0,0);
$date[0]=intval($date[0]);
$date[1]=intval($date[1]);
$date[2]=intval($date[2]);
return getDayCbo($date[2],$name_pref).getMonthCbo($date[1],$name_pref).getYearCbo($date[0],$name_pref);
}
function getDia($fecha=null){
if ($fecha==null){
$dia=date("N");
}
else{
$dia=date("N",strtotime($fecha));
}
if ($dia==1) $dia="Lunes";
if ($dia==2) $dia="Martes";
if ($dia==3) $dia="Miércoles";
if ($dia==4) $dia="Jueves";
if ($dia==5) $dia="Viernes";
if ($dia==6) $dia="Sabado";
if ($dia==7) $dia="Domingo";
return $dia;
}
function fecha(){
/*OBTENGO LA CADENA QUE REPRESENTA EL DIA PERO EN INGLES*/
$dia=getDia();
/*EL NUMERO DEL DIA*/
$dia2=date("d");
if ($dia2<10){
$dia2=str_replace("0","",$dia2);
}
/*OBTENGO EL STRING DEL MES*/
$mes=date("F");
$mes2=date("m");
if ($mes=="January") $mes="Enero";
if ($mes=="February") $mes="Febrero";
if ($mes=="March") $mes="Marzo";
if ($mes=="April") $mes="Abril";
if ($mes=="May") $mes="Mayo";
if ($mes=="June") $mes="Junio";
if ($mes=="July") $mes="Julio";
if ($mes=="August") $mes="Agosto";
if ($mes=="September")$mes="Setiembre";
if ($mes=="October") $mes="Octubre";
if ($mes=="November") $mes="Noviembre";
if ($mes=="December") $mes="Diciembre";
/*FINALMENTE EL AÑO*/
$ano=date("Y");
/*RETORNAMOS LA FECHA ENTERA*/
$fecha["dia"]=$dia;
$fecha["dia2"]=$dia2;
$fecha["mes"]=$mes;
$fecha["mes2"]=$mes2;
$fecha["ano"]=$ano;
$fecha["hora"]=date("H:i:s");
return $fecha;
}
function getDateConvert( $date_str)
{
$date = explode("/",$date_str);
return $date[2].$date[1].$date[0];
}
function xmlencode($txt){
$txt = str_replace('&','&', $txt);
$txt = str_replace( '<','<', $txt);
$txt = str_replace('>','>;', $txt);
$txt = str_replace("'",''', $txt);
$txt = str_replace('"','"', $txt);
return $txt;
}
function check_email_address($email)
{
// Primero, checamos que solo haya un símbolo @, y que los largos sean correctos
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email))
{
// correo inválido por número incorrecto de caracteres en una parte, o número incorrecto de símbolos @
return false;
}
// se divide en partes para hacerlo más sencillo
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++)
{
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i]))
{
return false;
}
}
// se revisa si el dominio es una IP. Si no, debe ser un nombre de dominio válido
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1]))
{
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2)
{
return false; // No son suficientes partes o secciones para se un dominio
}
for ($i = 0; $i < sizeof($domain_array); $i++)
{
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i]))
{
return false;
}
}
}
return true;
}
function cleanse($string, $allowedTags = array())
{
if (get_magic_quotes_gpc()) {
$string = stripslashes($string);
}
// $string = kses($string, $allowedTags); // For kses {@see http://sourceforge.net/projects/kses/}
// ============
// Remove MS Word Special Characters
// ============
$search = array('–','“','‘','’','£','¬','™');
$replace = array('-','“','‘','’','£','¬','™');
$string = str_replace($search, $replace, $string);
$string = str_replace('â€', '”', $string);
$search = array("'", "\xc3\xa2\xc2\x80\xc2\x99", "\xc3\xa2\xc2\x80\xc2\x93", "\xc3\xa2\xc2\x80\xc2\x9d", "\xc3\xa2\x3f\x3f");
$resplace = array("'", "'", ' - ', '"', "'");
$string = str_replace($search, $replace, $string);
$quotes = array(
"\xC2\xAB" => '"',
"\xC2\xBB" => '"',
"\xE2\x80\x98" => "'",
"\xE2\x80\x99" => "'",
"\xE2\x80\x9A" => "'",
"\xE2\x80\x9B" => "'",
"\xE2\x80\x9C" => '"',
"\xE2\x80\x9D" => '"',
"\xE2\x80\x9E" => '"',
"\xE2\x80\x9F" => '"',
"\xE2\x80\xB9" => "'",
"\xE2\x80\xBA" => "'",
"\xe2\x80\x93" => "-",
"\xc2\xb0" => "°",
"\xc2\xba" => "°",
"\xc3\xb1" => "ñ",
"\x96" => "ñ",
"\xe2\x81\x83" => '•',
"\xd5" => "'"
);
$string = strtr($string, $quotes);
/*
// Use the below to get the byte of the special char and put it in the array above + the replacement.
if (strpos($string, "Live Wave Buoy Data") !== false)
{
for ($i=strpos($string, "Live Wave Buoy Data") ; $i $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
function mqw_iplocation_func($ip) {
$default = 'Buenos Aires';
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost')
$ip = '8.8.8.8';
$curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';
$url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
$ch = curl_init();
$curl_opt = array(
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERAGENT => $curlopt_useragent,
CURLOPT_URL => $url,
CURLOPT_TIMEOUT => 1,
CURLOPT_REFERER => 'http://' . $_SERVER['HTTP_HOST'],
);
curl_setopt_array($ch, $curl_opt);
$content = curl_exec($ch);
if (!is_null($curl_info)) {
$curl_info = curl_getinfo($ch);
}
curl_close($ch);
if ( preg_match('{City : ([^<]*)}i', $content, $regs) ) {
$city = $regs[1];
}
if ( preg_match('{State/Province : ([^<]*)}i', $content, $regs) ) {
$state = $regs[1];
}
if ( preg_match('{Country : ([^<]*)}i', $content, $regs) ) {
$country = $regs[1];
}
if( $city!='' && $state!='' && $country !='' ){
$location = $city . ', ' . $state . ', '. $country;
return $location;
}else{
return $default;
}
}
function array_identical_values( $arrayA , $arrayB ) {
return $arrayA == $arrayB;
}
/**
* Reemplaza todos los acentos por sus equivalentes sin ellos
*
* @param $string
* string la cadena a sanear
*
* @return $string
* string saneada
*/
function sanear_string($string)
{
$string = trim($string);
$string = str_replace(
array('á', 'à', 'ä', 'â', 'ª', 'Á', 'À', 'Â', 'Ä'),
array('a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A'),
$string
);
$string = str_replace(
array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ê', 'Ë'),
array('e', 'e', 'e', 'e', 'E', 'E', 'E', 'E'),
$string
);
$string = str_replace(
array('í', 'ì', 'ï', 'î', 'Í', 'Ì', 'Ï', 'Î'),
array('i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'),
$string
);
$string = str_replace(
array('ó', 'ò', 'ö', 'ô', 'Ó', 'Ò', 'Ö', 'Ô'),
array('o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'),
$string
);
$string = str_replace(
array('ú', 'ù', 'ü', 'û', 'Ú', 'Ù', 'Û', 'Ü'),
array('u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'),
$string
);
$string = str_replace(
array('ñ', 'Ñ', 'ç', 'Ç'),
array('n', 'N', 'c', 'C',),
$string
);
//Esta parte se encarga de eliminar cualquier caracter extraño
$string = str_replace(
array("\\", "¨", "º", "~",
"#", "@", "|", "!", "\"",
"·", "$", "%", "&", "/",
"(", ")", "?", "'", "¡",
"¿", "[", "^", "`", "]",
"+", "}", "{", "¨", "´",
">", "< ", ";", ",", ":",
".", " "),
'',
$string
);
return $string;
}
function sanitize_v2($data, $base = '')
{
return strip_tags($data);
}
function sanitize_v3($data, $base = '')
{
return preg_replace("//s", "", $data);
}
?>
Fatal error: Uncaught Error: Call to undefined function get_server() in /var/www/html/website_ver2/frontend/www/index.php:31
Stack trace:
#0 {main}
thrown in /var/www/html/website_ver2/frontend/www/index.php on line 31