Exemple #1
0
 function execute()
 {
     global $win32, $cfg, $archivers;
     kprintheader(get_lang(260));
     $usearc = db_guinfo('archer');
     if (isset($archivers[$usearc]) && $archivers[$usearc][0] == 1) {
         $this->archiverinfo = $archivers[$usearc];
         $filegenerated = false;
         $totalmb = $this->determinesize();
         if ($totalmb <= db_guinfo('archivesize') || db_guinfo('archivesize') == 0) {
             $debugcode = 0;
             $method = 0;
             if (strpos($this->archiverinfo[2], '%LIST') !== false) {
                 $method = 1;
             } else {
                 if (strpos($this->archiverinfo[2], 'INB1') !== false) {
                     $method = 2;
                 }
             }
             if ($method == 1) {
                 $dual = true;
             } else {
                 $dual = false;
             }
             if ($this->createtemp($this->archiverinfo[1])) {
                 $initerror = false;
                 switch ($method) {
                     case 1:
                         $fp = fopen($this->tempfile, 'ab');
                         if ($fp) {
                             for ($i = 0, $c = count($this->files); $i < $c; $i++) {
                                 $f2 = new file2($this->files[$i]);
                                 if ($f2->ifexists()) {
                                     fwrite($fp, $f2->fullpath . $cfg['archivefilelist_cr']);
                                 }
                             }
                             fclose($fp);
                         } else {
                             $initerror = true;
                         }
                         break;
                     case 2:
                         $zip = new ZipArchive();
                         $php5code = 'if ($zip->open($this->destfile, ZIPARCHIVE::CREATE) !== true) $initerror = true;';
                         eval($php5code);
                         //if ($zip->open($this->destfile, ZIPARCHIVE::CREATE) !== true) $initerror = true;
                         break;
                 }
                 if (!$initerror) {
                     echo '<div id="up_status2" class="notice">0%</div><br/>';
                     flush();
                     $generror = false;
                     if ($method == 1) {
                         $out = array();
                         $ret = -1;
                         $run = $this->getarchiveline($this->destfile, $f2->getfullpath($win32), $this->tempfile);
                         if ($cfg['archivemodedebug']) {
                             echo $run . '<br/>';
                         }
                         exec($run, $out, $ret);
                         if ($ret != 0) {
                             $generror = true;
                         }
                         updateup_status('100%');
                     } else {
                         $cnt = 0;
                         $filescnt = count($this->files);
                         for ($i = 0; $i < $filescnt; $i++) {
                             $f2 = new file2($this->files[$i]);
                             if ($f2->ifexists()) {
                                 switch ($method) {
                                     case 2:
                                         $zip->addFile($f2->getfullpath($win32));
                                         break;
                                     case 0:
                                         $out = array();
                                         $ret = -1;
                                         $run = $this->getarchiveline($this->destfile, $f2->getfullpath($win32));
                                         if ($cfg['archivemodedebug']) {
                                             echo $run . '<br/>';
                                         }
                                         exec($run, $out, $ret);
                                         if ($ret != 0) {
                                             $generror = true;
                                         }
                                         break;
                                 }
                             }
                             $cnt++;
                             $per = $cnt / $filescnt * 100;
                             $per = number_format($per, 0) . '%';
                             updateup_status($per . ' .. ' . $f2->fname);
                             flush();
                         }
                     }
                     // deconstructer
                     if ($method == 2) {
                         $zip->close();
                     }
                     if (!$generror) {
                         if (file_exists($this->destfile)) {
                             if (filesize($this->destfile) > 0) {
                                 $id = $this->addarchivetbl($this->destfile);
                                 if ($id > 0) {
                                     $this->logdl();
                                     $this->downloadpage($this->archiverinfo[3], $id, $this->archiverinfo[1]);
                                     $filegenerated = true;
                                     @unlink($this->tempfile);
                                 } else {
                                     $debugcode = 6;
                                 }
                             } else {
                                 $debugcode = 5;
                             }
                         } else {
                             $debugcode = 4;
                         }
                     } else {
                         $debugcode = 3;
                     }
                 } else {
                     $debugcode = 2;
                 }
             } else {
                 $debugcode = 1;
             }
         } else {
             echo '<font class="notice">' . get_lang(328, $totalmb, db_guinfo('archivesize')) . '</font>';
             kprintend();
             return false;
         }
     } else {
         echo '<font class="notice">' . get_lang(363) . '</font>';
         kprintend();
         return false;
     }
     if (!$filegenerated) {
         echo '<font class="notice">' . get_lang(167) . '</font>';
         if ($cfg['archivemodedebug']) {
             echo $this->debugerr($debugcode);
         }
     }
     kprintend();
 }