$v) if (is_array($v)) $array[$k]=del_magic_quotes($v); else $array[$k]=stripslashes($v); return $array; } if (get_magic_quotes_gpc()) { $_GET = del_magic_quotes($_GET); $_POST = del_magic_quotes($_POST); $_COOKIE = del_magic_quotes($_COOKIE); } if (count($_GET)==1 and $_GET["get"]) { $get=urldecode($_GET["get"]); $get=explode("&", $get); $_GET=array(); foreach ($get as $val) { list($key, $val)=explode("=", $val); $_GET[$key]=$val; } } include LOC_BASE."config/config_general.php"; if (count($the_languages)==1) { $the_language=$the_default_language; unset($_GET[$var_GET_language]); } else { if ($_POST[$var_GET_language]) { $the_language=$_POST[$var_GET_language]; $_GET[$var_GET_language]=$the_language; } else $the_language=$_GET[$var_GET_language]; if (!$the_language) { $browser_languages=explode(",", getenv("HTTP_ACCEPT_LANGUAGE")); foreach ($browser_languages as $lang) { $lang=preg_replace("/(\w+).*/i", "\\1", $lang); if (isset($the_rel_languages)) if (array_key_exists($lang, $the_rel_languages)) $lang=$the_rel_languages[$lang]; if (file_exists(LOC_BASE.$LOC_lang."txt_idioma_$lang.inc") and array_key_exists($lang, $the_languages)) { $the_language=$lang; break; } } if (!$the_language) $the_language=$the_default_language; $_GET[$var_GET_language]=$the_language; $exist_GET_lang=false; } else { if (!array_key_exists($the_language, $the_languages)) { $the_language=$the_default_language; $_GET[$var_GET_language]=$the_language; } $exist_GET_lang=true; } } if (!$_GET[$var_GET_sections] or !isset($_GET[$var_GET_sections])) $_GET[$var_GET_sections]=$SECCIO_per_defecte; $SECCIO_ACTUAL=((isset($_GET[$var_GET_sections])) ? $_GET[$var_GET_sections] : $SECCIO_per_defecte); if (!isset($SECCIO[$SECCIO_ACTUAL])) { $SECCIO_ACTUAL=$SECCIO_per_defecte; $_GET[$var_GET_sections]=$SECCIO_per_defecte; } $dir_arxiu=LOC_BASE.$SECCIO[$SECCIO_ACTUAL][0]."/".$SECCIO[$SECCIO_ACTUAL][1]; $NOM_SECCIO=$SECCIO[$SECCIO_ACTUAL]["nom"]; if (!file_exists($dir_arxiu)) $SECCIO_ACTUAL=$SECCIO_per_defecte; if (is_array($SECCIO[$SECCIO_ACTUAL]["subseccio"])) { $ID_SUB_SECCIO=((!$_GET[$var_GET_subsection]) ? key($SECCIO[$SECCIO_ACTUAL]["subseccio"]) : $_GET[$var_GET_subsection]); $_GET[$var_GET_subsection]=$ID_SUB_SECCIO; $SUB_SECCIO=$SECCIO[$SECCIO_ACTUAL]["subseccio"][$ID_SUB_SECCIO]; $NOM_SUB_SECCIO=$SUB_SECCIO["nom"]; } else $ID_SUB_SECCIO=0; if ($_GET[$var_GET_sections]==$SECCIO_per_defecte) unset($_GET[$var_GET_sections]); if ($_GET[$var_GET_subsection]=="index") unset($_GET[$var_GET_subsection]); if ($SUB_SECCIO["DEBBUG"]) $DEBBUGER=$SUB_SECCIO["DEBBUG"]; else $DEBBUGER=((array_key_exists("DEBBUG", $SECCIO[$SECCIO_ACTUAL])) ? $SECCIO[$SECCIO_ACTUAL]["DEBBUG"] : $DEBBUGER); define("DEBBUGER", $DEBBUGER); include $LOC_funcions.'generals/funcions_catxe.inc'; if (!(strpos($SECCIO[$SECCIO_ACTUAL][2], "sess") === false)) { session_name(SESSION_USERS); session_start(); if ($_GET['login']=="logout" and $_SESSION["login"]) { $_SESSION=array(); unset($_GET['login']); $_SERVER["REQUEST_URI"] = preg_replace("/(&login=logout|login=logout)/", "", $_SERVER["REQUEST_URI"]); } clear_session(); if (count($_SESSION)) $ACTIVE_SESSION=true; else $ACTIVE_SESSION=false; } else if (!(strpos($SECCIO[$SECCIO_ACTUAL][2], "reg") === false)) $ACTIVE_SESSION=true; else $ACTIVE_SESSION=false; if ($_GET["cache"]=="flush") { set_time_limit(0); refresca_catxe("clear"); } else if ($_GET["cache"]=="refresh") refresca_catxe(); if ($_GET["cache"]) unset($_GET["cache"]); $CATXE_ACTIVA=false; $RENOVAR_CATXE=false; $CATXE_PERIOD=((isset($SECCIO[$SECCIO_ACTUAL]["subseccio"][$ID_SUB_SECCIO]["catxe"])) ? $SECCIO[$SECCIO_ACTUAL]["subseccio"][$ID_SUB_SECCIO]["catxe"] : ((isset($SECCIO[$SECCIO_ACTUAL]["catxe"])) ? $SECCIO[$SECCIO_ACTUAL]["catxe"] : false)); $CATXE_MODE=((isset($SECCIO[$SECCIO_ACTUAL]["subseccio"][$ID_SUB_SECCIO]["catxe_mode"])) ? $SECCIO[$SECCIO_ACTUAL]["subseccio"][$ID_SUB_SECCIO]["catxe_mode"] : ((isset($SECCIO[$SECCIO_ACTUAL]["catxe_mode"])) ? $SECCIO[$SECCIO_ACTUAL]["catxe_mode"] : "forced")); if ($CATXE_PERIOD and DEBBUGER<2 and ACTIVE_CACHE==true and !$ACTIVE_SESSION) { $CATXE_ACTIVA=true; $CATXE_NOM_REF="{$SECCIO_ACTUAL}_{$ID_SUB_SECCIO}"; $RENOVAR_CATXE=comprova_caducitat_catxe($CATXE_NOM_REF, $CATXE_MODE, "pages", $CATXE_PERIOD); } if (!$CATXE_ACTIVA or $RENOVAR_CATXE) { $FCONF_dir_lib = $LOC_funcions.'generals/'; include $FCONF_dir_lib.'funcions.inc'; if (DB_NAME) { $DB_GENERAL=false; $USE_DB=true; if (strpos($SECCIO[$SECCIO_ACTUAL]["subseccio"][$ID_SUB_SECCIO][2], "no-DB") === false) { $DB_general = new DB_general(); if ($DB_general->connect()) { if (defined("DB_ENCODING_NAMES")) { $sql="SET NAMES ".DB_ENCODING_NAMES.";"; $DB_general->query($sql); } $COUNT_QUERY=array(); $DB_GENERAL=true; if (DEBBUGER) { $sql="SHOW PRIVILEGES"; $DB_general->query($sql); if ($DB_general->num_rows()) { $flag_priv=0; while ($DB_general->next_record()) { $priv=$DB_general->f("Privilege"); if ($priv=="Select" or $priv=="Insert" or $priv=="Update") $flag_priv++; } if ($flag_priv<3) echo "[DEBBUGER] No hi ha suficients privilegis d'usuari per a la BD!
\n"; } } } } else $USE_DB=false; } if (!$DB_GENERAL and DB_NAME and $USE_DB==true) { $SECCIO_ACTUAL=$SECCIO_de_manteniment; $_GET[$var_GET_sections]=$SECCIO_ACTUAL; $NOM_SECCIO=$SECCIO[$SECCIO_ACTUAL]["nom"]; $ID_SUB_SECCIO=0; unset($_GET[$var_GET_subsection]); $RENOVAR_CATXE=false; $CATXE_ACTIVA=false; } if ( !(strpos($SECCIO[$SECCIO_ACTUAL][2], "plt") === false) ) { include $LOC_funcions.'smarty/Smarty.class.php'; $smarty = new Smarty(); $smarty->template_dir = LOC_BASE.'tpl'; $smarty->compile_dir = LOC_BASE.'/tpl/tpl_c'; $smarty->register_function("lang", "tradueix_smarty"); $smarty->register_function("lang_doc", "tradueix_docs_smarty"); $smarty->register_function("html", "htmlentities_smarty"); $smarty->register_function("imagesize", "getimagesize_smarty"); $smarty->register_function("image", "createimage_smarty"); $smarty->register_function("email", "email_smarty"); $smarty->register_function("posa_vars", "posa_variables"); $smarty->register_function("creaGet", "crea_GET_smarty"); $variables = array ( "URL_BASE"=>URL_BASE, "URL_GET"=>$QUERY_STRING, "URL_GET_FORM"=>creaGet(array("login", "pass")), "URL_grafics"=>$LOC_grafics, "URL_grafics_admin"=>$URL_grafics_admin, "WEB_TITLE"=>TITOL_WEB, "HEAD"=>array( "SHORTCUT_ICON"=>$ICONA_WEB, "TITLE"=>lang($NOM_SECCIO).(($NOM_SUB_SECCIO) ? " - ".lang($NOM_SUB_SECCIO) : ""), "CREDITS"=>CREDITS_WEB, "DESCRIPTION"=>$HEAD_DESCRIPTION, "HEAD_ENCODE_WEB"=>((defined("HEAD_ENCODE_WEB")) ? HEAD_ENCODE_WEB : "iso-8859-1"), "META"=>$HEAD_META, "FOCUS"=>ONLOAD_FOCUS, "CSS"=>(($SUB_SECCIO["css"]) ? $CSS[$SUB_SECCIO["css"]] : $CSS[$SECCIO[$SECCIO_ACTUAL]["css"]]), "JAVASCRIPT"=>(($SUB_SECCIO["javascript"]) ? $JAVASCRIPT[$SUB_SECCIO["javascript"]] : $JAVASCRIPT[$SECCIO[$SECCIO_ACTUAL]["javascript"]]), "LINK"=>$HEAD_LINK, "ROBOTS"=>(($SUB_SECCIO["robots"]) ? $SUB_SECCIO["robots"] : $SECCIO[$SECCIO_ACTUAL]["robots"]), "CACHE"=>(($RENOVAR_CATXE) ? false : true) ), "ADMIN_ACCES_LEVELS_KEYS"=>$ADMIN_ACCES_LEVELS_KEYS_SECTIONS, "ADMIN_MANAGE_TEAM"=>$ADMIN_MANAGE_TEAM, "FORMS_LOCKED"=>FORMS_LOCKED, "DIR_IMAGES"=>$LOC_grafics, "GET_LANG"=>"i=".$the_language, "VAR_GET_PAGINATION"=>$var_GET_pagination, "LANGUAGE"=>$the_language, "LANGUAGES"=>$the_languages, "EXIST_GET_LANG"=>$exist_GET_lang, "SECCIONS"=>$SECCIO, "subseccions"=>$SECCIO[$SECCIO_ACTUAL]["subseccio"], "seccio_actual"=>$SECCIO[$SECCIO_ACTUAL]["pare"], "seccio_get_actual"=>$SECCIO_ACTUAL, "seccio_per_defecte"=>$SECCIO_per_defecte, "subseccio_actual"=>$ID_SUB_SECCIO, "nom_seccio"=>$NOM_SECCIO, "nom_subseccio"=>$NOM_SUB_SECCIO, "nom_seccio_pare"=>$SECCIO[$SECCIO[$SECCIO_ACTUAL]["pare"]]["nom"], "LOC_TPL_GENERALS"=>$LOC_plantilles_generals, "LOC_TPL_ADMIN"=>$LOC_plantilles_admin, "LOC_TPL_FORMS"=>$LOC_plantilles_forms ); if (is_array($PLANTILLES_SET_VARIABLES)) if (count($PLANTILLES_SET_VARIABLES)) foreach ($PLANTILLES_SET_VARIABLES as $key=>$val) if (is_array($val)) $variables[$key]=$val; else $variables[$key]=${$val}; foreach ($variables as $key=>$value) $smarty->assign($key, $value); if ((!(strpos($SECCIO[$SECCIO_ACTUAL][2], "reg") === false) or (isset($_POST["login"]))) and $DB_GENERAL) { include LOC_BASE."inc/control_registre.inc"; if ($CATXE_ACTIVA) $RENOVAR_CATXE=true; } } if (!(strpos($SECCIO[$SECCIO_ACTUAL][2], "form") === false)) { include $LOC_funcions.'phpdbform/config_phpbdform.php'; if (DEBBUGER and !$DB_GENERAL) echo "[DEBBUGER] Avís crític: S'han demanat les funcions de formulari sense tindre assignada una ". "Base de Dades.
\n"; } } if ($SECCIO[$SECCIO_ACTUAL][0]=="tpl") if ($RENOVAR_CATXE) echo display_Smarty_cache ($SECCIO[$SECCIO_ACTUAL][1], $CATXE_NOM_REF, "forced", "pages"); else $smarty->display($SECCIO[$SECCIO_ACTUAL][1]); else { if ($RENOVAR_CATXE) { ob_start(); include LOC_BASE.$SECCIO[$SECCIO_ACTUAL][0]."/".$SECCIO[$SECCIO_ACTUAL][1]; $HTML=ob_get_contents(); ob_get_clean(); generate_HTML_cache($HTML, $CATXE_NOM_REF, $CATXE_MODE, "pages"); } else if ($CATXE_ACTIVA) { recover_cache($CATXE_NOM_REF, $CATXE_MODE, "pages", 1); if (DEBBUGER) echo "[DEBBUGER] Recuperat arxiu de catxé
\n"; } else include LOC_BASE.$SECCIO[$SECCIO_ACTUAL][0]."/".$SECCIO[$SECCIO_ACTUAL][1]; } if (DEBBUGER) { $DEBBUGER_contFiTemps=microtime(); echo "[DEBBUGER] Temps d'execució:". number_format(substr($DEBBUGER_contFiTemps,0,9)+substr($DEBBUGER_contFiTemps,-10)- substr($DEBBUGER_contTemps,0,9)-substr($DEBBUGER_contTemps,-10), 4)."
\n". "[DEBBUGER] SQL's demanades a la BD: ".count($COUNT_QUERY)."
\n"; if (is_Array($_SESSION)) { echo "[DEBBUGER] Activada sessió d'usuari '".SESSION_USERS."'
\n"; if (!count($_SESSION)) echo "[DEBBUGER] La sessió d'usuari està buida
\n"; } if (!is_writable(LOC_BASE.$LOC_catxe) and $LOC_catxe) echo "[DEBBUGER] ALERTA! sense permís d'escriptura a la carpeta $LOC_catxe
\n"; if (!is_writable($LOC_funcions."phpdbform/temp/") and $LOC_catxe) echo "[DEBBUGER] ALERTA! sense permís d'escriptura a la carpeta phpdbform/temp/
\n"; if (!is_writable(DIR_ARXIUS_USUARIS) and $LOC_catxe) echo "[DEBBUGER] ALERTA! sense permís d'escriptura a la carpeta ".DIR_ARXIUS_USUARIS."
\n"; } if (DEBBUGER>1) { echo "[DEBBUGER] SQL's de la BD:
\n"; print_r($COUNT_QUERY); } ?>