Example #1
0
/**
 * @version $Id: header.php 187 2011-01-18 15:25:24Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007-2009
 * @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
 * @author The	The QuiX project (http://quixplorer.sourceforge.net)
 * 
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 * 
 * This is the file, which prints the header row with the Logo
 */
function show_header($dirlinks = '')
{
    $url = str_replace(array('&dir=', '&action=', '&file_mode='), array('&a=', '&b=', '&c='), $_SERVER['REQUEST_URI']);
    $url_appendix = strpos($url, '?') === false ? '?' : '&';
    echo "<link rel=\"stylesheet\" href=\"" . _EXT_URL . "/style/style.css\" type=\"text/css\" />\n";
    echo "<div id=\"ext_header\">\n";
    echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"5\">\n";
    $mode = extGetParam($_SESSION, 'file_mode', $GLOBALS['ext_conf']['authentication_method_default']);
    $logoutlink = ' <a href="' . $GLOBALS['script_name'] . '?option=com_extplorer&amp;action=logout" title="' . $GLOBALS['messages']['logoutlink'] . '">[' . $GLOBALS['messages']['logoutlink'] . ']</a>';
    $alternate_modes = array();
    foreach ($GLOBALS['ext_conf']['authentication_methods_allowed'] as $method) {
        if ($method != $mode) {
            $onclick = '';
            if (empty($_SESSION['credentials_' . $method])) {
                $onclick = "onclick=\"openActionDialog('switch_file_mode', '" . $method . "_authentication');return false;\"";
            }
            $alternate_modes[] = "<a {$onclick} href=\"{$url}" . $url_appendix . "file_mode={$method}\">{$method}</a>";
        }
    }
    echo '<tr><td width="20%">';
    if (is_object($GLOBALS['_VERSION']) || class_exists('jversion')) {
        echo '<a href="' . basename($_SERVER['SCRIPT_NAME']) . '">Back to ' . (!empty($GLOBALS['_VERSION']->PRODUCT) ? @$GLOBALS['_VERSION']->PRODUCT : 'Joomla!') . '</a>';
    } else {
        echo ext_selectList('language_selector', $GLOBALS['language'], get_languages(), 1, '', 'onchange="document.location.href=\'' . $GLOBALS['script_name'] . '?lang=\' + this.options[this.selectedIndex].value;"');
    }
    // Logo
    echo "</td><td style=\"color:black;\" width=\"10%\">";
    //echo "<div style=\"margin-left:10px;float:right;\" width=\"305\" >";
    echo "<a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\" title=\"eXtplorer Project\">\r\n\t\t<img src=\"" . _EXT_URL . "/images/eXtplorer_logo.png\" alt=\"eXtplorer Logo\" border=\"0\" /></a>\r\n\t\t</td>";
    //echo "</div>";
    echo "<td style=\"padding-left: 15px; color:black;\" id=\"bookmark_container\" width=\"35%\"></td>\n";
    echo "<td width=\"25%\" style=\"padding-left: 15px; color:black;\">" . sprintf($GLOBALS['messages']['switch_file_mode'], $mode . $logoutlink, implode(', ', $alternate_modes)) . "\r\n\t</td>\n";
    echo '</tr></table>';
    echo '</div>';
}
/**
 * @version $Id: header.php 116 2009-01-15 20:39:58Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007
 * @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
 * 
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 * 
 * This is the file, which prints the header row with the Logo
 */
