Exemplo n.º 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;
 }
Exemplo n.º 2
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;

	}
Exemplo n.º 3
0
 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;
                 }
Exemplo n.º 4
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("-------------------------------------------------------------");
}
Exemplo n.º 5
0
<?php

echo "<font face=\"Verdana\" size=\"2\">";
echo "<b>TAR Archive Class</b><br><br>\n\n";
// Include TAR Class
include "tar.class.php";
// Create instance of TAR class
$tar = new tar();
// Open an uncompressed tar file
if (!$tar->openTar("main.tar", FALSE)) {
    echo "<b>Could not open main.tar!</b><br>\n";
} else {
    echo "<b>Opened main.tar successfully!</b><br>\n";
}
// Append a compressed gzipped tar file
if (!$tar->appendTar("append.tgz", TRUE)) {
    echo "<b>Could not append append.tgz to opened tar file!</b><br>\n";
} else {
    echo "<b>Appended append.tgz successfully!</b><br>\n";
}
// List directories in the currently opened tar file(s)
echo "<b>Directories in " . $tar->filename . "</b><br>\n";
if ($tar->numDirectories > 0) {
    foreach ($tar->directories as $id => $information) {
        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$information['directory']}/{$information['name']}<br>\n";
    }
} else {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There are no directories described in this tar archive.<br>\n";
}
echo "<br>\n";
// List files in the currently opened tar file(s)
Exemplo n.º 6
0
$orig_filename4check = strtolower($_FILES['tplset_archive']['name']);
if (strtolower(substr($orig_filename4check, -4)) == '.zip') {
    // zip
    require_once dirname(__FILE__) . '/include/Archive_Zip.php';
    $reader = new Archive_Zip($_FILES['tplset_archive']['tmp_name']);
    $files = $reader->extract(array('extract_as_string' => true));
    if (!is_array(@$files)) {
        die($reader->errorName());
    }
    $do_upload = true;
} else {
    if (substr($orig_filename4check, -4) == '.tgz' || substr($orig_filename4check, -7) == '.tar.gz') {
        // tar.gz
        require_once XOOPS_ROOT_PATH . '/class/class.tar.php';
        $tar = new tar();
        $tar->openTar($_FILES['tplset_archive']['tmp_name']);
        $files = array();
        foreach ($tar->files as $id => $info) {
            $files[] = array('filename' => $info['name'], 'mtime' => $info['time'], 'content' => $info['file']);
        }
        if (empty($files)) {
            die(_TPLSADMIN_ERR_INVALIDARCHIVE);
        }
        $do_upload = true;
    }
}
if (empty($do_upload)) {
    die(_TPLSADMIN_ERR_EXTENSION);
}
//
// IMPORT STAGE
Exemplo n.º 7
0
$tar->toTar("combined.tgz", TRUE);
unset($tar);
// Removing 2 files from the new.tar file created above
$tar = new tar();
$tar->openTar("new.tar", FALSE);
$tar->removeFile("example.php");
$tar->removeFile("example2.php");
$tar->saveTar();
// Saves to currently open TAR file (In this case, new.tar)
unset($tar);
// Check if a TAR file contains a specific file
$tar = new tar();
$tar->openTar("new.tar", FALSE);
if ($tar->containsFile("tar.class.php")) {
    echo "This tar file contains a file named 'tar.class.php'!<br>\n";
} else {
    echo "This tar file does NOT contain a file named 'tar.class.php'!<br>\n";
}
// There is no need to save our tar file since we did not edit it, so delete our tar class
unset($tar);
// Get information about a file in a TAR file
$tar = new tar();
$tar->openTar("new.tar");
// If second argument is not present, default is FALSE
$information = $tar->getFile("tar.class.php");
echo "<br>\n<b>Information about tar.class.php!</b><br>\n";
foreach ($information as $key => $value) {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;{$key} = " . text2html($value) . "<br>\n";
}
echo "<br>\n";
echo "</font>";
Exemplo n.º 8
0
 $orig_filename4check = strtolower($_FILES['upload_archive']['name']);
 $orig_ext4check = substr($orig_filename4check, strrpos($orig_filename4check, '.') + 1);
 if ($orig_ext4check == 'zip') {
     // zip
     include_once dirname(dirname(__FILE__)) . '/include/Archive_Zip.php';
     $reader = new Archive_Zip($_FILES['upload_archive']['tmp_name']);
     $files = $reader->extract(array('extract_as_string' => true));
     if (!is_array(@$files)) {
         die($reader->errorName());
     }
 } else {
     if ($orig_ext4check == 'tar' || $orig_ext4check == 'tgz' || $orig_ext4check == 'gz') {
         // tar or tgz or tar.gz
         include_once XOOPS_ROOT_PATH . '/class/class.tar.php';
         $tar = new tar();
         $tar->openTar($_FILES['upload_archive']['tmp_name']);
         $files = array();
         foreach ($tar->files as $id => $info) {
             $files[] = array('filename' => $info['name'], 'mtime' => $info['time'], 'content' => $info['file']);
         }
         if (empty($files)) {
             die(_AM_AVAMAN_ERR_INVALIDARCHIVE);
         }
     } else {
         if (!empty($avaman_allowed_exts[$orig_ext4check])) {
             // a single image file
             $files = array();
             $files[] = array('filename' => $_FILES['upload_archive']['name'], 'mtime' => time(), 'content' => function_exists('file_get_contents') ? file_get_contents($_FILES['upload_archive']['tmp_name']) : implode(file($_FILES['upload_archive']['tmp_name'])));
         } else {
             die(_AM_AVAMAN_INVALIDEXT);
         }