source: trunk/client/modules.php@ 4

Last change on this file since 4 was 2, checked in by root, 15 years ago

importo il progetto

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