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(); } }
public function unpack($content, $archtype) { $result = array(); if ($archtype == 'zip') { $archtype = 'unzip'; } $this->archtype = $archtype; //$this->createarchive(); switch ($archtype) { case 'tar': self::include_tar(); $tar = new tar(); $tar->loadfromstring($content); if (!is_array($tar->files)) { unset($tar); return $this->errorarch(); } foreach ($tar->files as $item) { $result[$item['name']] = $item['file']; } unset($tar); break; case 'unzip': case 'zip': self::include_unzip(); $unzip = new StrSimpleUnzip(); $unzip->ReadData($content); foreach ($unzip->Entries as $item) { $result[$item->Path . '/' . $item->Name] = $item->Data; } unset($unzip); break; default: $this->unknown_archive(); } return $result; }
public static function install() { $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR; //test write if (!file_put_contents($dir . 'test.php', ' ')) { die('Error write to test.php'); } chmod($dir . 'test.php', 0666); unlink($dir . 'test.php'); if ($version = self::getlatest()) { if (($s = http::get("http://litepublisher.googlecode.com/files/litepublisher.{$version}.tar.gz")) || ($s = http::get("http://litepublisher.com/download/litepublisher.{$version}.tar.gz"))) { $tar = new tar(); $tar->loadfromstring($s); foreach ($tar->files as $file) { $filename = $dir . str_replace('/', DIRECTORY_SEPARATOR, $file['name']); if (!self::forcedir(dirname($filename))) { die("error create folder " . dirname($filename)); } if (false === @file_put_contents($filename, $file['file'])) { die(sprintf('Error write file %s', $filename)); } @chmod($filename, 0666); } return true; } } die('Error download last release'); }