Esempio n. 1
1
    function com_install($mypath = '')
    {
        error_reporting(E_ALL ^ E_NOTICE);
        global $database;
        if (is_callable(array('JFactory', 'getDBO'))) {
            $database = JFactory::getDBO();
        }
        if ($mypath == '') {
            $mypath = dirname(__FILE__);
        }
        require_once $mypath . "/include/functions.php";
        require_once $mypath . "/libraries/Archive/archive.php";
        ext_RaiseMemoryLimit('50M');
        $archive_name = $mypath . '/scripts.tar.gz';
        $extract_dir = $mypath . '/';
        $result = extArchive::extract($archive_name, $extract_dir);
        if (!@PEAR::isError($result)) {
            unlink($archive_name);
        } else {
            echo '<pre style="color:white; font-weight:bold; background-color:red;">Error!
			' . $result->getMessage() . '
			</pre>';
        }
        if (!is_callable(array($database, 'loadNextRow'))) {
            $database->setQuery("SELECT id FROM #__components WHERE admin_menu_link = 'option=com_extplorer'");
            $id = $database->loadResult();
            //add new admin menu images
            $database->setQuery("UPDATE #__components SET admin_menu_img = '../administrator/components/com_extplorer/images/x_icon.png', admin_menu_link = 'option=com_extplorer' WHERE id={$id}");
            $database->query();
        }
    }
Esempio n. 2
0
 function execAction($dir, $item)
 {
     if (!ext_isArchive($item)) {
         ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive'));
     } else {
         // CSRF Security Check
         if (!ext_checkToken($GLOBALS['__POST']["token"])) {
             ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
         }
         $archive_name = realpath(get_abs_item($dir, $item));
         if (empty($dir)) {
             $extract_dir = realpath($GLOBALS['home_dir']);
         } else {
             $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir);
         }
         require_once _EXT_PATH . '/libraries/Archive/archive.php';
         $res = extArchive::extract($archive_name, $extract_dir);
         if (PEAR::isError($res)) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage());
         }
         if ($res === false) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure'));
         } else {
             ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
         }
         ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
     }
 }
