function strip_text($a){
$i=-1;$n='';$ok=1;
while(isset($a{++$i})){
if($ok&&$a{$i}!='<'){continue;}
elseif($a{$i}=='>'){$ok=1;$n.='>';continue;}
elseif($a{$i}=='<'){$ok=0;}
if(!$ok){$n.=$a{$i};}}
return $n;
}
function removeEvilTags($source)
{
global $allowedTags;
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('\\1').'>'", $source);
}
/**
* @return string
* @param string
* @desc Strip forbidden attributes from a tag
*/
function removeEvilAttributes($tagSource)
{
global $stripAttrib;
return stripslashes(preg_replace("/$stripAttrib/i", 'forbidden', $tagSource));
}
function strip_attributes($msg, $tag, $attr, $suffix = "")
{
$lengthfirst = 0;
while (strstr(substr($msg, $lengthfirst), "<$tag ") != "")
{
$tag_start = $lengthfirst + strpos(substr($msg, $lengthfirst), "<$tag ");
$partafterwith = substr($msg, $tag_start);
$img = substr($partafterwith, 0, strpos($partafterwith, ">") + 1);
$img = str_replace(" =", "=", $img);
$out = "<$tag";
for($i=0; $i < count($attr); $i++)
{
if (empty($attr[$i])) {
continue;
}
$long_val =
(strpos($img, " ", strpos($img, $attr[$i] . "=")) === FALSE) ?
strpos($img, ">", strpos($img, $attr[$i] . "=")) - (strpos($img, $attr[$i] . "=") + strlen($attr[$i]) + 1) :
strpos($img, " ", strpos($img, $attr[$i] . "=")) - (strpos($img, $attr[$i] . "=") + strlen($attr[$i]) + 1);
$val = substr($img, strpos($img, $attr[$i] . "=" ) + strlen($attr[$i]) + 1, $long_val);
if (!empty($val)) {
$out .= " " . $attr[$i] . "=" . $val;
}
}
if (!empty($suffix)) {
$out .= " " . $suffix;
}
$out .= ">";
$partafter = substr($partafterwith, strpos($partafterwith,">") + 1);
$msg = substr($msg, 0, $tag_start). $out. $partafter;
$lengthfirst = $tag_start + 3;
}
return $msg;
}
function admin_br2nl($text)
{
$text = str_replace('
', "\n", $text);
return str_replace('
', "\n", $text);
}
//########### FUNZIONI AMMINISTRAZIONE ########################
function admin_checkbox($nome,$def_sel="1",$def_nosel="0",$def_ini=NULL,$class=NULL,$agg=NULL) {
$sel = "";
//STATO INIZIALE
if(!isset($_SESSION[$nome])) {
if($def_ini == "on") {
$_REQUEST["$nome"] = $def_sel;
$_SESSION["$nome"] = $def_sel;
$sel = "checked";;
}
//else $_REQUEST[$nome] == $def_nosel;
}
//admin_ssv($nome);
if(isset($_REQUEST[$nome])) $_SESSION[$nome] = $_REQUEST[$nome];
//else if($_SESSION[$nome] != $def_nosel and isset($_SESSION[$nome])) $_SESSION[$nome] = $def_nosel;
else if($_REQUEST[modulo_inviato]) $_SESSION[$nome] = $def_nosel;
if($_SESSION[$nome] == $def_sel) $sel = "checked";
//else $sel = "";
$OUT = "";
return $OUT;
}
// server per mettere salvare in sessione variabili passate via get o post
function admin_ssv($var) {
if(isset($_REQUEST["$var"])) {
if($_SESSION["$var"] != $_REQUEST["$var"]) {
//setta la variabile
$_SESSION["$var"] = $_REQUEST["$var"];
}
}
return $_SESSION["$var"];
}
/// FUNZIONI
//due metodi di login, uno via get e l' altro via hash
function admin_login() {
global $ADMIN_CONF,$ADMIN_UTENTE,$ADMIN_MENU2;
//salvo automagicamente in sessione
$utente = trim(strtolower(admin_ssv("admin_user")));
$password = trim(strtolower(admin_ssv("admin_pass")));
//faccio il controllo
if ($password == $ADMIN_UTENTE[$utente][utente_pass] and $password != "" and $utente != "") {;
//sono autenticato, imposto l' utente, ecc, ecc
$OUT["ADMIN"] = "SI";
$OUT["AUTH"] = "SI";
//imposto l' utente
$OUT["utente"] = $utente;
//imposto la sessione per rimanere nell' amministrazione da fuori
$_SESSION["amministrazioneIndi"] = 1;
$_SESSION["debugIndi"] = 1;
//cambio template
//tolgo la password dall' array dell' utente per sicurezza
unset($ADMIN_UTENTE["$utente"]["utente_pass"]);
} else {
$OUT["AUTH"] = "NO";
if($_REQUEST[at] == "null") $ADMIN_CONF[template_login] = "tpl_null";
$OUT["template"] = $ADMIN_CONF[template_login];
//???
// if(isset($ADMIN_MENU2[$_REQUEST[ap]][template_login])) $OUT["template"] = $ADMIN_MENU2[$_REQUEST[ap]][template_login];
// if(isset($ADMIN_MENU2[$_REQUEST[ap2]][template_login])) $OUT["template"] = $ADMIN_MENU2[$_REQUEST[ap2]][template_login];
}
return $OUT;
}
function admin_menu_item($nome) {
global $ADMIN, $ADMIN_DATI;
if($ADMIN[$nome]["nome"] == "") $out = "Errore pagina";
else {
if($ADMIN_DATI[pagina] == $nome) $out = "".$ADMIN[$nome][a_nome]."";
else $out = "".$ADMIN[$nome][a_nome]."";
}
return $out;
}
function admin_menu() {
global $ADMIN,$A_DATI;
reset($ADMIN);
while(list($k, $v)=each($ADMIN)) {
if(stristr($v["nome"],$A_DATI[menu_pagine]) or $A_DATI[menu_pagine] == "ALL") {
if($k == $A_DATI[pagina]) $sel = 'id="selected"';
else $sel = "";
if($v["menu_link"] != "NO") $link = ''.$v["nome"].'';
else $link = $v["nome"];
if($v["menu_nascosto"] != "SI") $OUT .= '