コード例 #1
0
 function execute(&$controller, &$xoopsUser)
 {
     if (xoops_getrequest('_form_control_cancel') != null) {
         return LEGACYRENDER_FRAME_VIEW_CANCEL;
     }
     $this->mActionForm->fetch();
     $this->mActionForm->validate();
     if ($this->mActionForm->hasError()) {
         return $this->getDefaultView($controller, $xoopsUser);
     }
     require_once XOOPS_ROOT_PATH . "/class/class.tar.php";
     $tar = new tar();
     $formFile = $this->mActionForm->get('upload');
     //
     // [Warn] access private member directly
     // TODO We should define the access method because we oftern
     //      access private member of XCube_FormFile.
     //
     $tar->openTar($formFile->_mTmpFileName);
     if (!is_array($tar->files)) {
         return LEGACYRENDER_FRAME_VIEW_ERROR;
     }
     $tplsetName = null;
     foreach ($tar->files as $id => $info) {
         $infoArr = explode('/', str_replace("\\", '/', $info['name']));
         $tplsetName = $this->mActionForm->get('tplset_name');
         if ($tplsetName == null) {
             $tplsetName = trim($infoArr[0]);
         }
         if ($tplsetName != null) {
             break;
         }
     }
     //
     // Check tplset name.
     //
     if ($tplsetName == null || preg_match('/[' . preg_quote('\\/:*?"<>|', '/') . ']/', $tplsetName)) {
         $this->_addErrorMessage(_AD_LEGACYRENDER_ERROR_TPLSET_NAME_WRONG);
         return LEGACYRENDER_FRAME_VIEW_ERROR;
     }
     $handler =& xoops_getmodulehandler('tplset');
     if ($handler->getCount(new Criteria('tplset_name', $tplsetName)) != 0) {
         $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_TPLSET_ALREADY_EXISTS, $tplsetName));
         return LEGACYRENDER_FRAME_VIEW_ERROR;
     }
     $tplset =& $handler->create();
     $tplset->set('tplset_name', $tplsetName);
     if (!$handler->insert($tplset)) {
         $this->_addErrorMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_TPLSET);
         return LEGACYRENDER_FRAME_VIEW_ERROR;
     }
     $themeimages = array();
     if (!$this->_fetchTemplateFiles($tar, $tplset, $themeimages)) {
         return LEGACYRENDER_FRAME_VIEW_ERROR;
     }
     if (!$this->_fetchImageset($tar, $tplset, $themeimages)) {
         return LEGACYRENDER_FRAME_VIEW_ERROR;
     }
     return LEGACYRENDER_FRAME_VIEW_SUCCESS;
 }
コード例 #2
0
 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();
     }
 }
コード例 #3
0
	function execute(&$controller, &$xoopsUser)
	{
		$form_cancel = $controller->mRoot->mContext->mRequest->getRequest('_form_control_cancel');
		if ($form_cancel != null) {
			return USER_FRAME_VIEW_CANCEL;
		}

		$this->mActionForm->fetch();
		$this->mActionForm->validate();
		
		if ($this->mActionForm->hasError()) {
			return $this->getDefaultView($controller, $xoopsUser);
		}
		
		$formFile = $this->mActionForm->get('upload');		
		$formFileExt = $formFile->getExtension();
		$files = array();
		$avatarimages = array();

		if ( strtolower($formFileExt) == "zip" ) {
		If ( !file_exists(XOOPS_ROOT_PATH . "/class/Archive_Zip.php") ) {
			return USER_FRAME_VIEW_ERROR;
		}
		require_once XOOPS_ROOT_PATH . "/class/Archive_Zip.php" ;
		$zip = new Archive_Zip($formFile->_mTmpFileName) ;
		$files = $zip->extract( array( 'extract_as_string' => true ) ) ;
		if( ! is_array( @$files ) ) {
		return USER_FRAME_VIEW_ERROR;
		}
		if (!$this->_fetchZipAvatarImages($files, $avatarimages)) {
			return USER_FRAME_VIEW_ERROR;
		}		
		}//if zip end
		else { 
		require_once XOOPS_ROOT_PATH . "/class/class.tar.php";
		$tar =new tar();
		$tar->openTar($formFile->_mTmpFileName);
		if (!is_array( @$tar->files)) {
			return USER_FRAME_VIEW_ERROR;
		}
		if (!$this->_fetchTarAvatarImages($tar->files, $avatarimages)) {
			return USER_FRAME_VIEW_ERROR;
		}		
		}//end tar
						
		if (!$this->_saveAvatarImages($avatarimages)) {
			return USER_FRAME_VIEW_ERROR;
		}
		return USER_FRAME_VIEW_SUCCESS;

	}
