function find_item($dir, $pat, &$list, $recur)
{
    // find items
    $handle = @opendir(get_abs_dir($dir));
    if ($handle === false) {
        return;
    }
    // unable to open dir
    while (($new_item = readdir($handle)) !== false) {
        if (!@file_exists(get_abs_item($dir, $new_item))) {
            continue;
        }
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        // match?
        if (@eregi($pat, $new_item)) {
            $list[] = array($dir, $new_item);
        }
        // search sub-directories
        if (get_is_dir($dir, $new_item) && $recur) {
            find_item(get_rel_item($dir, $new_item), $pat, $list, $recur);
        }
    }
    closedir($handle);
}
Beispiel #2
0
/**
 * @version $Id: search.php 98 2008-02-11 17:56:04Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007
 * @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
 * 
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 * 
 * File-Search Functions
 */
function find_item($dir, $pat, &$list, $recur)
{
    // find items
    $homedir = realpath($GLOBALS['home_dir']);
    $handle = @$GLOBALS['ext_File']->opendir(get_abs_dir($dir));
    if ($handle === false && $dir == "") {
        $handle = @$GLOBALS['ext_File']->opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('search', false, $dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    while (($new_item = $GLOBALS['ext_File']->readdir($handle)) !== false) {
        if (is_array($new_item)) {
            $abs_new_item = $new_item;
        } else {
            $abs_new_item = get_abs_item($dir, $new_item);
        }
        if (!$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            continue;
        }
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        // match?
        if (@eregi($pat, $new_item)) {
            $list[] = array($dir, $new_item);
        }
        // search sub-directories
        if (get_is_dir($abs_new_item) && $recur) {
            find_item(get_rel_item($dir, $new_item), $pat, $list, $recur);
        }
    }
    $GLOBALS['ext_File']->closedir($handle);
}
Beispiel #3
0
/**
 * download_selected
 * @return void
 **/
function download_selected($dir)
{
    $dir = get_abs_dir($dir);
    global $site_name;
    require_once "_include/archive.php";
    $items = qxpage_selected_items();
    if (count($items) == 1 && is_file($items[0])) {
        download_item($dir, $items[0]);
    } else {
        zip_download($dir, $items);
    }
}
Beispiel #4
0
function zip_items($dir, $name)
{
    $cnt = count($GLOBALS['__POST']["selitems"]);
    $abs_dir = get_abs_dir($dir);
    $zipfile = new ZipFile();
    for ($i = 0; $i < $cnt; ++$i) {
        $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        if (!$zipfile->add($abs_dir, $selitem)) {
            show_error($selitem . ": Failed adding item.");
        }
    }
    if (!$zipfile->save(get_abs_item($dir, $name))) {
        show_error($name . ": Failed saving zipfile.");
    }
    header("Location: " . make_link("list", $dir, NULL));
}
/**
 * @version $Id: search.php 201 2011-06-27 09:45:09Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007-2013
 * @author The eXtplorer project (http://extplorer.net)
 * @author The	The QuiX project (http://quixplorer.sourceforge.net)
 *
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 *
 * File-Search Functions
 */
function find_item($dir, $pat, &$list, $recur, $content)
{
    // find items
    $homedir = realpath($GLOBALS['home_dir']);
    $opendir = $dir;
    if (!is_dir($dir)) {
        $opendir = get_abs_dir($dir);
    }
    $handle = @$GLOBALS['ext_File']->opendir($opendir);
    if ($handle === false && $dir == "") {
        $handle = @$GLOBALS['ext_File']->opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('search', false, $opendir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    while (($new_item = $GLOBALS['ext_File']->readdir($handle)) !== false) {
        if (is_array($new_item)) {
            $abs_new_item = $new_item;
        } else {
            $abs_new_item = get_abs_item($dir, $new_item);
        }
        //if(!$GLOBALS['ext_File']->file_exists($abs_new_item)) continue;
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        $isDir = get_is_dir($abs_new_item);
        // match?
        if (@preg_match('@' . $pat . '@is', $new_item) > 0) {
            $list[] = array($dir, $new_item);
        } else {
            if (!$isDir) {
                if ($content && $GLOBALS['ext_File']->filesize($abs_new_item) < 524288) {
                    $data = $GLOBALS['ext_File']->file_get_contents($abs_new_item);
                    //$data = fread($handle, 524288); // Only read first 512kb
                    if (preg_match('@' . $pat . '@is', $data) > 0) {
                        $list[] = array($dir, $new_item);
                    }
                }
            }
        }
        // search sub-directories
        if ($isDir && $recur) {
            find_item($abs_new_item, $pat, $list, $recur, $content);
        }
    }
    $GLOBALS['ext_File']->closedir($handle);
}
Beispiel #6
0
function _download_items($dir, $items)
{
    // check if user selected any items to download
    _debug("count items: '{$items['0']}'");
    if (count($items) == 0) {
        show_error($GLOBALS["error_msg"]["miscselitems"]);
    }
    // check if user has permissions to download
    // this file
    if (!_is_download_allowed($dir, $items)) {
        show_error($GLOBALS["error_msg"]["accessitem"]);
    }
    // if we have exactly one file and this is a real
    // file we directly download it
    if (count($items) == 1 && get_is_file($dir, $items[0])) {
        $abs_item = get_abs_item($dir, $items[0]);
        _download($abs_item, $items[0]);
    }
    // otherwise we do the zip download
    zip_download(get_abs_dir($dir), $items);
}
Beispiel #7
0
    $GLOBALS["separator"] = "\\";
}
// Get Sort
$GLOBALS["order"] = extGetParam($_REQUEST, 'order', 'name');
// Get Sortorder
$GLOBALS["direction"] = extGetParam($_REQUEST, 'direction', 'ASC');
// show hidden files in QuiXplorer: (hide files starting with '.', as in Linux/UNIX)
$GLOBALS["show_hidden"] = true;
// filenames not allowed to access: (uses PCRE regex syntax)
$GLOBALS["no_access"] = "^\\.ht";
// user permissions bitfield: (1=modify, 2=password, 4=admin, add the numbers)
$GLOBALS["permissions"] = 1;
$GLOBALS['file_mode'] = 'file';
//------------------------------------------------------------------------------
$GLOBALS['ext_File'] = new ext_File();
$abs_dir = get_abs_dir($GLOBALS["dir"]);
if (!file_exists($GLOBALS["home_dir"])) {
    if (!file_exists($GLOBALS["home_dir"] . $GLOBALS["separator"])) {
        if (!empty($GLOBALS["require_login"])) {
            $extra = "<a href=\"" . ext_make_link("logout", NULL, NULL) . "\">" . $GLOBALS["messages"]["btnlogout"] . "</A>";
        } else {
            $extra = NULL;
        }
        $GLOBALS['ERROR'] = $GLOBALS["error_msg"]["home"];
    }
}
if (!down_home($abs_dir)) {
    ext_Result::sendResult('', false, $GLOBALS["dir"] . " : " . $GLOBALS["error_msg"]["abovehome"]);
    $dir = $GLOBALS['dir'] = $_SESSION['ext_dir'] = '';
    return false;
}
Beispiel #8
0
/**
 * File/Directory Copy & Move Functions
 */
function copy_move_items($dir)
{
    // copy/move file/dir
    $action = extGetParam($_REQUEST, 'action');
    if (($GLOBALS["permissions"] & 01) != 01) {
        ext_Result::sendResult($action, false, $GLOBALS["error_msg"]["accessfunc"]);
    }
    // Vars
    $first = extGetParam($GLOBALS['__POST'], 'first');
    if ($first == "y") {
        $new_dir = $dir;
    } else {
        $new_dir = stripslashes($GLOBALS['__POST']["new_dir"]);
    }
    if ($new_dir == ".") {
        $new_dir = "";
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    // DO COPY/MOVE
    // ALL OK?
    if (!@$GLOBALS['ext_File']->file_exists(get_abs_dir($new_dir))) {
        ext_Result::sendResult($action, false, get_abs_dir($new_dir) . ": " . $GLOBALS["error_msg"]["targetexist"]);
    }
    if (!get_show_item($new_dir, "")) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["accesstarget"]);
    }
    if (!down_home(get_abs_dir($new_dir))) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["targetabovehome"]);
    }
    // copy / move files
    $err = false;
    for ($i = 0; $i < $cnt; ++$i) {
        $tmp = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        $new = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $tmp);
            $abs_new_item = get_item_info('/' . $new_dir, $new);
        } else {
            $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 (!@$GLOBALS['ext_File']->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 (@$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            $error[$i] = $GLOBALS["error_msg"]["targetdoesexist"];
            $err = true;
            continue;
        }
        // Copy / Move
        if ($action == "copy") {
            if (@is_link($abs_item) || get_is_file($abs_item)) {
                // check file-exists to avoid error with 0-size files (PHP 4.3.0)
                if (ext_isFTPMode()) {
                    $abs_item = '/' . $dir . '/' . $abs_item['name'];
                }
                $ok = @$GLOBALS['ext_File']->copy($abs_item, $abs_new_item);
                //||@file_exists($abs_new_item);
            } elseif (@get_is_dir($abs_item)) {
                $copy_dir = ext_isFTPMode() ? '/' . $dir . '/' . $abs_item['name'] . '/' : $abs_item;
                if (ext_isFTPMode()) {
                    $abs_new_item .= '/';
                }
                $ok = $GLOBALS['ext_File']->copy_dir($copy_dir, $abs_new_item);
            }
        } else {
            $ok = $GLOBALS['ext_File']->rename($abs_item, $abs_new_item);
        }
        if ($ok === false || PEAR::isError($ok)) {
            $error[$i] = $action == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            if (PEAR::isError($ok)) {
                $error[$i] .= ' [' . $ok->getMessage() . ']';
            }
            $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] . "\n";
        }
        ext_Result::sendResult($action, false, $err_msg);
    }
    ext_Result::sendResult($action, true, 'The File(s)/Directory(s) were successfully ' . ($action == 'copy' ? 'copied' : 'moved') . '.');
}
Beispiel #9
0
    function execAction($dir)
    {
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (!$GLOBALS["zip"] && !$GLOBALS["tgz"]) {
            ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnofunc"]);
        }
        $allowed_types = array('zip', 'tgz', 'tbz', 'tar');
        // If we have something to archive, let's do it now
        if (extGetParam($_POST, 'confirm') == 'true') {
            $saveToDir = utf8_decode($GLOBALS['__POST']['saveToDir']);
            if (!file_exists(get_abs_dir($saveToDir))) {
                ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_notexists'));
            }
            if (!is_writable(get_abs_dir($saveToDir))) {
                ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_unwritable'));
            }
            require_once _EXT_PATH . '/libraries/Archive/archive.php';
            if (!in_array(strtolower($GLOBALS['__POST']["type"]), $allowed_types)) {
                ext_Result::sendResult('archive', false, ext_Lang::err('extract_unknowntype') . ': ' . htmlspecialchars($GLOBALS['__POST']["type"]));
            }
            // This controls how many files are processed per Step (it's split up into steps to prevent time-outs)
            $files_per_step = 2000;
            $cnt = count($GLOBALS['__POST']["selitems"]);
            $abs_dir = get_abs_dir($dir);
            $name = basename(stripslashes($GLOBALS['__POST']["name"]));
            if ($name == "") {
                ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            $startfrom = extGetParam($_REQUEST, 'startfrom', 0);
            $dir_contents_cache_name = 'ext_' . md5(implode(null, $GLOBALS['__POST']["selitems"]));
            $dir_contents_cache_file = _EXT_FTPTMP_PATH . '/' . $dir_contents_cache_name . '.txt';
            $archive_name = get_abs_item($saveToDir, $name);
            $fileinfo = pathinfo($archive_name);
            if (empty($fileinfo['extension'])) {
                $archive_name .= "." . $GLOBALS['__POST']["type"];
                $fileinfo['extension'] = $GLOBALS['__POST']["type"];
                foreach ($allowed_types as $ext) {
                    if ($GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext) {
                        $archive_name .= "." . $ext;
                    }
                }
            }
            if ($startfrom == 0) {
                for ($i = 0; $i < $cnt; $i++) {
                    $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
                    if ($selitem == 'ext_root') {
                        $selitem = '';
                    }
                    if (is_dir(utf8_decode($abs_dir . "/" . $selitem))) {
                        $items = extReadDirectory(utf8_decode($abs_dir . "/" . $selitem), '.', true, true);
                        foreach ($items as $item) {
                            if (is_dir($item) || !is_readable($item) || $item == $archive_name) {
                                continue;
                            }
                            $v_list[] = str_replace('\\', '/', $item);
                        }
                    } else {
                        $v_list[] = utf8_decode(str_replace('\\', '/', $abs_dir . "/" . $selitem));
                    }
                }
                if (count($v_list) > $files_per_step) {
                    if (file_put_contents($dir_contents_cache_file, implode("\n", $v_list)) == false) {
                        ext_Result::sendResult('archive', false, 'Failed to create a temporary list of the directory contents');
                    }
                }
            } else {
                $file_list_string = file_get_contents($dir_contents_cache_file);
                if (empty($file_list_string)) {
                    ext_Result::sendResult('archive', false, 'Failed to retrieve the temporary list of the directory contents');
                }
                $v_list = explode("\n", $file_list_string);
            }
            $cnt_filelist = count($v_list);
            // Now we go to the right range of files and "slice" the array
            $v_list = array_slice($v_list, $startfrom, $files_per_step - 1);
            $remove_path = $GLOBALS["home_dir"];
            if ($dir) {
                $remove_path .= $dir;
            }
            $remove_path = str_replace('\\', '/', realpath($remove_path)) . '/';
            $debug = 'Starting from: ' . $startfrom . "\n";
            $debug .= 'Files to process: ' . $cnt_filelist . "\n";
            $debug .= implode("\n", $v_list);
            //file_put_contents( 'log.txt', $debug, FILE_APPEND );
            // Do some setup stuff
            ini_set('memory_limit', '128M');
            @set_time_limit(0);
            //error_reporting( E_ERROR | E_PARSE );
            $result = extArchive::create($archive_name, $v_list, $GLOBALS['__POST']["type"], '', $remove_path);
            if (PEAR::isError($result)) {
                ext_Result::sendResult('archive', false, $name . ': ' . ext_Lang::err('archive_creation_failed') . ' (' . $result->getMessage() . $archive_name . ')');
            }
            $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON';
            $json = new $classname();
            if ($cnt_filelist > $startfrom + $files_per_step) {
                $response = array('startfrom' => $startfrom + $files_per_step, 'totalitems' => $cnt_filelist, 'success' => true, 'action' => 'archive', 'message' => sprintf(ext_Lang::msg('processed_x_files'), $startfrom + $files_per_step, $cnt_filelist));
            } else {
                @unlink($dir_contents_cache_file);
                if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') {
                    chmod($archive_name, 0644);
                }
                $response = array('action' => 'archive', 'success' => true, 'message' => ext_Lang::msg('archive_created'), 'newlocation' => ext_make_link('download', $dir, basename($archive_name)));
            }
            echo $json->encode($response);
            ext_exit();
        }
        $default_archive_type = 'zip';
        ?>
		{
		"xtype": "form",
		"id": "simpleform",
		"height": "200",
		"width": "350",
		"labelWidth": 125,
		"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		"dialogtitle": "<?php 
        echo $GLOBALS["messages"]["actarchive"];
        ?>
",
		"frame": true,
		"items": [{
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('archive_name', true);
        ?>
",
			"name": "name",
			"value": "<?php 
        echo $GLOBALS['item'] . '.' . $default_archive_type;
        ?>
",
			"width": "200"
		},
		{
			"xtype": "combo",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('typeheader', true);
        ?>
",
			"store": [
					['zip', 'Zip (<?php 
        echo ext_Lang::msg('normal_compression', true);
        ?>
)'],
					['tgz', 'Tar/Gz (<?php 
        echo ext_Lang::msg('good_compression', true);
        ?>
)'],
					<?php 
        if (extension_loaded("bz2")) {
            echo "['tbz', 'Tar/Bzip2 (" . ext_Lang::msg('best_compression', true) . ")'],";
        }
        ?>
					['tar', 'Tar (<?php 
        echo ext_Lang::msg('no_compression', true);
        ?>
)']
					],
			"displayField":"typename",
			"valueField": "type",
			"name": "type",
			"value": "<?php 
        echo $default_archive_type;
        ?>
",
			"triggerAction": "all",
			"hiddenName": "type",
			"disableKeyFilter": "true",
			"editable": "false",
			"mode": "local",
			"allowBlank": "false",
			"selectOnFocus":"true",
			"width": "200",
			"listeners": { "select": { 
							fn: function(o, record ) {
								form = Ext.getCmp("simpleform").getForm();
								var nameField = form.findField("name").getValue();								
								if( nameField.indexOf( '.' ) > 0 ) {
									form.findField('name').setValue( nameField.substring( 0, nameField.indexOf('.')+1 ) + o.getValue() );
								} else {
									form.findField('name').setValue( nameField + '.'+ o.getValue());
								}
							}
						  }
						}
		
		
		}, {
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('archive_saveToDir', true);
        ?>
",
			"name": "saveToDir",
			"value": "<?php 
        echo str_replace("'", "\\'", $dir);
        ?>
",
			"width": "200"
		},{
			"xtype": "checkbox",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('downlink', true);
        ?>
?",
			"name": "download",
			"checked": "true"
		}
		],
		"buttons": [{
			"text": "<?php 
        echo ext_Lang::msg('btncreate', true);
        ?>
", 
			"type": "submit", 
			"handler": function() { 
				Ext.ux.OnDemandLoad.load( "<?php 
        echo $GLOBALS['script_name'];
        ?>
?option=com_extplorer&action=include_javascript&file=archive.js", 
											function(options) { submitArchiveForm(0) } ); 
			}
		},{
			"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
			"handler": function() { Ext.getCmp("dialog").destroy() }
		}]
}

	<?php 
    }
