source: trunk/client/modules.php@ 222

Last change on this file since 222 was 154, checked in by luciano, 12 years ago
File size: 9.4 KB
RevLine 
[2]1<?php
2
3/************************************************************************/
4/* Eleonline - Raccolta e diffusione dei dati elettorali */
5/* by Luciano Apolito & Roberto Gigli */
6/* http://www.eleonline.it */
7/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
8/************************************************************************/
9
10define('MODULE_FILE', true);
11
12// Additional security (Union, CLike, XSS)
13// We want to use the function stripos,
14// but thats only available since PHP5.
15// So we cloned the function...
16if(!function_exists('stripos')) {
17 function stripos_clone($haystack, $needle, $offset=0) {
18 return strpos(strtoupper($haystack), strtoupper($needle), $offset);
19 }
20} else {
21// But when this is PHP5, we use the original function
22 function stripos_clone($haystack, $needle, $offset=0) {
23 return stripos($haystack, $needle, $offset=0);
24 }
25}
26
27 if(isset($_SERVER['QUERY_STRING']) && (!stripos_clone($_SERVER['QUERY_STRING'], "ad_click") || !stripos_clone($_SERVER['QUERY_STRING'], "url"))) {
28 $queryString = $_SERVER['QUERY_STRING'];
[12]29 if (stripos_clone($queryString,'%20union%20') OR stripos_clone($queryString,'..') OR stripos_clone($queryString,'+') OR stripos_clone($queryString,'/*') OR stripos_clone($queryString,'*/union/*') OR stripos_clone($queryString,'c2nyaxb0') OR stripos_clone($queryString,'+union+') OR stripos_clone($queryString,'http://') OR (stripos_clone($queryString,'cmd=') AND !stripos_clone($queryString,'&cmd')) OR (stripos_clone($queryString,'exec') AND !stripos_clone($queryString,'execu')) OR stripos_clone($queryString,'concat')) {
[2]30 die('Operazione non consentita');
31 }
32 }
33
34foreach ($_GET as $sec_key => $secvalue) {
[23]35 if ((preg_match("/<[^>]*script*\"?[^>]*>/i",$secvalue)) ||
36 (preg_match("/<[^>]*object*\"?[^>]*>/i", $secvalue)) ||
37 (preg_match("/<[^>]*iframe*\"?[^>]*>/i", $secvalue)) ||
38 (preg_match("/<[^>]*applet*\"?[^>]*>/i", $secvalue)) ||
39 (preg_match("/<[^>]*meta*\"?[^>]*>/i", $secvalue)) ||
40 (preg_match("/<[^>]*style*\"?[^>]*>/i", $secvalue)) ||
41 (preg_match("/<[^>]*form*\"?[^>]*>/i", $secvalue)) ||
42 (preg_match("/<[^>]*img*\"?[^>]*>/i", $secvalue)) ||
43 (preg_match("/<[^>]*onmouseover*\"?[^>]*>/i", $secvalue)) ||
44 (preg_match("/<[^>]*body*\"?[^>]*>/i", $secvalue)) ||
45 (preg_match("/\([^>]*\"?[^)]*\)/", $secvalue)) ||
46 (preg_match("/\"/", $secvalue)) ||
47 (preg_match("/inside_mod/i", $sec_key))) {
[2]48 die ("Operazione non consentita");
49 }
50 }
51
52 foreach ($_POST as $secvalue) {
[23]53 if ((preg_match("/<[^>]*onmouseover*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]script*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]*body*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]style*\"?[^>]*>/i", $secvalue))) {
[2]54 die ($htmltags);
55 }
56 }
57
58// Posting from other servers in not allowed
59// Fix by Quake
60// Bug found by PeNdEjO
61if ($_SERVER['REQUEST_METHOD'] == "POST") {
62 if (isset($_SERVER['HTTP_REFERER'])) {
63 if (!stripos_clone($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
64 die('Posting da un altro server non consentito!');
65 } else {
66# die('<b>Attenzione:</b> il tuo browser non puo inviare gli header HTTP_REFERER al website.<br/>');
67 }
68 }
69}
70
71function jsexist(){ // controlla javascript by l.apolito 2008
72global $op,$name;
73if(!isset($_GET['js'])){
[23]74$querystring= @preg_replace('/'.$_SERVER['DOCUMENT_ROOT'].'/i','http://'.$_SERVER['HTTP_HOST'].'/',$_SERVER['SCRIPT_FILENAME']);
75if (preg_match("/modules.php/i",$_SERVER['SCRIPT_NAME'])) $pagina="name=$name"; // reindirizza
76if (preg_match("/admin.php/i",$_SERVER['SCRIPT_NAME'])) $pagina="op=$op"; // reindirizza
[2]77 echo "<noscript><meta http-equiv=\"refresh\" content=\"0; url=".$querystring."?js=b&amp;$pagina\"/></noscript>";
78 }
79$js=$_GET['js'];
80return $js;
81}
82
83
84
85
86
87
88session_start();//MODIFICHE PER GESTIONE SESSIONI
89// apre database
90////////////////////////
91
[154]92@require_once("config.php");
93# verifica se effettuata la configurazione
94if(empty($dbname)) {
95 die("<html><body><div style=\"text-align:center\"><br /><br /><img src=\"modules/Elezioni/images/logo.jpg\" alt=\"Eleonline\" title=\"Eleonline\"><br /><br /><strong>Sembra che <a href='http://www.eleonline.it' title='Eleonline'>Eleonline</a> non sia stato ancora installato.<br /><br />Puoi procedere <a href='../install/index.php'>cliccando qui</a> per iniziare l'installazione</strong></div></body></html>");
96}
[2]97
98
99
100
[154]101
[2]102if(!$dbi = mysql_connect($dbhost, $dbuname, $dbpass)){
103die("<center><img src=\"images/logo.gif\" target=\"Logo Avviso Errore\"><br/><br/><b>Ci sono dei problemi di connessione al Server $dbtype, chiediamo scusa per l'inconveniente.<br/><br/>Provate piu' tardi, Grazie.</b><br/><font color=\"#ff0000\">". mysql_error()."</font></center>");
104}
105
106if(!mysql_select_db($dbname)){
107die("<center><img src=src=\"images/logo.gif\" target=\"Logo Avviso Errore\"><br/><br/><b>Ci sono dei problemi di connessione al DataBase $dbtype, chiediamo scusa per l'inconveniente.<br/><br/>Provate piu' tardi, Grazie.</b><br/><font color=\"#ff0000\">". mysql_error()."</font></center>");
108}
[23]109mysql_query("SET NAMES 'utf8'", $dbi);
[2]110
[153]111# protezione csrf ottobre 2012 - by l.apolito
112if (file_exists("inc/csrf-magic/csrf-magic.php")) {
113 include_once 'inc/csrf-magic/csrf-magic.php';
114}
115
116
117
118
119
120
[2]121# carica i parametri di default sulla tabella
122$res = mysql_query("SELECT * FROM ".$prefix."_config" , $dbi);
123$row = mysql_fetch_array($res);
124$sitename = stripslashes($row['sitename']);
125$siteurl = $row['siteurl'];
126$site_logo = $row['site_logo'];
127$startdate = $row['startdate'];
128$adminmail = $row['adminmail'];
129$tema = $row['tema'];
130$language = $row['language'];
131$blocco = intval($row['blocco']);
132$fileout = intval($row['fileout']);
133$copyright = $row['copyright'];
134$Versione = $row['Versione'];
135$patch = $row['patch'];
136$siteistat = intval($row['siteistat']);
137$multicomune = intval($row['multicomune']);
138$flash = intval($row['flash']);
139$displayerrors = $row['displayerrors'];
140$gkey = $row['gkey'];
141$googlemaps = intval($row['googlemaps']);
142$editor = intval($row['editor']);
143$tema_on = intval($row['tema_on']);
144$ed_user = $row['ed_user'];
145# altre config
146$res = mysql_query("SELECT * FROM ".$prefix."_ele_comuni where id_comune='$siteistat' ", $dbi);
147$row = mysql_fetch_array($res);
148$id_cons_pred = intval($row['id_cons']);
149if($id_cons_pred=='0')$id_cons_pred='';
150if(!isset($id_cons_gen)) $id_cons_gen=$id_cons_pred;
151# carica il metodo d'hontd
152$res = mysql_query("SELECT * FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' ", $dbi);
153$row = mysql_fetch_array($res);
154
155
156
157
158$param=strip_tags(strtolower($_SERVER['REQUEST_METHOD'])) == 'get' ? $_GET : $_POST;
159////////////////////
160#funzione di backup
161if (isset($param['op']) and $param['op']=='backup')
162{
163$id_cons_bak=intval($param['id_cons_gen']);
[10]164if (isset($param['id_comune'])) $id_combak=intval($param['id_comune']); else $id_combak=$_SESSION['id_comune'];
[2]165$res = mysql_query("SELECT id_cons,id_conf FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_bak' and id_comune='$id_combak'" , $dbi);
166list($id_cons,$hondt) = mysql_fetch_row($res);
167
168// incluso in consiglieri.php, ma io carico le vecchie variabili per compatibilit'a all'indietro
169if($hondt>=1){
170# proiezione consiglio
171 $res = mysql_query("SELECT * FROM ".$prefix."_ele_conf where id_conf='$hondt'", $dbi);
172 $row = mysql_fetch_array($res);
173 $descrizione_consiglio = $row['descrizione'];
174 $LIMITE = intval($row['limite']);
175 $CONSIN = intval($row['consin']);
176 $INFPREMIO=intval($row['infpremio']);
177 $SUPSBARRAMENTO=intval($row['supsbarramento']);
178 $SUPMINPREMIO=intval($row['supminpremio']);
179 $SUPPREMIO=intval($row['suppremio']);
180 $LISTINFSBAR=intval($row['listinfsbar']);
181 $LISTINFCONTA=intval($row['listinfconta']);
182 $LISTSUPCONTA=intval($row['listsupconta']);
183 $SUPMINPREMIO=intval($row['supminpremio']);
184 $INFMINPREMIO=intval($row['infminpremio']);
185}
186
187
188include("modules/Elezioni/backup.php");
189die();
190}
191///////////////////
192// lingua x demo
193if (isset($param['newl'])){
194 $newl=$param['newl'];
195 if (file_exists("modules/Elezioni/language/lang-$newl.php")){ $lang=$newl;$_SESSION['newl']="$lang";
196 }
197}
198
199// seesioni per flash, blocco e linguaggio, tour
200
201if (isset($param['block'])){
202 $blocco=$param['block'];
203 $_SESSION['newblock']="$blocco";
204 }
205if (isset($_SESSION['newblock'])) $blocco=$_SESSION['newblock'];
206
207
208
209// linguaggio
210if (isset($_SESSION['newl'])) $lang=$_SESSION['newl'];
211//else $lang=$lang;
212if (! isset($lang)) $lang=$language;
213if (strlen($lang)!=2) $lang=$language;
214
215// flash x demo
216if (isset($param['flash'])){
217 $flash=$param['flash'];
218 $_SESSION['newflash']="$flash";
219 }
220if (isset($_SESSION['newflash'])) $flash=$_SESSION['newflash'];
221
222if (isset($param['tema'])){
223 $tema=$param['tema'];
[12]224 $tema=htmlentities($tema); // evita xss
[23]225 if(preg_match("/%/i", $tema)) $tema="default";// evita xss
[2]226 $_SESSION['newtema']="$tema";
227 }
[29]228if (isset($_SESSION['newtema'])) {
229 $tema=$_SESSION['newtema'];
230 if (preg_match("/%/i",$_SESSION['newtema'])) $_SESSION['newtema']="default"; // xss
231}
[2]232$PHP_SELF=$_SERVER['PHP_SELF'];
[80]233$file=(isset($_GET['file'])) ? htmlentities($_GET['file']):"index";
234$name=(isset($_GET['name'])) ? htmlentities($_GET['name']):"Elezioni";
[153]235$op=(isset($_GET['op'])) ? htmlentities($_GET['op']):"gruppo";
[80]236if (!isset($_GET['op'])) $_GET['op']="gruppo";
[10]237
[2]238$modpath = "modules/$name/$file.php";
239if (file_exists($modpath)) {
240 include($modpath);
241} else {
242 die ("Sorry, such file doesn't exist...:$modpath");
243}
244
245
246
247
248
249
250
251?>
Note: See TracBrowser for help on using the repository browser.