コード例 #4
0
ファイル: tar_test.php プロジェクト: dw4dev/Phalanger
function main()
{
    $tar = new tar();
    $tar->addFile('./test.pdf');
    $tar->toTar('./test_create.tar', false);
    $tar1 = new tar();
    $opened = $tar1->openTAR('./test_create.tar');
    if ($opened) {
        $soubor = $tar1->getFile('./test.pdf');
        echo $soubor["file"];
    } else {
        echo "FAILED TO OPEN ARCHIVE";
    }
}
コード例 #5
0
ファイル: export_lib.php プロジェクト: bitweaver/wiki
 function MakeWikiZip($pExportFile)
 {
     global $gBitUser, $gBitSystem;
     include_once UTIL_PKG_PATH . "tar.class.php";
     $tar = new tar();
     $query = "SELECT wp.`page_id` from `" . BIT_DB_PREFIX . "wiki_pages` wp INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = wp.`content_id`) \n\t\t\t\t  ORDER BY lc." . $this->mDb->convertSortmode("title_asc");
     $result = $this->mDb->query($query, array());
     while ($res = $result->fetchRow()) {
         $page_id = $res["page_id"];
         $content = $this->export_wiki_page($page_id, 0);
         $tar->addData($page_id, $content, $gBitSystem->getUTCTime());
     }
     $tar->toTar($pExportFile, FALSE);
     return '';
 }
コード例 #6
0
ファイル: exportlib.php プロジェクト: rjsmelo/tiki
 function MakeWikiZip()
 {
     global $tikidomain;
     $zipname = 'wikidb.zip';
     include_once 'lib/tar.class.php';
     $tar = new tar();
     $query = 'select `pageName` from `tiki_pages` order by ' . $this->convertSortMode('pageName_asc');
     $result = $this->query($query, array());
     while ($res = $result->fetchRow()) {
         $page = $res['pageName'];
         $content = $this->export_wiki_page($page, 0);
         $tar->addData($page, $content, $this->now);
     }
     $dump = 'dump';
     if ($tikidomain) {
         $dump .= "/{$tikidomain}";
     }
     $tar->toTar("{$dump}/export.tar", FALSE);
     return '';
 }
コード例 #7
0
ファイル: exportlib.php プロジェクト: noikiy/owaspbwa
 function MakeWikiZip()
 {
     global $tikidomain;
     $zipname = "wikidb.zip";
     include_once "lib/tar.class.php";
     $tar = new tar();
     $query = "select `pageName` from `tiki_pages` order by " . $this->convert_sortmode("pageName_asc");
     $result = $this->query($query, array());
     while ($res = $result->fetchRow()) {
         $page = $res["pageName"];
         $content = $this->export_wiki_page($page, 0);
         $tar->addData($page, $content, date("U"));
     }
     $dump = "dump";
     if ($tikidomain) {
         $dump .= "/{$tikidomain}";
     }
     $tar->toTar("{$dump}/export.tar", FALSE);
     return '';
 }
コード例 #8
0
 function s_export_structure($structure_id)
 {
     global $exportlib, $tikidomain;
     global $dbTiki;
     include_once 'lib/wiki/exportlib.php';
     include_once 'lib/tar.class.php';
     $page_info = $this->s_get_structure_info($structure_id);
     $page_name = $page_info['pageName'];
     $zipname = $page_name . '.zip';
     $tar = new tar();
     $pages = $this->s_get_structure_pages($page_info['page_ref_id']);
     foreach ($pages as $page) {
         $data = $exportlib->export_wiki_page($page['pageName'], 0);
         $tar->addData($page['pageName'], $data, $this->now);
     }
     $dump = 'dump';
     if ($tikidomain) {
         $dump .= "/{$tikidomain}";
     }
     $tar->toTar("{$dump}/{$page_name}.tar", FALSE);
     header("location: {$dump}/{$page_name}.tar");
     return '';
 }
