Пример #1
0
 function onAuthenticate($credentials, $options = null)
 {
     $ftp_login = $credentials['username'];
     $ftp_pass = $credentials['password'];
     if ($ftp_login != '' || $ftp_pass != '') {
         $ftp_host = empty($_SESSION['ftp_host']) ? extGetParam($_POST, 'ftp_host', 'localhost:21') : $_SESSION['ftp_host'];
         $url = @parse_url('ftp://' . $ftp_host);
         if (empty($url)) {
             ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21');
         }
         $port = empty($url['port']) ? 21 : $url['port'];
         $GLOBALS['FTPCONNECTION'] = new Net_FTP($url['host'], $port, 20);
         $res = $GLOBALS['FTPCONNECTION']->connect();
         if (PEAR::isError($res)) {
             ext_Result::sendResult('ftp_authentication', false, ext_Lang::msg('ftp_connection_failed') . ' (' . $url['host'] . ')');
         } else {
             $res = $GLOBALS['FTPCONNECTION']->login($ftp_login, $ftp_pass);
             if (PEAR::isError($res)) {
                 ext_Result::sendResult('ftp_authentication', false, ext_Lang::msg('ftp_login_failed'));
             }
             $_SESSION['credentials_ftp']['username'] = $ftp_login;
             $_SESSION['credentials_ftp']['password'] = $ftp_pass;
             $_SESSION['ftp_host'] = $ftp_host;
             $_SESSION['file_mode'] = 'ftp';
             $_SESSION['ftp_login'] = $ftp_login;
             return true;
         }
     }
     return false;
 }
Пример #2
0
 function onAuthenticate($credentials, $options = null)
 {
     $ssh2_user = $credentials['username'];
     $ssh2_pass = $credentials['password'];
     if ($ssh2_user != '' || $ssh2_pass != '') {
         $ssh2_host = empty($_SESSION['ssh2_host']) ? extGetParam($_POST, 'ssh2_host', 'localhost:22') : $_SESSION['ssh2_host'];
         $url = @parse_url('ssh2.sftp://' . $ssh2_host);
         if (empty($url)) {
             ext_Result::sendResult('ssh2_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:22');
         }
         $port = empty($url['port']) ? 22 : $url['port'];
         $GLOBALS['FTPCONNECTION'] = new SFTPConnection();
         $res = $GLOBALS['FTPCONNECTION']->connect($url['host'], $port);
         if (PEAR::isError($res)) {
             return $res;
         }
         $res = $GLOBALS['FTPCONNECTION']->login($ssh2_user, $ssh2_pass);
         if (PEAR::isError($res)) {
             return $res;
         }
         $_SESSION['credentials_ssh2']['username'] = $ssh2_user;
         $_SESSION['credentials_ssh2']['password'] = $ssh2_pass;
         $_SESSION['ssh2_host'] = $ssh2_host;
         $_SESSION['file_mode'] = 'ssh2';
         return true;
     }
     return false;
 }
Пример #3
0
 function execAction($dir, $item)
 {
     if (!ext_isArchive($item)) {
         ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive'));
     } else {
         // CSRF Security Check
         if (!ext_checkToken($GLOBALS['__POST']["token"])) {
             ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
         }
         $archive_name = realpath(get_abs_item($dir, $item));
         if (empty($dir)) {
             $extract_dir = realpath($GLOBALS['home_dir']);
         } else {
             $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir);
         }
         require_once _EXT_PATH . '/libraries/Archive/archive.php';
         $res = extArchive::extract($archive_name, $extract_dir);
         if (PEAR::isError($res)) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage());
         }
         if ($res === false) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure'));
         } else {
             ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
         }
         ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
     }
 }