Beispiel #10
0
function get_dircontents($dir, &$dir_list, &$file_list, &$tot_file_size, &$num_items)
{
    $search = @$_POST['searchword'];
    $pattern = '';
    if (!empty($search)) {
        $pattern = preg_quote($search, '/');
        // finalise the regular expression, matching the whole line
        $pattern = "/^.*{$pattern}.*\$/m";
        // search, and store all matching occurrences in $matches
    }
    if (!empty($_POST['mdate_start'])) {
        $mdate_start = strtotime($_POST['mdate_start']);
        if (empty($_POST['mdate_end'])) {
            $mdate_end = time();
        } else {
            $mdate_end = strtotime($_POST['mdate_end']);
        }
    }
    $homedir = realpath($GLOBALS['home_dir']);
    $tot_file_size = $num_items = 0;
    // Open directory
    $handle = @$GLOBALS['ext_File']->opendir(get_abs_dir($dir));
    if ($handle === false && $dir == "") {
        $handle = @$GLOBALS['ext_File']->opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('list', false, $dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    $file_list = array();
    $dir_list = array();
    // Read directory
    while (($new_item = @$GLOBALS['ext_File']->readdir($handle)) !== false) {
        if (is_array($new_item)) {
            $abs_new_item = $new_item;
        } else {
            $abs_new_item = get_abs_item($dir, $new_item);
        }
        /*if (get_is_dir($abs_new_item)) {
        			continue;
        		}*/
        if ($new_item == "." || $new_item == "..") {
            continue;
        }
        if (!@$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            //ext_Result::sendResult('list', false, $dir."/$abs_new_item: ".$GLOBALS["error_msg"]["readdir"]);
        }
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        if (!empty($pattern) && !preg_match_all($pattern, $new_item, $matches)) {
            continue;
        }
        if ($mdate_start && $mdate_end) {
            $filemtime = @$GLOBALS['ext_File']->filemtime($abs_new_item);
            if ($filemtime < $mdate_start || $filemtime > $mdate_end) {
                continue;
            }
        }
        $new_file_size = @$GLOBALS['ext_File']->filesize($abs_new_item);
        $tot_file_size += $new_file_size;
        $num_items++;
        $new_item_name = $new_item;
        if (ext_isFTPMode()) {
            $new_item_name = $new_item['name'];
        }
        if (get_is_dir($abs_new_item)) {
            if ($GLOBALS["order"] == "modified") {
                $dir_list[$new_item_name] = @$GLOBALS['ext_File']->filemtime($abs_new_item);
            } else {
                // order == "size", "type" or "name"
                $dir_list[$new_item_name] = $new_item;
            }
        } else {
            if ($GLOBALS["order"] == "size") {
                $file_list[$new_item_name] = $new_file_size;
            } elseif ($GLOBALS["order"] == "modified") {
                $file_list[$new_item_name] = @$GLOBALS['ext_File']->filemtime($abs_new_item);
            } elseif ($GLOBALS["order"] == "type") {
                $file_list[$new_item_name] = get_mime_type($abs_new_item, "type");
            } else {
                // order == "name"
                $file_list[$new_item_name] = $new_item;
            }
        }
    }
    @$GLOBALS['ext_File']->closedir($handle);
    // sort
    if (is_array($dir_list)) {
        if ($GLOBALS["order"] == "modified") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($dir_list);
            } else {
                asort($dir_list);
            }
        } else {
            // order == "size", "type" or "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($dir_list);
            } else {
                krsort($dir_list);
            }
        }
    }
    // sort
    if (is_array($file_list)) {
        if ($GLOBALS["order"] == "modified") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($file_list);
            } else {
                asort($file_list);
            }
        } elseif ($GLOBALS["order"] == "size" || $GLOBALS["order"] == "type") {
            if ($GLOBALS["direction"] == "ASC") {
                asort($file_list);
            } else {
                arsort($file_list);
            }
        } else {
            // order == "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($file_list);
            } else {
                krsort($file_list);
            }
        }
    }
    if ($GLOBALS['start'] > $num_items) {
        $GLOBALS['start'] = 0;
    }
}
Beispiel #11
0
/**
 * make tables & place results in reference-variables passed to function
 * also 'return' total filesize & total number of items
 *
 * @param string $dir
 * @param array $dir_list
 * @param array $file_list
 * @param int $tot_file_size
 * @param int $num_items
 */
