[2] | 1 | <?php
|
---|
| 2 | /************************************************************************/
|
---|
| 3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 4 | /* by Roberto Gigli & Luciano Apolito */
|
---|
| 5 | /* http://www.eleonline.it */
|
---|
| 6 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 7 | /************************************************************************/
|
---|
| 8 | /* Modulo Inserimento dati */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 |
|
---|
| 12 | if (!defined('ADMIN_FILE')) {
|
---|
| 13 | die ("You can't access this file directly...");
|
---|
| 14 | }
|
---|
| 15 | $perms=ChiSei(0);
|
---|
| 16 | if ($perms!=256) die("Non hai i permessi per effettuare questa operazione!");
|
---|
| 17 |
|
---|
| 18 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 19 | if (isset($param['datafile'])) get_magic_quotes_gpc() ? $datafile=$param['datafile']:$datafile=addslashes($param['datafile']); else $datafile='';
|
---|
| 20 | include("modules/Elezioni/ele.php");
|
---|
| 21 | ele();
|
---|
[31] | 22 | if (isset($_FILES['datafile']['tmp_name'])) $updfile=$_FILES['datafile']['tmp_name']; else $updfile='';
|
---|
| 23 | if (!is_uploaded_file($updfile))
|
---|
| 24 | # if (!is_uploaded_file($_FILES['datafile']['tmp_name']))
|
---|
[2] | 25 | # if (file_exists($datafile))
|
---|
| 26 | {
|
---|
| 27 | echo "<form name=\"restore\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\" >"
|
---|
| 28 | ."<input type=\"hidden\" name=\"op\" value=\"restore\">";
|
---|
| 29 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 30 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\">";
|
---|
| 31 | echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\"><tr class=\"bggray\"><td colspan=\"2\" align=\"center\">"._SEL_DATA_FILE."</td></tr><tr><td><input name=\"datafile\" type=\"file\"></td>";
|
---|
| 32 | echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._OK."\"></td></tr></table></form>";
|
---|
| 33 | ////////////////////////////
|
---|
| 34 | }else{$datafile=$_FILES['datafile']['tmp_name'];
|
---|
| 35 | $arrFile = file($datafile);
|
---|
| 36 | $handle = fopen($datafile, "r");
|
---|
| 37 | $test=array();
|
---|
| 38 | $errore=0;
|
---|
| 39 |
|
---|
| 40 | // Set counters
|
---|
| 41 | $currentLine = 0;
|
---|
| 42 | $cntFile = count($arrFile);
|
---|
| 43 | // $res_comune = mysql_query("delete from ".$prefix."_ele_lista where id_cons='10'" ,$dbi); if(!$res_comune) echo "delete ".$prefix."_ele_lista where id_cons='10'--- errore di cancellazione".mysql_error();
|
---|
| 44 | // Write contents, inserting $item as first item
|
---|
| 45 | $tabs=array($prefix."_ele_cons_comune",$prefix."_ele_gruppo",$prefix."_ele_lista",$prefix."_ele_candidati",$prefix."_ele_circoscrizione",$prefix."_ele_sede",$prefix."_ele_sezioni",$prefix."_ele_link",$prefix."_ele_come",$prefix."_ele_numeri",$prefix."_ele_servizi",$prefix."_ele_voti_candidati",$prefix."_ele_voti_gruppo",$prefix."_ele_voti_lista",$prefix."_ele_voti_parziale",$prefix."_ele_voti_ref");
|
---|
| 46 | $x=0;
|
---|
| 47 | $scarto=0;
|
---|
| 48 | $conta=array();
|
---|
| 49 | while( $currentLine <= $cntFile ){
|
---|
| 50 | $appo=substr($arrFile[$currentLine],1,-2);
|
---|
| 51 | $conta[$x]=0;
|
---|
| 52 | $conf=$tabs[$x];
|
---|
| 53 | if ($appo==$conf){
|
---|
| 54 | $currentLine++;
|
---|
| 55 | while($currentLine <= $cntFile ){
|
---|
[31] | 56 | if(isset($arrFile[$currentLine]))
|
---|
| 57 | $appo=substr($arrFile[$currentLine],1,-2);
|
---|
| 58 | else $appo='';
|
---|
| 59 | if(isset($tabs[($x+1)]))
|
---|
| 60 | if ($appo==$tabs[($x+1)]){ $x++; break;}
|
---|
| 61 | elseif($appo=='') { $x++; break;}
|
---|
[2] | 62 | $conta[$x]++;
|
---|
| 63 | $currentLine++;
|
---|
| 64 | }
|
---|
| 65 | }else {$scarto++;$currentLine++;}
|
---|
| 66 | }
|
---|
| 67 | if ($scarto==0){
|
---|
| 68 | $currentLine = 0;
|
---|
| 69 | $x=0;
|
---|
| 70 | $y=0;
|
---|
| 71 | while( $currentLine <= $cntFile ){
|
---|
[31] | 72 | if(isset($arrFile[$currentLine]))
|
---|
| 73 | $tab=substr($arrFile[$currentLine],1,-2);
|
---|
| 74 | else $tab='';
|
---|
| 75 | if(isset($tabs[$x]))
|
---|
| 76 | $conf=$tabs[$x];
|
---|
| 77 | else $conf='';
|
---|
[2] | 78 | if ($tab==$conf){
|
---|
| 79 | $currentLine++;
|
---|
| 80 | while($currentLine <= $cntFile ){
|
---|
[31] | 81 | # $appo=substr($arrFile[$currentLine],1,-2);
|
---|
| 82 | # if ($appo==$tabs[($x+1)]){ $x++; break;}
|
---|
| 83 | if(isset($arrFile[$currentLine]))
|
---|
| 84 | $appo=substr($arrFile[$currentLine],1,-2);
|
---|
| 85 | else $appo='';
|
---|
| 86 | if(isset($tabs[($x+1)]))
|
---|
| 87 | if ($appo==$tabs[($x+1)]){ $x++; break;}
|
---|
| 88 | elseif($appo=='') { $x++; break;}
|
---|
| 89 | if(isset($arrFile[$currentLine]))
|
---|
[2] | 90 | $test=explode(':',$arrFile[$currentLine]); if(!is_array($test)) {die("errore di import<br>");}
|
---|
| 91 | $valori='';
|
---|
| 92 | foreach($test as $key=>$val)
|
---|
| 93 | if($key==0){
|
---|
| 94 | $valori.= "'".base64_decode($val)."'";
|
---|
| 95 | if ($y==0) {$idcns=$valori;$y++;
|
---|
| 96 | foreach($tabs as $tbs){
|
---|
| 97 | $res_del = mysql_query("delete from $tbs where id_cons=$idcns" ,$dbi);
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 | if(!$res_del) die ("delete $tbs where id_cons=$idcns--- errore di cancellazione").mysql_error();
|
---|
| 101 | }else $valori.= ",'".addslashes(base64_decode($val))."'";
|
---|
| 102 | $res_comune = mysql_query("insert into $tab values($valori)" ,$dbi);
|
---|
| 103 | $currentLine++;
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | }
|
---|
| 108 | } else $errore=1;
|
---|
| 109 | fclose($handle);
|
---|
| 110 | }
|
---|
| 111 | if (isset($errore))
|
---|
| 112 | if ($errore) die( _MEX_RESTORE_FAILED);
|
---|
| 113 | else echo _MEX_RESTORE_OK;
|
---|
| 114 | echo"</td></tr></table>";
|
---|
| 115 | include("footer.php");
|
---|
| 116 |
|
---|
| 117 | ?>
|
---|