public function processform()
 {
     $plugin = tsourcefiles::i();
     if (isset($_POST['download'])) {
         set_time_limit(300);
         $version = litepublisher::$options->version;
         if (!(($s = http::get("http://litepublisher.googlecode.com/files/litepublisher.{$version}.tar.gz")) || ($s = http::get("http://litepublisher.com/download/litepublisher.{$version}.tar.gz")))) {
             return 'Error download';
         }
         tbackuper::include_tar();
         $tar = new tar();
         $tar->loadfromstring($s);
         if (!is_array($tar->files)) {
             unset($tar);
             return 'Invalid file archive';
         }
         tfiler::delete($plugin->root, true, false);
         foreach ($tar->files as $item) {
             $filename = $plugin->root . $item['name'];
             $dir = dirname($filename);
             if (!is_dir($dir)) {
                 $this->mkdir($dir);
             }
             file_put_contents($filename, $item['file']);
             @chmod($filename, 0666);
         }
         unset($tar);
         $plugin->reread();
     } elseif (isset($_POST['reread'])) {
         $plugin->reread();
     } else {
         $plugin->root = $_POST['root'];
         $plugin->save();
     }
 }
Exemplo n.º 2
0
 public function processform()
 {
     $html = $this->html;
     switch ($this->name) {
         case 'service':
             return $this->doupdate($_POST);
         case 'backup':
             if (!$this->checkbackuper()) {
                 return $html->h3->erroraccount;
             }
             extract($_POST, EXTR_SKIP);
             $backuper = tbackuper::i();
             if (isset($restore)) {
                 if (!is_uploaded_file($_FILES['filename']['tmp_name'])) {
                     return sprintf($html->h4red->attack, $_FILES["filename"]["name"]);
                 }
                 if (strpos($_FILES['filename']['name'], '.sql')) {
                     $backuper->uploaddump(file_get_contents($_FILES["filename"]["tmp_name"]), $_FILES["filename"]["name"]);
                 } else {
                     $url = litepublisher::$site->url;
                     if (dbversion) {
                         $dbconfig = litepublisher::$options->dbconfig;
                     }
                     $backuper->upload(file_get_contents($_FILES['filename']['tmp_name']), $backuper->getarchtype($_FILES['filename']['name']));
                     if (isset($saveurl)) {
                         $storage = new tdata();
                         $storage->basename = 'storage';
                         $storage->load();
                         $storage->data['site'] = litepublisher::$site->data;
                         if (dbversion) {
                             $data->data['options']['dbconfig'] = $dbconfig;
                         }
                         $storage->save();
                     }
                 }
                 ttheme::clearcache();
                 @header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                 exit;
             } elseif (isset($downloadpartial)) {
                 $filename = str_replace('.', '-', litepublisher::$domain) . date('-Y-m-d') . $backuper->getfiletype();
                 $content = $backuper->getpartial(isset($plugins), isset($theme), isset($lib));
                 $this->sendfile($content, $filename);
             } elseif (isset($fullbackup)) {
                 $filename = str_replace('.', '-', litepublisher::$domain) . date('-Y-m-d') . $backuper->getfiletype();
                 $content = $backuper->getfull();
                 $this->sendfile($content, '');
             } elseif (isset($sqlbackup)) {
                 $content = $backuper->getdump();
                 $filename = litepublisher::$domain . date('-Y-m-d') . '.sql';
                 switch ($backuper->archtype) {
                     case 'tar':
                         tbackuper::include_tar();
                         $tar = new tar();
                         $tar->addstring($content, $filename, 0644);
                         $content = $this->tar->savetostring(true);
                         $filename .= '.tar.gz';
                         unset($tar);
                         break;
                     case 'zip':
                         tbackuper::include_zip();
                         $zip = new zipfile();
                         $zip->addFile($content, $filename);
                         $content = $zip->file();
                         $filename .= '.zip';
                         unset($zip);
                         break;
                     default:
                         $content = gzencode($content);
                         $filename .= '.gz';
                         break;
                 }
                 $this->sendfile($content, $filename);
             }
             break;
         case 'run':
             $result = eval($_POST['content']);
             return sprintf('<pre>%s</pre>', $result);
         case 'upload':
             $backuper = tbackuper::i();
             if (!$this->checkbackuper()) {
                 return $html->h3->erroraccount;
             }
             if (is_uploaded_file($_FILES['filename']['tmp_name']) && !(isset($_FILES['filename']['error']) && $_FILES['filename']['error'] > 0)) {
                 $s = file_get_contents($_FILES['filename']['tmp_name']);
                 $archtype = $backuper->getarchtype($_FILES['filename']['name']);
             } else {
                 $url = trim($_POST['url']);
                 if (empty($url)) {
                     return '';
                 }
                 if (!($s = http::get($url))) {
                     return $html->h3->errordownload;
                 }
                 $archtype = $backuper->getarchtype($url);
             }
             if (!$archtype) {
                 //         local file header signature     4 bytes  (0x04034b50)
                 $archtype = strbegin($s, "PK") ? 'zip' : 'tar';
             }
             if ($backuper->uploaditem($s, $archtype)) {
                 return $html->h3->itemuploaded;
             } else {
                 return sprintf('<h3>%s</h3>', $backuper->result);
             }
             break;
     }
 }