コード例 #9
0
    foreach ($dir_array as $n) {
        #echo $n."<br>";
        if ($n != '.' and $n != '..') {
            #echo "hier : $n <br>";
            if (is_dir($predir . $dir . "/" . $n)) {
                add_file_reku($predir . $dir . "/", $n);
            }
            if (!is_dir($predir . $dir . "/" . $n)) {
                $tar->addFile($predir . $dir . "/" . $n, TRUE);
            }
            #echo $predir.$dir."/".$n."<br>";
        }
    }
}
if ($FORM[filesubmit]) {
    $tar = new tar();
    foreach ($DIR as $key => $item) {
        add_file_reku("../", $key);
    }
    header("Content-type: tar/gzip");
    header("Content-Disposition: attachment; filename=redaxo_export_" . date("Ymd") . ".tar.gz");
    echo $tar->toTarOutput("redaxo_export_" . date("Ymd") . ".tar.gz", TRUE);
    exit;
}
if (isset($err_msg)) {
    $err_msg = "<tr><td class=dgrey colspan=2><font color=error>{$err_msg}</font></td></tr>";
}
## make dir inputs
chdir("..");
$handle = opendir(".");
$dirstring = "";
コード例 #10
0
ファイル: setup.php プロジェクト: BackupTheBerlios/redaxo-svn
     // ----- community0.5 anlegen
     $REX[version] = "2.7";
     // ----- db anlegen
     $file_temp = "include/install/community0.5_redaxo2.7.sql";
     $h = fopen($file_temp, "r");
     $conts = fread($h, filesize($file_temp));
     $all = explode("\n", $conts);
     $add = new sql();
     // $add->debugsql = 1;
     foreach ($all as $hier) {
         $add->setquery(Trim(str_replace("||||||+N+||||||", "\n", $hier), ";"));
         $add->flush();
     }
     // ----- dateien anlegen
     $file_temp = $REX[INCLUDE_PATH] . "/install/community0.5_redaxo2.7.tar.gz";
     $tar = new tar();
     $tar->openTAR($file_temp);
     if (!$tar->extractTar()) {
         $err_msg = $I18N->msg("problem_when_extracting") . "<br>";
         if (count($tar->message) > 0) {
             $err_msg .= $I18N->msg("create_dirs_manually") . "<br>";
             reset($tar->message);
             for ($fol = 0; $fol < count($tar->message); $fol++) {
                 $err_msg .= key($tar->message) . "<br>";
                 next($tar->message);
             }
         }
     }
 } elseif ($dbanlegen == 3) {
     // ----- update
     $fname = "include/install/update2_6-2_7.sql";
コード例 #11
0
        } elseif ($extension == 'tar.gz') {
            gzAbortNotLoaded();
            $temp = gzTempfile($file);
            $temp = realpath($temp);
            include 'classes/class.tar.php';
            $tar = new tar();
            $tar->new_tar(viscacha_dirname($temp), basename($temp));
            $tar->extract_files(realpath($dir));
            $err = $tar->error;
            $filesystem->unlink($temp);
            if (!empty($err)) {
                error($redirect, $err);
            }
        } elseif ($extension == 'tar') {
            include 'classes/class.tar.php';
            $tar = new tar();
            $file = realpath($file);
            $tar->new_tar(viscacha_dirname($file), basename($file));
            $tar->extract_files($dir);
        } elseif ($extension == 'gz') {
            gzAbortNotLoaded();
            $new = $dir . DIRECTORY_SEPARATOR . basename($file);
            $temp = gzTempfile($file, $new);
        }
    }
    if (!isset($extension)) {
        error($redirect, 'File is not an supported archive. (Failed at position: setting extension)');
    } else {
        ok($redirect);
    }
} else {
コード例 #12
0
ファイル: adminlib.php プロジェクト: noikiy/owaspbwa
 function dump()
 {
     global $tikidomain, $wikiHomePage, $style;
     $dump_path = "dump";
     if ($tikidomain) {
         $dump_path .= "/{$tikidomain}";
     }
     @unlink("{$dump_path}/new.tar");
     $tar = new tar();
     $tar->addFile("styles/{$style}");
     // Foreach page
     $query = "select * from `tiki_pages`";
     $result = $this->query($query, array());
     while ($res = $result->fetchRow()) {
         $pageName = $res["pageName"] . '.html';
         $dat = $this->parse_data($res["data"]);
         // Now change index.php?page=foo to foo.html
         // and index.php to HomePage.html
         $dat = preg_replace("/tiki-index.php\\?page=([^\\'\"\$]+)/", "\$1.html", $dat);
         $dat = preg_replace("/tiki-editpage.php\\?page=([^\\'\"\$]+)/", "", $dat);
         //preg_match_all("/tiki-index.php\?page=([^ ]+)/",$dat,$cosas);
         //print_r($cosas);
         $data = "<html><head><title>" . $res["pageName"] . "</title><link rel='StyleSheet' href='styles/{$style}' type='text/css'></head><body><a class='wiki' href='{$wikiHomePage}.html'>home</a><br /><h1>" . $res["pageName"] . "</h1><div class='wikitext'>" . $dat . '</div></body></html>';
         $tar->addData($pageName, $data, $res["lastModif"]);
     }
     $tar->toTar("{$dump_path}/new.tar", FALSE);
     unset($tar);
     $action = "dump created";
     $t = date("U");
     $query = "insert into `tiki_actionlog`(`action`,`pageName`,`lastModif`,`user`,`ip`,`comment`) values(?,?,?,?,?,?)";
     $result = $this->query($query, array($action, $wikiHomePage, $t, 'admin', $_SERVER["REMOTE_ADDR"], ''));
 }
コード例 #13
0
ファイル: system.php プロジェクト: Parashutik/ReloadCMS
 function logMerge($title, $t_d, $t_m, $t_y, $f_d = 1, $f_m = 1, $f_y = 1980)
 {
     $logs = rcms_scandir($this->logging);
     $f = mktime(0, 0, 0, $f_m, $f_d, $f_y);
     $t = mktime(0, 0, 0, $t_m, $t_d, $t_y);
     $to_merge = array();
     foreach ($logs as $log_entry) {
         if (preg_match("/^(.*?)-(.*?)-(.*?)\\.log(|.gz)\$/i", $log_entry, $matches)) {
             $c = mktime(0, 0, 0, $matches[2], $matches[3], $matches[1]);
             if ($c >= $f && $c <= $t) {
                 $to_merge[] = $log_entry;
             }
         }
     }
     if (!empty($to_merge)) {
         if ($this->logging_gz) {
             $suffix = '.gz';
         } else {
             $suffix = '';
         }
         $merged_file = $this->logging . $title . '.tar' . $suffix;
         $merged = new tar();
         $merged->isGzipped = $this->logging_gz;
         $merged->filename = $merged_file;
         $path = getcwd();
         chdir($this->logging);
         foreach ($to_merge as $file) {
             $merged->addFile($file, substr($file, -3) == '.gz');
         }
         chdir($path);
         if ($merged->saveTar()) {
             foreach ($to_merge as $file) {
                 rcms_delete_files($this->logging . $file);
             }
         }
     }
     return true;
 }
コード例 #14
0
ファイル: tar.php プロジェクト: alsahh/redaxo
 public function __construct()
 {
     parent::__construct();
 }
コード例 #15
0
ファイル: autoinstall.lib.php プロジェクト: Gunmania/xe-core
 /**
  * Untar a downloaded tar ball
  *
  * @return array Returns file list
  */
 function _unPack()
 {
     require_once _XE_PATH_ . 'libs/tar.class.php';
     $oTar = new tar();
     $oTar->openTAR($this->download_file);
     $_files = $oTar->files;
     $file_list = array();
     if (is_array($_files)) {
         foreach ($_files as $key => $info) {
             FileHandler::writeFile($this->download_path . "/" . $info['name'], $info['file']);
             $file_list[] = $info['name'];
         }
     }
     return $file_list;
 }
コード例 #16
0
 function rex_tar()
 {
     parent::tar();
 }
コード例 #17
0
ファイル: modslib.php プロジェクト: rjsmelo/tiki
 /**
  * @param $remote
  * @param $file
  * @param $local
  * @return bool
  */
 function dl_remote($remote, $file, $local)
 {
     $meat = $this->get_remote($remote . "/Dist/" . $file . ".tgz");
     if ($meat === FALSE) {
         return FALSE;
     }
     $localfile = $local . "/Cache/" . $file . ".tgz";
     if (is_file($localfile)) {
         unlink($localfile);
     }
     $fp = fopen($localfile, "wb");
     fwrite($fp, $meat);
     fclose($fp);
     require_once "lib/tar.class.php";
     $tar = new tar();
     if ($tar->openTAR($localfile)) {
         foreach ($tar->files as $f) {
             $this->prepare_dir(dirname($local . '/' . $f['name']));
             $fp = fopen($local . '/' . $f['name'], "wb");
             fwrite($fp, $f['file'], $f['size']);
             fclose($fp);
         }
     } else {
         $this->feedback_error(sprintf(tra('File %s is not a valid archive'), $localfile));
         return false;
     }
 }
コード例 #18
0
ファイル: 3.php プロジェクト: BackupTheBerlios/viscacha-svn
include 'data/config.inc.php';
if (!class_exists('filesystem')) {
    require_once 'install/classes/class.filesystem.php';
    $filesystem = new filesystem($config['ftp_server'], $config['ftp_user'], $config['ftp_pw'], $config['ftp_port']);
    $filesystem->set_wd($config['ftp_path'], $config['fpath']);
}
$tar_packs = array(1 => 'update.admin.tar', 2 => 'update.misc.tar');
if (empty($_REQUEST['sub']) || !isset($tar_packs[$_REQUEST['sub']])) {
    $sub = 1;
} else {
    $sub = $_REQUEST['sub'];
}
require 'install/classes/function.chmod.php';
require 'install/classes/class.tar.php';
$tar = new tar(realpath('install/files/'), $tar_packs[$sub]);
$tar->ignore_chmod();
$error = $tar->extract_files('./');
$files = implode("\n", $tar->list_files());
$dirs = array('language' => null, 'templates' => null, 'designs' => null, 'images' => null);
preg_match_all('~^(' . implode('|', array_keys($dirs)) . ')/(\\d+)/([^\\n]+)$~m', $files, $replicable, PREG_SET_ORDER);
foreach ($replicable as $rep) {
    if ($dirs[$rep[1]] === null) {
        $dirs[$rep[1]] = array();
        $dir = dir($rep[1]);
        while (false !== ($entry = $dir->read())) {
            if (is_id($entry) && is_dir($rep[1] . '/' . $entry)) {
                $dirs[$rep[1]][$entry] = $rep[1] . '/' . $entry . '/';
            }
        }
        $dir->close();
コード例 #19
0
        } elseif ($extension == 'tar.gz') {
            gzAbortNotLoaded();
            $temp = gzTempfile($file);
            $temp = realpath($temp);
            include 'classes/class.tar.php';
            $tar = new tar();
            $tar->new_tar(dirname($temp), basename($temp));
            $tar->extract_files(realpath($dir));
            $err = $tar->error;
            $filesystem->unlink($temp);
            if (!empty($err)) {
                error($redirect, $err);
            }
        } elseif ($extension == 'tar') {
            include 'classes/class.tar.php';
            $tar = new tar();
            $file = realpath($file);
            $tar->new_tar(dirname($file), basename($file));
            $tar->extract_files($dir);
        } elseif ($extension == 'gz') {
            gzAbortNotLoaded();
            $new = $dir . DIRECTORY_SEPARATOR . basename($file);
            $temp = gzTempfile($file, $new);
        }
    }
    if (!isset($extension)) {
        error($redirect, 'File is not an supported archive. (Failed at position: setting extension)');
    } else {
        ok($redirect);
    }
} else {
コード例 #20
0
ファイル: i_backup.php プロジェクト: JulioCF/MZnews
         require_once $s->cfg['path']['inc'] . "/l_tar.php";
         $tar = new tar();
         $tar->new_tar($s->cfg['path']['data'], "backup.tar");
         $list = array();
         foreach ($s->cfg['file'] as $file) {
             $list[] = basename($file);
         }
         $tar->add_files($list, $s->cfg['path']['data']);
         $tar->write_tar();
     }
     $m->location("sec=backup", "Backup criado");
 } else {
     if ($act == "restore") {
         if (!$s->cfg['ver']['demo']) {
             require_once $s->cfg['path']['inc'] . "/l_tar.php";
             $tar = new tar();
             if ($s->req['use'] == "local") {
                 if (!@file_exists($s->cfg['path']['data'] . "/backup.tar")) {
                     $m->error_redir("backup_notar");
                 }
             } else {
                 if (@file_exists($s->cfg['path']['data'] . "/backup.tar")) {
                     @unlink($s->cfg['path']['data'] . "/backup.tar");
                 }
                 if (!$HTTP_POST_FILES['file']['tmp_name']) {
                     $m->error_redir("backup_upload_notmp");
                 }
                 if (!preg_match("/\\.tar\$/", $HTTP_POST_FILES['file']['name'])) {
                     @unlink($HTTP_POST_FILES['file']['tmp_name']);
                     $m->error_redir("backup_upload_invalid");
                 }
コード例 #21
0
ファイル: adminlib.php プロジェクト: linuxwhy/tiki-1
 function dump()
 {
     global $tikidomain, $prefs;
     $parserlib = TikiLib::lib('parser');
     $dump_path = "dump";
     if ($tikidomain) {
         $dump_path .= "/{$tikidomain}";
     }
     @unlink("{$dump_path}/new.tar");
     $tar = new tar();
     $tar->addFile('styles/' . $prefs['style']);
     // Foreach page
     $query = "select * from `tiki_pages`";
     $result = $this->query($query, array());
     while ($res = $result->fetchRow()) {
         $pageName = $res["pageName"] . '.html';
         $dat = $parserlib->parse_data($res["data"]);
         // Now change index.php?page=foo to foo.html
         // and index.php to HomePage.html
         $dat = preg_replace("/tiki-index.php\\?page=([^\\'\"\$]+)/", "\$1.html", $dat);
         $dat = preg_replace("/tiki-editpage.php\\?page=([^\\'\"\$]+)/", "", $dat);
         //preg_match_all("/tiki-index.php\?page=([^ ]+)/",$dat,$cosas);
         //print_r($cosas);
         $data = "<html><head><title>" . $res["pageName"] . "</title><link rel='StyleSheet' href='styles/" . $prefs['style'] . "' type='text/css'></head><body><a class='wiki' href='" . $prefs['wikiHomePage'] . ".html'>home</a><br /><h1>" . $res["pageName"] . "</h1><div class='wikitext'>" . $dat . '</div></body></html>';
         $tar->addData($pageName, $data, $res["lastModif"]);
     }
     $tar->toTar("{$dump_path}/new.tar", FALSE);
     unset($tar);
     $logslib = TikiLib::lib('logs');
     $logslib->add_log('dump', 'dump created');
 }
コード例 #22
0
 function extract($src, $dest = false)
 {
     $path_parts = pathinfo($src);
     if (!$dest) {
         $dest = $path_parts['dirname'] . '/';
     }
     $ext = '.' . $path_parts['extension'];
     $name = $path_parts['filename'];
     foreach ($this->WathArchive as $key => $val) {
         if (stripos($ext, $key) !== false) {
             $comp = $val;
         }
     }
     if ($comp == 'zip') {
         $zip = new zip();
         return $zip->extractZip($src, $dest);
     } elseif (strlen($comp) > 1) {
         $tar = new tar();
         if ($comp == 'bz') {
             $bzip2 = new bzip2();
             $src = $bzip2->extractBzip2($src);
         } elseif ($comp == 'gz') {
             $gzip = new gzip();
             $src = $gzip->extractGzip($src);
         }
         if ($tar->is_tar($src) || is_file($src)) {
             return $tar->extractTar($src, $dest);
         } else {
             file_put_contents($dest . $name, $src);
         }
         return $dest;
     }
     return false;
 }
コード例 #23
0
ファイル: backup.php プロジェクト: l1ght13aby/Ubilling
//   http://reloadcms.sf.net                                                  //
//                                                                            //
//   This program is distributed in the hope that it will be useful,          //
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   This product released under GNU General Public License v2                //
////////////////////////////////////////////////////////////////////////////////
if (!empty($_POST['backupit'])) {
    if (!empty($_POST['gzip'])) {
        $suffix = '.gz';
    } else {
        $suffix = '';
    }
    $bkupfilename = RCMS_ROOT_PATH . 'backups/backup_' . date('H-i-s_d.m.Y') . '.tar' . $suffix;
    $backup = new tar();
    $backup->isGzipped = !empty($_POST['gzip']);
    $backup->filename = $bkupfilename;
    $path = getcwd();
    chdir(RCMS_ROOT_PATH);
    $backup->addDirectory('config', true);
    $backup->addDirectory('content', true);
    chdir($path);
    $backup->saveTar();
    rcms_showAdminMessage(__('Backup complete') . ' (' . basename($bkupfilename) . ')');
}
// Interface generation
$frm = new InputForm('', 'post', __('Backup data'));
$frm->addbreak(__('Backup data'));
$frm->hidden('backupit', '1');
$frm->addrow(__('To backup all your data from directories "config" and "content" press "Create backup" button. Speed of backup creation depends on size of your site. In order to be more secure we do not provide any backups management from there. You must download or delete backups using FTP or another way to reach /backups/ folder, because HTTP access for it was forbidden.'));
コード例 #24
0
 /**
  *  Uncompress update TAR
  * 
  * Extract forum files to extensions folder 
  * Step three (of 3) in Auto Update process.
  * @todo Finish auto-update, need work on exstrating, need run auto run update script
  * @uses Set_AWC_Forum_BreadCrumbs
  * @since Version 2.5.8
  */
 function autoupdate_unpack_and_update()
 {
     global $wgRequest, $IP;
     Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('admin_autoupdate') . ' - ' . get_awcsforum_word('admin_expearimental'), true);
     $get_ver = $wgRequest->getVal('get_ver');
     $save_tar = awc_dir . 'updates/AutoUpdate_tars/' . $get_ver . '.tar';
     require awc_dir . 'includes/tar_cls.php';
     $tar = new awcsforum_tar_compress_cls();
     //$tar->filename = $save_tar;
     $arch = new tar();
     $arch->extractTar($save_tar, awc_dir . 'updates/AutoUpdate_tars/');
     // die($IP);
     //  $tar->extract_files($IP . '/');
     // working, just need to fix the TAR error problem above...
     // die(header("Location: " . awc_url . 'admin/get_updates/' . $get_ver));
 }
コード例 #25
0
 /**
  * import layout
  * @param int $layout_srl
  * @param string $source_file path of imported file
  * @return void
  */
 function importLayout($layout_srl, $source_file)
 {
     $oLayoutModel = getModel('layout');
     $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl));
     $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl);
     foreach ($file_list as $key => $file) {
         FileHandler::removeFile($user_layout_path . $file);
     }
     require_once _XE_PATH_ . 'libs/tar.class.php';
     $image_path = $oLayoutModel->getUserLayoutImagePath($layout_srl);
     FileHandler::makeDir($image_path);
     $tar = new tar();
     $tar->openTAR($source_file);
     // If layout.ini file does not exist
     if (!$tar->getFile('layout.ini')) {
         return;
     }
     $replace_path = getNumberingPath($layout_srl, 3);
     foreach ($tar->files as $key => $info) {
         FileHandler::writeFile($user_layout_path . $info['name'], str_replace('__LAYOUT_PATH__', $replace_path, $info['file']));
     }
     // Remove uploaded file
     FileHandler::removeFile($source_file);
 }