function get_dircontents($dir, &$dir_list, &$file_list, &$tot_file_size, &$num_items)
{
    // make table of files in dir
    $homedir = realpath($GLOBALS['home_dir']);
    $tot_file_size = $num_items = 0;
    // Open directory
    $handle = @$GLOBALS['ext_File']->opendir(get_abs_dir($dir));
    if ($handle === false && $dir == "") {
        $handle = @$GLOBALS['ext_File']->opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('list', false, $dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    $file_list = array();
    $dir_list = array();
    // Read directory
    while (($new_item = @$GLOBALS['ext_File']->readdir($handle)) !== false) {
        if (is_array($new_item)) {
            $abs_new_item = $new_item;
        } else {
            $abs_new_item = get_abs_item($dir, $new_item);
        }
        /*if(get_is_dir( $abs_new_item)) {
        			continue;
        		}*/
        if ($new_item == "." || $new_item == "..") {
            continue;
        }
        if (!@$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            //ext_Result::sendResult( 'list', false, $dir."/$abs_new_item: ".$GLOBALS["error_msg"]["readdir"]);
        }
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        $new_file_size = @$GLOBALS['ext_File']->filesize($abs_new_item);
        $tot_file_size += $new_file_size;
        $num_items++;
        $new_item_name = $new_item;
        if (ext_isFTPMode()) {
            $new_item_name = $new_item['name'];
        }
        if (get_is_dir($abs_new_item)) {
            if ($GLOBALS["order"] == "modified") {
                $dir_list[$new_item_name] = @$GLOBALS['ext_File']->filemtime($abs_new_item);
            } else {
                // order == "size", "type" or "name"
                $dir_list[$new_item_name] = $new_item;
            }
        } else {
            if ($GLOBALS["order"] == "size") {
                $file_list[$new_item_name] = $new_file_size;
            } elseif ($GLOBALS["order"] == "modified") {
                $file_list[$new_item_name] = @$GLOBALS['ext_File']->filemtime($abs_new_item);
            } elseif ($GLOBALS["order"] == "type") {
                $file_list[$new_item_name] = get_mime_type($abs_new_item, "type");
            } else {
                // order == "name"
                $file_list[$new_item_name] = $new_item;
            }
        }
    }
    @$GLOBALS['ext_File']->closedir($handle);
    // sort
    if (is_array($dir_list)) {
        if ($GLOBALS["order"] == "modified") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($dir_list);
            } else {
                asort($dir_list);
            }
        } else {
            // order == "size", "type" or "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($dir_list);
            } else {
                krsort($dir_list);
            }
        }
    }
    // sort
    if (is_array($file_list)) {
        if ($GLOBALS["order"] == "modified") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($file_list);
            } else {
                asort($file_list);
            }
        } elseif ($GLOBALS["order"] == "size" || $GLOBALS["order"] == "type") {
            if ($GLOBALS["direction"] == "ASC") {
                asort($file_list);
            } else {
                arsort($file_list);
            }
        } else {
            // order == "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($file_list);
            } else {
                krsort($file_list);
            }
        }
    }
    if ($GLOBALS['start'] > $num_items) {
        $GLOBALS['start'] = 0;
    }
}
/**
 make table of files in dir
 make tables & place results in reference-variables passed to function
 also 'return' total filesize & total number of items
*/
function make_tables($dir, &$dir_list, &$file_list, &$tot_file_size, &$num_items)
{
    $tot_file_size = $num_items = 0;
    // Open directory
    $handle = @opendir(get_abs_dir($dir));
    if ($handle === false) {
        show_error($dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    // Read directory
    while (($new_item = readdir($handle)) !== false) {
        $abs_new_item = get_abs_item($dir, $new_item);
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        $new_file_size = is_link($abs_new_item) ? 0 : @filesize($abs_new_item);
        $tot_file_size += $new_file_size;
        $num_items++;
        if (is_dir($dir . DIRECTORY_SEPARATOR . $new_item)) {
            if ($GLOBALS["order"] == "mod") {
                $dir_list[$new_item] = @filemtime($abs_new_item);
            } else {
                // order == "size", "type" or "name"
                $dir_list[$new_item] = $new_item;
            }
        } else {
            if ($GLOBALS["order"] == "size") {
                $file_list[$new_item] = $new_file_size;
            } elseif ($GLOBALS["order"] == "mod") {
                $file_list[$new_item] = @filemtime($abs_new_item);
            } elseif ($GLOBALS["order"] == "type") {
                $file_list[$new_item] = get_mime_type($dir, $new_item, "type");
            } else {
                // order == "name"
                $file_list[$new_item] = $new_item;
            }
        }
    }
    closedir($handle);
    // sort
    if (is_array($dir_list)) {
        if ($GLOBALS["order"] == "mod") {
            if ($GLOBALS["srt"] == "yes") {
                arsort($dir_list);
            } else {
                asort($dir_list);
            }
        } else {
            // order == "size", "type" or "name"
            if ($GLOBALS["srt"] == "yes") {
                ksort($dir_list);
            } else {
                krsort($dir_list);
            }
        }
    }
    // sort
    if (is_array($file_list)) {
        if ($GLOBALS["order"] == "mod") {
            if ($GLOBALS["srt"] == "yes") {
                arsort($file_list);
            } else {
                asort($file_list);
            }
        } elseif ($GLOBALS["order"] == "size" || $GLOBALS["order"] == "type") {
            if ($GLOBALS["srt"] == "yes") {
                asort($file_list);
            } else {
                arsort($file_list);
            }
        } else {
            // order == "name"
            if ($GLOBALS["srt"] == "yes") {
                ksort($file_list);
            } else {
                krsort($file_list);
            }
        }
    }
}
Beispiel #13
0
function get_abs_item($dir, $item)
{
    // get absolute file+path
    if (is_array($item)) {
        // FTP Mode
        $abs_item = '/' . get_abs_dir($dir)."/".$item['name'];
        if (get_is_dir($item)) {
            $abs_item.='/';
        }
        return extPathName($abs_item);
    }
    return extPathName(get_abs_dir($dir)."/".$item);
}
Beispiel #14
0
/**
 * Zip & TarGzip Functions
 */
function archive_items($dir)
{
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!$GLOBALS["zip"] && !$GLOBALS["tgz"]) {
        show_error($GLOBALS["error_msg"]["miscnofunc"]);
    }
    $allowed_types = array('zip', 'tgz', 'tbz', 'tar');
    $actionURL = str_replace("index2.php", "index3.php", make_link("arch", $dir, NULL));
    // If we have something to archive, let's do it now
    if (isset($GLOBALS['__POST']["name"])) {
        $saveToDir = $GLOBALS['__POST']['saveToDir'];
        if (!file_exists(get_abs_dir($saveToDir))) {
            echo nx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';');
            echo nx_alertBox('The Save-To Directory you have specified does not exist.');
            die('The Save-To Directory you have specified does not exist.');
        }
        if (!is_writable(get_abs_dir($saveToDir))) {
            echo nx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';');
            echo nx_alertBox('Please specify a writable directory to save the archive to.');
            die('Please specify a writable directory to save the archive to.');
        }
        require_once _QUIXPLORER_PATH . '/libraries/Archive.php';
        if (!in_array(strtolower($GLOBALS['__POST']["type"]), $allowed_types)) {
            echo 'Unknown Archive Format: ' . htmlspecialchars($GLOBALS['__POST']["type"]);
            nx_exit();
        }
        while (@ob_end_clean()) {
        }
        header('Status: 200 OK');
        echo '<?xml version="1.0" ?>' . "\n";
        $files_per_step = 2500;
        $cnt = count($GLOBALS['__POST']["selitems"]);
        $abs_dir = get_abs_dir($dir);
        $name = basename(stripslashes($GLOBALS['__POST']["name"]));
        if ($name == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        $download = JArrayHelper::getValue($_REQUEST, 'download', "n");
        $startfrom = JArrayHelper::getValue($_REQUEST, 'startfrom', 0);
        $archive_name = get_abs_item($saveToDir, $name);
        $fileinfo = pathinfo($archive_name);
        if (empty($fileinfo['extension'])) {
            $archive_name .= "." . $GLOBALS['__POST']["type"];
            $fileinfo['extension'] = $GLOBALS['__POST']["type"];
        }
        foreach ($allowed_types as $ext) {
            if ($GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext) {
                $archive_name .= "." . $ext;
            }
        }
        for ($i = 0; $i < $cnt; $i++) {
            $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
            if (is_dir($abs_dir . "/" . $selitem)) {
                $items = JFolder::files($abs_dir . "/" . $selitem, '.', true, true);
                foreach ($items as $item) {
                    if (is_dir($item) || !is_readable($item) || $item == $archive_name) {
                        continue;
                    }
                    $v_list[] = $item;
                }
            } else {
                $v_list[] = $abs_dir . "/" . $selitem;
            }
        }
        $cnt_filelist = count($v_list);
        $remove_path = $GLOBALS["home_dir"];
        if ($dir) {
            $remove_path .= $dir . $GLOBALS['separator'];
        }
        for ($i = $startfrom; $i < $cnt_filelist && $i < $startfrom + $files_per_step; $i++) {
            $filelist[] = File_Archive::read($v_list[$i], str_replace($remove_path, '', $v_list[$i]));
        }
        //echo '<strong>Starting from: '.$startfrom.'</strong><br />';
        //echo '<strong>Files to process: '.$cnt_filelist.'</strong><br />';
        //print_r( $filelist );exit;
        // Do some setup stuff
        ini_set('memory_limit', '128M');
        @set_time_limit(0);
        error_reporting(E_ERROR | E_PARSE);
        $result = File_Archive::extract($filelist, $archive_name);
        if (PEAR::isError($result)) {
            echo $name . ": Failed saving Archive File. Error: " . $result->getMessage();
            nx_exit();
        }
        if ($cnt_filelist > $startfrom + $files_per_step) {
            echo "\n <script type=\"text/javascript\">document.archform.startfrom.value = '" . ($startfrom + $files_per_step) . "';</script>\n";
            echo '<script type="text/javascript"> doArchiving( \'' . $actionURL . '\' );</script>';
            printf($GLOBALS['messages']['processed_x_files'], $startfrom + $files_per_step, $cnt_filelist);
        } else {
            if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') {
                chmod($archive_name, 0644);
            }
            if ($download == "y") {
                echo '<script type="text/javascript">document.location=\'' . make_link('download', dirname($archive_name), basename($archive_name)) . '\';</script>';
            } else {
                echo '<script type="text/javascript">document.location=\'' . str_replace("index3.php", "index2.php", make_link("list", $dir, NULL)) . '&mosmsg=The%20Archive%20File%20has%20been%20created\';</script>';
            }
        }
        nx_exit();
    }
    ?>
	<script type="text/javascript" src="components/com_osefileman/scripts/functions.js"></script>
	<script type="text/javascript">
	function doArchiving( url ) {
		showLoadingIndicator( $('loadingindicator'), true );
		$('loadingindicator').style.display = '';

		var controller = new Ajax( url, { 	postBody: $('adminform'),
											evalScripts: true,
											update: 'statustext'
											}
								);
		controller.request();
		return false;
	}</script>
	<?php 
    show_header($GLOBALS["messages"]["actarchive"]);
    ?>
<br/>

	<form name="archform" method="post" action="<?php 
    echo $actionURL;
    ?>
" onsubmit="return doArchiving(this.action);" id="adminform">

	<input type="hidden" name="no_html" value="1" />
	<input type="hidden" name="startfrom" value="0" />
	<?php 
    $cnt = count($GLOBALS['__POST']["selitems"]);
    for ($i = 0; $i < $cnt; ++$i) {
        echo '<input type="hidden" name="selitems[]" value="' . stripslashes($GLOBALS['__POST']["selitems"][$i]) . '">';
    }
    ?>
	<table class="adminform" style="width:600px;">
		<tr><td colspan="2" style="text-align:center;display:none;" id="loadingindicator"><strong><?php 
    echo $GLOBALS['messages']['creating_archive'];
    ?>
</strong></td></tr>
		<tr><td colspan="2" style="font-weight:bold;text-align:center" id="statustext">&nbsp;</td></tr>
		<tr><td><?php 
    echo $GLOBALS['messages']['archive_name'];
    ?>
:</td>
			<td align="left">
				<input type="text" name="name" size="25" value="<?php 
    echo $dir != '' ? basename($dir) : $GLOBALS['__POST']["selitems"][0];
    ?>
" />
			</td>
		</tr>
		<tr><td><?php 
    echo $GLOBALS["messages"]["typeheader"];
    ?>
:</td>
			<td align="left">
				<select name="type">
				<?php 
    if (extension_loaded("zlib")) {
        echo '<option value="zip">Zip (' . $GLOBALS["messages"]['normal_compression'] . ')</option>' . "\n";
        echo '<option value="tgz">Tar/Gz (' . $GLOBALS["messages"]['good_compression'] . ')</option>' . "\n";
    }
    if (extension_loaded("bz2")) {
        echo '<option value="tbz">Tar/Bzip2 (' . $GLOBALS["messages"]['best_compression'] . ')</option>' . "\n";
    }
    echo '<option value="" disabled="disabled"> - - - - - - -</option>' . "\n";
    echo '<option value="tar">Tar (' . $GLOBALS["messages"]['no_compression'] . ')</option>' . "\n";
    ?>
				</select>
			</td>
		</tr>
		<tr><td><?php 
    echo $GLOBALS['messages']['archive_saveToDir'];
    ?>
:</td>
			<td align="left">
				<input type="text" name="saveToDir" size="50" value="<?php 
    echo $dir;
    ?>
" />
			</td>
		</tr>
		<tr><td><?php 
    echo $GLOBALS["messages"]["downlink"];
    ?>
?:</td>
			<td align="left">
				<input type="checkbox" checked="checked" name="download" value="y" />
			</td>
		</tr>
		<tr>
			<td colspan="2" style="text-align:center;">
				<input type="submit" value="<?php 
    echo $GLOBALS["messages"]["btncreate"];
    ?>