function show_header($dirlinks = '')
{
    $url = str_replace('&dir=', '&ignore=', $_SERVER['REQUEST_URI']);
    $url_appendix = strpos($url, '?') === false ? '?' : '&amp;';
    echo "<link rel=\"stylesheet\" href=\"" . _EXT_URL . "/style/style.css\" type=\"text/css\" />\n";
    echo "<div id=\"ext_header\">\n";
    echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"5\">\n";
    $mode = extGetParam($_SESSION, 'file_mode', 'file');
    $logoutlink = $mode == 'ftp' ? ' <a href="' . $GLOBALS['script_name'] . '?option=com_extplorer&amp;action=ftp_logout" title="' . $GLOBALS['messages']['logoutlink'] . '">[' . $GLOBALS['messages']['logoutlink'] . ']</a>' : '';
    $alternate_mode = $mode == 'file' ? 'ftp' : 'file';
    echo '<tr><td width="20%">';
    if (is_object($GLOBALS['_VERSION']) || class_exists('jversion')) {
        echo "<a href=\"index2.php\">Back to " . (!empty($GLOBALS['_VERSION']->PRODUCT) ? @$GLOBALS['_VERSION']->PRODUCT : 'Joomla!') . '</a>';
    } else {
        echo ext_selectList('language_selector', $GLOBALS['language'], get_languages(), 1, '', 'onchange="document.location.href=\'' . $GLOBALS['script_name'] . '?lang=\' + this.options[this.selectedIndex].value;"');
    }
    // Logo
    echo "</td><td style=\"color:black;\" width=\"10%\">";
    //echo "<div style=\"margin-left:10px;float:right;\" width=\"305\" >";
    echo "<a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\" title=\"eXtplorer Project\">\r\n\t\t<img src=\"" . _EXT_URL . "/images/eXtplorer.gif\" alt=\"eXtplorer Logo\" border=\"0\" /></a>\r\n\t\t</td>";
    //echo "</div>";
    echo "<td style=\"padding-left: 15px; color:black;\" id=\"bookmark_container\" width=\"35%\"></td>\n";
    echo "<td width=\"25%\" style=\"padding-left: 15px; color:black;\">" . sprintf($GLOBALS['messages']['switch_file_mode'], $mode . $logoutlink, "<a id=\"switch_file_mode\" href=\"{$url}" . $url_appendix . "file_mode={$alternate_mode}\">{$alternate_mode}</a>") . "\r\n\t</td>\n";
    echo '</tr></table>';
    echo '</div>';
}
Example #3
0
function system_info()
{
    $version = $GLOBALS['ext_version'];
    //$tab = extGetParam( $_REQUEST, 'tab', 'tab1' );
    $width = 400;
    // width of 100%
    switch (extGetParam($GLOBALS['__POST'], 'action2', 'panel')) {
        case 'systeminfo':
            ?>
		<div class="body-wrap">
		  <table class="member-table">
			<tr>
				<td valign="top" width="250" style="font-weight:bold;">
				Logged in as:
				</td>
				<td><?php 
            echo $_SESSION['credentials_extplorer']['username'];
            ?>
</td>
			<tr>
				<td valign="top" width="250" style="font-weight:bold;">
					<?php 
            echo ext_lang::msg('sibuilton');
            ?>
:
				</td>
				<td>
				<?php 
            echo php_uname();
            ?>
				</td>
			</tr>
			<tr>
				<td valign="top" style="font-weight:bold;">
					<?php 
            echo ext_lang::msg('siphpversion');
            ?>
:
				</td>
				<td>
				<?php 
            echo phpversion();
            ?>
				&nbsp;
				<?php 
            echo phpversion() >= '4.3' ? '' : $GLOBALS['messages']['siphpupdate'];
            ?>
				</td>
			</tr>
			<tr>
				<td style="font-weight:bold;">
					<?php 
            echo ext_lang::msg('siwebserver');
            ?>
:
				</td>
				<td>
				<?php 
            echo get_server_software();
            ?>
				</td>
			</tr>
			<tr>
				<td style="font-weight:bold;">
					<?php 
            echo ext_lang::msg('siwebsphpif');
            ?>
:
				</td>
				<td>
				<?php 
            echo php_sapi_name();
            ?>
				</td>
			</tr>
			<tr>
				<td style="font-weight:bold;">
					<?php 
            echo ext_lang::msg('simamboversion');
            ?>
:
				</td>
				<td>
				<?php 
            echo $version;
            ?>
				</td>
			</tr>
			<tr>
				<td style="font-weight:bold;">
					<?php 
            echo ext_lang::msg('siuseragent');
            ?>
:
				</td>
				<td>
				<?php 
            echo phpversion() <= "4.2.1" ? getenv("HTTP_USER_AGENT") : $_SERVER['HTTP_USER_AGENT'];
            ?>
				</td>
			</tr>
			<tr>
				<td valign="top" style="font-weight:bold;">
					<?php 
            echo ext_lang::msg('sirelevantsettings');
            ?>
:
				</td>
				<td>
					<table cellspacing="1" cellpadding="1" border="0">
					<tr>
						<td valign="top">
							<?php 
            echo ext_lang::msg('sisafemode');
            ?>
:
						</td>
						<td>
						<?php 
            echo get_php_setting('safe_mode', 0);
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sibasedir');
            ?>
:
						</td>
						<td>
						<?php 
            echo ($ob = ini_get('open_basedir')) ? $ob : 'none';
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sidisplayerrors');
            ?>
:
						</td>
						<td>
						<?php 
            echo get_php_setting('display_errors', 0);
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sishortopentags');
            ?>
:
						</td>
						<td>
						<?php 
            echo get_php_setting('short_open_tag', 0);
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sifileuploads');
            ?>
:
						</td>
						<td>
						<?php 
            echo get_php_setting('file_uploads');
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('simagicquotes');
            ?>
:
						</td>
						<td>
						<?php 
            echo get_php_setting('magic_quotes_gpc');
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('siregglobals');
            ?>
:
						</td>
						<td>
						<?php 
            echo get_php_setting('register_globals', 0);
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sioutputbuf');
            ?>
:
						</td>
						<td>
						<?php 
            echo get_php_setting('output_buffering', 0);
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sisesssavepath');
            ?>
:
						</td>
						<td>
						<?php 
            echo ($sp = ini_get('session.save_path')) ? $sp : 'none';
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sisessautostart');
            ?>
:
						</td>
						<td>
						<?php 
            echo intval(ini_get('session.auto_start'));
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sixmlenabled');
            ?>
:
						</td>
						<td>
							<?php 
            echo extension_loaded('xml') ? '<font style="color: green;">' . $GLOBALS['messages']['miscyesno'][0] . '</font>' : '<font style="color: red;">' . $GLOBALS['messages']['miscyesno'][1] . '</font>';
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sizlibenabled');
            ?>
:
						</td>
						<td>
						<?php 
            echo extension_loaded('zlib') ? '<font style="color: green;">' . $GLOBALS['messages']['miscyesno'][0] . '</font>' : '<font style="color: red;">' . $GLOBALS['messages']['miscyesno'][1] . '</font>';
            ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php 
            echo ext_lang::msg('sidisabledfuncs');
            ?>
:
						</td>
						<td>
						<?php 
            echo ($df = ini_get('disable_functions')) ? $df : 'none';
            ?>
						</td>
					</tr>
					</table>
				</td>
			</tr>
			</table>
		</div>
			<?php 
            break;
        case 'phpinfo':
            ob_start();
            phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
            $phpinfo = ob_get_contents();
            ob_end_clean();
            preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output);
            $output = preg_replace('#<table#', '<table class="member-table" align="center"', $output[1][0]);
            $output = '<div class="body-wrap">' . $output . '</div>';
            $output = preg_replace('#(\\w),(\\w)#', '\\1, \\2', $output);
            $output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
            $output = preg_replace('#<hr />#', '', $output);
            echo $output;
            break;
        case 'about':
            show_about();
            break;
        default:
            ?>
			{
				"xtype": "tabpanel",
				
				"height": 350,
				"activeTab": 0,
				"items": [{
					"title": "<?php 
            echo ext_Lang::msg('aboutlink');
            ?>
",
					"autoScroll": true,
					"autoLoad": { 
						"url": "<?php 
            echo $GLOBALS['script_name'];
            ?>
",
						"params": {
							"option": "com_extplorer",
							"action": "get_about",
							"action2": "about"
						}
					}
				},{
					"title": "<?php 
            echo ext_Lang::msg('sisysteminfo');
            ?>
",
					"autoScroll": true,
					"autoLoad": { 
						"url": "<?php 
            echo $GLOBALS['script_name'];
            ?>
",
						"params": {
							"option": "com_extplorer",
							"action": "get_about",
							"action2": "systeminfo"
						}
					}
				},{
					"title": "<?php 
            echo ext_Lang::msg('siphpinfo');
            ?>
",
					"autoScroll": true,
					"autoLoad": { 
						"url": "<?php 
            echo $GLOBALS['script_name'];
            ?>
",
						"params": {
							"option": "com_extplorer",
							"action": "get_about",
							"action2": "phpinfo"
						}
					}
				}]
			}
			<?php 
    }
}
Example #4
0
/**
 * Adds a new bookmark to the bookmark ini file
 *
 * @param string $dir
 */