コード例 #26
0
function downgrade($file)
{
    $unix = new unix();
    $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidFile);
    if ($unix->process_exists($pid)) {
        Events("??%: A process already exists PID {$pid}");
        return;
    }
    @file_put_contents($pidFile, getmypid());
    $workdir = "/home/squid/downgrade";
    $gzf = "/home/squid/downgrade/{$file}";
    @mkdir("/home/squid/downgrade", 0755, true);
    Events("0%: Ask to update package name {$file}");
    Events("1%: downloading {$file}");
    if (!is_dir($workdir)) {
        Events("100%: Failed,  {$workdir} Permission denied");
        die;
    }
    if (is_file($gzf)) {
        @unlink($gzf);
    }
    $unix = new unix();
    $URIBASE = $unix->MAIN_URI();
    Events("5%: PLEASE WAIT,PLEASE WAIT,PLEASE WAIT.....downloading {$file}");
    $curl = new ccurl("{$URIBASE}/download/old-squid/{$file}");
    $curl->NoHTTP_POST = true;
    $curl->ProgressFunction = "downgrade_prg";
    $curl->WriteProgress = true;
    if (!$curl->GetFile($gzf)) {
        Events("100%: Failed to download {$curl->error}");
        die;
    }
    if (!is_file($gzf)) {
        Events("100%: Failed to download permission denied on disk");
        die;
    }
    $size = @filesize($gzf);
    $size = $size / 1024;
    $size = $size / 1024;
    Events("10%: " . basename($gzf) . " " . round($size, 2) . " MB");
    Events("10%: Testing {$gzf}");
    if ($GLOBALS["VERBOSE"]) {
        echo "Open TAR...\n";
    }
    $tar = new tar();
    if (!$tar->openTar($gzf)) {
        Events("100%: Failed archive seems corrupted..");
        die;
    }
    Events("10%: Testing {$gzf} success");
    Events("15%: Start upgrade procedure...");
    Events("16%: Stopping Squid-Cache...");
    shell_exec("/etc/init.d/squid stop");
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $rm = $unix->find_program("rm");
    $tar = $unix->find_program("tar");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    Events("17%: Removing {$squidbin}...");
    @unlink($squidbin);
    $f[] = "/lib/squid3";
    $f[] = "/usr/share/squid-langpack";
    $f[] = "/usr/share/squid3";
    while (list($num, $dir) = each($f)) {
        Events("20%: Removing {$dir} directory...");
        shell_exec("{$rm} -rf {$dir} >/dev/null 2>&1");
    }
    Events("50%: Installing...");
    shell_exec("{$tar} xf {$gzf} -C / >/dev/null");
    $squidbin = $unix->LOCATE_SQUID_BIN();
    if (!is_file($squidbin)) {
        Events("100%: Failed archive seems corrupted, please restart again or contact or support team...");
        die;
    }
    $ver = $unix->squid_version();
    Events("60%: New Squid-cache version {$ver}");
    Events("65%: Reconfiguring parameters");
    shell_exec("{$php5} /usr/share/artica-postfix/exec.squid.php --build --force >/dev/null");
    Events("70%: Starting Squid-Cache");
    shell_exec("/etc/init.d/squid start");
    Events("80%: Refresh Artica with the new version...");
    shell_exec("/etc/init.d/artica-process1 start");
    Events("90%: Restarting watchdogs...");
    system("/etc/init.d/cache-tail restart");
    system("{$nohup} /etc/init.d/artica-status reload >/dev/null 2>&1 &");
    shell_exec("{$nohup} /etc/init.d/monit restart  >/dev/null 2>&1 &");
    Events("100%: Done...");
    Events("-------------------------------------------------------------");
    Events("----------------     Squid Cache V.{$ver}    ------------------");
    Events("-------------------------------------------------------------");
}
コード例 #27
0
            }
        } elseif ($extension == 'tar.gz') {
            gzAbortNotLoaded();
            $temp = gzTempfile($file);
            $temp = realpath($temp);
            include 'classes/class.tar.php';
            $tar = new tar(dirname($temp), basename($temp));
            $tar->extract_files(realpath($dir));
            $filesystem->unlink($temp);
            if (!empty($tar->error)) {
                error($redirect, $tar->error);
            }
        } elseif ($extension == 'tar') {
            $file = realpath($file);
            include 'classes/class.tar.php';
            $tar = new tar(dirname($file), basename($file));
            $tar->extract_files($dir);
            if (!empty($tar->error)) {
                error($redirect, $tar->error);
            }
        } elseif ($extension == 'gz') {
            gzAbortNotLoaded();
            $new = $dir . DIRECTORY_SEPARATOR . basename($file);
            $temp = gzTempfile($file, $new);
        }
    }
    ok($redirect);
} elseif ($job == 'all_chmod') {
    echo head();
    $chmod = getViscachaCHMODs();
    ?>
コード例 #28
0
     $where_sql[] = "group_id='{$group_id}'";
 }
 if (!empty($where_sql)) {
     $where_sql = ' WHERE ' . implode(' AND ', $where_sql);
 } else {
     $where_sql = '';
 }
 //$tablename=$old_game?$cfg['tb_oldgames']:$cfg['tb_games'];
 //$sql="SELECT * FROM `$cfg[tb_games]` $where_sql ORDER BY gid DESC LIMIT";
 //echo "$row[0]";
 if ($packdown) {
     require_once './include/tar.class.php';
     header("Content-type: /tar.gz");
     $filename = md5(uniqid(rand()));
     header("Content-Disposition: attachment; filename={$filename}.tar.gz");
     $tar = new tar();
     $sql = "SELECT * FROM `{$cfg['tb_games']}` {$where_sql}";
     $result = RenDB_Query($sql);
     while ($gdata = RenDB_Fetch_Array($result)) {
         $tar->addPosFile($gdata);
     }
     $tar->addInfo('Generated by RBB, ' . TimeToDate(time(), true));
     $tar->echoTar();
 } else {
     SetNoUseCache();
     $sql = "SELECT COUNT(*) FROM `{$cfg['tb_games']}` {$where_sql}";
     $result = RenDB_Query($sql);
     $row = RenDB_Fetch_Row($result);
     if (!isset($page)) {
         $page = 1;
     }
コード例 #29
0
ファイル: main.php プロジェクト: BackupTheBerlios/xoops4-svn
     break;
 case 'uploadtar_go':
     if (!$GLOBALS['xoopsSecurity']->check()) {
         redirect_header('admin.php?fct=tplsets', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
     }
     include_once XOOPS_ROOT_PATH . '/class/uploader.php';
     $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('application/x-gzip', 'application/gzip', 'application/gzip-compressed', 'application/x-gzip-compressed', 'application/x-tar', 'application/x-tar-compressed', 'application/octet-stream'), 1000000);
     $uploader->setPrefix('tmp');
     xoops_cp_header();
     echo '<code>';
     if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
         if (!$uploader->upload()) {
             xoops_error($uploader->getErrors());
         } else {
             include_once XOOPS_ROOT_PATH . '/class/class.tar.php';
             $tar = new tar();
             $tar->openTar($uploader->getSavedDestination());
             @unlink($uploader->getSavedDestination());
             $themefound = false;
             foreach ($tar->files as $id => $info) {
                 $infoarr = explode('/', str_replace("\\", '/', $info['name']));
                 if (!isset($tplset_name)) {
                     $tplset_name = trim($infoarr[0]);
                 } else {
                     $tplset_name = trim($tplset_name);
                     if ($tplset_name == '') {
                         $tplset_name = trim($infoarr[0]);
                     }
                 }
                 if ($tplset_name != '') {
                     break;
コード例 #30
0
             }
             foreach ($dir_array as $n) {
                 #echo $n."<br>";
                 if ($n != '.' and $n != '..') {
                     #echo "hier : $n <br>";
                     if (is_dir($predir . $dir . "/" . $n)) {
                         add_file_reku($predir . $dir . "/", $n);
                     }
                     if (!is_dir($predir . $dir . "/" . $n)) {
                         $tar->addFile($predir . $dir . "/" . $n, TRUE);
                     }
                     #echo $predir.$dir."/".$n."<br>";
                 }
             }
         }
         $tar = new tar();
         foreach ($EXPDIR as $key => $item) {
             add_file_reku($REX[INCLUDE_PATH] . "/../../", $key);
         }
         $content = $tar->toTarOutput($filename . $ext, TRUE);
     }
     // ------------------------------ /FUNC FILES
 }
 if ($content != "" && $exportdl == 1) {
     $filename = $filename . $ext;
     header("Content-type: {$header}");
     header("Content-Disposition: attachment; filename={$filename}");
     echo $content;
     exit;
 } elseif ($content != "") {
     // check filename ob vorhanden