Пример #4
0
 function execAction($dir, $item, $unlink = false)
 {
     // download file
     global $action, $mosConfig_cache_path;
     // Security Fix:
     $item = basename($item);
     while (@ob_end_clean()) {
     }
     ob_start();
     if (ext_isFTPMode()) {
         $abs_item = $dir . '/' . $item;
     } else {
         $abs_item = get_abs_item($dir, $item);
         //if( !strstr( $abs_item, $GLOBALS['home_dir']) )
         //  $abs_item = realpath($GLOBALS['home_dir']).$abs_item;
     }
     if (($GLOBALS["permissions"] & 01) != 01) {
         ext_Result::sendResult('download', false, $GLOBALS["error_msg"]["accessfunc"]);
     }
     if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
     }
     if (!get_show_item($dir, $item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
     }
     if (ext_isFTPMode()) {
         $abs_item = ext_ftp_make_local_copy($abs_item);
         $unlink = true;
     }
     $browser = id_browser();
     header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Transfer-Encoding: binary');
     header('Content-Length: ' . filesize(realpath($abs_item)));
     //header("Content-Encoding: none");
     if ($browser == 'IE') {
         header('Content-Disposition: attachment; filename="' . $item . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: attachment; filename="' . $item . '"');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
     }
     @set_time_limit(0);
     @readFileChunked(utf8_decode($abs_item));
     if ($unlink == true) {
         unlink(utf8_decode($abs_item));
     }
     ob_end_flush();
     ext_exit();
 }
Пример #5
0
/**
 * @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);
}
Пример #6
0
 function &getAdapter($type)
 {
     static $adapters;
     if (!isset($adapters)) {
         $adapters = array();
     }
     if (!isset($adapters[$type])) {
         // Try to load the adapter object
         $class = 'xfileArchive' . ucfirst($type);
         if (!class_exists($class)) {
             $path = dirname(__FILE__) . '/adapter/' . strtolower($type) . '.php';
             if (file_exists($path)) {
                 require_once $path;
             } else {
                 echo 'Unknown Archive Type: ' . $class;
                 ext_Result::sendResult('archive', false, 'Unable to load archive');
             }
         }
         $adapters[$type] = new $class();
     }
     return $adapters[$type];
 }
Пример #7
0
 function execAction($dir, $item)
 {
     if (!ext_isArchive($item)) {
         ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive'));
     } else {
         $archive_name = realpath(get_abs_item($dir, $item));
         if (empty($dir)) {
             $extract_dir = realpath($GLOBALS['home_dir']);
         } else {
             $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir);
         }
         require_once _EXT_PATH . '/libraries/Archive/archive.php';
         $res = extArchive::extract($archive_name, $extract_dir);
         if (PEAR::isError($res)) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage());
         }
         if ($res === false) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure'));
         } else {
             ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
         }
         ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
     }
 }
Пример #8
0
 function execAction($dir, $item, $unlink = false)
 {
     // Security Fix:
     $item = basename($item);
     while (@ob_end_clean()) {
     }
     ob_start();
     if (ext_isFTPMode()) {
         $abs_item = $dir . '/' . $item;
     } else {
         $abs_item = get_abs_item($dir, $item);
         //if( !strstr( $abs_item, $GLOBALS['home_dir']) )
         //	$abs_item = realpath($GLOBALS['home_dir']).$abs_item;
     }
     if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
         return false;
     }
     if (!get_show_item($dir, $item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
         return false;
     }
     @set_time_limit(0);
     if (ext_isFTPMode()) {
         $abs_item = ext_ftp_make_local_copy($abs_item);
         $unlink = true;
     }
     $browser = id_browser();
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Transfer-Encoding: binary');
     header('Content-Length: ' . filesize(realpath($abs_item)));
     //header("Content-Encoding: none");
     if (isset($_GET['action2']) && $_GET['action2'] == 'view') {
         $content_disposition = 'inline';
         include_once _EXT_PATH . '/libraries/Archive/file.php';
         $extension = extFile::getExt($item);
         switch (strtolower($extension)) {
             case 'doc':
             case 'dot':
                 $extension = 'msword';
                 break;
             case 'docx':
             case 'dotx':
                 $extension = 'vnd.openxmlformats-officedocument.wordprocessingml.template';
                 break;
             case 'docm':
                 $extension = 'vnd.ms-word.document.macroEnabled.12';
                 break;
             case 'docm':
                 $extension = 'vnd.ms-word.template.macroEnabled.12';
                 break;
             case 'xls':
             case 'xlt':
             case 'xla':
                 $extension = 'vnd.ms-excel';
                 break;
             case 'xlsx':
                 $extension = 'vnd.openxmlformats-officedocument.spreadsheetml.sheet';
                 break;
             case 'xltx':
                 $extension = 'vnd.openxmlformats-officedocument.spreadsheetml.template';
                 break;
             case 'xlsm':
                 $extension = 'vnd.ms-excel.sheet.macroEnabled.12';
                 break;
             case 'xltm':
                 $extension = 'vnd.ms-excel.template.macroEnabled.12';
                 break;
             case 'xlam':
                 $extension = 'vnd.ms-excel.addin.macroEnabled.12';
                 break;
             case 'xlsb':
                 $extension = 'vnd.ms-excel.sheet.binary.macroEnabled.12';
                 break;
             case 'ppt':
             case 'pot':
             case 'pps':
             case 'ppa':
                 $extension = 'vnd.ms-powerpoint';
                 break;
             case 'pptx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.presentation';
                 break;
             case 'potx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.template';
                 break;
             case 'ppsx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.slideshow';
                 break;
             case 'ppam':
                 $extension = 'vnd.ms-powerpoint.addin.macroEnabled.12';
                 break;
             case 'pptm':
                 $extension = 'vnd.ms-powerpoint.presentation.macroEnabled.12';
                 break;
             case 'potm':
                 $extension = 'vnd.ms-powerpoint.template.macroEnabled.12';
                 break;
             case 'ppsm':
                 $extension = 'vnd.ms-powerpoint.slideshow.macroEnabled.12';
                 break;
             case 'rtf':
                 $extension = 'application/rtf';
                 break;
         }
         header('Content-Type: application/' . $extension . '; Charset=' . $GLOBALS["system_charset"]);
     } else {
         $content_disposition = 'attachment';
         if ($browser == 'IE' || $browser == 'OPERA') {
             header('Content-Type: application/octetstream; Charset=' . $GLOBALS["system_charset"]);
         } else {
             header('Content-Type: application/octet-stream; Charset=' . $GLOBALS["system_charset"]);
         }
     }
     if ($browser == 'IE') {
         // http://support.microsoft.com/kb/436616/ja
         header('Content-Disposition: ' . $content_disposition . '; filename="' . urlencode($item) . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: ' . $content_disposition . '; filename="' . $item . '"');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
     }
     if ($GLOBALS['use_mb']) {
         if (mb_detect_encoding($abs_item) == 'ASCII') {
             @readFileChunked(utf8_decode($abs_item));
         } else {
             @readFileChunked($abs_item);
         }
     } else {
         @readFileChunked(utf8_decode($abs_item));
     }
     if ($unlink == true) {
         unlink(utf8_decode($abs_item));
     }
     ob_end_flush();
     ext_exit();
 }
Пример #9
0
 function savefile($file_name)
 {
     // save edited file
     if (get_magic_quotes_gpc()) {
         $code = stripslashes($GLOBALS['__POST']["code"]);
     } else {
         $code = $GLOBALS['__POST']["code"];
     }
     $langs = $GLOBALS["language"];
     if ($langs == "japanese") {
         $_encoding = $GLOBALS['__POST']["file_encoding"];
         if ($_encoding != "UTF-8") {
             $code = mb_convert_encoding($code, $_encoding, "UTF-8");
         }
     }
     $res = $GLOBALS['ext_File']->file_put_contents($file_name, $code);
     if ($res == false || PEAR::isError($res)) {
         $err = basename($file_name) . ": " . ext_Lang::err('savefile');
         if (PEAR::isError($res)) {
             $err .= $res->getMessage();
         }
         ext_Result::sendResult('edit', false, $err);
     }
 }
Пример #10
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 
    }
Пример #11
0
    $GLOBALS["dir"] = $dir = urldecode(stripslashes(extGetParam($_REQUEST, "dir")));
}
if ($dir == 'ext_root') {
    $GLOBALS["dir"] = $dir = '';
}
if (ext_isFTPMode() && $dir != '') {
    $GLOBALS['FTPCONNECTION']->cd($dir);
}
$abs_dir = get_abs_dir($GLOBALS["dir"]);
if (!file_exists($GLOBALS["home_dir"])) {
    if (!file_exists($GLOBALS["home_dir"] . $GLOBALS["separator"])) {
        if ($GLOBALS["require_login"]) {
            $extra = "<a href=\"" . make_link("logout", NULL, NULL) . "\">" . $GLOBALS["messages"]["btnlogout"] . "</a>";
        } else {
            $extra = NULL;
        }
        ext_Result::sendResult('', false, $GLOBALS["error_msg"]["home"] . " (" . $GLOBALS["home_dir"] . ")", $extra);
    }
}
if (!$GLOBALS['ext_conf']['symlink_allow_abovehome']) {
    if (!down_home($abs_dir)) {
        ext_Result::sendResult('', false, $GLOBALS["dir"] . " : " . $GLOBALS["error_msg"]["abovehome"]);
        $dir = '';
    }
}
if (!get_is_dir(utf8_decode($abs_dir)) && !get_is_dir($abs_dir . $GLOBALS["separator"])) {
    ext_Result::sendResult('', false, '"' . $abs_dir . '" - ' . $GLOBALS["error_msg"]["direxist"]);
    $dir = '';
}
$_SESSION['ext_' . $GLOBALS['file_mode'] . 'dir'] = $dir;
//------------------------------------------------------------------------------
Пример #12
0
     require_once _EXT_PATH . "/include/admin.php";
     show_admin($dir);
     break;
     //------------------------------------------------------------------------------
     // BOOKMARKS
 //------------------------------------------------------------------------------
 // BOOKMARKS
 case 'modify_bookmark':
     $task = extGetParam($_REQUEST, 'task');
     require_once _EXT_PATH . '/include/bookmarks.php';
     modify_bookmark($task, $dir);
     break;
     //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 case 'show_error':
     ext_Result::sendResult('', false, '');
     break;
 case 'get_about':
     require_once _EXT_PATH . "/include/system_info.php";
     system_info();
     break;
     //------------------------------------------------------------------------------
     // DEFAULT: LIST FILES & DIRS
 //------------------------------------------------------------------------------
 // DEFAULT: LIST FILES & DIRS
 case "getdircontents":
     require_once _EXT_PATH . "/include/list.php";
     $requestedDir = stripslashes(str_replace('_RRR_', '/', extGetParam($_REQUEST, 'node')));
     if (empty($requestedDir) || $requestedDir == 'ext_root') {
         $requestedDir = $dir;
     }
Пример #13
0
    function execAction($dir)
    {
        // make new directory or file
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('mkitem', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (extGetParam($_POST, 'confirm') == 'true') {
            // CSRF Security Check
            if (!ext_checkToken($GLOBALS['__POST']["token"])) {
                ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
            }
            $mkname = $GLOBALS['__POST']["mkname"];
            $mktype = $GLOBALS['__POST']["mktype"];
            $symlink_target = $GLOBALS['__POST']['symlink_target'];
            $mkname = basename(stripslashes($mkname));
            if ($mkname == "") {
                ext_Result::sendResult('mkitem', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            $new = get_abs_item($dir, $mkname);
            if (@$GLOBALS['ext_File']->file_exists($new)) {
                ext_Result::sendResult('mkitem', false, $mkname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
            }
            $err = print_r($_POST, true);
            if ($mktype == "dir") {
                $ok = @$GLOBALS['ext_File']->mkdir($new, 0777);
                $err = $GLOBALS["error_msg"]["createdir"];
            } elseif ($mktype == 'file') {
                $ok = @$GLOBALS['ext_File']->mkfile($new);
                $err = $GLOBALS["error_msg"]["createfile"];
            } elseif ($mktype == 'symlink') {
                if (empty($symlink_target)) {
                    ext_Result::sendResult('mkitem', false, 'Please provide a valid <strong>target</strong> for the symbolic link.');
                }
                if (!file_exists($symlink_target) || !is_readable($symlink_target)) {
                    ext_Result::sendResult('mkitem', false, 'The file you wanted to make a symbolic link to does not exist or is not accessible by PHP.');
                }
                $ok = symlink($symlink_target, $new);
                $err = 'The symbolic link could not be created.';
            }
            if ($ok == false || PEAR::isError($ok)) {
                if (PEAR::isError($ok)) {
                    $err .= $ok->getMessage();
                }
                ext_Result::sendResult('mkitem', false, $err);
            }
            ext_Result::sendResult('mkitem', true, 'The item ' . $new . ' was created');
            return;
        }
        ?>
		{
		"xtype": "form",
		"id": "simpleform",
		"labelWidth": 125,
		"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		"dialogtitle": "Create New File/Directory",
		"frame": true,
		"items": [{
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg("nameheader", true);
        ?>
",
			"name": "mkname",
			"width":175,
			"allowBlank":false
			},{
			"xtype": "combo",
			"fieldLabel": "Type",
			"store": [["file", "<?php 
        echo ext_Lang::mime('file', true);
        ?>
"],
						["dir", "<?php 
        echo ext_Lang::mime('dir', true);
        ?>
"]
						<?php 
        if (!ext_isFTPMode() && !$GLOBALS['isWindows']) {
            ?>
						,["symlink", "<?php 
            echo ext_Lang::mime('symlink', true);
            ?>
"]
						<?php 
        }
        ?>
					],
			displayField:"type",
			valueField: "mktype",
			value: "file",
			hiddenName: "mktype",
			disableKeyFilter: true,
			editable: false,
			triggerAction: "all",
			mode: "local",
			allowBlank: false,
			selectOnFocus:true
		},{
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('symlink_target', true);
        ?>
",
			"name": "symlink_target",
			"width":175,
			"allowBlank":true
		}],
		"buttons": [{
			"text": "<?php 
        echo ext_Lang::msg('btncreate', true);
        ?>
", 
			"handler": function() {
				statusBarMessage( "Please wait...", true );
				Ext.getCmp("simpleform").getForm().submit({
					//reset: true,
					reset: false,
					success: function(form, action) {
						statusBarMessage( action.result.message, false, true );
						try{ 
							dirTree.getSelectionModel().getSelectedNode().reload(); 
						} catch(e) {}
						datastore.reload();
						Ext.getCmp("dialog").destroy();
					},
					failure: function(form, action) {
						if( !action.result ) return;
						Ext.Msg.alert("Error!", action.result.error);
						statusBarMessage( action.result.error, false, false );
					},
					scope: Ext.getCmp("simpleform"),
					// add some vars to the request, similar to hidden fields
					params: {option: "com_extplorer", 
							action: "mkitem", 
							dir: datastore.directory, 
							confirm: "true",
							token: "<?php 
        echo ext_getToken();
        ?>
"
					}
				})
			}
		},{
			"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
			"handler": function() { Ext.getCmp("dialog").destroy(); }
		}]
	}
	<?php 
    }
Пример #14
0
function list_dir($dir)
{
    // list directory contents
    global $dir_up, $mosConfig_live_site, $_VERSION;
    $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))) {
        ext_Result::sendResult('', false, $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>&nbsp;/&nbsp;";
    foreach ($dirs as $directory) {
        if ($directory != "") {
            $implode .= $directory . "/";
            $dir_links .= "<a href=\"" . make_link("list", $implode, null) . "\">{$directory}</a>&nbsp;/&nbsp;";
        }
    }
    echo '<div class="componentheading">' . $GLOBALS["messages"]["actdir"] . ": " . $dir_links . '</div>';
    // Sorting of items
    $images = "&nbsp;<img width=\"10\" height=\"10\" border=\"0\" align=\"absmiddle\" src=\"" . _EXT_URL . "/images/";
    if ($GLOBALS["direction"] == "ASC") {
        $_srt = "DESC";
        $images .= "_arrowup.gif\" alt=\"^\">";
    } else {
        $_srt = "ASC";
        $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=\""._EXT_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=\""._EXT_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=\""._EXT_URL."/images/_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=\"22\" height=\"22\" align=\"absmiddle\" src=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_URL."/images/_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=\"22\" height=\"22\" ";
    			echo "align=\"absmiddle\" src=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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=\""._EXT_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['ext_home']."\" target=\"_blank\" title=\"joomlaXplorer Project\"><img border=\"0\" align=\"absmiddle\" id=\"ext_logo\" style=\"filter:alpha(opacity=10);-moz-opacity:.10;opacity:.10;\" onmouseover=\"opacity('ext_logo', 60, 99, 500);\" onmouseout=\"opacity('ext_logo', 100, 60, 500);\" ";
    	echo "src=\""._EXT_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 && is_writable($GLOBALS['home_dir'].'/'.$dir)) {
    		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%\" cellpadding=\"5\" cellspacing=\"2\"><tr class=\"sectiontableheader\">\n";
    echo "<th width=\"44%\"><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 $images;
    }
    echo "</a></b></td>\n<th width=\"10%\"><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 $images;
    }
    echo "</a></b></th>\n<th width=\"12%\" ><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 $images;
    }
    echo "</a></b></th>\n<th width=\"12%\"><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 $images;
    }
    echo "</a></b></th></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=\"4\"><hr/></td></tr><tr>\n<td>&nbsp;</td>";
    echo "<td>" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " " . parse_file_size($tot_file_size) . "</td>\n";
    echo "<td>&nbsp;</td><td>&nbsp;</td>";
    echo "</tr>\n<tr><td colspan=\"4\"><hr/></td></tr></table>\n";
}
Пример #15
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;
}
Пример #16
0
 function execAction($dir)
 {
     // delete files/dirs
     if (($GLOBALS["permissions"] & 01) != 01) {
         ext_Result::sendResult('delete', false, $GLOBALS["error_msg"]["accessfunc"]);
     }
     // CSRF Security Check
     if (!ext_checkToken($GLOBALS['__POST']["token"])) {
         ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
     }
     $cnt = count($GLOBALS['__POST']["selitems"]);
     $err = false;
     // delete files & check for errors
     for ($i = 0; $i < $cnt; ++$i) {
         $items[$i] = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
         if (ext_isFTPMode()) {
             $abs = get_item_info($dir, $items[$i]);
         } else {
             $abs = get_abs_item($dir, $items[$i]);
         }
         if (!@$GLOBALS['ext_File']->file_exists($abs)) {
             $error[$i] = $GLOBALS["error_msg"]["itemexist"];
             $err = true;
             continue;
         }
         if (!get_show_item($dir, $items[$i])) {
             $error[$i] = $GLOBALS["error_msg"]["accessitem"];
             $err = true;
             continue;
         }
         // Delete
         if (ext_isFTPMode()) {
             $abs = str_replace('\\', '/', get_abs_item($dir, $abs));
         }
         $ok = $GLOBALS['ext_File']->remove($abs);
         if ($ok === false || PEAR::isError($ok)) {
             $error[$i] = $GLOBALS["error_msg"]["delitem"];
             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('delete', false, $err_msg);
     }
     ext_Result::sendResult('delete', true, $GLOBALS['messages']['success_delete_file']);
 }
Пример #17
0
    }
} else {
    $GLOBALS["dir"] = $dir = urldecode(stripslashes(extGetParam($_REQUEST, "dir")));
}
if ($dir == 'ext_root') {
    $GLOBALS["dir"] = $dir = '';
}
if (ext_isFTPMode() && $dir != '') {
    $GLOBALS['FTPCONNECTION']->cd($dir);
}
$abs_dir = get_abs_dir($GLOBALS["dir"]);
if (!file_exists($GLOBALS["home_dir"])) {
    if (!file_exists($GLOBALS["home_dir"] . $GLOBALS["separator"])) {
        if ($GLOBALS["require_login"]) {
            $extra = "<a href=\"" . make_link("logout", NULL, NULL) . "\">" . $GLOBALS["messages"]["btnlogout"] . "</a>";
        } else {
            $extra = NULL;
        }
        ext_Result::sendResult('', false, $GLOBALS["error_msg"]["home"] . " (" . $GLOBALS["home_dir"] . ")", $extra);
    }
}
if (!down_home($abs_dir)) {
    ext_Result::sendResult('', false, $GLOBALS["dir"] . " : " . $GLOBALS["error_msg"]["abovehome"]);
    $dir = '';
}
if (!get_is_dir(utf8_decode($abs_dir)) && !get_is_dir($abs_dir . $GLOBALS["separator"])) {
    ext_Result::sendResult('', false, $abs_dir . " : " . $GLOBALS["error_msg"]["direxist"]);
    $dir = '';
}
$_SESSION['ext_' . $GLOBALS['file_mode'] . 'dir'] = $dir;
//------------------------------------------------------------------------------
Пример #18
0
    function execAction()
    {
        $ftp_login = extGetParam($_POST, 'ftp_login_name', '');
        $ftp_pass = extGetParam($_POST, 'ftp_login_pass', '');
        global $dir, $mosConfig_live_site;
        if ($ftp_login != '' || $ftp_pass != '') {
            $ftp_host = extGetParam($_POST, 'ftp_hostname_port', 'localhost:21');
            $url = @parse_url('ftp://' . $ftp_host);
            if (empty($url)) {
                ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21');
            }
            $port = empty($url['port']) ? 21 : $url['port'];
            $ftp = new Net_FTP($url['host'], $port, 20);
            $res = $ftp->connect();
            if (PEAR::isError($res)) {
                ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_connection_failed'] . ' (' . $url['host'] . ')');
            } else {
                $res = $ftp->login($ftp_login, $ftp_pass);
                $ftp->disconnect();
                if (PEAR::isError($res)) {
                    ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_login_failed']);
                }
                $_SESSION['ftp_login'] = $ftp_login;
                $_SESSION['ftp_pass'] = $ftp_pass;
                $_SESSION['ftp_host'] = $ftp_host;
                $_SESSION['file_mode'] = 'ftp';
                session_write_close();
                ext_Result::sendResult('ftp_authentication', true, ext_Lang::msg('actlogin_success'));
            }
        } else {
            ?>
	<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"]["ftp_header"];
            ?>
</h3>
	        <strong><?php 
            echo $GLOBALS["messages"]["ftp_login_lbl"];
            ?>
</strong><br />
	<br />
	        <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 simple = new Ext.form.Form({
	    labelWidth: 175, // label settings here cascade unless overridden
	    url:'<?php 
            echo make_link("rename", $dir, $item);
            ?>
'
	});
	simple.add(
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
            echo ext_Lang::msg('ftp_login_name', true);
            ?>
',
	        name: 'ftp_login_name',
	        width:175,
	        allowBlank:false
	    }),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
            echo ext_Lang::msg('ftp_login_pass', true);
            ?>
',
	        name: 'ftp_login_pass',
	        inputType: 'password',
	        width:175,
	        allowBlank:false
	    }),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
            echo ext_Lang::msg('ftp_hostname_port', true);
            ?>
',
	        name: 'ftp_hostname_port',
	        value: '<?php 
            echo extGetParam($_SESSION, 'ftp_host', 'localhost:21');
            ?>
',
	        width:175,
	        allowBlank:false
	    })
	    );
	
	simple.addButton({text: '<?php 
            echo ext_Lang::msg('btnlogin', true);
            ?>
', type: 'submit' }, function() {
		statusBarMessage( '<?php 
            echo ext_Lang::msg('ftp_login_check', true);
            ?>
', true );
	    simple.submit({
	        //reset: true,
	        reset: false,
	        success: function(form, action) { location.reload() },
	        failure: function(form, action) {
	        	if( !action.result ) return;
	        	Ext.MessageBox.alert('<?php 
            echo ext_Lang::err('error', true);
            ?>
', action.result.error);
	        	statusBarMessage( action.result.error, false, false );
	        },
	        scope: simple,
	        // add some vars to the request, similar to hidden fields
	        params: {option: 'com_extplorer', 
	        		action: 'ftp_authentication'
	        }
	    });
	});
	simple.addButton('<?php 
            echo ext_Lang::msg('btncancel', true);
            ?>
', function() { dialog.destroy(); } );
	simple.render('adminForm');
			</script>
			
			<br/>
		<?php 
        }
    }
Пример #19
0
function show_admin($dir)
{
    // Execute Admin Action
    $pwd = ($GLOBALS["permissions"] & 2) == 2;
    $admin = ($GLOBALS["permissions"] & 4) == 4;
    if (!$GLOBALS["require_login"]) {
        ext_Result::sendResult('admin', false, $GLOBALS["error_msg"]["miscnofunc"]);
    }
    if (!$pwd && !$admin) {
        ext_Result::sendResult('admin', false, $GLOBALS["error_msg"]["accessfunc"]);
    }
    if (isset($GLOBALS['__GET']["action2"])) {
        $action2 = $GLOBALS['__GET']["action2"];
    } elseif (isset($GLOBALS['__POST']["action2"])) {
        $action2 = $GLOBALS['__POST']["action2"];
    } else {
        $action2 = "";
    }
    switch ($action2) {
        case "chpwd":
            changepwd($dir);
            break;
        case "adduser":
            if (!$admin) {
                ext_Result::sendResult('admin', false, $GLOBALS["error_msg"]["accessfunc"]);
            }
            adduser($dir);
            break;
        case "edituser":
            if (!$admin) {
                ext_Result::sendResult('admin', false, $GLOBALS["error_msg"]["accessfunc"]);
            }
            edituser($dir);
            break;
        case "rmuser":
            if (!$admin) {
                ext_Result::sendResult('admin', false, $GLOBALS["error_msg"]["accessfunc"]);
            }
            removeuser($dir);
            break;
        default:
            admin($admin, $dir);
    }
}
Пример #20
0
    function execAction($dir)
    {
        // list directory contents
        global $dir_up, $mosConfig_live_site, $_VERSION;
        $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))) {
            ext_Result::sendResult('list', false, $dir . " : " . $GLOBALS["error_msg"]["accessdir"]);
        }
        // Sorting of items
        if ($GLOBALS["direction"] == "ASC") {
            $_srt = "no";
        } else {
            $_srt = "yes";
        }
        show_header();
        $scriptTag = '
		<script type="text/javascript" src="' . _EXT_URL . '/fetchscript.php?' . '&amp;subdir[]=scripts/editarea/&amp;file[]=edit_area_full_with_plugins.js' . '&amp;subdir[]=scripts/extjs/&amp;file[]=yui-utilities.js' . '&amp;subdir[]=scripts/extjs/&amp;file[]=ext-yui-adapter.js' . '&amp;subdir[]=scripts/extjs/&amp;file[]=ext-all.js&amp;gzip=1"></script>
		<script type="text/javascript" src="' . $GLOBALS['script_name'] . '?option=com_extplorer&amp;action=include_javascript&amp;file=functions.js"></script>		
		<link rel="stylesheet" href="' . _EXT_URL . '/fetchscript.php?subdir[0]=scripts/extjs/css/&file[0]=ext-all.css&amp;subdir[1]=scripts/extjs/css/&file[1]=xtheme-aero.css&amp;gzip=1" />';
        if (defined('EXT_STANDALONE')) {
            $GLOBALS['mainframe']->addcustomheadtag($scriptTag);
        } else {
            echo $scriptTag;
        }
        ?>
		<div id="dirtree"></div>
	<div id="dirtree-panel"></div>
	<div id="item-grid"></div>
	<div id="ext_statusbar" class="ext_statusbar"></div>
	
	<?php 
        // That's the main javascript file to build the Layout & App Logic
        include _EXT_PATH . '/scripts/application.js.php';
    }
Пример #21
0
function ext_ftp_make_local_copy($abs_item, $use_filehandle = false)
{
    if (get_is_dir($abs_item)) {
        $tmp_dir = _EXT_FTPTMP_PATH . '/' . uniqid('ext_tmpdir_') . '/';
        $res = $GLOBALS['FTPCONNECTION']->getRecursive($abs_item, $tmp_dir, true);
        if (PEAR::isError($res)) {
            ext_Result::sendResult('list', false, 'Failed to fetch the directory via FTP: ' . $res->getMessage());
        }
        return $tmp_dir;
    }
    $abs_item = str_replace("\\", '/', $abs_item);
    if ($abs_item[0] != '/') {
        $abs_item = '/' . $abs_item;
    }
    if (!$use_filehandle) {
        $tmp_file = tempnam(_EXT_FTPTMP_PATH, 'ext_ftp_dl_');
        if ($tmp_file == 'false') {
            ext_Result::sendResult('list', false, 'The /ftp_tmp Directory must be writable in order to use this functionality in FTP Mode.');
        }
        $res = $GLOBALS['FTPCONNECTION']->get($abs_item, $tmp_file, true);
        if (PEAR::isError($res)) {
            ext_Result::sendResult('list', false, 'Failed to fetch the file via filehandle from FTP: ' . $res->getMessage());
        }
    } else {
        $tmp_file = tmpfile();
        $res = $GLOBALS['FTPCONNECTION']->fget('/' . $abs_item, $tmp_file, true);
        if (PEAR::isError($res)) {
            ext_Result::sendResult('list', false, 'Failed to fetch the file via FTP: ' . $res->getMessage());
        }
        rewind($tmp_file);
    }
    return $tmp_file;
}
Пример #22
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') . '.');
}
Пример #23
0
    function execAction($dir, $item)
    {
        // change permissions
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (!empty($GLOBALS['__POST']["selitems"])) {
            $cnt = count($GLOBALS['__POST']["selitems"]);
        } else {
            $GLOBALS['__POST']["selitems"][] = $item;
            $cnt = 1;
        }
        if (!empty($GLOBALS['__POST']['do_recurse'])) {
            $do_recurse = true;
        } else {
            $do_recurse = false;
        }
        // Execute
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            $bin = '';
            for ($i = 0; $i < 3; $i++) {
                for ($j = 0; $j < 3; $j++) {
                    $tmp = "r_" . $i . $j;
                    if (!empty($GLOBALS['__POST'][$tmp])) {
                        $bin .= '1';
                    } else {
                        $bin .= '0';
                    }
                }
            }
            if ($bin == '0') {
                // Changing permissions to "none" is not allowed
                ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed'));
            }
            $old_bin = $bin;
            for ($i = 0; $i < $cnt; ++$i) {
                if (ext_isFTPMode()) {
                    $mode = decoct(bindec($bin));
                } else {
                    $mode = bindec($bin);
                }
                $item = $GLOBALS['__POST']["selitems"][$i];
                if (ext_isFTPMode()) {
                    $abs_item = get_item_info($dir, $item);
                } else {
                    $abs_item = get_abs_item($dir, $item);
                }
                if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
                }
                if (!get_show_item($dir, $item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
                }
                if ($do_recurse) {
                    $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode);
                } else {
                    if (get_is_dir($abs_item)) {
                        // when we chmod a directory we must care for the permissions
                        // to prevent that the directory becomes not readable (when the "execute bits" are removed)
                        $bin = substr_replace($bin, '1', 2, 1);
                        // set 1st x bit to 1
                        $bin = substr_replace($bin, '1', 5, 1);
                        // set  2nd x bit to 1
                        $bin = substr_replace($bin, '1', 8, 1);
                        // set 3rd x bit to 1
                        if (ext_isFTPMode()) {
                            $mode = decoct(bindec($bin));
                        } else {
                            $mode = bindec($bin);
                        }
                    }
                    //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd());
                    $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode);
                }
                $bin = $old_bin;
            }
            if ($ok === false || PEAR::isError($ok)) {
                $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"];
                $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : '';
                ext_Result::sendResult('chmod', false, $msg);
            }
            ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange'));
            return;
        }
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]);
        } else {
            $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]);
            $abs_item = utf8_decode($abs_item);
        }
        $mode = parse_file_perms(get_file_perms($abs_item));
        if ($mode === false) {
            ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]);
        }
        $pos = "rwx";
        $text = "";
        for ($i = 0; $i < $cnt; ++$i) {
            $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]);
            if (strlen($s_item) > 50) {
                $s_item = "..." . substr($s_item, -47);
            }
            $text .= $s_item . ($i + 1 < $cnt ? ', ' : '');
        }
        ?>
		{
		"xtype": "form",
		"id": "simpleform",
		"width": "300",
		"labelWidth": 125,
		"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		"dialogtitle": "<?php 
        echo ext_Lang::msg('actperms');
        ?>
",
		"title" : "<?php 
        echo $text;
        ?>
",
		"frame": true,
		"items": [{
			"layout": "column",
			"items": [{
	<?php 
        // print table with current perms & checkboxes to change
        for ($i = 0; $i < 3; ++$i) {
            ?>
			"width":80, 
			"title":"<?php 
            echo ext_Lang::msg(array('miscchmod' => $i), true);
            ?>
",					
			"items": [{
				<?php 
            for ($j = 0; $j < 3; ++$j) {
                ?>
					"xtype": "checkbox",
					"boxLabel":"<?php 
                echo $pos[$j];
                ?>
",
					<?php 
                if ($mode[3 * $i + $j] != "-") {
                    echo '"checked":true,';
                }
                ?>
						"name":"<?php 
                echo "r_" . $i . $j;
                ?>
"
					}	<?php 
                if ($j < 2) {
                    echo ',{';
                }
            }
            ?>
	
				]
			}
		<?php 
            if ($i < 2) {
                echo ',{';
            }
        }
        ?>
,{
			"width":400, 
			"style":"margin-left:10px", 
			"clear":true,
			"html": "&nbsp;"
		}]

	},{
		"xtype": "checkbox",
		"fieldLabel":"<?php 
        echo ext_Lang::msg('recurse_subdirs', true);
        ?>
",
		"name":"do_recurse"
	}],
	"buttons": [{
		"text": "<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( '<?php 
        echo ext_Lang::msg('permissions_processing', true);
        ?>
', true );
			form = Ext.getCmp("simpleform").getForm();
			form.submit({
				//reset: true,
				reset: false,
				success: function(form, action) {
					statusBarMessage( action.result.message, false, true );
					datastore.reload();
					Ext.getCmp("dialog").destroy();
				},
				failure: function(form, action) {
					statusBarMessage( action.result.error, false, false );
					Ext.Msg.alert('<?php 
        echo ext_Lang::err('error', true);
        ?>
', action.result.error);
				},
				scope: form,
				params: {
					"option": "com_extplorer", 
					"action": "chmod", 
					"dir": "<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
", 
					"selitems[]": ['<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
'], 
					confirm: 'true'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); }
	}]
}
	
		<?php 
    }
Пример #24
0
 function execAction($dir)
 {
     if (($GLOBALS["permissions"] & 01) != 01) {
         ext_Result::sendResult('upload', false, $GLOBALS["error_msg"]["accessfunc"]);
     }
     $this->_downloadMethods = array(new CurlDownloader(), new WgetDownloader(), new FopenDownloader(), new FsockopenDownloader());
     //DEBUG ext_Result::sendResult('transfer', false, $dir );
     // Execute
     if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
         $cnt = count($GLOBALS['__POST']['userfile']);
         $err = false;
         foreach ($this->_downloadMethods as $method) {
             if ($method->isSupported()) {
                 $downloader =& $method;
                 break;
             }
         }
         // upload files & check for errors
         for ($i = 0; $i < $cnt; $i++) {
             $errors[$i] = NULL;
             $items[$i] = stripslashes(basename($GLOBALS['__POST']['userfile'][$i]));
             $abs = get_abs_item($dir, $items[$i]);
             if ($items[$i] == "") {
                 continue;
             }
             if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) {
                 $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                 $err = true;
                 continue;
             }
             // Upload
             $ok = $downloader->download($GLOBALS['__POST']['userfile'][$i], $abs);
             if ($ok === true) {
                 $mode = ext_isFTPMode() ? 644 : 0644;
                 @$GLOBALS['ext_File']->chmod($abs, $mode);
             } else {
                 $errors[$i] = $ok;
                 $err = true;
                 continue;
             }
         }
         if ($err) {
             // there were errors
             $err_msg = "";
             for ($i = 0; $i < $cnt; $i++) {
                 if ($errors[$i] == NULL) {
                     continue;
                 }
                 $err_msg .= $items[$i] . " : " . $errors[$i] . "\n";
             }
             ext_Result::sendResult('transfer', false, $err_msg);
         }
         ext_Result::sendResult('transfer', true, ext_Lang::msg('transfer_completed'));
         return;
     }
 }
Пример #25
0
$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;
}
if (!is_dir($abs_dir) && !is_dir($abs_dir . $GLOBALS["separator"])) {
    $GLOBALS['ERROR'] = $abs_dir . " : " . $GLOBALS["error_msg"]["direxist"];
    $dir = $GLOBALS['dir'] = $_SESSION['ext_dir'] = '';
}
//------------------------------------------------------------------------------
Пример #26
0
    function execAction($dir)
    {
        // list directory contents
        global $dir_up, $mosConfig_live_site, $_VERSION;
        $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))) {
            ext_Result::sendResult('list', false, $dir . " : " . $GLOBALS["error_msg"]["accessdir"]);
        }
        // Sorting of items
        if ($GLOBALS["direction"] == "ASC") {
            $_srt = "no";
        } else {
            $_srt = "yes";
        }
        show_header();
        extHTML::loadExtJS();
        ?>
		
	<div id="dirtree-panel"></div>
	<div id="locationbar-panel"></div>
	<div id="item-grid"></div>
	<div id="ext_statusbar" class="ext_statusbar"></div>

	<?php 
        // That's the main javascript file to build the Layout & App Logic
        include _EXT_PATH . '/scripts/application.js.php';
    }
Пример #27
0
function login()
{
    global $auth, $authentication_type;
    if (!is_object($auth)) {
        return false;
    }
    if (!empty($GLOBALS['__POST']['username']) || !empty($_SESSION['credentials_' . $authentication_type])) {
        if (!empty($GLOBALS['__POST']['username'])) {
            $username = $GLOBALS['__POST']['username'];
            $password = $GLOBALS['__POST']['password'];
        } else {
            $username = $_SESSION['credentials_' . $authentication_type]['username'];
            $password = $_SESSION['credentials_' . $authentication_type]['password'];
        }
        $res = $auth->onAuthenticate(array('username' => $username, 'password' => $password));
        if (!PEAR::isError($res) && $res !== false) {
            if (@$GLOBALS['__POST']['action'] == 'login' && ext_isXHR()) {
                session_write_close();
                ext_Result::sendResult('login', true, ext_Lang::msg('actlogin_success'));
            }
            return true;
        } else {
            if ($authentication_type == 'extplorer') {
                // Second attempt to authenticate, since we've switched password hashing algorithm
                // now we fall back to md5 hashing.
                $password = md5((string) $GLOBALS['__POST']['password']);
                $res = $auth->onAuthenticate(array('username' => $username, 'password' => $password));
                if (!PEAR::isError($res) && $res !== false) {
                    if (@$GLOBALS['__POST']['action'] == 'login' && ext_isXHR()) {
                        session_write_close();
                        ext_Result::sendResult('login', true, ext_Lang::msg('actlogin_success'));
                    }
                    return true;
                }
            }
            if (ext_isXHR()) {
                $errmsg = PEAR::isError($res) ? $res->getMessage() : ext_Lang::msg('actlogin_failure');
                ext_Result::sendResult('login', false, $errmsg);
            }
            return false;
        }
    }
    if (ext_isXHR() && $GLOBALS['action'] != 'login') {
        echo '<script type="text/javascript>document.location="' . _EXT_URL . '/index.php";</script>';
        exit;
    }
    session_write_close();
    session_id(get_session_id());
    session_start();
    // Ask for Login
    $GLOBALS['mainframe']->setPageTitle(ext_Lang::msg('actlogin'));
    $GLOBALS['mainframe']->addcustomheadtag('
		<script type="text/javascript" src="scripts/extjs3/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="scripts/extjs3/ext-all.js"></script>
		<script type="text/javascript" src="' . $GLOBALS['script_name'] . '?option=com_extplorer&amp;action=include_javascript&amp;file=functions.js"></script>
		<link rel="stylesheet" href="' . _EXT_URL . '/scripts/extjs3/resources/css/ext-all.css" />
		<link rel="stylesheet" href="scripts/extjs3/resources/css/xtheme-blue.css" />');
    ?>
		<div style="width: 400px;" id="formContainer">
			<div id="ext_logo" style="text-align:center;">
			<a href="http://extplorer.net" target="_blank">
				<img src="<?php 
    echo _EXT_URL;
    ?>
/images/eXtplorer-horizontal2.png" align="middle" alt="eXtplorer Logo" style="border:none;" />
			</a>
			</div>
			<noscript>
				<div style="width:400px;text-align:center;">
					<h1>eXtplorer Login</h1>
					<p style="color:red;">Oh, Javascript is disabled!</p>
					<p>Find out <a target="_blank" href="https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=12654">how you can enable Javascript in your browser.</a>
					</p>
				</div>
			</noscript>
			<div id="adminForm"></div>
			
	</div>
	<script type="text/javascript">
Ext.onReady( function() {
	var simple = new Ext.FormPanel(<?php 
    $auth->onShowLoginForm();
    ?>
);
	
	Ext.get( 'formContainer').center();
	Ext.get( 'formContainer').setTop(100);
	simple.getForm().findField('username').focus();
	Ext.EventManager.onWindowResize( function() { Ext.get( 'formContainer').center();Ext.get( 'formContainer').setTop(100); } );
});
</script><?php 
    define('_LOGIN_REQUIRED', 1);
}
Пример #28
0
function chmod_recursive($item, $mode)
{
    // chmod file / dir
    $ok = true;
    if (@is_link($item) || @is_file($item)) {
        $ok = @chmod($item, $mode);
        if ($ok) {
            ext_Result::add_message($GLOBALS['messages']['permchange'] . ' ' . $new_item);
        } else {
            ext_Result::add_error($GLOBALS['error_msg']['permchange'] . ' ' . $new_item);
        }
    } elseif (@is_dir($item)) {
        if (($handle = @opendir($item)) === false) {
            ext_Result::add_error(basename($item) . ": " . $GLOBALS["error_msg"]["opendir"]);
            return false;
        }
        while (($file = readdir($handle)) !== false) {
            if ($file == ".." || $file == ".") {
                continue;
            }
            $new_item = $item . "/" . $file;
            if (!@file_exists($new_item)) {
                ext_Result::add_error(basename($item) . ": " . $GLOBALS["error_msg"]["readdir"]);
                continue;
            }
            //if(!get_show_item($item, $new_item)) continue;
            if (@is_dir($new_item)) {
                $ok = chmod_recursive($new_item, $mode);
            } else {
                $ok = @chmod($new_item, $mode);
                if ($ok) {
                    ext_Result::add_message($GLOBALS['messages']['permchange'] . ' ' . $new_item);
                } else {
                    ext_Result::add_error($GLOBALS['error_msg']['permchange'] . ' ' . $new_item);
                }
            }
        }
        closedir($handle);
        if (@is_dir($item)) {
            $bin = decbin($mode);
            // when we chmod a directory we must care for the permissions
            // to prevent that the directory becomes not readable (when the "execute bits" are removed)
            $bin = substr_replace($bin, '1', 2, 1);
            // set 1st x bit to 1
            $bin = substr_replace($bin, '1', 5, 1);
            // set  2nd x bit to 1
            $bin = substr_replace($bin, '1', 8, 1);
            // set 3rd x bit to 1
            $mode = bindec($bin);
        }
        $ok = @chmod($item, $mode);
        if ($ok) {
            ext_Result::add_message($GLOBALS['messages']['permchange'] . ' ' . $item);
        } else {
            ext_Result::add_error($GLOBALS['error_msg']['permchange'] . ' ' . $item);
        }
    }
    return $ok;
}
Пример #29
0
    function execAction($dir, $item)
    {
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('diff', false, ext_Lang::err('accessfunc'));
        }
        $fname = get_abs_item($dir, $item);
        if (!get_is_file(utf8_decode($fname))) {
            ext_Result::sendResult('diff', false, $item . ": " . ext_Lang::err('fileexist'));
        }
        if (!get_show_item($dir, $item)) {
            ext_Result::sendResult('diff', false, $item . ": " . ext_Lang::err('accessfile'));
        }
        $cnt = 0;
        if (!empty($GLOBALS['__POST']["selitems"])) {
            $cnt = count($GLOBALS['__POST']["selitems"]);
        }
        $item2 = extGetParam($_POST, 'item2');
        if ($item2 !== null) {
            $fname2 = get_abs_item('', utf8_decode($item2));
        } elseif ($cnt >= 2) {
            $item2 = $GLOBALS['__POST']["selitems"][1];
            $fname2 = get_abs_item($dir, $item2);
        }
        if ($item2 !== null) {
            if (!get_is_file($fname2)) {
                ext_Result::sendResult('diff', false, $item2 . ": " . ext_Lang::err('fileexist'));
            }
            if (!get_show_item('', $item2)) {
                ext_Result::sendResult('diff', false, $item2 . ": " . ext_Lang::err('accessfile'));
            }
        } elseif (empty($cnt) && extGetParam($_POST, 'confirm') == 'true') {
            ext_Result::sendResult('diff', false, 'Please select a second file to diff to');
        }
        if ($item2 || $cnt >= 2) {
            // Show File In TextArea
            $content = $GLOBALS['ext_File']->file_get_contents($fname);
            $content2 = $GLOBALS['ext_File']->file_get_contents($fname2);
            //$content = nl2br(str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", htmlentities($content)));
            //$content2 = nl2br(str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", htmlentities($content2)));
            $diff = $this->inline_diff($content, $content2);
            if (empty($diff)) {
                ext_Result::sendResult('diff', true, 'Both Files are identical');
            }
            $diff = utf8_encode(nl2br($diff));
            echo '{ "xtype": "panel", "dialogtitle": "Diff Result", "html": "' . str_replace(array("\n", "\r"), array('', ''), $diff) . '" }';
            exit;
        }
        ?>
{
	"xtype": "form",
	"id": "simpleform",
	"width": "700",
	"labelWidth": 125,
	"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
	"dialogtitle": "Diff <?php 
        echo htmlentities($item);
        if ($item2) {
            echo ' and ' . htmlentities($item2);
        }
        ?>
",
	"title": "Diff",
	"items": [{
		xtype: "textfield",
		fieldLabel: 'File to Compare',
		name: 'item2',
		value: "<?php 
        echo $dir;
        ?>
/",
		width:175,
		allowBlank:false
		}],
    buttons: [{
		"text": "<?php 
        echo ext_Lang::msg('btndiff', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( 'Please wait...', true );
			form = Ext.getCmp("simpleform").getForm();
			form.submit({
				//reset: true,
				reset: false,
				success: function(form, action) {
					Ext.getCmp("dialog").setContent( action.result.message, true );
				},
				failure: function(form, action) {
					if( !action.result ) return;
					Ext.MessageBox.alert('Error!', action.result.error);
					statusBarMessage( action.result.error, false, true );
				},
				scope: form,
				// add some vars to the request, similar to hidden fields
				params: {
					"option": "com_extplorer", 
					"action": "diff", 
					"dir": "<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
", 
					"item": "<?php 
        echo $item;
        ?>
",
					"selitems[]": ['<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
'], 
					confirm: 'true'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); }
	}]
}
	<?php 
    }
Пример #30
0
    function execAction($dir, $item)
    {
        // change permissions
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (!empty($GLOBALS['__POST']["selitems"])) {
            $cnt = count($GLOBALS['__POST']["selitems"]);
        } else {
            $GLOBALS['__POST']["selitems"][] = $item;
            $cnt = 1;
        }
        if (!empty($GLOBALS['__POST']['do_recurse'])) {
            $do_recurse = true;
        } else {
            $do_recurse = false;
        }
        // Execute
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            $bin = '';
            for ($i = 0; $i < 3; $i++) {
                for ($j = 0; $j < 3; $j++) {
                    $tmp = "r_" . $i . $j;
                    if (!empty($GLOBALS['__POST'][$tmp])) {
                        $bin .= '1';
                    } else {
                        $bin .= '0';
                    }
                }
            }
            if ($bin == '0') {
                // Changing permissions to "none" is not allowed
                ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed'));
            }
            $old_bin = $bin;
            for ($i = 0; $i < $cnt; ++$i) {
                if (ext_isFTPMode()) {
                    $mode = decoct(bindec($bin));
                } else {
                    $mode = bindec($bin);
                }
                $item = $GLOBALS['__POST']["selitems"][$i];
                if (ext_isFTPMode()) {
                    $abs_item = get_item_info($dir, $item);
                } else {
                    $abs_item = get_abs_item($dir, $item);
                }
                if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
                }
                if (!get_show_item($dir, $item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
                }
                if ($do_recurse) {
                    $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode);
                } else {
                    if (get_is_dir($abs_item)) {
                        // when we chmod a directory we must care for the permissions
                        // to prevent that the directory becomes not readable (when the "execute bits" are removed)
                        $bin = substr_replace($bin, '1', 2, 1);
                        // set 1st x bit to 1
                        $bin = substr_replace($bin, '1', 5, 1);
                        // set  2nd x bit to 1
                        $bin = substr_replace($bin, '1', 8, 1);
                        // set 3rd x bit to 1
                        if (ext_isFTPMode()) {
                            $mode = decoct(bindec($bin));
                        } else {
                            $mode = bindec($bin);
                        }
                    }
                    //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd());
                    $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode);
                }
                $bin = $old_bin;
            }
            if ($ok === false || PEAR::isError($ok)) {
                $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"];
                $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : '';
                ext_Result::sendResult('chmod', false, $msg);
            }
            ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange'));
            return;
        }
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]);
        } else {
            $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]);
            $abs_item = utf8_decode($abs_item);
        }
        $mode = parse_file_perms(get_file_perms($abs_item));
        if ($mode === false) {
            ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]);
        }
        $pos = "rwx";
        $text = "";
        for ($i = 0; $i < $cnt; ++$i) {
            $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]);
            if (strlen($s_item) > 50) {
                $s_item = "..." . substr($s_item, -47);
            }
            $text .= $s_item . ($i + 1 < $cnt ? ', ' : '');
        }
        ?>
	<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 ext_Lang::msg('actperms');
        ?>
</h3>
	        <?php 
        echo $text;
        ?>
	        <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 form = new Ext.form.Form({
	    labelWidth: 125, // label settings here cascade unless overridden
	    url:'<?php 
        echo basename($GLOBALS['script_name']);
        ?>
'
	});
	
	<?php 
        // print table with current perms & checkboxes to change
        for ($i = 0; $i < 3; ++$i) {
            ?>
			form.column(
		        {width:70, style:'margin-left:10px', clear:true}
		    );
			form.fieldset(
			        {legend:'<?php 
            echo ext_Lang::msg(array('miscchmod' => $i), true);
            ?>
', hideLabels:true},
			        <?php 
            for ($j = 0; $j < 3; ++$j) {
                ?>
				        new Ext.form.Checkbox({
				            boxLabel:'<?php 
                echo $pos[$j];
                ?>
',
				            <?php 
                if ($mode[3 * $i + $j] != "-") {
                    echo 'checked:true,';
                }
                ?>
				            name:'<?php 
                echo "r_" . $i . $j;
                ?>
'
				        })     <?php 
                if ($j < 2) {
                    echo ',';
                }
            }
            ?>
   );
	    	form.end();
	    <?php 
        }
        ?>
	form.column(
	        {width:400, style:'margin-left:10px', clear:true}
	    );
	form.add(new Ext.form.Checkbox({
		fieldLabel:'<?php 
        echo ext_Lang::msg('recurse_subdirs', true);
        ?>
',
		name:'do_recurse'
	}));
	form.end();
	
	form.addButton('<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
', function() {
		statusBarMessage( '<?php 
        echo ext_Lang::msg('permissions_processing', true);
        ?>
', true );
	    form.submit({
	        //reset: true,
	        reset: false,
	        success: function(form, action) {
	        	statusBarMessage( action.result.message, false, true );
	        	datastore.reload();
	    		dialog.hide();
	        	dialog.destroy();
	        },
	        failure: function(form, action) {
	        	statusBarMessage( action.result.error, false, false );
	        	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: 'chmod', 
	        		dir: '<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
', 
	        		'selitems[]': ['<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
'], 
	        		confirm: 'true'}
	    });
	});
	form.addButton('<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
', function() { dialog.hide();dialog.destroy(); } );
	form.render('adminForm');
	</script>
	
		<?php 
    }