function modify_bookmark($task, $dir)
{
    global $my, $user, $mainframe;
    $alias = substr(extGetParam($_REQUEST, 'alias'), 0, 150);
    $bookmarks = read_bookmarks();
    $bookmarkfile = _EXT_PATH . '/config/bookmarks_' . $GLOBALS['file_mode'] . '_';
    if (empty($my->id)) {
        if (class_exists('jfactory')) {
            $user = JFactory::getUser();
            $bookmarkfile .= $user->get('id') . '.php';
        } else {
            $bookmarkfile .= $mainframe->getUserName() . '.php';
        }
    } else {
        $bookmarkfile .= $my->id . '.php';
    }
    while (@ob_end_clean()) {
    }
    header("Status: 200 OK");
    switch ($task) {
        case 'add':
            if (in_array($dir, $bookmarks)) {
                echo ext_alertBox($GLOBALS['messages']['already_bookmarked']);
                exit;
            }
            //$alias = preg_replace('~[^\w-.\/\\\]~','', $alias ); // Make the alias ini-safe by removing all non-word characters
            $alias = strip_invalid_key_char($alias, "_");
            $bookmarks[$alias] = $dir;
            //we deal with the flippped array here
            $msg = ext_successBox($GLOBALS['messages']['bookmark_was_added']);
            break;
        case 'remove':
            if (!in_array($dir, $bookmarks)) {
                echo ext_alertBox($GLOBALS['messages']['not_a_bookmark']);
                exit;
            }
            $bookmarks = array_flip($bookmarks);
            unset($bookmarks[$dir]);
            $bookmarks = array_flip($bookmarks);
            $msg = ext_successBox($GLOBALS['messages']['bookmark_was_removed']);
    }
    $inifile = "; <?php if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' ); ?>\n";
    $inifile .= $GLOBALS['messages']['homelink'] . "=\n";
    foreach ($bookmarks as $alias => $directory) {
        //changed by pokemon
        if (empty($directory) || empty($alias)) {
            continue;
        }
        if ($directory[0] == $GLOBALS['separator']) {
            $directory = substr($directory, 1);
        }
        $inifile .= "{$alias}={$directory}\n";
    }
    if (!is_writable($bookmarkfile)) {
        echo ext_alertBox(sprintf($GLOBALS['messages']['bookmarkfile_not_writable'], $task, $bookmarkfile));
        exit;
    }
    file_put_contents($bookmarkfile, $inifile);
    echo $msg;
    echo list_bookmarks($dir);
    exit;
}
 /**
  * Gets the value of a user state variable
  * @param string The name of the variable
  */
 function getUserState($var_name)
 {
     if (is_array($this->_userstate)) {
         return extGetParam($this->_userstate, $var_name, null);
     } else {
         return null;
     }
 }
Example #6
0
     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;
     }
     send_dircontents($requestedDir, extGetParam($_REQUEST, 'sendWhat', 'files'));
     break;
 case 'get_dir_selects':
     echo get_dir_selects($dir);
     break;
 case 'chdir_event':
     require_once _EXT_PATH . '/include/bookmarks.php';
     $response = array('bookmarks' => list_bookmarks($dir));
     $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON';
     $json = new $classname();
     echo $json->encode($response);
     break;
 case 'get_image':
     require_once _EXT_PATH . "/include/view.php";
     ext_View::sendImage($dir, $item);
 case 'ftp_authentication':
Example #7
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 
    }
Example #8
0
/**
 * File/Directory Copy & Move Functions
 */
function copy_move_items($dir)
{
    // copy/move file/dir
    $action = extGetParam($_REQUEST, 'action');
    if (($GLOBALS["permissions"] & 01) != 01) {
        ext_Result::sendResult($action, false, $GLOBALS["error_msg"]["accessfunc"]);
    }
    // Vars
    $first = extGetParam($GLOBALS['__POST'], 'first');
    if ($first == "y") {
        $new_dir = $dir;
    } else {
        $new_dir = stripslashes($GLOBALS['__POST']["new_dir"]);
    }
    if ($new_dir == ".") {
        $new_dir = "";
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    // DO COPY/MOVE
    // ALL OK?
    if (!@$GLOBALS['ext_File']->file_exists(get_abs_dir($new_dir))) {
        ext_Result::sendResult($action, false, get_abs_dir($new_dir) . ": " . $GLOBALS["error_msg"]["targetexist"]);
    }
    if (!get_show_item($new_dir, "")) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["accesstarget"]);
    }
    if (!down_home(get_abs_dir($new_dir))) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["targetabovehome"]);
    }
    // copy / move files
    $err = false;
    for ($i = 0; $i < $cnt; ++$i) {
        $tmp = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        $new = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $tmp);
            $abs_new_item = get_item_info('/' . $new_dir, $new);
        } else {
            $abs_item = get_abs_item($dir, $tmp);
            $abs_new_item = get_abs_item($new_dir, $new);
        }
        $items[$i] = $tmp;
        // Check
        if ($new == "") {
            $error[$i] = $GLOBALS["error_msg"]["miscnoname"];
            $err = true;
            continue;
        }
        if (!@$GLOBALS['ext_File']->file_exists($abs_item)) {
            $error[$i] = $GLOBALS["error_msg"]["itemexist"];
            $err = true;
            continue;
        }
        if (!get_show_item($dir, $tmp)) {
            $error[$i] = $GLOBALS["error_msg"]["accessitem"];
            $err = true;
            continue;
        }
        if (@$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            $error[$i] = $GLOBALS["error_msg"]["targetdoesexist"];
            $err = true;
            continue;
        }
        // Copy / Move
        if ($action == "copy") {
            if (@is_link($abs_item) || get_is_file($abs_item)) {
                // check file-exists to avoid error with 0-size files (PHP 4.3.0)
                if (ext_isFTPMode()) {
                    $abs_item = '/' . $dir . '/' . $abs_item['name'];
                }
                $ok = @$GLOBALS['ext_File']->copy($abs_item, $abs_new_item);
                //||@file_exists($abs_new_item);
            } elseif (@get_is_dir($abs_item)) {
                $copy_dir = ext_isFTPMode() ? '/' . $dir . '/' . $abs_item['name'] . '/' : $abs_item;
                if (ext_isFTPMode()) {
                    $abs_new_item .= '/';
                }
                $ok = $GLOBALS['ext_File']->copy_dir($copy_dir, $abs_new_item);
            }
        } else {
            $ok = $GLOBALS['ext_File']->rename($abs_item, $abs_new_item);
        }
        if ($ok === false || PEAR::isError($ok)) {
            $error[$i] = $action == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            if (PEAR::isError($ok)) {
                $error[$i] .= ' [' . $ok->getMessage() . ']';
            }
            $err = true;
            continue;
        }
        $error[$i] = NULL;
    }
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "\n";
        }
        ext_Result::sendResult($action, false, $err_msg);
    }
    ext_Result::sendResult($action, true, 'The File(s)/Directory(s) were successfully ' . ($action == 'copy' ? 'copied' : 'moved') . '.');
}
Example #9
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') {
            $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;
        }
        ?>
		<div>
	    <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;">Create New File/Directory</h3>
	        <div id="adminForm">
	
	        </div>
	    </div></div></div>
	    <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
	</div>
	<script type="text/javascript">
	var mktypes = new Ext.data.SimpleStore({
	    fields: ['mktype', 'type'],
	    data :  [
	        ['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 
        }
        ?>
	        ]
	});
	var simple = new Ext.form.Form({
	    labelWidth: 125, // label settings here cascade unless overridden
	    url:'<?php 
        echo basename($GLOBALS['script_name']);
        ?>
'
	});
	simple.add(
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
        echo ext_Lang::msg('nameheader', true);
        ?>
',
	        name: 'mkname',
	        width:175,
	        allowBlank:false
	    }),
		new Ext.form.ComboBox({
			fieldLabel: 'Type',
		    store: mktypes,
		    displayField:'type',
		    valueField: 'mktype',
		    value: 'file',
		    hiddenName: 'mktype',
		    disableKeyFilter: true,
		    editable: false,
		    triggerAction: 'all',
		    mode: 'local',
		    allowBlank: false,
		    selectOnFocus:true
		}),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
        echo ext_Lang::msg('symlink_target', true);
        ?>