Esempio n. 3
0
 function execAction($dir, $item)
 {
     if (!ext_isArchive($item)) {
         ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive'));
     } else {
         $archive_name = realpath(get_abs_item($dir, $item));
         if (empty($dir)) {
             $extract_dir = realpath($GLOBALS['home_dir']);
         } else {
             $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir);
         }
         require_once _EXT_PATH . '/libraries/Archive/archive.php';
         $res = extArchive::extract($archive_name, $extract_dir);
         if (PEAR::isError($res)) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage());
         }
         if ($res === false) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure'));
         } else {
             ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
         }
         ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
     }
 }
    $text = str_replace('&&', '*--*', $text);
    $text = str_replace('&#', '*-*', $text);
    $text = str_replace('&amp;', '&', $text);
    $text = preg_replace('|&(?![\\w]+;)|', '&amp;', $text);
    $text = str_replace('*-*', '&#', $text);
    $text = str_replace('*--*', '&&', $text);
    return $text;
}
$mainframe = new extMainFrame();
$mypath = realpath(dirname(__FILE__) . '/..');
$archive_name = $mypath . '/scripts.tar.gz';
if (file_exists($archive_name) && !file_exists($mypath . '/scripts/functions.js.php')) {
    require_once $mypath . "/include/functions.php";
    require_once $mypath . "/libraries/Archive/archive.php";
    ext_RaiseMemoryLimit('16M');
    error_reporting(E_ALL ^ E_NOTICE);
    $extract_dir = $mypath . '/';
    $result = extArchive::extract($archive_name, $extract_dir);
    if (!PEAR::isError($result)) {
        unlink($archive_name);
    } else {
        die('<html><head><title>eXtplorer - Error!</title></head>
			<body><h2>Installation needs to be completed!</h2>
			<p>To complete the eXtplorer Installation you need to extract the contents of the file <strong>scripts.zip</strong>
 (you can find this file in the extplorer package) and upload it to the subdirectory <strong>/scripts</strong> of your eXtplorer installation.
	<br/>
	Please just upload the contents of the extracted folder &quot;/scripts&quot; into the subdirectory <strong>/scripts</strong> and do not create a subdirectory like &quot;/scripts/scripts/&quot;. 
</p>
			</body></html>');
    }
}
Esempio n. 5
0
function unzip_item($dir)
{
    _debug("unzip_item({$dir})");
    global $home_dir;
    // copy and move are only allowed if the user may read and change files
    if (!permissions_grant_all($dir, NULL, array("read", "create"))) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Vars
    $new_dir = isset($GLOBALS['__POST']["new_dir"]) ? stripslashes($GLOBALS['__POST']["new_dir"]) : $dir;
    $_img = $GLOBALS["baricons"]["unzip"];
    // Get Selected Item
    if (!isset($GLOBALS['__POST']["item"]) && isset($GLOBALS['__GET']["item"])) {
        $s_item = $GLOBALS['__GET']["item"];
    } elseif (isset($GLOBALS['__POST']["item"])) {
        $s_item = $GLOBALS['__POST']["item"];
    }
    $dir_extract = "{$home_dir}/{$new_dir}";
    if ($new_dir != "") {
        $dir_extract .= "/";
    }
    $zip_name = "{$home_dir}/{$dir}/{$s_item}";
    // Get New Location & Names
    if (!isset($GLOBALS['__POST']["confirm"]) || $GLOBALS['__POST']["confirm"] != "true") {
        show_header($GLOBALS["messages"]["actunzipitem"]);
        // JavaScript for Form:
        // Select new target directory / execute action
        ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	function NewDir(newdir) {
		document.selform.new_dir.value = newdir;
		document.selform.submit();
	}
	
	function Execute() {
		document.selform.confirm.value = "true";
	}
//-->
</script><?php 
        // "Copy / Move from .. to .."
        $s_dir = $dir;
        if (strlen($s_dir) > 40) {
            $s_dir = "..." . substr($s_dir, -37);
        }
        $s_ndir = $new_dir;
        if (strlen($s_ndir) > 40) {
            $s_ndir = "..." . substr($s_ndir, -37);
        }
        echo "<!-- dirextr = " . $dir_extract . " -->\n";
        echo "<!-- zipname = " . $zip_name . " -->\n";
        echo "<CENTER><BR><BR><IMG SRC=\"" . $_img . "\" align=\"ABSMIDDLE\" ALT=\"\">&nbsp;";
        echo "<IMG SRC=\"" . $GLOBALS["baricons"]["unzipto"] . "\" align=\"ABSMIDDLE\" ALT=\"\">\n";
        // Form for Target Directory & New Names
        echo "<BR><BR><FORM name=\"selform\" method=\"post\" action=\"";
        echo make_link("post", $dir, NULL) . "\"><TABLE>\n";
        echo "<INPUT type=\"hidden\" name=\"do_action\" value=\"" . $GLOBALS["action"] . "\">\n";
        echo "<INPUT type=\"hidden\" name=\"confirm\" value=\"false\">\n";
        //echo "<INPUT type=\"hidden\" name=\"dir\" value=\"n\">\n";
        echo "<INPUT type=\"hidden\" name=\"new_dir\" value=\"" . $new_dir . "\">\n";
        // List Directories to select Target
        dir_print(dir_list($new_dir), $new_dir);
        echo "</TABLE><BR><TABLE>\n";
        // Print Text Inputs to change Names
        echo "<TR><TD><IMG SRC=\"" . $GLOBALS["baricons"]["zip"] . "\" align=\"ABSMIDDLE\" ALT=\"\">";
        echo "<INPUT type=\"hidden\" name=\"item\" value=\"" . $s_item . "\">&nbsp;" . $s_item . "&nbsp;";
        // Submit & Cancel
        echo "</TABLE><BR><TABLE><TR>\n<TD>";
        echo "<INPUT type=\"submit\" value=\"";
        echo $GLOBALS["messages"]["btnunzip"];
        echo "\" onclick=\"javascript:Execute();\"></TD>\n<TD>";
        echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"];
        echo "\" onClick=\"javascript:location='" . make_link("list", $dir, NULL);
        echo "';\"></TD>\n</TR></FORM></TABLE><BR><BR><BR>\n";
        return;
    }
    // DO COPY/MOVE
    // ALL OK?
    if (!@file_exists(get_abs_dir($new_dir))) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["targetexist"]);
    }
    if (!get_show_item($new_dir, "")) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["accesstarget"]);
    }
    if (!down_home(get_abs_dir($new_dir))) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["targetabovehome"]);
    }
    // copy / move files
    $err = false;
    /*for($i=0;$i<$cnt;++$i) {
    		$tmp = stripslashes($GLOBALS['__POST']["selitems"][$i]);
    		$new = basename(stripslashes($GLOBALS['__POST']["newitems"][$i]));
    		$abs_item = get_abs_item($dir,$tmp);
    		$abs_new_item = get_abs_item($new_dir,$new);
    		$items[$i] = $tmp;
    	
    		// Check
    		if($new=="") {
    			$error[$i]= $GLOBALS["error_msg"]["miscnoname"];
    			$err=true;	continue;
    		}
    		if(!@file_exists($abs_item)) {
    			$error[$i]= $GLOBALS["error_msg"]["itemexist"];
    			$err=true;	continue;
    		}
    		if(!get_show_item($dir, $tmp)) {
    			$error[$i]= $GLOBALS["error_msg"]["accessitem"];
    			$err=true;	continue;
    		}
    		if(@file_exists($abs_new_item)) {
    			$error[$i]= $GLOBALS["error_msg"]["targetdoesexist"];
    			$err=true;	continue;
    		}
    	*/
    // Copy / Move
    //if($GLOBALS["action"]=="copy") {
    //if($GLOBALS["action"]=="unzip") {
    /*
    	if(@is_link($abs_item) || @is_file($abs_item)) {
    		// check file-exists to avoid error with 0-size files (PHP 4.3.0)
    		$ok=@copy($abs_item,$abs_new_item);	//||@file_exists($abs_new_item);
    	} elseif(@is_dir($abs_item)) {
    		$ok=copy_dir($abs_item,$abs_new_item);
    	}
    */
    //----------------------------------          print_r($GLOBALS);
    _debug("unzip_item(): Extracting {$zip_name} to {$dir_extract}");
    //$dir_extract[0]='/';
    //$dir_extract = '.'. $dir_extract;
    //------------------------------------------------------echo $zip_name.' aa'.$dir_extract.'aa';
    $exx = pathinfo($zip_name, PATHINFO_EXTENSION);
    if ($exx == 'zip') {
        $zip = new ZipArchive();
        $res = $zip->open($zip_name);
        if ($res === TRUE) {
            $zip->extractTo($dir_extract);
            $zip->close();
        } else {
        }
    } else {
        // gz, tar, bz2, ....
        include_once './_lib/archive.php';
        extArchive::extract($zip_name, $dir_extract);
    }
    // FIXME $i is not set anymore.. remove code?
    if (!isset($i)) {
        $i = 0;
    }
    if ($res == false) {
        $error[$i] = $GLOBALS["error_msg"]["unzip"];
        $err = true;
        continue;
    }
    $error[$i] = NULL;
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "<BR>\n";
        }
        show_error($err_msg);
    }
    header("Location: " . make_link("list", $dir, NULL));
}