$secvalue) {
if ((preg_match("/<[^>]*script*\"?[^>]*>/i",$secvalue)) ||
(preg_match("/<[^>]*object*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*iframe*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*applet*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*meta*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*style*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*form*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*img*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*onmouseover*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*body*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/\([^>]*\"?[^)]*\)/", $secvalue)) ||
(preg_match("/\"/", $secvalue)) ||
(preg_match("/inside_mod/i", $sec_key))) {
die ("Operazione non consentita");
}
}
foreach ($_POST as $secvalue) {
if ((preg_match("/<[^>]*onmouseover*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]script*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]*body*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]style*\"?[^>]*>/i", $secvalue))) {
die ('Operazione non consentita');
}
}
// Posting from other servers in not allowed
// Fix by Quake
// Bug found by PeNdEjO
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (isset($_SERVER['HTTP_REFERER'])) {
if (!stripos_clone($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
die('Posting da un altro server non consentito!');
}
} else {
# die('Attenzione: il tuo browser non puo inviare gli header HTTP_REFERER al website.
'.$_SERVER['HTTP_REFERER']);
}
}
//===================================================================
session_name('sesadmin');
session_start();//MODIFICHE PER GESTIONE SESSIONI
// gestione sessione
include("config.php");
$dbi=mysql_connect($dbhost, $dbuname, $dbpass) or die("Connessione non riuscita: " . mysql_error());
mysql_select_db($dbname)or die("Connessione non riuscita:" . mysql_error());
# mysql_set_charset('utf8', $dbi);
mysql_query("SET NAMES 'utf8'", $dbi);
//---10/05/2009 gestione consultazione predefinita
$res_config = mysql_query("select * from ".$prefix."_config ",$dbi);
list ($sitename,$siteurl,$site_logo,$slogan,$startdate,$adminmail,$tema,$foot,$language,$blocco
,$testata,$logo,$fileout,$copyright,$versione,$patch,$id_comune,$multicomune,$flash,$displayerrors,$editor,$tema_on,$ed_user) = mysql_fetch_row($res_config);
$siteistat=$id_comune;
if (!isset($_SESSION['id_comune'])){
$_SESSION['sitename']=$sitename;
$_SESSION['siteurl']=$siteurl;
$_SESSION['site_logo']=$site_logo;
$_SESSION['slogan']=$slogan;
$_SESSION['startdate']=$startdate;
$_SESSION['adminmail']=$adminmail;
if ($tema=='facebook')
$_SESSION['tema']=$tema;
else $_SESSION['tema']='default';
$_SESSION['foot']=$foot;
$_SESSION['lang']=$language;
$_SESSION['blocco']=$blocco;
$_SESSION['testata']=$testata;
$_SESSION['logo']=$logo;
$_SESSION['fileout']=$fileout;
$_SESSION['copyright']=$copyright;
$_SESSION['versione']=$versione;
$_SESSION['patch']=$patch;
$_SESSION['id_comune']=$id_comune;
$_SESSION['multicomune']=$multicomune;
$_SESSION['flash']=$flash;
$_SESSION['displayerrors']=$displayerrors;
$_SESSION['editor']=$editor;
$_SESSION['tema_on']=$tema_on;
$_SESSION['ed_user']=$ed_user;
}
//fine
if (isset($param['aid'])) {
if (strlen($aid)>25 ) { die ("Nome utente troppo lungo: $aid"); }
if (!isset($param['id_ses']) or $param['id_ses'] != session_id()) logout();
if (strstr( $aid," ")) { die ("Gli spazi non sono ammessi nel nome utente: $aid"); }
if (isset($_SESSION['aid'])){
logout();//se hai gia' una sessione aperta non puoi postare 'aid'
}else{
// $pwd2=$param['pwd'];
$mpwd=md5($pwd2);
// se superUserAdmin
########
$res_comune = mysql_query("select adminsuper from ".$prefix."_authors where aid='$aid' and pwd='$mpwd'",$dbi);
list ($adminsuper) = mysql_fetch_row($res_comune);
if ($adminsuper==1) $id_comune='0';
elseif (is_numeric($param['id_comune']) and intval($param['id_comune'])>0) $id_comune=intval($param['id_comune']);
$res= mysql_query("select counter,admlanguage from ".$prefix."_authors where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune'", $dbi);
if ($res){
$esiste=mysql_num_rows($res);
list ($counter,$tmplang) = mysql_fetch_row($res);
$counter+=1;
if(strlen($tmplang)==2) $language=$tmplang;
$resup=mysql_query("update ".$prefix."_authors set counter=$counter where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune'", $dbi);
if ($esiste==1) {
$_SESSION['dbi']=$dbi;
$_SESSION['aid']="$aid";
$_SESSION['pwd']="$mpwd";
$_SESSION['lang']="$language";
$_SESSION['id_comune']="$id_comune";
$_SESSION['prefix']="soraldo";
$_SESSION['remote']=$_SERVER['REMOTE_ADDR'];
$_SESSION['bgcolor1']='#ffffff';
$_SESSION['bgcolor2']='#c5c5c5';
session_regenerate_id();
}
}
}
}else{
$_SESSION['dbi']=$dbi;
}
if (! isset($_SESSION['lang'])) $_SESSION['lang']=$language;
$currentlang=strlen($_SESSION['lang'])==2 ? $_SESSION['lang']: $language;
#if (isset($_SESSION['lang'])) $currentlang=$_SESSION['lang']; else $currentlang='it';
if (isset($_SESSION['aid']))
{
//lettura sessione
$aid=$_SESSION['aid'];
$dbi=$_SESSION['dbi'];
$prefix=$_SESSION['prefix'];
$id_comune=$_SESSION['id_comune'];
if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']);
else {
//10/05/2009 gestione consultazione predefinita
$result = mysql_query("select id_cons_gen from ".$prefix."_ele_cons_comune where preferita='1' and (id_comune='$id_comune' or id_comune=0)", $dbi);
list($id_cons_gen) = mysql_fetch_row($result);
//---fine $id_cons_gen='';
}
$currentlang=$_SESSION['lang'];
$bgcolor1=$_SESSION['bgcolor1'];
$bgcolor2=$_SESSION['bgcolor2'];
$bgcolor1='#e7e7e7';
$session=$_SESSION['remote'];
$perms=ChiSei($id_cons_gen);
}
/*********************************************************/
/* Login Function */
/*********************************************************/
function ChiSei($id_cons_gen){
//$server=$_SERVER['REMOTE_ADDR'];
//$session=$_SESSION['remote'];
//if ($session!=$server) { die ("Problema di sessione"); };
$aid=$_SESSION['aid'];
$dbi=$_SESSION['dbi'];
$prefix=$_SESSION['prefix'];
$pwd=$_SESSION['pwd'];
$id_comune=$_SESSION['id_comune'];
$perms=0;
$result = mysql_query("select adminsuper, admincomune, adminop from ".$prefix."_authors where aid='$aid' and pwd='$pwd' and (id_comune='$id_comune' or id_comune=0)", $dbi);
list($adminsuper,$admincomune,$adminop) = mysql_fetch_row($result);
//exit;
if (($adminsuper==1 || $admincomune==1 || $adminop==1)) {
if ($adminsuper==1)
return 256;
// $ressup = mysql_query("select permessi from ".$prefix."_ele_operatori where id_cons='0' and aid='$aid' and id_comune='0'",$dbi);
elseif ($adminop==1)
$ressup = mysql_query("select permessi from ".$prefix."_ele_operatori where id_cons='0' and aid='$aid' and id_comune='$id_comune'",$dbi);
elseif ($admincomune==1) {
$res=mysql_query("select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'",$dbi);
list ($id_cons)=mysql_fetch_row($res);
$ressup = mysql_query("select permessi from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'",$dbi);
}
if (mysql_num_rows($ressup)==1) list($perms)=mysql_fetch_row($ressup); else $perms=0;
return $perms;
} else return 0;
}
function OpenTable(){
echo "