',
	        name: 'symlink_target',
	        width:175,
	        allowBlank:true
	    })
	);
	
	simple.addButton('<?php 
        echo ext_Lang::msg('btncreate', true);
        ?>
', function() {
		statusBarMessage( 'Please wait...', true );
	    simple.submit({
	        //reset: true,
	        reset: false,
	        success: function(form, action) {	
	        	statusBarMessage( action.result.message, false, true );
	        	try{ 
	        		dirTree.getSelectionModel().getSelectedNode().reload(); 
	        	} catch(e) {}
				datastore.reload();
				dialog.destroy();
	        },
	        failure: function(form, action) {
	        	if( !action.result ) return;
				Ext.MessageBox.alert('Error!', action.result.error);
				statusBarMessage( action.result.error, false, true );
	        },
	        scope: simple,
	        // add some vars to the request, similar to hidden fields
	        params: {option: 'com_extplorer', 
	        		action: 'mkitem', 
	        		dir: datastore.directory, 
	        		confirm: 'true'}
	    })
	});
	simple.addButton('<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
', function() { dialog.destroy(); } );
	simple.render('adminForm');
	simple.findField( 'mkname').focus();
	</script>
	<?php 
    }
Example #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;
            }
            $debug = 'Starting from: ' . $startfrom . "\n";
            $debug .= 'Files to process: ' . $cnt_filelist . "\n";
            $debug .= implode("\n", $v_list);
            //file_put_contents( 'log.txt', $debug, FILE_APPEND );
            // Do some setup stuff
            ini_set('memory_limit', '128M');
            @set_time_limit(0);
            error_reporting(E_ERROR | E_PARSE);
            $result = extArchive::create($archive_name, $v_list, $GLOBALS['__POST']["type"], '', $remove_path);
            if (PEAR::isError($result)) {
                ext_Result::sendResult('archive', false, $name . ': ' . ext_Lang::err('archive_creation_failed') . ' (' . $result->getMessage() . $archive_name . ')');
            }
            $json = new ext_Json();
            if ($cnt_filelist > $startfrom + $files_per_step) {
                $response = array('startfrom' => $startfrom + $files_per_step, 'totalitems' => $cnt_filelist, 'success' => true, 'action' => 'archive', 'message' => sprintf(ext_Lang::msg('processed_x_files'), $startfrom + $files_per_step, $cnt_filelist));
            } else {
                @unlink($dir_contents_cache_file);
                if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') {
                    chmod($archive_name, 0644);
                }
                $response = array('action' => 'archive', 'success' => true, 'message' => ext_Lang::msg('archive_created'), 'newlocation' => make_link('download', $dir, basename($archive_name)));
            }
            echo $json->encode($response);
            ext_exit();
        }
        ?>
<div style="width:auto;">
    <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
    <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">

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

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

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

	form.render('adminForm');

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

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

	</script>

	<?php 
    }
Example #11
0
if (!is_object($database)) {
    $database = JFactory::getDBO();
}
$res = new StdClass();
$database->setQuery('SELECT id, name FROM `#__menu` WHERE link LIKE \'%option=com_extplorer%\' ORDER BY `id` LIMIT 1');
$database->loadObject($res);
if (is_object($res) && !empty($res->name)) {
    $name = $res->name;
} else {
    $name = '';
}
if ($name || $dir) {
    $mainframe->setPageTitle($name . ' - ' . $dir);
}
$action = extGetParam($_REQUEST, 'action', 'list');
$item = extGetParam($_REQUEST, 'item', '');
// Here we allow *download* and *directory listing*, nothing more, nothing less
switch ($action) {
    case 'download':
        require _EXT_PATH . "/include/download.php";
        ext_Download::execAction($dir, $item);
        exit;
    case 'list':
    default:
        list_dir($dir);
        break;
}
// A small nice footer. Remove if you don't want to give credit to the developer.
echo '<br style="clear:both;"/>
	<small>
	<a class="title" href="' . $GLOBALS['ext_home'] . '" target="_blank">powered by eXtplorer</a>
