" .""; echo ""; echo ""; echo ""; echo "
"._SEL_DATA_FILE."
"; //////////////////////////// }else{$datafile=$_FILES['datafile']['tmp_name']; $arrFile = file($datafile); $handle = fopen($datafile, "r"); $test=array(); $errore=0; // Set counters $currentLine = 0; $cntFile = count($arrFile); // $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(); // Write contents, inserting $item as first item $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"); $x=0; $scarto=0; $conta=array(); while( $currentLine <= $cntFile ){ $appo=substr($arrFile[$currentLine],1,-2); $conta[$x]=0; $conf=$tabs[$x]; if ($appo==$conf){ $currentLine++; while($currentLine <= $cntFile ){ if(isset($arrFile[$currentLine])) $appo=substr($arrFile[$currentLine],1,-2); else $appo=''; if(isset($tabs[($x+1)])) if ($appo==$tabs[($x+1)]){ $x++; break;} elseif($appo=='') { $x++; break;} $conta[$x]++; $currentLine++; } }else {$scarto++;$currentLine++;} } if ($scarto==0){ $currentLine = 0; $x=0; $y=0; while( $currentLine <= $cntFile ){ if(isset($arrFile[$currentLine])) $tab=substr($arrFile[$currentLine],1,-2); else $tab=''; if(isset($tabs[$x])) $conf=$tabs[$x]; else $conf=''; if ($tab==$conf){ $currentLine++; while($currentLine <= $cntFile ){ # $appo=substr($arrFile[$currentLine],1,-2); # if ($appo==$tabs[($x+1)]){ $x++; break;} if(isset($arrFile[$currentLine])) $appo=substr($arrFile[$currentLine],1,-2); else $appo=''; if(isset($tabs[($x+1)])) if ($appo==$tabs[($x+1)]){ $x++; break;} elseif($appo=='') { $x++; break;} if(isset($arrFile[$currentLine])) $test=explode(':',$arrFile[$currentLine]); if(!is_array($test)) {die("errore di import
");} $valori=''; foreach($test as $key=>$val) if($key==0){ $valori.= "'".base64_decode($val)."'"; if ($y==0) {$idcns=$valori;$y++; foreach($tabs as $tbs){ $sql="delete from $tbs where id_cons=$idcns"; $res_del = $dbi->prepare("$sql"); $res_del->execute(); } } if(!$res_del->rowCount()) die ("delete $tbs where id_cons=$idcns--- errore di cancellazione"); }else $valori.= ",'".addslashes(base64_decode($val))."'"; $sql="insert into $tab values($valori)"; $res_comune = $dbi->prepare("$sql"); $res_comune->execute(); $currentLine++; } } } } else $errore=1; fclose($handle); } if (isset($errore)) if ($errore) die( _MEX_RESTORE_FAILED); else echo _MEX_RESTORE_OK; echo""; include("footer.php"); ?>