[378] | 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(!file_exists('../admin')) {die("Non trovo la cartella admin, aggiornamento interrotto");}
|
---|
| 13 | $righe='';
|
---|
| 14 | if(phpversion()<5.6) $host="http://80.211.143.127";
|
---|
| 15 | else $host="https://trac.eleonline.it";
|
---|
| 16 | if(false === $file = file("$host/ele3/changeset/")) die("Impossibile collegarsi al server - Aggiornamento interrotto");
|
---|
| 17 | $cntFile = count($file);
|
---|
| 18 | $fine=0;
|
---|
| 19 | $currentLine=0;
|
---|
| 20 |
|
---|
| 21 | foreach ($file as $line_num => $line) {
|
---|
| 22 | if(strpos($line,'<title>') ) {$fine=1; continue;}
|
---|
| 23 | if ($fine){
|
---|
| 24 | $newrev=(int) filter_var($line, FILTER_SANITIZE_NUMBER_INT);
|
---|
| 25 | $righe.= "<b>Ultima revisione:</b> " .$newrev." \n"; break;
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | unset($file);
|
---|
| 29 |
|
---|
| 30 | include('./versione.php');
|
---|
| 31 | $myrev=intval(substr($versione,-4,4));
|
---|
| 32 | $righe.= "<br><b>Revisione installata:</b> ".$myrev;
|
---|
| 33 | if($newrev==$myrev) die( "<br><br>---------- Non sono disponibili nuovi aggiornamenti ---------");
|
---|
| 34 | #else{
|
---|
| 35 |
|
---|
| 36 | # define('_PATH', dirname(__FILE__));
|
---|
| 37 | $file = '../admin';
|
---|
| 38 | $client = '../client';
|
---|
| 39 | # $dest_path = './admin-bak';
|
---|
| 40 | $trunk='./files/trunk';
|
---|
| 41 | $trunkadm='./files/trunk/admin';
|
---|
| 42 | $trunkcli='./files/trunk/client';
|
---|
| 43 | $path = "./files/";
|
---|
| 44 | if(file_exists($path))
|
---|
| 45 | if (!is_dir($path)) { die("<br>E' presente un file di nome $path nella cartella admin, va cancellato per poter aggiornare");}
|
---|
| 46 | else $righe.= "<br>La cartella $path Ú già presente, procedo con l'aggiornamento";
|
---|
| 47 | else{
|
---|
| 48 | $righe.= "<br>La cartella $path non Ú presente, procedo con la creazione";
|
---|
| 49 | mkdir($path, 0777, true);
|
---|
| 50 | }
|
---|
| 51 | # if(!file_exists($trunk)) if (false === mkdir($trunk)) { die("Impossibile creare la cartella trunk, il programma viene interrotto");}
|
---|
| 52 | # if(!copy($file,$trunkadm)){ $righe.= "<br>Errore durante la copia del pacchetto di aggiornamento<br>";}
|
---|
| 53 | // Nome del file zip : https://trac.eleonline.it/ele3/changeset?format=zip&new=377&new_path=%2F&old=360&old_path=%2F
|
---|
| 54 | # https://trac.eleonline.it/ele3/browser/trunk?format=zip&rev=377
|
---|
| 55 |
|
---|
| 56 | $filename = "$host/ele3/changeset?format=zip&new=$newrev&new_path=%2F&old=$myrev&old_path=%2F";
|
---|
| 57 | $newfile="./files/aggiornamento".$newrev;
|
---|
| 58 | if(!copy($filename,$newfile)){ die( "<br><br>Errore durante la copia del pacchetto - aggiornamento interrotto<br>");}
|
---|
| 59 | $zip = new ZipArchive;
|
---|
| 60 | $res = $zip->open($newfile);
|
---|
| 61 | $righe.= "<br>$newfile scaricato";
|
---|
| 62 | if ($res === TRUE) {
|
---|
| 63 | $zip->extractTo($path);
|
---|
| 64 | $zip->close();
|
---|
| 65 | $righe.= '<br>File zip estratto';
|
---|
| 66 | } else {
|
---|
| 67 | die( '<br>Errore nell\'estrazione del file zip! Aggiornamento interrotto');
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | #}
|
---|
| 71 | $righe.= "<br><br><b>Copio i nuovi files nell'installazione di amministrazione locale</b>";
|
---|
| 72 | recurse_copy($trunkadm,$file);
|
---|
| 73 | $righe.= "<br>Files di aggiornamento copiati correttamente.";
|
---|
| 74 | $righe.= "<br><br><b>Copio i nuovi files nell'installazione client locale</b>";
|
---|
| 75 | recurse_copy($trunkcli,$client);
|
---|
| 76 | $righe.= "<br>Files di aggiornamento copiati correttamente.";
|
---|
| 77 | function recurse_copy($src,$dst) {
|
---|
| 78 | $dir = opendir($src);
|
---|
| 79 | if(!file_exists($dst)) @mkdir($dst);
|
---|
| 80 | while(false !== ( $file = readdir($dir)) ) {
|
---|
| 81 | if (( $file != '.' ) && ( $file != '..' )) {
|
---|
| 82 | if ( is_dir($src . '/' . $file) ) {
|
---|
| 83 | recurse_copy($src . '/' . $file,$dst . '/' . $file);
|
---|
| 84 | }
|
---|
| 85 | else {
|
---|
| 86 | if(!copy($src . '/' . $file,$dst . '/' . $file)) die("<br>Errore durante la copia del file".$dst . '/' . $file.", aggiornamento interrotto");
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | closedir($dir);
|
---|
| 91 | }
|
---|
| 92 | echo "<br><b>------------------Aggiornamento completato controllare il log e poi tornare al programma-----------------------</b><br>";
|
---|
| 93 | echo "<br><a href=\"admin.php\"> <------------- Torna al programma --------------> </a><br><br><br>";
|
---|
| 94 | $righedb='';
|
---|
| 95 | if(file_exists('./files/trunk/admin/aggiornadb.php')) {
|
---|
| 96 | $righe.= "<br><br><b>Aggiornamento del database</b>";
|
---|
| 97 | ob_start();
|
---|
| 98 | include ('./aggiornadb.php');
|
---|
| 99 | $righedb=ob_get_contents();
|
---|
| 100 | ob_end_clean();
|
---|
| 101 | }
|
---|
| 102 | $righe.=$righedb;
|
---|
| 103 | $righe.= "<br><br><b>Pulisco la cartella temporanea. Operazioni concluse.</b>";
|
---|
| 104 | $dir = "./files/";
|
---|
| 105 | if(file_exists($dir)){
|
---|
| 106 | $di = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
|
---|
| 107 | $ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
|
---|
| 108 | foreach ( $ri as $file ) {
|
---|
| 109 | $file->isDir() ? rmdir($file) : unlink($file);
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
| 112 | echo $righe;die();
|
---|
| 113 |
|
---|
| 114 | ?>
|
---|
| 115 |
|
---|