Example #12
0
function ext_copy_move_dialog($dir = '')
{
    $action = extGetParam($_REQUEST, 'action');
    ?>
{
	"xtype": "form",
	"id": "simpleform",
	"labelWidth": 125,
	"width": "340",
	"url":"<?php 
    echo basename($GLOBALS['script_name']);
    ?>
",
	"dialogtitle": "<?php 
    echo 'Copy/Move';
    ?>
",
	"frame": true,
	"items": [{
		"xtype": "textfield",
        "fieldLabel": "Destination",
        "name": "new_dir",
        "value": "<?php 
    echo $dir;
    ?>
/",
        "width":175,
        "allowBlank":false
    }],
    "buttons": [{
    	text: '<?php 
    echo ext_Lang::msg('btncreate', true);
    ?>
', 
    	handler: function() {
    		form =  Ext.getCmp('simpleform').getForm();
			statusBarMessage( 'Please wait...', true );
		    var requestParams = getRequestParams();
		    requestParams.confirm = 'true';
		    requestParams.action  = '<?php 
    echo $action;
    ?>
';
		    form.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.MessageBox.alert('Error!', action.result.error);
					statusBarMessage( action.result.error, false, false );
		        },
		        scope: form,
		        // add some vars to the request, similar to hidden fields
		        params: requestParams
		    });
		  }
	},{
		text: '<?php 
    echo ext_Lang::msg('btncancel', true);
    ?>
', 
		handler: function() { Ext.getCmp("dialog").destroy(); }
	}
	]
}
	<?php 
}
Example #13
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 {
            ?>
	{
		"xtype": "form",
		"id": "simpleform",
		"labelWidth": 125,
		"url":"<?php 
            echo basename($GLOBALS['script_name']);
            ?>
",
		"dialogtitle": "<?php 
            echo $GLOBALS["messages"]["ftp_header"];
            ?>
",
		"title": "<?php 
            echo $GLOBALS["messages"]["ftp_login_lbl"];
            ?>
",
		"frame": true,
		"keys": {
		    "key": Ext.EventObject.ENTER,
		    "fn" : function(){
				if (Ext.getCmp("simpleform").getForm().isValid()) {
					statusBarMessage( '<?php 
            echo ext_Lang::msg('ftp_login_check', true);
            ?>
', true );
					Ext.getCmp("simpleform").getForm().submit({
						"reset": false,
						"success": function(form, action) { location.reload() },
						"failure": function(form, action) {
							if( !action.result ) return;
							Ext.Msg.alert('<?php 
            echo ext_Lang::err('error', true);
            ?>
', action.result.error);
							statusBarMessage( action.result.error, false, false );
						},
						"scope": Ext.getCmp("simpleform").getForm(),
						"params": {
							"option": "com_extplorer", 
							"action": "ftp_authentication"
						}
					});
    	        } else {
        	        return false;
            	}
            }
		},
		"items": [{
			"xtype": "textfield",
			"fieldLabel": "<?php 
            echo ext_Lang::msg('ftp_login_name', true);
            ?>
",
			"name": "ftp_login_name",
			"width":175,
			"allowBlank":false
		},{
			"xtype": "textfield",
			"fieldLabel": "<?php 
            echo ext_Lang::msg('ftp_login_pass', true);
            ?>
",
			"name": "ftp_login_pass",
			"inputType": "password",
			"width":175,
			"allowBlank":false
		},{
			"xtype": "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
		}],
		"buttons": [{
			"text": "<?php 
            echo ext_Lang::msg('btnlogin', true);
            ?>
", 
			"type": "submit",
			"handler": function() {
				statusBarMessage( '<?php 
            echo ext_Lang::msg('ftp_login_check', true);
            ?>
', true );
				Ext.getCmp("simpleform").getForm().submit({
					"reset": false,
					"success": function(form, action) { location.reload() },
					"failure": function(form, action) {
						if( !action.result ) return;
						Ext.Msg.alert('<?php 
            echo ext_Lang::err('error', true);
            ?>
', action.result.error);
						statusBarMessage( action.result.error, false, false );
					},
					"scope": Ext.getCmp("simpleform").getForm(),
					"params": {
						"option": "com_extplorer", 
						"action": "ftp_authentication"
					}
				});
			}
		},{
			"text": "<?php 
            echo ext_Lang::msg('btncancel', true);
            ?>
", 
			"handler": function() { Ext.getCmp("dialog").destroy(); }
		}]
	}
		<?php 
        }
    }
Example #14
0
function ext_isXHR()
{
    return strtolower(extGetParam($_SERVER, 'HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest' || strtolower(extGetParam($_POST, 'requestType')) == 'xmlhttprequest';
}
Example #15
0
    function onShowLoginForm()
    {
        ?>
	{
		xtype: "form",
		<?php 
        if (!ext_isXHR()) {
            ?>
renderTo: "adminForm", <?php 
        }
        ?>
		id: "simpleform",
		labelWidth: 125,
		url:"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		dialogtitle: "<?php 
        echo ext_Lang::msg('ftp_header');
        ?>
",
		title: "<?php 
        echo ext_Lang::msg('ftp_login_lbl');
        ?>
",
		frame: true,
		keys: {
		    key: Ext.EventObject.ENTER,
		    fn : function(){
				if (Ext.getCmp("simpleform").getForm().isValid()) {
					Ext.get( 'statusBar').update( '<?php 
        echo ext_Lang::msg('ftp_login_check', true);
        ?>
' );
					Ext.getCmp("simpleform").getForm().submit({
						reset: false,
						success: function(form, action) { location.reload() },
						failure: function(form, action) {
							if( !action.result ) return;
							Ext.Msg.alert('<?php 
        echo ext_Lang::err('error', true);
        ?>
', action.result.error);
							Ext.get( 'statusBar').update( action.result.error );
						},
						scope: Ext.getCmp("simpleform").getForm(),
						params: {
							option: "com_extplorer", 
							action: "login",
							type: "ftp",
							file_mode: "ftp"
						}
					});
    	        } else {
        	        return false;
            	}
            }
		},
		items: [{
			xtype: "textfield",
			fieldLabel: "<?php 
        echo ext_Lang::msg('ftp_login_name', true);
        ?>
",
			name: "username",
			width:175,
			allowBlank:false
		},{
			xtype: "textfield",
			fieldLabel: "<?php 
        echo ext_Lang::msg('ftp_login_pass', true);
        ?>
",
			name: "password",
			inputType: "password",
			width:175,
			allowBlank:false
		},{
			xtype: "combo",
			fieldLabel: "<?php 
        echo ext_Lang::msg('ftp_hostname_port', true);
        ?>
",
			hiddenName: "ftp_host",
			triggerAction: "all",
			value: "<?php 
        echo extGetParam($_SESSION, 'ftp_host');
        ?>
",
			store: ["<?php 
        echo implode('","', $GLOBALS['ext_conf']['remote_hosts_allowed']);
        ?>
"],
			width:175,
			editable: false,
			forceSelection: true,
			allowBlank:false
		},
		{
			xtype: "displayfield",
			id: "statusBar"
		}],
		buttons: [{
			text: "<?php 
        echo ext_Lang::msg('btnlogin', true);
        ?>
", 
			type: "submit",
			handler: function() {
				Ext.get( 'statusBar').update( '<?php 
        echo ext_Lang::msg('ftp_login_check', true);
        ?>
' );
				Ext.getCmp("simpleform").getForm().submit({
					reset: false,
					success: function(form, action) { location.reload() },
					failure: function(form, action) {
						if( !action.result ) return;
						Ext.Msg.alert('<?php 
        echo ext_Lang::err('error', true);
        ?>
', action.result.error);
						Ext.get( 'statusBar').update( action.result.error );
					},
					scope: Ext.getCmp("simpleform").getForm(),
					params: {
						option: "com_extplorer", 
						action: "login",
						type: "ftp",
						file_mode: "ftp"
					}
				});
			}
		},
		<?php 
        if (!ext_isXHR()) {
            ?>
		{
			text: '<?php 
            echo ext_Lang::msg('btnreset', true);
            ?>
', 
			handler: function() { simple.getForm().reset(); } 
		}
		<?php 
        } else {
            ?>
		{
			text: "<?php 
            echo ext_Lang::msg('btncancel', true);
            ?>
", 
			handler: function() { Ext.getCmp("dialog").destroy(); }
		}
		<?php 
        }
        ?>
]
	}
		<?php 
    }
Example #16
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 
    }
Example #17
0
 static function sendResult($action, $success, $msg, $extra = array())
 {
     // show error-message
     if (ext_isXHR()) {
         $success = (bool) $success;
         if ($success && ext_Result::count_errors() > 0) {
             $success = false;
             foreach (@$_SESSION['ext_error'] as $type) {
                 if (is_array($type)) {
                     foreach ($type as $error) {
                         $msg .= '<br />' . $error;
                     }
                 }
             }
         }
         $result = array('action' => $action, 'message' => str_replace("'", "\\'", $msg), 'error' => str_replace("'", "\\'", $msg), 'success' => $success);
         foreach ($extra as $key => $value) {
             $result[$key] = $value;
         }
         $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON';
         $json = new $classname();
         $jresult = $json->encode($result);
         if (strtolower(extGetParam($_POST, 'requestType')) == 'xmlhttprequest') {
             header("Content-type: text/html");
         }
         print $jresult;
         ext_exit();
     }
     $messagetxt = '';
     if ($extra != NULL) {
         $msg .= " - " . $extra;
     }
     if ($msg != '') {
         ext_Result::add_error($msg);
     }
     if (ext_Result::count_messages() < 1 && ext_Result::count_errors() < 1) {
         return;
     }
     if (ext_Result::count_messages() > 0) {
         $messagetxt .= '<h3>' . $GLOBALS["error_msg"]["message"] . ':</h3>';
         foreach ($_SESSION['ext_message'] as $msgtype) {
             foreach ($msgtype as $message) {
                 $messagetxt .= $message . '<br/>';
             }
             $messagetxt .= '<br /><hr /><br />';
         }
         ext_Result::empty_messages();
         if (!empty($_REQUEST['extra'])) {
             $messagetxt .= ' - ' . htmlspecialchars(urldecode($_REQUEST['extra']), ENT_QUOTES);
         }
     }
     if (!empty($_SESSION['ext_error'])) {
         $messagetxt .= '<h3>' . $GLOBALS["error_msg"]["error"] . ':</h3>';
         foreach ($_SESSION['ext_error'] as $errortype) {
             foreach ($errortype as $error) {
                 $messagetxt .= $error . '<br/>';
             }
             $messagetxt .= '<br /><hr /><br />';
         }
         ext_Result::empty_errors();
     }
     if (!empty($_REQUEST['extra'])) {
         $messagetxt .= " - " . htmlspecialchars(urldecode($_REQUEST['extra']), ENT_QUOTES);
     }
     extHTML::loadExtJS();
     show_header();
     defined('EXPLORER_NOEXEC') or define('EXPLORER_NOEXEC', 1);
     echo ext_scriptTag('', 'Ext.Msg.alert(\'Status\', \'' . $messagetxt . '\')');
     //}
     $GLOBALS['action'] = 'show_error';
 }
Example #18
0
}
@session_start();
if (!isset($_REQUEST['dir'])) {
    $dir = $GLOBALS['dir'] = extGetParam($_SESSION, 'ext_dir', '');
} else {
    $dir = $GLOBALS['dir'] = $_SESSION['ext_dir'] = extGetParam($_REQUEST, "dir");
}
if (strstr($mosConfig_absolute_path, "/")) {
    $GLOBALS["separator"] = "/";
} else {
    $GLOBALS["separator"] = "\\";
}
// Get Sort
$GLOBALS["order"] = extGetParam($_REQUEST, 'order', 'name');
// Get Sortorder
$GLOBALS["direction"] = extGetParam($_REQUEST, 'direction', 'ASC');
// show hidden files in QuiXplorer: (hide files starting with '.', as in Linux/UNIX)
$GLOBALS["show_hidden"] = true;
// filenames not allowed to access: (uses PCRE regex syntax)
$GLOBALS["no_access"] = "^\\.ht";
// user permissions bitfield: (1=modify, 2=password, 4=admin, add the numbers)
$GLOBALS["permissions"] = 1;
$GLOBALS['file_mode'] = 'file';
//------------------------------------------------------------------------------
$GLOBALS['ext_File'] = new ext_File();
$abs_dir = get_abs_dir($GLOBALS["dir"]);
if (!file_exists($GLOBALS["home_dir"])) {
    if (!file_exists($GLOBALS["home_dir"] . $GLOBALS["separator"])) {
        if (!empty($GLOBALS["require_login"])) {
            $extra = "<a href=\"" . ext_make_link("logout", NULL, NULL) . "\">" . $GLOBALS["messages"]["btnlogout"] . "</A>";
        } else {
Example #19
0
<?php

/** @version $Id: mimes.php 232 2014-02-13 20:08:10Z soeren $ */
/** ensure this file is being included by a parent file */
if (!defined('_JEXEC') && !defined('_VALID_MOS')) {
    die('Restricted access');
}
//------------------------------------------------------------------------------
// editable files:
$GLOBALS["editable_ext"] = "\\.asm\$|\\.rc\$|\\.hh\$|\\.hxx\$|\\.odl\$|\\.idl\$|\\.rc2\$|\\.dlg\$|\\.less\$" . "|\\.php\$|\\.php3\$|\\.php4\$|\\.php5\$|\\.phtml\$|\\.inc\$|\\.sql\$|\\.csv\$" . "|\\.vb\$|\\.vbs\$|\\.bas\$|\\.frm\$|\\.cls\$|\\.ctl\$|\\.rb\$|\\.htm\$|\\.html\$|\\.shtml\$|\\.dhtml\$|\\.xml\$" . "|\\.js\$|\\.css\$|\\.cgi\$|\\.cpp\$|\\.c\$|\\.cc\$|\\.cxx\$|\\.hpp\$|\\.h\$|\\.lua\$" . "|\\.pas\$|\\.p\$|\\.pl\$|\\.java\$|\\.py\$|\\.sh\$|\\.bat\$|\\.tcl\$|\\.tk\$" . "|\\.txt\$|\\.ini\$|\\.conf\$|\\.properties\$|\\.htaccess\$|\\.htpasswd\$";
//------------------------------------------------------------------------------
// image files:
$GLOBALS["images_ext"] = "\\.png\$|\\.bmp\$|\\.jpg\$|\\.jpeg\$|\\.gif\$|\\.tif\$|\\.ico\$";
//------------------------------------------------------------------------------
// mime types: (description,image,extension)
$GLOBALS["super_mimes"] = array("dir" => array(extGetParam($GLOBALS["mimes"], 'dir', 'Dir'), "extension/folder.png"), "exe" => array(extGetParam($GLOBALS["mimes"], 'exe', 'exe'), "extension/exe.png", "\\.exe\$|\\.com\$|\\.bin\$"), "file" => array(extGetParam($GLOBALS["mimes"], 'file', 'file'), "extension/document.png"));
$GLOBALS["used_mime_types"] = array("text" => array(extGetParam($GLOBALS["mimes"], 'text', 'Text'), "extension/txt.png", "\\.txt\$"), "php" => array(extGetParam($GLOBALS["mimes"], 'php', 'php'), "extension/php.png", "\\.php\$"), "php3" => array(extGetParam($GLOBALS["mimes"], 'php3', 'php3'), "extension/php3.png", "\\.php3\$"), "php4" => array(extGetParam($GLOBALS["mimes"], 'php4', 'php4'), "extension/php4.png", "\\.php4\$"), "php5" => array(extGetParam($GLOBALS["mimes"], 'php5', 'php5'), "extension/php5.png", "\\.php5\$"), "phtml" => array(extGetParam($GLOBALS["mimes"], 'phtml', 'phtml'), "extension/phtml.png", "\\.phtml\$"), "inc" => array(extGetParam($GLOBALS["mimes"], 'inc', 'inc'), "extension/inc.png", "\\.inc\$"), "sql" => array(extGetParam($GLOBALS["mimes"], 'sql', 'SQL'), "extension/sql.png", "\\.sql\$"), "pl" => array(extGetParam($GLOBALS["mimes"], 'pl', 'Perl'), "extension/pl.png", "\\.pl\$"), "cgi" => array(extGetParam($GLOBALS["mimes"], 'cgi', 'CGI'), "extension/cgi.png", "\\.cgi\$"), "py" => array(extGetParam($GLOBALS["mimes"], 'py', 'Python'), "extension/py.png", "\\.py\$"), "sh" => array(extGetParam($GLOBALS["mimes"], 'sh', 'Shell'), "extension/sh.png", "\\.sh\$"), "c" => array(extGetParam($GLOBALS["mimes"], 'c', 'C'), "extension/c.png", "\\.c\$"), "cc" => array(extGetParam($GLOBALS["mimes"], 'cc', 'CC'), "extension/cc.png", "\\.cc\$"), "cpp" => array(extGetParam($GLOBALS["mimes"], 'cpp', 'CPP'), "extension/cpp.png", "\\.cpp\$"), "cxx" => array(extGetParam($GLOBALS["mimes"], 'cxx', 'CXX'), "extension/cxx.png", "\\.cxx\$"), "h" => array(extGetParam($GLOBALS["mimes"], 'h', 'H'), "extension/h.png", "\\.h\$"), "hpp" => array(extGetParam($GLOBALS["mimes"], 'hpp', 'hpp'), "extension/hpp.png", "\\.hpp\$"), "java" => array(extGetParam($GLOBALS["mimes"], 'java', 'Java'), "extension/java.png", "\\.java\$"), "class" => array(extGetParam($GLOBALS["mimes"], 'class', 'Class'), "extension/class.png", "\\.class\$"), "jar" => array(extGetParam($GLOBALS["mimes"], 'jar', 'Jar'), "extension/jar.png", "\\.jar\$"), "htm" => array(extGetParam($GLOBALS["mimes"], 'htm', 'HTML'), "extension/htm.png", "\\.htm\$"), "html" => array(extGetParam($GLOBALS["mimes"], 'html', 'HTML'), "extension/html.png", "\\.html\$"), "shtml" => array(extGetParam($GLOBALS["mimes"], 'shtml', 'sHTML'), "extension/shtml.png", "\\.shtml\$"), "dhtml" => array(extGetParam($GLOBALS["mimes"], 'dhtml', 'dHTML'), "extension/dhtml.png", "\\.dhtml\$"), "xhtml" => array(extGetParam($GLOBALS["mimes"], 'xhtml', 'XHTML'), "extension/xhtml.png", "\\.xhtml\$"), "xml" => array(extGetParam($GLOBALS["mimes"], 'xml', 'XML'), "extension/xml.png", "\\.xml\$"), "js" => array(extGetParam($GLOBALS["mimes"], 'js', 'JS'), "extension/js.png", "\\.js\$"), "css" => array(extGetParam($GLOBALS["mimes"], 'css', 'CSS'), "extension/css.png", "\\.css\$"), "gif" => array(extGetParam($GLOBALS["mimes"], 'gif', 'GIF'), "extension/gif.png", "\\.gif\$"), "jpg" => array(extGetParam($GLOBALS["mimes"], 'jpg', 'JPG'), "extension/jpg.png", "\\.jpg\$"), "jpeg" => array(extGetParam($GLOBALS["mimes"], 'jpeg', 'JPEG'), "extension/jpeg.png", "\\.jpeg\$"), "bmp" => array(extGetParam($GLOBALS["mimes"], 'bmp', 'Bitmap'), "extension/bmp.png", "\\.bmp\$"), "png" => array(extGetParam($GLOBALS["mimes"], 'png', 'PNG'), "extension/png.png", "\\.png\$"), "zip" => array(extGetParam($GLOBALS["mimes"], 'zip', 'ZIP'), "extension/zip.png", "\\.zip\$"), "tar" => array(extGetParam($GLOBALS["mimes"], 'tar', 'TAR'), "extension/tar.png", "\\.tar\$"), "tgz" => array(extGetParam($GLOBALS["mimes"], 'tgz', 'Tar/GZ'), "extension/tgz.png", "\\.tgz\$"), "gz" => array(extGetParam($GLOBALS["mimes"], 'gz', 'GZip'), "extension/gz.png", "\\.gz\$"), "bz2" => array(extGetParam($GLOBALS["mimes"], 'bz2', 'Bzip2'), "extension/bz2.png", "\\.bz2\$"), "tbz" => array(extGetParam($GLOBALS["mimes"], 'tbz', 'Tar/Bz2'), "extension/tbz.png", "\\.tbz\$"), "rar" => array(extGetParam($GLOBALS["mimes"], 'rar', 'RAR'), "extension/rar.png", "\\.rar\$"), "mp3" => array(extGetParam($GLOBALS["mimes"], 'mp3', 'Mp3'), "extension/mp3.png", "\\.mp3\$"), "wav" => array(extGetParam($GLOBALS["mimes"], 'wav', 'WAV'), "extension/wav.png", "\\.wav\$"), "midi" => array(extGetParam($GLOBALS["mimes"], 'midi', 'Midi'), "extension/midi.png", "\\.mid\$"), "rm" => array(extGetParam($GLOBALS["mimes"], 'real', 'Real Media'), "extension/rm.png", "\\.rm\$"), "ra" => array(extGetParam($GLOBALS["mimes"], 'real', 'Real Audio'), "extension/ra.png", "\\.ra\$"), "ram" => array(extGetParam($GLOBALS["mimes"], 'real', 'Real Media'), "extension/ram.png", "\\.ram\$"), "pls" => array(extGetParam($GLOBALS["mimes"], 'pls', 'pls'), "extension/pls.png", "\\.pls\$"), "m3u" => array(extGetParam($GLOBALS["mimes"], 'm3u', 'm3u'), "extension/m3u.png", "\\.m3u\$"), "mpg" => array(extGetParam($GLOBALS["mimes"], 'mpg', 'MPG'), "extension/mpg.png", "\\.mpg\$"), "mpeg" => array(extGetParam($GLOBALS["mimes"], 'mpeg', 'MPG'), "extension/mpeg.png", "\\.mpeg\$"), "mov" => array(extGetParam($GLOBALS["mimes"], 'mov', 'MOV'), "extension/mov.png", "\\.mov\$"), "avi" => array(extGetParam($GLOBALS["mimes"], 'avi', 'AVI'), "extension/avi.png", "\\.avi\$"), "swf" => array(extGetParam($GLOBALS["mimes"], 'swf', 'SWF'), "extension/swf.png", "\\.swf\$"), "doc" => array(extGetParam($GLOBALS["mimes"], 'doc', 'Word'), "extension/doc.png", "\\.doc\$"), "docx" => array(extGetParam($GLOBALS["mimes"], 'docx', 'Word'), "extension/docx.png", "\\.docx\$"), "xls" => array(extGetParam($GLOBALS["mimes"], 'xls', 'Excel'), "extension/xls.png", "\\.xls\$"), "xlsx" => array(extGetParam($GLOBALS["mimes"], 'xlsx', 'Excel'), "extension/xlsx.png", "\\.xlsx\$"), "rtf" => array(extGetParam($GLOBALS["mimes"], 'rtf', 'Rich Text Format'), "extension/doc.png", "\\.rtf\$"), "pdf" => array(extGetParam($GLOBALS["mimes"], 'pdf', 'PDF'), "extension/pdf.png", "\\.pdf\$"));
//------------------------------------------------------------------------------
Example #20
0
 * 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."
 * 
 * User Authentication Functions
 */
//------------------------------------------------------------------------------
require_once _EXT_PATH . "/include/users.php";
ext_load_users();
//------------------------------------------------------------------------------
$GLOBALS['__SESSION'] =& $_SESSION;
if (!empty($_REQUEST['type'])) {
    $GLOBALS['authentication_type'] = basename(extGetParam($_REQUEST, 'type', $GLOBALS['ext_conf']['authentication_method_default']));
} else {
    $GLOBALS['authentication_type'] = $GLOBALS['file_mode'];
}
if ($GLOBALS['authentication_type'] == 'file') {
    $GLOBALS['authentication_type'] = 'extplorer';
}
if (!in_array($GLOBALS['authentication_type'], $GLOBALS['ext_conf']['authentication_methods_allowed'])) {
    $GLOBALS['authentication_type'] = extgetparam($_SESSION, 'file_mode', $GLOBALS['ext_conf']['authentication_method_default']);
    if (!in_array($GLOBALS['authentication_type'], $GLOBALS['ext_conf']['authentication_methods_allowed'])) {
        $GLOBALS['authentication_type'] = $_SESSION['file_mode'] = $GLOBALS['ext_conf']['authentication_method_default'];
    }
}
if (file_exists(_EXT_PATH . '/include/authentication/' . $authentication_type . '.php')) {
    require_once _EXT_PATH . '/include/authentication/' . $authentication_type . '.php';
    $classname = 'ext_' . $authentication_type . '_authentication';
Example #21
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 
        }
    }
Example #22
0
					checkLoggedOut( response ); // Check if current user is logged off. If yes, Joomla! sends a document.location redirect, which will be eval'd here
					var result = Ext.decode( response.responseText );						
					document.title = 'eXtplorer - ' + datastore.directory;
					Ext.get('bookmark_container').update( result.bookmarks );
				}
			}
		});

	    if( !loadGridOnly ) {
			expandTreeToDir( null, directory );
    	}
    }
	
	function expandTreeToDir( node, dir ) {
		dir = dir ? dir : new String('<?php 
echo str_replace("'", "\\'", extGetParam($_SESSION, 'ext_' . $GLOBALS['file_mode'] . 'dir', ''));
?>
');
		var dirs = dir.split('/');
		if( dirs[0] == '') { dirs.shift(); }
		if( dirs.length > 0 ) {
			node = Ext.getCmp("dirTree").getNodeById( '_RRR_'+ dirs[0] );
			if( !node ) return;
			if( node.isExpanded() ) {
				expandNode( node, dir );
				return;
			}
			node.on('load', function() { expandNode( node, dir ) } );
			node.expand();
		}
	}
Example #23
0
    if (strstr($GLOBALS['home_dir'], ':')) {
        $GLOBALS['home_dir'][0] = strtoupper($GLOBALS['home_dir'][0]);
    }
}
//------------------------------------------------------------------------------
if (!isset($_REQUEST['dir'])) {
    $GLOBALS["dir"] = $dir = extGetParam($_SESSION, 'ext_' . $GLOBALS['file_mode'] . 'dir', '');
    if (!empty($dir)) {
        $dir = @$dir[0] == '/' ? substr($dir, 1) : $dir;
    }
    $try_this = ext_isFTPMode() ? '/' . $dir : $GLOBALS['home_dir'] . '/' . $dir;
    if (!empty($dir) && !$GLOBALS['ext_File']->file_exists($try_this)) {
        $dir = '';
    }
} 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;
        }
Example #24
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 
    }
Example #25
0
 function sendResult($action, $success, $msg, $extra = array())
 {
     // show error-message
     if (ext_isXHR()) {
         $success = (bool) $success;
         if ($success && ext_Result::count_errors() > 0) {
             $success = false;
             foreach (@$_SESSION['ext_error'] as $type) {
                 if (is_array($type)) {
                     foreach ($type as $error) {
                         $msg .= '<br />' . $error;
                     }
                 }
             }
         }
         $result = array('action' => $action, 'message' => str_replace("'", "\\'", $msg), 'error' => str_replace("'", "\\'", $msg), 'success' => $success);
         foreach ($extra as $key => $value) {
             $result[$key] = $value;
         }
         $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON';
         $json = new $classname();
         $jresult = $json->encode($result);
         if (strtolower(extGetParam($_POST, 'requestType')) == 'xmlhttprequest') {
             header("Content-type: text/html");
         }
         print $jresult;
         ext_exit();
     }
     if ($extra != NULL) {
         $msg .= " - " . $extra;
     }
     ext_Result::add_error($msg);
     if (empty($_GET['error'])) {
         session_write_close();
         extRedirect(make_link("show_error", $GLOBALS["dir"], null, null, null, null, '&error=1&extra=' . urlencode($extra)));
     } else {
         show_header($GLOBALS["error_msg"]["error"]);
         echo '<div class="quote">';
         echo '<a href="#errors">' . ext_Result::count_errors() . ' ' . $GLOBALS["error_msg"]["error"] . '</a>, ';
         echo '<a href="#messages">' . ext_Result::count_messages() . ' ' . $GLOBALS["error_msg"]["message"] . '</a><br />';
         echo "</div>\n";
         if (!empty($_SESSION['ext_message'])) {
             echo "<a href=\"" . str_replace('&dir=', '&ignore=', make_link("list", '')) . "\">[ " . $GLOBALS["error_msg"]["back"] . " ]</a>";
             echo "<div class=\"ext_message\"><a name=\"messages\"></a>\r\n\t\t\t\t\t\t<h3>" . $GLOBALS["error_msg"]["message"] . ":</strong>" . "</h3>\n";
             foreach ($_SESSION['ext_message'] as $msgtype) {
                 foreach ($msgtype as $message) {
                     echo $message . "\n<br/>";
                 }
                 echo '<br /><hr /><br />';
             }
             ext_Result::empty_messages();
             if (!empty($_REQUEST['extra'])) {
                 echo " - " . htmlspecialchars(urldecode($_REQUEST['extra']), ENT_QUOTES);
             }
             echo "</div>\n";
         }
         if (!empty($_SESSION['ext_error'])) {
             echo "<div class=\"ext_error\"><a name=\"errors\"></a>\r\n\t\t\t\t\t\t<h3>" . $GLOBALS["error_msg"]["error"] . ":</strong>" . "</h3>\n";
             foreach ($_SESSION['ext_error'] as $errortype) {
                 foreach ($errortype as $error) {
                     echo $error . "\n<br/>";
                 }
                 echo '<br /><hr /><br />';
             }
             ext_Result::empty_errors();
         }
         echo "<a href=\"" . str_replace('&dir=', '&ignore=', make_link("list", '')) . "\">" . $GLOBALS["error_msg"]["back"] . "</a>";
         if (!empty($_REQUEST['extra'])) {
             echo " - " . htmlspecialchars(urldecode($_REQUEST['extra']), ENT_QUOTES);
         }
         echo "</div>\n";
         defined('EXPLORER_NOEXEC') or define('EXPLORER_NOEXEC', 1);
     }
 }