">
				<input type="button" value="<?php 
    echo $GLOBALS["messages"]["btncancel"];
    ?>
" onclick="javascript:location='<?php 
    echo make_link("list", $dir, NULL);
    ?>
';">
			</td>
		</tr>
		<tr><td colspan="2">&nbsp;</td></tr>
	</table>
	</form>
	<br/>
	<script type="text/javascript">if(document.archform) document.archform.name.focus();</script>
	<?php 
}
Beispiel #15
0
function list_dir($dir)
{
    $dir_up = dirname($dir);
    if ($dir_up == ".") {
        $dir_up = "";
    }
    if (!get_show_item($dir_up, basename($dir))) {
        show_error($dir . " : " . $GLOBALS["error_msg"]["accessdir"]);
    }
    // make file & dir tables, & get total filesize & number of items
    make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items);
    $s_dir = $dir;
    if (strlen($s_dir) > 50) {
        $s_dir = "..." . substr($s_dir, -47);
    }
    show_header("<a href='javascript:history.go(-1);'><font color=#0a0a0a>Go Back to Problem List</font></a><br>" . $GLOBALS["messages"]["actdir"] . ": /" . get_rel_item("", $s_dir));
    // Javascript functions:
    include "./.include/javascript.php";
    // Sorting of items
    $_img = "&nbsp;<IMG width=\"10\" height=\"10\" border=\"0\" align=\"ABSMIDDLE\" src=\"_img/";
    if ($GLOBALS["srt"] == "yes") {
        $_srt = "no";
        $_img .= "_arrowup.gif\" ALT=\"^\">";
    } else {
        $_srt = "yes";
        $_img .= "_arrowdown.gif\" ALT=\"v\">";
    }
    // Toolbar
    echo "<BR><TABLE width=\"95%\"><TR><TD><TABLE><TR>\n";
    // PARENT DIR
    echo "<TD><A HREF=\"" . make_link("list", $dir_up, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_up.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["uplink"] . "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></A></TD>\n";
    // HOME DIR
    echo "<TD><A HREF=\"" . make_link("list", NULL, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_home.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["homelink"] . "\" TITLE=\"" . $GLOBALS["messages"]["homelink"] . "\"></A></TD>\n";
    // RELOAD
    echo "<TD><A HREF=\"javascript:location.reload();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
    echo "align=\"ABSMIDDLE\" src=\"_img/_refresh.gif\" ALT=\"" . $GLOBALS["messages"]["reloadlink"];
    echo "\" TITLE=\"" . $GLOBALS["messages"]["reloadlink"] . "\"></A></TD>\n";
    // SEARCH
    echo "<TD><A HREF=\"" . make_link("search", $dir, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_search.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["searchlink"] . "\" TITLE=\"" . $GLOBALS["messages"]["searchlink"];
    echo "\"></A></TD>\n";
    echo "<TD>::</TD>";
    // print the edit buttons
    _print_edit_buttons($dir);
    // ADMIN & LOGOUT
    if (login_ok()) {
        echo "<TD>::</TD>";
        // ADMIN
        _print_link("admin", permissions_grant(NULL, NULL, "admin") || permissions_grant(NULL, NULL, "password"), $dir, NULL);
        // LOGOUT
        _print_link("logout", true, $dir, NULL);
    }
    echo "</TR></TABLE></TD>\n";
    // Create File / Dir
    if (permissions_grant($dir, NULL, "create")) {
        echo "<TD align=\"right\"><TABLE><FORM action=\"" . make_link("mkitem", $dir, NULL) . "\" method=\"post\">\n<TR><TD>";
        echo "<SELECT name=\"mktype\"><option value=\"file\">" . $GLOBALS["mimes"]["file"] . "</option>";
        echo "<option value=\"dir\">" . $GLOBALS["mimes"]["dir"] . "</option></SELECT>\n";
        echo "<INPUT name=\"mkname\" type=\"text\" size=\"15\">";
        echo "<INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"];
        echo "\"></TD></TR></FORM></TABLE></TD>\n";
    }
    echo "</TR></TABLE>\n";
    // End Toolbar
    // Begin Table + Form for checkboxes
    echo "<TABLE WIDTH=\"95%\"><FORM name=\"selform\" method=\"POST\" action=\"" . make_link("post", $dir, NULL) . "\">\n";
    echo "<INPUT type=\"hidden\" name=\"do_action\"><INPUT type=\"hidden\" name=\"first\" value=\"y\">\n";
    // Table Header
    echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR><TD WIDTH=\"2%\" class=\"header\">\n";
    echo "<INPUT TYPE=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\"></TD>\n";
    echo "<TD WIDTH=\"44%\" class=\"header\"><B>\n";
    if ($GLOBALS["order"] == "name") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "name", $new_srt) . "\">" . $GLOBALS["messages"]["nameheader"];
    if ($GLOBALS["order"] == "name") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"10%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "size") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "size", $new_srt) . "\">" . $GLOBALS["messages"]["sizeheader"];
    if ($GLOBALS["order"] == "size") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"16%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "type") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "type", $new_srt) . "\">" . $GLOBALS["messages"]["typeheader"];
    if ($GLOBALS["order"] == "type") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"14%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "mod") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "mod", $new_srt) . "\">" . $GLOBALS["messages"]["modifheader"];
    if ($GLOBALS["order"] == "mod") {
        echo $_img;
    }
    echo "</A></B></TD><TD WIDTH=\"8%\" class=\"header\"><B>" . $GLOBALS["messages"]["permheader"] . "</B>\n";
    echo "</TD><TD WIDTH=\"6%\" class=\"header\"><B>" . $GLOBALS["messages"]["actionheader"] . "</B></TD></TR>\n";
    echo "<TR><TD colspan=\"7\"><HR></TD></TR>\n";
    // make & print Table using lists
    print_table($dir, make_list($dir_list, $file_list));
    // print number of items & total filesize
    echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR>\n<TD class=\"header\"></TD>";
    echo "<TD class=\"header\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " (";
    if (function_exists("disk_free_space")) {
        $free = parse_file_size(disk_free_space(get_abs_dir($dir)));
    } elseif (function_exists("diskfreespace")) {
        $free = parse_file_size(diskfreespace(get_abs_dir($dir)));
    } else {
        $free = "?";
    }
    // echo "Total: ".parse_file_size(disk_total_space(get_abs_dir($dir))).", ";
    echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</TD>\n";
    echo "<TD class=\"header\">" . parse_file_size($tot_file_size) . "</TD>\n";
    for ($i = 0; $i < 4; ++$i) {
        echo "<TD class=\"header\"></TD>";
    }
    echo "</TR>\n<TR><TD colspan=\"7\"><HR></TD></TR></FORM></TABLE>\n";
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	// Uncheck all items (to avoid problems with new items)
	var ml = document.selform;
	var len = ml.elements.length;
	for(var i=0; i<len; ++i) {
		var e = ml.elements[i];
		if(e.name == "selitems[]" && e.checked == true) {
			e.checked=false;
		}
	}
// -->
</script><?php 
}
Beispiel #16
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));
}
function list_dir($dir)
{
    // list directory contents
    global $QUIXPATH;
    $allow = ($GLOBALS["permissions"] & 01) == 01;
    $admin = ($GLOBALS["permissions"] & 04) == 04 || ($GLOBALS["permissions"] & 02) == 02;
    $dir_up = dirname($dir);
    if ($dir_up == ".") {
        $dir_up = "";
    }
    if (!get_show_item($dir_up, basename($dir))) {
        show_error($dir . " : " . $GLOBALS["error_msg"]["accessdir"]);
    }
    // make file & dir tables, & get total filesize & number of items
    make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items);
    $s_dir = $dir;
    if (strlen($s_dir) > 50) {
        $s_dir = "..." . substr($s_dir, -47);
    }
    show_header($GLOBALS["messages"]["actdir"] . ": /" . get_rel_item("", $s_dir));
    // Javascript functions:
    include $QUIXPATH . ".include/javascript.php";
    // Sorting of items
    $_img = "&nbsp;<IMG width=\"10\" height=\"10\" border=\"0\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/";
    if ($GLOBALS["srt"] == "yes") {
        $_srt = "no";
        $_img .= "_arrowup.gif\" ALT=\"^\">";
    } else {
        $_srt = "yes";
        $_img .= "_arrowdown.gif\" ALT=\"v\">";
    }
    // Toolbar
    echo "<BR><TABLE width=\"95%\"><TR><TD><TABLE><TR>\n";
    // PARENT DIR
    echo "<TD><A HREF=\"" . make_link("list", $dir_up, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_up.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["uplink"] . "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></A></TD>\n";
    // HOME DIR
    echo "<TD><A HREF=\"" . make_link("list", NULL, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_home.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["homelink"] . "\" TITLE=\"" . $GLOBALS["messages"]["homelink"] . "\"></A></TD>\n";
    // RELOAD
    echo "<TD><A HREF=\"javascript:location.reload();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
    echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_refresh.gif\" ALT=\"" . $GLOBALS["messages"]["reloadlink"];
    echo "\" TITLE=\"" . $GLOBALS["messages"]["reloadlink"] . "\"></A></TD>\n";
    // SEARCH
    echo "<TD><A HREF=\"" . make_link("search", $dir, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_search.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["searchlink"] . "\" TITLE=\"" . $GLOBALS["messages"]["searchlink"];
    echo "\"></A></TD>\n";
    echo "<TD>::</TD>";
    if ($allow) {
        // COPY
        echo "<TD><A HREF=\"javascript:Copy();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_copy.gif\" ALT=\"" . $GLOBALS["messages"]["copylink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["copylink"] . "\"></A></TD>\n";
        // MOVE
        echo "<TD><A HREF=\"javascript:Move();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_move.gif\" ALT=\"" . $GLOBALS["messages"]["movelink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["movelink"] . "\"></A></TD>\n";
        // DELETE
        echo "<TD><A HREF=\"javascript:Delete();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_delete.gif\" ALT=\"" . $GLOBALS["messages"]["dellink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["dellink"] . "\"></A></TD>\n";
        // UPLOAD
        if (get_cfg_var("file_uploads")) {
            echo "<TD><A HREF=\"" . make_link("upload", $dir, NULL) . "\">";
            echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"../files/quixexplorer/_upload.gif\" ALT=\"" . $GLOBALS["messages"]["uploadlink"];
            echo "\" TITLE=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></A></TD>\n";
        } else {
            echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"../files/quixexplorer/_upload_.gif\" ALT=\"" . $GLOBALS["messages"]["uploadlink"];
            echo "\" TITLE=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></TD>\n";
        }
        // ARCHIVE
        if ($GLOBALS["zip"] || $GLOBALS["tar"] || $GLOBALS["tgz"]) {
            echo "<TD><A HREF=\"javascript:Archive();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
            echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_archive.gif\" ALT=\"" . $GLOBALS["messages"]["comprlink"];
            echo "\" TITLE=\"" . $GLOBALS["messages"]["comprlink"] . "\"></A></TD>\n";
        }
    } else {
        // COPY
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"../files/quixexplorer/_copy_.gif\" ALT=\"" . $GLOBALS["messages"]["copylink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["copylink"] . "\"></TD>\n";
        // MOVE
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"../files/quixexplorer/_move_.gif\" ALT=\"" . $GLOBALS["messages"]["movelink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["movelink"] . "\"></TD>\n";
        // DELETE
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"../files/quixexplorer/_delete_.gif\" ALT=\"" . $GLOBALS["messages"]["dellink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["dellink"] . "\"></TD>\n";
        // UPLOAD
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"../files/quixexplorer/_upload_.gif\" ALT=\"" . $GLOBALS["messages"]["uplink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></TD>\n";
    }
    // ADMIN & LOGOUT
    if ($GLOBALS["require_login"]) {
        echo "<TD>::</TD>";
        // ADMIN
        if ($admin) {
            echo "<TD><A HREF=\"" . make_link("admin", $dir, NULL) . "\">";
            echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"../files/quixexplorer/_admin.gif\" ALT=\"" . $GLOBALS["messages"]["adminlink"] . "\" TITLE=\"";
            echo $GLOBALS["messages"]["adminlink"] . "\"></A></TD>\n";
        }
        // LOGOUT
        echo "<TD><A HREF=\"" . make_link("logout", NULL, NULL) . "\">";
        echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"../files/quixexplorer/_logout.gif\" ALT=\"" . $GLOBALS["messages"]["logoutlink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["logoutlink"] . "\"></A></TD>\n";
    }
    echo "</TR></TABLE></TD>\n";
    // Create File / Dir
    if ($allow) {
        echo "<TD align=\"right\"><TABLE><FORM action=\"" . make_link("mkitem", $dir, NULL) . "\" method=\"post\">\n<TR><TD>";
        echo "<SELECT name=\"mktype\"><option value=\"file\">" . $GLOBALS["mimes"]["file"] . "</option>";
        echo "<option value=\"dir\">" . $GLOBALS["mimes"]["dir"] . "</option></SELECT>\n";
        echo "<INPUT name=\"mkname\" type=\"text\" size=\"15\">";
        echo "<INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"];
        echo "\"></TD></TR></FORM></TABLE></TD>\n";
    }
    echo "</TR></TABLE>\n";
    // End Toolbar
    // Begin Table + Form for checkboxes
    echo "<TABLE WIDTH=\"95%\"><FORM name=\"selform\" method=\"POST\" action=\"" . make_link("post", $dir, NULL) . "\">\n";
    echo "<INPUT type=\"hidden\" name=\"do_action\"><INPUT type=\"hidden\" name=\"first\" value=\"y\">\n";
    // Table Header
    echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR><TD WIDTH=\"2%\" class=\"header\">\n";
    echo "<INPUT TYPE=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\"></TD>\n";
    echo "<TD WIDTH=\"44%\" class=\"header\"><B>\n";
    if ($GLOBALS["order"] == "name") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "name", $new_srt) . "\">" . $GLOBALS["messages"]["nameheader"];
    if ($GLOBALS["order"] == "name") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"10%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "size") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "size", $new_srt) . "\">" . $GLOBALS["messages"]["sizeheader"];
    if ($GLOBALS["order"] == "size") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"16%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "type") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "type", $new_srt) . "\">" . $GLOBALS["messages"]["typeheader"];
    if ($GLOBALS["order"] == "type") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"14%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "mod") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "mod", $new_srt) . "\">" . $GLOBALS["messages"]["modifheader"];
    if ($GLOBALS["order"] == "mod") {
        echo $_img;
    }
    echo "</A></B></TD><TD WIDTH=\"8%\" class=\"header\"><B>" . $GLOBALS["messages"]["permheader"] . "</B>\n";
    echo "</TD><TD WIDTH=\"6%\" class=\"header\"><B>" . $GLOBALS["messages"]["actionheader"] . "</B></TD></TR>\n";
    echo "<TR><TD colspan=\"7\"><HR></TD></TR>\n";
    // make & print Table using lists
    print_table($dir, make_list($dir_list, $file_list), $allow);
    // print number of items & total filesize
    echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR>\n<TD class=\"header\"></TD>";
    echo "<TD class=\"header\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " (";
    if (function_exists("disk_free_space")) {
        $free = parse_file_size(disk_free_space(get_abs_dir($dir)));
    } elseif (function_exists("diskfreespace")) {
        $free = parse_file_size(diskfreespace(get_abs_dir($dir)));
    } else {
        $free = "?";
    }
    // echo "Total: ".parse_file_size(disk_total_space(get_abs_dir($dir))).", ";
    echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</TD>\n";
    echo "<TD class=\"header\">" . parse_file_size($tot_file_size) . "</TD>\n";
    for ($i = 0; $i < 4; ++$i) {
        echo "<TD class=\"header\"></TD>";
    }
    echo "</TR>\n<TR><TD colspan=\"7\"><HR></TD></TR></FORM></TABLE>\n";
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	// Uncheck all items (to avoid problems with new items)
	var ml = document.selform;
	var len = ml.elements.length;
	for(var i=0; i<len; ++i) {
		var e = ml.elements[i];
		if(e.name == "selitems[]" && e.checked == true) {
			e.checked=false;
		}
	}
// -->
</script><?php 
}
Beispiel #18
0
function find_item($dir, $pat, &$files, $subdir, $content)
{
    if (!is_dir($dir)) {
        $dir = get_abs_dir($dir);
    }
    if (!$subdir) {
        $files = glob($dir . '/' . $pat);
    } else {
        $files = glob_recursive($dir . '/' . $pat);
    }
    if ($files === false) {
        ext_Result::sendResult('search', false, $dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    if ($content) {
        $newList = array();
        foreach ($files as $file) {
            $contents = file_get_contents($file);
            $pattern = preg_quote($content, '/');
            // finalise the regular expression, matching the whole line
            $pattern = "/^.*{$pattern}.*\$/m";
            // search, and store all matching occurences in $matches
            if (preg_match_all($pattern, $contents, $matches)) {
                $newList[] = $file;
            }
        }
        $files = $newList;
    }
    if (!empty($_POST['mdate_start'])) {
        $mdate_start = strtotime($_POST['mdate_start']);
        if (empty($_POST['mdate_end'])) {
            $mdate_end = time();
        } else {
            $mdate_end = strtotime($_POST['mdate_end']);
        }
        if ($mdate_start && $mdate_end) {
            $newList = array();
            foreach ($files as $file) {
                $filemtime = filemtime($file);
                if ($filemtime > $mdate_start && $filemtime < $mdate_end) {
                    $newList[] = $file;
                }
            }
            $files = $newList;
        }
    }
    if (!empty($_POST['age_value'])) {
        $age_value = (int) $_POST['age_value'];
        $age_units = array("minutes", "hours", "days", "weeks", "months", "years");
        if (in_array($_POST['age_unit'], $age_units)) {
            $age_unit = $_POST['age_unit'];
        } else {
            $age_unit = "days";
        }
        $age_time = strtotime("-" . $age_value . " " . $age_unit);
        if ($age_time) {
            $newList = array();
            foreach ($files as $file) {
                $filemtime = filemtime($file);
                if ($filemtime > $age_time) {
                    $newList[] = $file;
                }
            }
            $files = $newList;
        }
    }
    $newList = array();
    foreach ($files as $file) {
        $newList[] = array(dirname($file), basename($file));
    }
    $files = $newList;
}
function copy_move_items($dir)
{
    // copy and move are only allowed if the user may read and change files
    if ($GLOBALS["action"] == "copy" && !permissions_grant_all($dir, NULL, array("read", "create"))) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if ($GLOBALS["action"] == "move" && !permissions_grant($dir, NULL, "change")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Vars
    $first = $GLOBALS['__POST']["first"];
    if ($first == "y") {
        $new_dir = $dir;
    } else {
        $new_dir = $GLOBALS['__POST']["new_dir"];
    }
    if ($new_dir == ".") {
        $new_dir = "";
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    // Copy or Move?
    if ($GLOBALS["action"] != "move") {
        $_img = "_img/__copy.gif";
    } else {
        $_img = "_img/__cut.gif";
    }
    // Get New Location & Names
    if (!isset($GLOBALS['__POST']["confirm"]) || $GLOBALS['__POST']["confirm"] != "true") {
        $msg = $GLOBALS["action"] != "move" ? $GLOBALS["messages"]["actcopyitems"] : $GLOBALS["messages"]["actmoveitems"];
        show_header($msg);
        // 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 "<BR><IMG SRC=\"" . $_img . "\" align=\"ABSMIDDLE\" ALT=\"\">&nbsp;";
        echo htmlspecialchars(sprintf($GLOBALS["action"] != "move" ? $GLOBALS["messages"]["actcopyfrom"] : $GLOBALS["messages"]["actmovefrom"], $s_dir, $s_ndir));
        echo "<IMG SRC=\"_img/__paste.gif\" 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=\"first\" value=\"n\">\n";
        echo "<INPUT type=\"hidden\" name=\"new_dir\" value=\"" . htmlspecialchars($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
        for ($i = 0; $i < $cnt; ++$i) {
            $selitem = $GLOBALS['__POST']["selitems"][$i];
            if (isset($GLOBALS['__POST']["newitems"][$i])) {
                $newitem = $GLOBALS['__POST']["newitems"][$i];
                if ($first == "y") {
                    $newitem = $selitem;
                }
            } else {
                $newitem = $selitem;
            }
            $s_item = $selitem;
            if (strlen($s_item) > 50) {
                $s_item = substr($s_item, 0, 47) . "...";
            }
            echo "<TR><TD><IMG SRC=\"_img/_info.gif\" align=\"ABSMIDDLE\" ALT=\"\">";
            // Old Name
            echo "<INPUT type=\"hidden\" name=\"selitems[]\" value=\"";
            echo htmlspecialchars($selitem) . "\">&nbsp;" . htmlspecialchars($s_item) . "&nbsp;";
            // New Name
            echo "</TD><TD><INPUT type=\"text\" size=\"25\" name=\"newitems[]\" value=\"";
            echo htmlspecialchars($newitem) . "\"></TD></TR>\n";
        }
        // Submit & Cancel
        echo "</TABLE><BR><TABLE><TR>\n<TD>";
        echo "<INPUT type=\"submit\" value=\"";
        echo $GLOBALS["action"] != "move" ? $GLOBALS["messages"]["btncopy"] : $GLOBALS["messages"]["btnmove"];
        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>\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 = $GLOBALS['__POST']["selitems"][$i];
        $new = basename($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 (@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);
            }
        } else {
            $ok = @rename($abs_item, $abs_new_item);
        }
        if ($ok === false) {
            $error[$i] = $GLOBALS["action"] == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            $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));
}
function copy_move_items($dir)
{
    // copy/move file/dir
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $action = stripslashes(JRequest::getCmd('action'));
    if ($action == "post") {
        $action = JRequest::getCmd("do_action");
    } elseif (empty($action)) {
        $action = "list";
    }
    // Vars
    $first = $GLOBALS['__POST']["first"];
    if ($first == "y") {
        $new_dir = $dir;
    } else {
        $new_dir = stripslashes($GLOBALS['__POST']["new_dir"]);
    }
    if ($new_dir == ".") {
        $new_dir = "";
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    // Copy or Move?
    if ($action != "move") {
        $images = "images/__copy.gif";
    } else {
        $images = "images/__cut.gif";
    }
    // Get New Location & Names
    if (!isset($GLOBALS['__POST']["confirm"]) || $GLOBALS['__POST']["confirm"] != "true") {
        show_header($action != "move" ? $GLOBALS["messages"]["actcopyitems"] : $GLOBALS["messages"]["actmoveitems"]);
        // 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 "<br /><img src=\"" . _QUIXPLORER_URL . '/images/' . $images . "\" align=\"absmiddle\" alt=\"\" />&nbsp;<strong>";
        echo sprintf($action != "move" ? $GLOBALS["messages"]["actcopyfrom"] : $GLOBALS["messages"]["actmovefrom"], $s_dir, $s_ndir);
        echo "</strong><img src=\"" . _QUIXPLORER_URL . "/images/__paste.gif\" 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 style=\"width:500px;\" class=\"adminform\">\n";
        echo "<input type=\"hidden\" name=\"do_action\" value=\"" . $action . "\">\n";
        echo "<input type=\"hidden\" name=\"confirm\" value=\"false\">\n";
        echo "<input type=\"hidden\" name=\"first\" 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 />\n\t\t<table style=\"width:500px;\" class=\"adminform\">\n";
        // Print Text Inputs to change Names
        for ($i = 0; $i < $cnt; ++$i) {
            $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
            if (isset($GLOBALS['__POST']["newitems"][$i])) {
                $newitem = stripslashes($GLOBALS['__POST']["newitems"][$i]);
                if ($first == "y") {
                    $newitem = $selitem;
                }
            } else {
                $newitem = $selitem;
            }
            $s_item = $selitem;
            if (strlen($s_item) > 50) {
                $s_item = substr($s_item, 0, 47) . "...";
            }
            echo "<tr><td><img src=\"" . _QUIXPLORER_URL . "/images/information.png\" align=\"absmiddle\" alt=\"\">";
            // old name
            echo "<input type=\"hidden\" name=\"selitems[]\" value=\"";
            echo $selitem . "\">&nbsp;" . $s_item . "&nbsp;";
            // New Name
            echo "</td><td><input type=\"text\" size=\"25\" name=\"newitems[]\" value=\"";
            echo $newitem . "\"></td></tr>\n";
        }
        // Submit & Cancel
        echo "</table><br /><table><tr>\n<td>";
        echo "<input type=\"submit\" value=\"";
        echo $action != "move" ? $GLOBALS["messages"]["btncopy"] : $GLOBALS["messages"]["btnmove"];
        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></table><br /></form>\n";
        return;
    }
    // DO COPY/MOVE
    // ALL OK?
    if (!@$GLOBALS['nx_File']->file_exists(get_abs_dir($new_dir))) {
        show_error(get_abs_dir($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]));
        if (nx_isFTPMode()) {
            $abs_item = get_item_info($dir, $tmp);
            $abs_new_item = get_item_info('/' . $new_dir, $new);
        } else {
            $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 (!@$GLOBALS['nx_File']->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 (@$GLOBALS['nx_File']->file_exists($abs_new_item)) {
            $error[$i] = $GLOBALS["error_msg"]["targetdoesexist"];
            $err = true;
            continue;
        }
        // Copy / Move
        if ($action == "copy") {
            if (@is_link($abs_item) || get_is_file($abs_item)) {
                // check file-exists to avoid error with 0-size files (PHP 4.3.0)
                if (nx_isFTPMode()) {
                    $abs_item = '/' . $dir . '/' . $abs_item['name'];
                }
                $ok = @$GLOBALS['nx_File']->copy($abs_item, $abs_new_item);
                //||@file_exists($abs_new_item);
            } elseif (@get_is_dir($abs_item)) {
                $dir = nx_isFTPMode() ? '/' . $dir . '/' . $abs_item['name'] . '/' : $abs_item;
                if (nx_isFTPMode()) {
                    $abs_new_item .= '/';
                }
                $ok = $GLOBALS['nx_File']->copy_dir($dir, $abs_new_item);
            }
        } else {
            $ok = $GLOBALS['nx_File']->rename($abs_item, $abs_new_item);
        }
        if ($ok === false || PEAR::isError($ok)) {
            $error[$i] = $action == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            if (PEAR::isError($ok)) {
                $error[$i] .= ' [' . $ok->getMessage() . ']';
            }
            $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));
}
Beispiel #21
0
function get_abs_item($dir, $item)
{
    // get absolute file+path
    return get_abs_dir($dir) . DIRECTORY_SEPARATOR . $item;
}
Beispiel #22
0
function get_dir_list($dir = '')
{
    if (ext_isFTPMode()) {
        $files = getCachedFTPListing(empty($dir) ? '.' : $dir);
    } else {
        $files = extReadDirectory(get_abs_dir($dir), '.', false, true);
    }
    $dirs = array();
    foreach ($files as $item) {
        $itemname = ext_isFTPMode() ? (empty($dir) ? '' : $dir . '/') . $item['name'] : $item;
        $itemname = str_replace('\\', '/', $itemname);
        if (get_is_dir($item)) {
            $index = str_replace(str_replace('\\', '/', $GLOBALS['home_dir'] . $GLOBALS['separator']), '', $itemname);
            $dirs[$index] = basename($index);
        }
    }
    return $dirs;
}
Beispiel #23
0
    function execAction($dir)
    {
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (!$GLOBALS["zip"] && !$GLOBALS["tgz"]) {
            ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnofunc"]);
        }
        $allowed_types = array('zip', 'tgz', 'tbz', 'tar');
        // If we have something to archive, let's do it now
        if (extGetParam($_POST, 'confirm') == 'true') {
            $saveToDir = utf8_decode($GLOBALS['__POST']['saveToDir']);
            if (!file_exists(get_abs_dir($saveToDir))) {
                ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_notexists'));
            }
            if (!is_writable(get_abs_dir($saveToDir))) {
                ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_unwritable'));
            }
            require_once _EXT_PATH . '/libraries/Archive/archive.php';
            if (!in_array(strtolower($GLOBALS['__POST']["type"]), $allowed_types)) {
                ext_Result::sendResult('archive', false, ext_Lang::err('extract_unknowntype') . ': ' . htmlspecialchars($GLOBALS['__POST']["type"]));
            }
            // This controls how many files are processed per Step (it's split up into steps to prevent time-outs)
            $files_per_step = 2000;
            $cnt = count($GLOBALS['__POST']["selitems"]);
            $abs_dir = get_abs_dir($dir);
            $name = basename(stripslashes($GLOBALS['__POST']["name"]));
            if ($name == "") {
                ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            $startfrom = extGetParam($_REQUEST, 'startfrom', 0);
            $dir_contents_cache_name = 'ext_' . md5(implode(null, $GLOBALS['__POST']["selitems"]));
            $dir_contents_cache_file = _EXT_FTPTMP_PATH . '/' . $dir_contents_cache_name . '.txt';
            $archive_name = get_abs_item($saveToDir, $name);
            $fileinfo = pathinfo($archive_name);
            if (empty($fileinfo['extension'])) {
                $archive_name .= "." . $GLOBALS['__POST']["type"];
                $fileinfo['extension'] = $GLOBALS['__POST']["type"];
                foreach ($allowed_types as $ext) {
                    if ($GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext) {
                        $archive_name .= "." . $ext;
                    }
                }
            }
            if ($startfrom == 0) {
                for ($i = 0; $i < $cnt; $i++) {
                    $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
                    if ($selitem == 'ext_root') {
                        $selitem = '';
                    }
                    if (is_dir(utf8_decode($abs_dir . "/" . $selitem))) {
                        $items = extReadDirectory(utf8_decode($abs_dir . "/" . $selitem), '.', true, true);
                        foreach ($items as $item) {
                            if (is_dir($item) || !is_readable($item) || $item == $archive_name) {
                                continue;
                            }
                            $v_list[] = str_replace('\\', '/', $item);
                        }
                    } else {
                        $v_list[] = utf8_decode(str_replace('\\', '/', $abs_dir . "/" . $selitem));
                    }
                }
                if (count($v_list) > $files_per_step) {
                    if (file_put_contents($dir_contents_cache_file, implode("\n", $v_list)) == false) {
                        ext_Result::sendResult('archive', false, 'Failed to create a temporary list of the directory contents');
                    }
                }
            } else {
                $file_list_string = file_get_contents($dir_contents_cache_file);
                if (empty($file_list_string)) {
                    ext_Result::sendResult('archive', false, 'Failed to retrieve the temporary list of the directory contents');
                }
                $v_list = explode("\n", $file_list_string);
            }
            $cnt_filelist = count($v_list);
            // Now we go to the right range of files and "slice" the array
            $v_list = array_slice($v_list, $startfrom, $files_per_step - 1);
            $remove_path = $GLOBALS["home_dir"];
            if ($dir) {
                $remove_path .= $dir;
            }
            $debug = 'Starting from: ' . $startfrom . "\n";
            $debug .= 'Files to process: ' . $cnt_filelist . "\n";
            $debug .= implode("\n", $v_list);
            //file_put_contents( 'log.txt', $debug, FILE_APPEND );
            // Do some setup stuff
            ini_set('memory_limit', '128M');
            @set_time_limit(0);
            error_reporting(E_ERROR | E_PARSE);
            $result = extArchive::create($archive_name, $v_list, $GLOBALS['__POST']["type"], '', $remove_path);
            if (PEAR::isError($result)) {
                ext_Result::sendResult('archive', false, $name . ': ' . ext_Lang::err('archive_creation_failed') . ' (' . $result->getMessage() . $archive_name . ')');
            }
            $json = new ext_Json();
            if ($cnt_filelist > $startfrom + $files_per_step) {
                $response = array('startfrom' => $startfrom + $files_per_step, 'totalitems' => $cnt_filelist, 'success' => true, 'action' => 'archive', 'message' => sprintf(ext_Lang::msg('processed_x_files'), $startfrom + $files_per_step, $cnt_filelist));
            } else {
                @unlink($dir_contents_cache_file);
                if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') {
                    chmod($archive_name, 0644);
                }
                $response = array('action' => 'archive', 'success' => true, 'message' => ext_Lang::msg('archive_created'), 'newlocation' => make_link('download', $dir, basename($archive_name)));
            }
            echo $json->encode($response);
            ext_exit();
        }
        ?>
<div style="width:auto;">
    <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
    <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">

        <h3 style="margin-bottom:5px;"><?php 
        echo $GLOBALS["messages"]["actarchive"];
        ?>
</h3>
        
        <div id="adminForm"></div>
    </div></div></div>
    <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
</div>
	<script type="text/javascript">	
	var comprTypes = new Ext.data.SimpleStore({
		fields: ['type', 'typename'],
		data :  [
		['zip', 'Zip (<?php 
        echo ext_Lang::msg('normal_compression', true);
        ?>
)'],
		['tgz', 'Tar/Gz (<?php 
        echo ext_Lang::msg('good_compression', true);
        ?>
)'],
		<?php 
        if (extension_loaded("bz2")) {
            echo "['tbz', 'Tar/Bzip2 (" . ext_Lang::msg('best_compression', true) . ")'],";
        }
        ?>
		['tar', 'Tar (<?php 
        echo ext_Lang::msg('no_compression', true);
        ?>
)']
		]
	});
	var form = new Ext.form.Form({
		labelWidth: 125, // label settings here cascade unless overridden
		url:'<?php 
        echo basename($GLOBALS['script_name']);
        ?>
'
	});
	var combo = new Ext.form.ComboBox({
		fieldLabel: '<?php 
        echo ext_Lang::msg('typeheader', true);
        ?>
',
		store: comprTypes,
		displayField:'typename',
		valueField: 'type',
		name: 'type',
		value: 'zip',
	    triggerAction: 'all',
		hiddenName: 'type',
		disableKeyFilter: true,
		editable: false,
		mode: 'local',
		allowBlank: false,
		selectOnFocus:true,
		width: 200
	});
	form.add( new Ext.form.TextField({
		fieldLabel: '<?php 
        echo ext_Lang::msg('archive_name', true);
        ?>
',
		name: 'name',
		width: 200
	}),
	combo,
	new Ext.form.TextField({
		fieldLabel: '<?php 
        echo ext_Lang::msg('archive_saveToDir', true);
        ?>
',
		name: 'saveToDir',
		value: '<?php 
        echo str_replace("'", "\\'", $dir);
        ?>
',
		width: 200
	}),
	new Ext.form.Checkbox({
		fieldLabel: '<?php 
        echo ext_Lang::msg('downlink', true);
        ?>
?',
		name: 'download',
		checked: true
	})
	);
	combo.on('select', function(o, record ) {

		var nameField = form.findField('name').getValue();
		if( nameField.indexOf( '.' ) > 0 ) {
			form.findField('name').setValue( nameField.substring( 0, nameField.indexOf('.')+1 ) + record.get('type') );
		} else {
			form.findField('name').setValue( nameField + '.'+ record.get('type'));
		}
	});

	form.addButton({text: '<?php 
        echo ext_Lang::msg('btncreate', true);
        ?>
', type: 'submit' }, function() { formSubmit(0) });
	form.addButton('<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
', function() { dialog.hide();dialog.destroy(); } );

	form.render('adminForm');

	function formSubmit( startfrom, msg ) {
		if( startfrom == 0 ) {
			Ext.MessageBox.show({
		           title: 'Please wait',
		           msg: msg ? msg : '<?php 
        echo ext_Lang::msg('creating_archive', true);
        ?>
',
		           progressText: 'Initializing...',
		           width:300,
		           progress:true,
		           closable:false,
       		});
       	}
		form.submit({
			reset: false,
			success: function(form, action) {
				if( !action.result ) return;
				
				if( action.result.startfrom > 0 ) {
					formSubmit( action.result.startfrom, action.result.message );
			       
					i = action.result.startfrom/action.result.totalitems;
			       Ext.MessageBox.updateProgress(i, action.result.startfrom + " of "+action.result.totalitems + " (" + Math.round(100*i)+'% completed)');
			        
					return
				} else {

					if( form.findField('download').getValue() ) {
						datastore.reload();
						location.href = action.result.newlocation;
						dialog.hide();
						dialog.destroy();
					} else {
						Ext.MessageBox.alert('<?php 
        echo ext_Lang::msg('success', true);
        ?>
!', action.result.message);
						datastore.reload();
						dialog.hide();
						dialog.destroy();
					}
					return;
				}
			},
			failure: function(form, action) {
				if( action.result ) {
					Ext.MessageBox.alert('<?php 
        echo ext_Lang::err('error', true);
        ?>
', action.result.error);
				}
			},
			scope: form,
			// add some vars to the request, similar to hidden fields
			params: {option: 'com_extplorer',
			action: 'archive',
			dir: '<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
',
			'selitems[]':  [ '<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
' ],
			startfrom: startfrom,
			confirm: 'true'}
		});
	}

	</script>

	<?php 
    }
Beispiel #24
0
function list_dir($dir)
{
    // list directory contents
    global $dir_up, $mosConfig_live_site, $_VERSION;
    ?>
	<script type="text/javascript" src="<?php 
    echo $mosConfig_live_site;
    ?>
/includes/js/overlib_mini.js"></script>
	<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
	<?php 
    $allow = ($GLOBALS["permissions"] & 01) == 01;
    $admin = ($GLOBALS["permissions"] & 04) == 04 || ($GLOBALS["permissions"] & 02) == 02;
    $dir_up = dirname($dir);
    if ($dir_up == ".") {
        $dir_up = "";
    }
    if (!get_show_item($dir_up, basename($dir))) {
        show_error($dir . " : " . $GLOBALS["error_msg"]["accessdir"]);
    }
    // make file & dir tables, & get total filesize & number of items
    make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items);
    $dirs = explode("/", $dir);
    $implode = "";
    $dir_links = "<a href=\"" . make_link("list", "", null) . "\">..</a>/";
    foreach ($dirs as $directory) {
        if ($directory != "") {
            $implode .= $directory . "/";
            $dir_links .= "<a href=\"" . make_link("list", $implode, null) . "\">{$directory}</a>/";
        }
    }
    show_header($GLOBALS["messages"]["actdir"] . ": " . $dir_links);
    // Javascript functions:
    include _QUIXPLORER_PATH . "/include/javascript.php";
    // Sorting of items
    $images = "&nbsp;<img width=\"10\" height=\"10\" border=\"0\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/";
    if ($GLOBALS["srt"] == "yes") {
        $_srt = "no";
        $images .= "_arrowup.gif\" alt=\"^\">";
    } else {
        $_srt = "yes";
        $images .= "_arrowdown.gif\" alt=\"v\">";
    }
    // Toolbar
    echo "<br><table width=\"95%\"><tr><td><table><tr>\n";
    // PARENT DIR
    echo "<td>";
    if ($dir != "") {
        echo "<a href=\"" . make_link("list", $dir_up, NULL) . "\">";
        echo "<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_up.png\" ";
        echo "alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"></a>";
    }
    echo "</td>\n";
    // HOME DIR
    echo "<td><a href=\"" . make_link("list", NULL, NULL) . "\">";
    echo "<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_home.gif\" ";
    echo "alt=\"" . $GLOBALS["messages"]["homelink"] . "\" title=\"" . $GLOBALS["messages"]["homelink"] . "\"></a></td>\n";
    // RELOAD
    echo "<td><a href=\"javascript:location.reload();\"><img border=\"0\" width=\"22\" height=\"22\" ";
    echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_refresh.gif\" alt=\"" . $GLOBALS["messages"]["reloadlink"];
    echo "\" title=\"" . $GLOBALS["messages"]["reloadlink"] . "\"></A></td>\n";
    // SEARCH
    if (!jx_isFTPMode()) {
        echo "<td><a href=\"" . make_link("search", $dir, NULL) . "\">";
        echo "<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_search.gif\" ";
        echo "alt=\"" . $GLOBALS["messages"]["searchlink"] . "\" title=\"" . $GLOBALS["messages"]["searchlink"];
        echo "\"></a></td>\n";
    }
    echo "<td><img src=\"images/menu_divider.png\" height=\"22\" width=\"2\" border=\"0\" alt=\"|\" /></td>";
    // Joomla Sysinfo
    echo "<td><a href=\"" . make_link("sysinfo", $dir, NULL) . "\">";
    echo "<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/systeminfo.gif\" ";
    echo "alt=\"" . $GLOBALS['messages']['mossysinfolink'] . "\" title=\"" . $GLOBALS['messages']['mossysinfolink'] . "\"></a></td>\n";
    echo "<td><img src=\"images/menu_divider.png\" height=\"22\" width=\"2\" border=\"0\" alt=\"|\" /></td>";
    if ($allow) {
        // COPY
        echo "<td><a href=\"javascript:Copy();\"><img border=\"0\" width=\"22\" height=\"22\" ";
        echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_copy.gif\" alt=\"" . $GLOBALS["messages"]["copylink"];
        echo "\" title=\"" . $GLOBALS["messages"]["copylink"] . "\"></a></td>\n";
        // MOVE
        echo "<td><a href=\"javascript:Move();\"><img border=\"0\" width=\"22\" height=\"22\" ";
        echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_move.gif\" alt=\"" . $GLOBALS["messages"]["movelink"];
        echo "\" title=\"" . $GLOBALS["messages"]["movelink"] . "\"></A></td>\n";
        // DELETE
        echo "<td><a href=\"javascript:Delete();\"><img border=\"0\" width=\"22\" height=\"22\" ";
        echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_delete.gif\" alt=\"" . $GLOBALS["messages"]["dellink"];
        echo "\" title=\"" . $GLOBALS["messages"]["dellink"] . "\"></A></td>\n";
        // CHMOD
        echo "<td><a href=\"javascript:Chmod();\"><img border=\"0\" width=\"22\" height=\"22\" ";
        echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_chmod.gif\" alt=\"chmod\" title=\"" . $GLOBALS['messages']['chmodlink'] . "\"></a></td>\n";
        // UPLOAD
        if (ini_get("file_uploads")) {
            echo "<td><a href=\"" . make_link("upload", $dir, NULL) . "\">";
            echo "<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/_upload.gif\" alt=\"" . $GLOBALS["messages"]["uploadlink"];
            echo "\" title=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></A></td>\n";
        } else {
            echo "<td><img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/_upload_.gif\" alt=\"" . $GLOBALS["messages"]["uploadlink"];
            echo "\" title=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></td>\n";
        }
        // ARCHIVE
        if (($GLOBALS["zip"] || $GLOBALS["tar"] || $GLOBALS["tgz"]) && !jx_isFTPMode()) {
            echo "<td><a href=\"javascript:Archive();\"><img border=\"0\" width=\"22\" height=\"22\" ";
            echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_archive.gif\" alt=\"" . $GLOBALS["messages"]["comprlink"];
            echo "\" title=\"" . $GLOBALS["messages"]["comprlink"] . "\"></a></td>\n";
        }
    } else {
        // COPY
        echo "<td><img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
        echo "src=\"" . _QUIXPLORER_URL . "/images/_copy_.gif\" alt=\"" . $GLOBALS["messages"]["copylink"] . "\" title=\"";
        echo $GLOBALS["messages"]["copylink"] . "\"></td>\n";
        // MOVE
        echo "<td><img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
        echo "src=\"" . _QUIXPLORER_URL . "/images/_move_.gif\" alt=\"" . $GLOBALS["messages"]["movelink"] . "\" title=\"";
        echo $GLOBALS["messages"]["movelink"] . "\"></td>\n";
        // DELETE
        echo "<td><img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
        echo "src=\"" . _QUIXPLORER_URL . "/images/_delete_.gif\" alt=\"" . $GLOBALS["messages"]["dellink"] . "\" title=\"";
        echo $GLOBALS["messages"]["dellink"] . "\"></td>\n";
        // UPLOAD
        echo "<td><img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
        echo "src=\"" . _QUIXPLORER_URL . "/images/_upload_.gif\" alt=\"" . $GLOBALS["messages"]["uplink"];
        echo "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"></td>\n";
    }
    // ADMIN & LOGOUT
    if ($GLOBALS["require_login"]) {
        echo "<td>::</td>";
        // ADMIN
        if ($admin) {
            echo "<td><a href=\"" . make_link("admin", $dir, NULL) . "\">";
            echo "<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/_admin.gif\" alt=\"" . $GLOBALS["messages"]["adminlink"] . "\" title=\"";
            echo $GLOBALS["messages"]["adminlink"] . "\"></A></td>\n";
        }
        // LOGOUT
        echo "<td><a href=\"" . make_link("logout", NULL, NULL) . "\">";
        echo "<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" ";
        echo "src=\"" . _QUIXPLORER_URL . "/images/_logout.gif\" alt=\"" . $GLOBALS["messages"]["logoutlink"] . "\" title=\"";
        echo $GLOBALS["messages"]["logoutlink"] . "\"></a></td>\n";
    }
    // Logo
    echo "<td style=\"padding-left:10px;\">";
    //echo "<div style=\"margin-left:10px;float:right;\" width=\"305\" >";
    echo "<a href=\"" . $GLOBALS['jx_home'] . "\" target=\"_blank\" title=\"joomlaXplorer Project\"><img border=\"0\" align=\"absmiddle\" id=\"jx_logo\" style=\"filter:alpha(opacity=10);-moz-opacity:.10;opacity:.10;\" onmouseover=\"opacity('jx_logo', 60, 99, 500);\" onmouseout=\"opacity('jx_logo', 100, 60, 500);\" ";
    echo "src=\"" . _QUIXPLORER_URL . "/images/logo.gif\" align=\"right\" alt=\"" . $GLOBALS['messages']['logolink'] . "\"></a>";
    //echo "</div>";
    echo "</td>\n";
    echo "</tr></table></td>\n";
    // Create File / Dir
    if ($allow && @$GLOBALS['jx_File']->is_writable(get_abs_dir($dir))) {
        echo "<td align=\"right\">\n\t\t\t\t<form action=\"" . make_link("mkitem", $dir, NULL) . "\" method=\"post\" name=\"mkitemform\">\n\n\t\t\t\t<table><tr><td>\n\t\t\t\t\t<select name=\"mktype\" onchange=\"checkMkitemForm(this.options[this.selectedIndex])\">\n\t\t\t\t\t\t<option value=\"file\">" . $GLOBALS["mimes"]["file"] . "</option>\n\t\t\t\t\t\t<option value=\"dir\">" . $GLOBALS["mimes"]["dir"] . "</option>";
        if (!jx_isFTPMode() && !$GLOBALS['isWindows']) {
            echo "\t\t\t<option value=\"symlink\">" . $GLOBALS["mimes"]["symlink"] . "</option>\n";
        }
        echo "\t\t</select>\n\t\t\t\t\t<input name=\"symlink_target\" type=\"hidden\" size=\"25\" title=\"{$GLOBALS['messages']['symlink_target']}\" value=\"{$GLOBALS['mosConfig_absolute_path']}\" />\n\t\t\t\t\t<input name=\"mkname\" type=\"text\" size=\"15\" title=\"{$GLOBALS['messages']['nameheader']}\" />\n\t\t\t\t\t<input type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"] . "\" />\n\t\t\t\t\t</td></tr>\n\t\t\t\t\t<tr><td id=\"quick_jumpto\">" . list_bookmarks($dir) . "</td></tr>\n\t\t\t\t</table>\n\t\t\t\t<script type=\"text/javascript\">function checkMkitemForm( el ) { if( el.value =='symlink' ) document.mkitemform.symlink_target.type='text'; else document.mkitemform.symlink_target.type='hidden';} </script>\n\t\t\t\t</form>\n\t\t\t  </td>\n";
    } else {
        echo "<td align=\"right\">\n\t\t\t\t<table><tr><td id=\"quick_jumpto\">" . list_bookmarks($dir) . "</td></tr></table>\n\t\t\t </td>";
    }
    echo "</tr></table>\n";
    // End Toolbar
    // Begin Table + Form for checkboxes
    echo "<form name=\"selform\" method=\"post\" action=\"" . make_link("post", $dir, null) . "\">\n\t<input type=\"hidden\" name=\"do_action\" /><input type=\"hidden\" name=\"first\" value=\"y\" />\n\t<table class=\"adminlist\" width=\"95%\">\n";
    if (extension_loaded("posix")) {
        $owner_info = '<th width="15%" class="title">' . $GLOBALS['messages']['miscowner'] . '&nbsp;';
        if (jx_isFTPMode()) {
            $my_user_info = posix_getpwnam($_SESSION['ftp_login']);
            $my_group_info = posix_getgrgid($my_user_info['gid']);
        } else {
            $my_user_info = posix_getpwuid(posix_geteuid());
            $my_group_info = posix_getgrgid(posix_getegid());
        }
        $owner_info .= mosTooltip(mysql_escape_string(sprintf($GLOBALS['messages']['miscownerdesc'], $my_user_info['name'], $my_user_info['uid'], $my_group_info['name'], $my_group_info['gid'])));
        // new [mic]
        $owner_info .= "</th>\n";
        $colspan = 8;
    } else {
        $owner_info = "";
        $colspan = 7;
    }
    // Table Header
    echo "<tr>\n\t<th width=\"2%\" class=\"title\">\n\t\t<input type=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\" />\n\t</th>\n\t<th width=\"34%\" class=\"title\">\n";
    if ($GLOBALS["order"] == "name") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<a href=\"" . make_link("list", $dir, NULL, "name", $new_srt) . "\">" . $GLOBALS["messages"]["nameheader"];
    if ($GLOBALS["order"] == "name") {
        echo $images;
    }
    echo '</a>';
    echo "</th>\n\t<th width=\"10%\" class=\"title\">";
    if ($GLOBALS["order"] == "size") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<a href=\"" . make_link("list", $dir, NULL, "size", $new_srt) . "\">" . $GLOBALS["messages"]["sizeheader"];
    if ($GLOBALS["order"] == "size") {
        echo $images;
    }
    echo "</a></th>\n\t<th width=\"14%\" class=\"title\">";
    if ($GLOBALS["order"] == "type") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<a href=\"" . make_link("list", $dir, NULL, "type", $new_srt) . "\">" . $GLOBALS["messages"]["typeheader"];
    if ($GLOBALS["order"] == "type") {
        echo $images;
    }
    echo "</a></th>\n\t<th width=\"14%\" class=\"title\">";
    if ($GLOBALS["order"] == "mod") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<a href=\"" . make_link("list", $dir, NULL, "mod", $new_srt) . "\">" . $GLOBALS["messages"]["modifheader"];
    if ($GLOBALS["order"] == "mod") {
        echo $images;
    }
    echo "</a></th>\n\t<th width=\"2%\" class=\"title\">" . $GLOBALS["messages"]["permheader"] . "\n";
    echo "</th>";
    echo $owner_info;
    echo "<th width=\"10%\" class=\"title\">" . $GLOBALS["messages"]["actionheader"] . "</th>\n\t\n\t</tr>\n";
    // make & print Table using lists
    print_table($dir, make_list($dir_list, $file_list), $allow);
    // print number of items & total filesize
    echo "<tr><td colspan=\"{$colspan}\"><hr/></td></tr><tr>\n<td class=\"title\"></td>";
    echo "<td class=\"title\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " (";
    if (function_exists("disk_free_space")) {
        $size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']);
        $free = parse_file_size($size);
    } elseif (function_exists("diskfreespace")) {
        $size = diskfreespace($GLOBALS['home_dir'] . $GLOBALS['separator']);
        $free = parse_file_size($size);
    } else {
        $free = "?";
    }
    echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</td>\n";
    echo "<td class=\"title\">" . parse_file_size($tot_file_size) . "</td>\n";
    for ($i = 0; $i < $colspan - 3; ++$i) {
        echo "<td class=\"title\"></td>";
    }
    echo "</tr>\n<tr><td colspan=\"{$colspan}\"><hr/></td></tr></table>\n\t\t</form>";
    ?>
<script type="text/javascript"><!--
	// Uncheck all items (to avoid problems with new items)
	var ml = document.selform;
	var len = ml.elements.length;
	for(var i=0; i<len; ++i) {
		var e = ml.elements[i];
		if(e.name == "selitems[]" && e.checked == true) {
			e.checked=false;
		}
	}
	opacity('jx_logo', 10, 60, 2000);
// --></script>

<?php 
}
Beispiel #25
0
function unzip_item($dir)
{
    // copy and move are only allowed if the user may read and change files
    /*if ($GLOBALS["action"] == "copy"
    	&& !permissions_grant_all($dir, NULL, array("read", "create")))
    		show_error($GLOBALS["error_msg"]["accessfunc"]);
    	if ($GLOBALS["action"] == "move"
    	&& !permissions_grant($dir, NULL, "change"))
    		show_error($GLOBALS["error_msg"]["accessfunc"]);
    	*/
    if (!permissions_grant_all($dir, NULL, array("read", "create"))) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Vars
    /*
    $first = $GLOBALS['__POST']["first"];
    if($first=="y") 
    $new_dir=$dir;
    else $new_dir = stripslashes($GLOBALS['__POST']["new_dir"]);
    */
    $new_dir = stripslashes($GLOBALS['__POST']["new_dir"]);
    //if($new_dir==".") $new_dir="";
    //$cnt=count($GLOBALS['__POST']["selitems"]);
    // Copy or Move?
    /*
    if($GLOBALS["action"]!="move") {
    	$_img="_img/__copy.gif";
    } else {
    	$_img="_img/__cut.gif";
    }
    */
    $_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 = $GLOBALS["home_dir"] . $new_dir;
    if ($new_dir != "") {
        $dir_extract .= "/";
    }
    $zip_name = $GLOBALS["home_dir"] . $GLOBALS["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 "<BR><IMG SRC=\"" . $_img . "\" align=\"ABSMIDDLE\" ALT=\"\">&nbsp;";
        //echo sprintf(($GLOBALS["action"]!="move"?$GLOBALS["messages"]["actcopyfrom"]:
        //	$GLOBALS["messages"]["actmovefrom"]),$s_dir, $s_ndir);
        echo sprintf($GLOBALS["messages"]["actunzipto"], $s_ndir);
        //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
        /*for($i=0;$i<$cnt;++$i) {
            $selitem=stripslashes($GLOBALS['__POST']["selitems"][$i]);
            if(isset($GLOBALS['__POST']["newitems"][$i])) {
              $newitem=stripslashes($GLOBALS['__POST']["newitems"][$i]);
              if($first=="y") $newitem=$selitem;
            } else {$newitem=$selitem;}
            $s_item=$selitem;	if(strlen($s_item)>50) $s_item=substr($s_item,0,47)."...";
            echo "<TR><TD><IMG SRC=\"".$GLOBALS["baricons"]["info"]."\" align=\"ABSMIDDLE\" ALT=\"\">";
            // Old Name
            echo "<INPUT type=\"hidden\" name=\"selitems[]\" value=\"";
            echo $selitem."\">&nbsp;".$s_item."&nbsp;";
            // New Name
            echo "</TD><TD><INPUT type=\"text\" size=\"25\" name=\"newitems[]\" value=\"";
            echo $newitem."\"></TD></TR>\n";
          }*/
        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>";
        if ($new_dir == 'hn') {
            echo "<INPUT type=\"submit\" value=\"Rozbaliť archív\" onclick=\"javascript:Execute();\" style=\"color:#fff;background:#337ab7;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #2e6da4;border-radius:4px;\">";
        }
        echo "</TD>\n<TD>Rovnako bude pomenovaný slug pre vydanie Horezza News. Pre zmenu názvu, je potrebné zmeniť názov ZIP súboru, pred nahraním.<br>";
        echo "<input type=\"button\" value=\"Zrušiť\" onClick=\"javascript:location='" . make_link("list", $dir, NULL);
        echo "';\" style=\"color:#333;background:#fff;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #ccc;border-radius:4px;\"></TD>\n</TR></FORM></TABLE><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);
    	}
    */
    $zip = new ZipArchive();
    //			$zip_name = "../../".$GLOBALS["dir"].$s_item;
    //			$dir_extract = "../../".$new_dir."/";
    $res = $zip->open($zip_name);
    if ($res === TRUE) {
        $zip->extractTo($dir_extract);
        $zip->close();
        //echo �ok�;
    } else {
        // echo �failed�;
    }
    //} //else {
    //	$ok=@rename($abs_item,$abs_new_item);
    //}
    if ($ok === false || $res == false) {
        //$error[$i]=($GLOBALS["action"]=="copy"?
        //	$GLOBALS["error_msg"]["copyitem"]:
        //	$GLOBALS["error_msg"]["moveitem"]
        //);
        $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);
    }
    miwoftp_redirect(make_link("list", $dir, NULL));
}
Beispiel #26
0
function make_tables($dir, &$dir_list, &$file_list, &$tot_file_size, &$num_items)
{
    // make table of files in dir
    // make tables & place results in reference-variables passed to function
    // also 'return' total filesize & total number of items
    $homedir = realpath($GLOBALS['home_dir']);
    $tot_file_size = $num_items = 0;
    // Open directory
    $handle = @opendir(get_abs_dir($dir));
    if ($handle === false && $dir == "") {
        $handle = @opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('', false, $dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    // Read directory
    while (($new_item = readdir($handle)) !== false) {
        $abs_new_item = get_abs_item($dir, $new_item);
        if ($new_item == "." || $new_item == "..") {
            continue;
        }
        if (!file_exists($abs_new_item)) {
            //ext_Result::sendResult('', false, $dir."/$abs_new_item: ".$GLOBALS["error_msg"]["readdir"]);
            if (!get_show_item($dir, $new_item)) {
                continue;
            }
        }
        $new_file_size = @filesize($abs_new_item);
        $tot_file_size += $new_file_size;
        $num_items++;
        if (get_is_dir($abs_new_item)) {
            if ($GLOBALS["order"] == "mod") {
                $dir_list[$new_item] = @filemtime($abs_new_item);
            } else {
                // order == "size", "type" or "name"
                $dir_list[$new_item] = $new_item;
            }
        } else {
            if ($GLOBALS["order"] == "size") {
                $file_list[$new_item] = $new_file_size;
            } elseif ($GLOBALS["order"] == "mod") {
                $file_list[$new_item] = @filemtime($abs_new_item);
            } elseif ($GLOBALS["order"] == "type") {
                $file_list[$new_item] = get_mime_type($abs_new_item, "type");
            } else {
                // order == "name"
                $file_list[$new_item] = $new_item;
            }
        }
    }
    closedir($handle);
    // sort
    if (is_array($dir_list)) {
        if ($GLOBALS["order"] == "mod") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($dir_list);
            } else {
                asort($dir_list);
            }
        } else {
            // order == "size", "type" or "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($dir_list);
            } else {
                krsort($dir_list);
            }
        }
    }
    // sort
    if (is_array($file_list)) {
        if ($GLOBALS["order"] == "mod") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($file_list);
            } else {
                asort($file_list);
            }
        } elseif ($GLOBALS["order"] == "size" || $GLOBALS["order"] == "type") {
            if ($GLOBALS["direction"] == "ASC") {
                asort($file_list);
            } else {
                arsort($file_list);
            }
        } else {
            // order == "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($file_list);
            } else {
                krsort($file_list);
            }
        }
    }
}
Beispiel #27
0
function get_dir_list($dir = '')
{
    $files = mosReadDirectory(get_abs_dir($dir), '.', false, true);
    $dirs = array();
    foreach ($files as $item) {
        $item = str_replace('\\', '/', $item);
        if (get_is_dir($item)) {
            $index = str_replace($GLOBALS['home_dir'] . $GLOBALS['separator'], '', $item);
            $dirs[$index] = basename($index);
        }
    }
    return $dirs;
}
Beispiel #28
0
function get_abs_item($dir, $item)
{
    // get absolute file+path
    return get_abs_dir($dir) . "/" . $item;
}
Beispiel #29
0
function get_abs_item($dir, $item)
{
    return get_abs_dir($dir) . DIRECTORY_SEPARATOR . $item;
}