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") { // CSRF Security Check if (!ext_checkToken($GLOBALS['__POST']["token"])) { ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.'); } $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; } }
/** * @version $Id: footer.php 107 2008-07-22 17:27:12Z 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." * * Shows the About Box! */ function show_about() { // footer for html-page echo "\n<div id=\"ext_footer\" style=\"text-align:center;\">\r\n\t<img src=\"" . _EXT_URL . "/images/MangosWeb_small.png\" align=\"middle\" alt=\"Mangosweb Enhanced Logo\" />\r\n\t<br />\r\n\t" . ext_Lang::msg('your_version') . ": <a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\">eXtplorer {$GLOBALS['ext_version']}</a>\r\n\t<br />\r\n (<a href=\"http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "\" onclick=\"javascript:void window.open('http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=580,directories=no,location=no'); return false;\" title=\"" . $GLOBALS["messages"]["check_version"] . "\">" . $GLOBALS["messages"]["check_version"] . "</a>)\r\n\t\r\n\t"; if (function_exists("disk_free_space")) { $size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']); $free = parse_file_size($size); } elseif (function_exists("diskfreespace")) { $size = diskfreespace($GLOBALS['home_dir'] . $GLOBALS['separator']); $free = parse_file_size($size); } else { $free = "?"; } echo '<br />' . $GLOBALS["messages"]["miscfree"] . ": " . $free . " \n"; if (extension_loaded("posix")) { $owner_info = '<br /><br />' . ext_Lang::msg('current_user') . ' '; if (ext_isFTPMode()) { $my_user_info = posix_getpwnam($_SESSION['ftp_login']); $my_group_info = posix_getgrgid($my_user_info['gid']); } else { $my_user_info = posix_getpwuid(posix_geteuid()); $my_group_info = posix_getgrgid(posix_getegid()); } $owner_info .= $my_user_info['name'] . ' (' . $my_user_info['uid'] . '), ' . $my_group_info['name'] . ' (' . $my_group_info['gid'] . ')'; echo $owner_info; } echo "\r\n\t</div>"; }
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']); }
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(); }
id: 'dirCtxMenu_remove', icon: '<?php echo _EXT_URL; ?> /images/_editdelete.png', text: '<?php echo ext_Lang::msg('btnremove', true); ?> ', handler: function() { dirCtxMenu.hide();var num = 1; Ext.Msg.confirm('Confirm', String.format("<?php echo $GLOBALS['error_msg']['miscdelitems']; ?> ", num ), function(btn) { deleteDir( btn, dirCtxMenu.node ) }); } },'-', <?php if (($GLOBALS["zip"] || $GLOBALS["tar"] || $GLOBALS["tgz"]) && !ext_isFTPMode()) { ?> { id: 'dirCtxMenu_archive', icon: '<?php echo _EXT_URL; ?> /images/_archive.png', text: '<?php echo ext_Lang::msg('comprlink', true); ?> ', handler: function() { openActionDialog(this, 'archive'); } }, <?php }
function execAction($dir, $item) { // rename directory or file if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["accessfunc"]); } if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $newitemname = $GLOBALS['__POST']["newitemname"]; $newitemname = trim(basename(stripslashes($newitemname))); if ($newitemname == '') { ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["miscnoname"]); } if (!ext_isFTPMode()) { $abs_old = get_abs_item($dir, $item); $abs_new = get_abs_item($dir, $newitemname); } else { $abs_old = get_item_info($dir, $item); $abs_new = get_item_info($dir, $newitemname); } if (@$GLOBALS['ext_File']->file_exists($abs_new)) { ext_Result::sendResult('rename', false, $newitemname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]); } $perms_old = $GLOBALS['ext_File']->fileperms($abs_old); $ok = $GLOBALS['ext_File']->rename(get_abs_item($dir, $item), get_abs_item($dir, $newitemname)); if (ext_isFTPMode()) { $abs_new = get_item_info($dir, $newitemname); } $GLOBALS['ext_File']->chmod($abs_new, $perms_old); if ($ok === false || PEAR::isError($ok)) { ext_Result::sendResult('rename', false, 'Could not rename ' . $dir . '/' . $item . ' to ' . $newitemname); } $msg = sprintf($GLOBALS['messages']['success_rename_file'], $item, $newitemname); ext_Result::sendResult('rename', true, $msg); } $is_dir = get_is_dir(ext_isFTPMode() ? get_item_info($dir, $item) : get_abs_item($dir, $item)); ?> <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']['rename_file']; ?> </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 simple = new Ext.form.Form({ labelWidth: 75, // 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('newname', true); ?> ', name: 'newitemname', value: '<?php echo str_replace("'", "\\'", stripslashes($item)); ?> ', width:175, allowBlank:false }) ); simple.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( 'Please wait...', true ); simple.submit({ //reset: true, reset: false, success: function(form, action) { <?php if ($is_dir) { ?> parentDir = dirTree.getSelectionModel().getSelectedNode().parentNode; parentDir.reload(); parentDir.select(); <?php } else { ?> datastore.reload(); <?php } ?> statusBarMessage( action.result.message, false, true ); dialog.destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('Error!', 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: 'rename', dir: '<?php echo stripslashes($dir); ?> ', item: '<?php echo stripslashes($item); ?> ', confirm: 'true'} }); }); simple.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.destroy(); } ); simple.render('adminForm'); </script> <?php }
function get_result_array($list) { // print table of found items if (!is_array($list)) { return; } $cnt = count($list); $array = array(); for ($i = 0; $i < $cnt; ++$i) { $dir = $list[$i][0]; $item = $list[$i][1]; $s_dir = str_replace($GLOBALS['home_dir'], '', $dir); if (strlen($s_dir) > 65) { $s_dir = substr($s_dir, 0, 62) . "..."; } $s_item = $item; if (strlen($s_item) > 45) { $s_item = substr($s_item, 0, 42) . "..."; } $link = ""; $target = ""; if (get_is_dir($dir, $item)) { $img = "dir.png"; $link = ext_make_link("list", get_rel_item($dir, $item), NULL); } else { $img = get_mime_type($item, "img"); //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) { $link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item); $target = "_blank"; //} } $array[$i]['last_mtime'] = ext_isFTPMode() ? $GLOBALS['ext_File']->filemtime($GLOBALS['home_dir'] . '/' . $dir . '/' . $item) : filemtime($dir . '/' . $item); $array[$i]['file_id'] = md5($s_dir . $s_item); $array[$i]['dir'] = str_replace($GLOBALS['home_dir'], '', $dir); $array[$i]['s_dir'] = empty($s_dir) ? '' : $s_dir; $array[$i]['file'] = $s_item; $array[$i]['link'] = $link; $array[$i]['icon'] = _EXT_URL . "/images/{$img}"; } return $array; }
}); layout.beginUpdate(); layout.add('north', new Ext.ContentPanel('ext_header', {closable: false})); layout.add('west', new Ext.ContentPanel('dirtree', {title: '<?php echo ext_Lang::msg('directory_tree', true); ?> <img src="<?php echo _EXT_URL; ?> /images/reload.png" hspace="20" style="cursor:pointer;" title="reload" onclick="dirTree.getRootNode().reload();" alt="Reload" align="middle" />', closable: false})); layout.add('center', new Ext.GridPanel(ext_itemgrid, {})); layout.endUpdate(); <?php if (!ext_isFTPMode() && empty($_SESSION['ftp_login'])) { ?> Ext.get('switch_file_mode').on('click', handleFTPLogin ); function handleFTPLogin( e ) { e.preventDefault(); openActionDialog( 'switch_file_mode', 'ftp_authentication' ); } <?php } ?> /** * This function is for changing into a specified directory * It updates the tree, the grid and the ContentPanel title */ chDir = function( directory ) {
function execAction($dir, $item) { // show file contents global $action; if (@eregi($GLOBALS["images_ext"], $item)) { $html = '<img src="' . make_link('get_image', $dir, rawurlencode($item)) . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />'; } elseif (@eregi($GLOBALS["editable_ext"], $item)) { $geshiFile = _EXT_PATH . '/libraries/geshi/geshi.php'; ext_RaiseMemoryLimit('32M'); // GeSHi 1.0.7 is very memory-intensive include_once $geshiFile; // Create the GeSHi object that renders our source beautiful $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi'); $file = get_abs_item($dir, $item); $pathinfo = pathinfo($file); if (ext_isFTPMode()) { $file = ext_ftp_make_local_copy($file); } if (is_callable(array($geshi, 'load_from_file'))) { $geshi->load_from_file($file); } else { $geshi->set_source(file_get_contents($file)); } if (is_callable(array($geshi, 'get_language_name_from_extension'))) { $lang = $geshi->get_language_name_from_extension($pathinfo['extension']); } else { $pathinfo = pathinfo($item); $lang = $pathinfo['extension']; } $geshi->set_language($lang); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $langs = $GLOBALS["language"]; if ($langs == "japanese") { $enc_list = array("ASCII", "ISO-2022-JP", "UTF-8", "EUCJP-WIN", "SJIS-WIN"); $_e0 = strtoupper(mb_detect_encoding($geshi->source, $enc_list, true)); if ($_e0 == "SJIS-WIN") { $_encoding = "Shift_JIS"; } elseif ($_e0 == "EUCJP-WIN") { $_e0 = "EUC-JP"; } elseif ($_e0 == "ASCII") { $_e0 = "UTF-8"; } else { $_encoding = $_e0; } $geshi->set_encoding($_encoding); } $html = $geshi->parse_code(); if ($langs == "japanese") { if (empty($lang) || strtoupper(mb_detect_encoding($html, $enc_list)) != "UTF-8") { $html = mb_convert_encoding($html, "UTF-8", $_e0); } } if (ext_isFTPMode()) { unlink($file); } $html .= '<hr /><div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>'; } else { $html = ' <iframe src="' . make_link('download', $dir, $item, null, null, null, '&action2=view') . '" id="iframe1" width="100%" height="100%" frameborder="0"></iframe>'; } $html = str_replace(array("\r", "\n"), array('\\r', '\\n'), addslashes($html)); ?> { "dialogtitle": "<?php echo $GLOBALS['messages']['actview'] . ": " . $item; ?> ", "height": 500, "autoScroll": true, "html": "<?php echo $html; ?> " } <?php }
/** * 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') . '.'); }
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 }
/** * This function assembles an array (list) of files or directories in the directory specified by $dir * The result array is send using JSON * * @param string $dir * @param string $sendWhat Can be "files" or "dirs" */ function send_dircontents($dir, $sendWhat = 'files') { // print table of files global $dir_up, $mainframe; // make file & dir tables, & get total filesize & number of items get_dircontents($dir, $dir_list, $file_list, $tot_file_size, $num_items); if ($sendWhat == 'files') { $list = $file_list; } elseif ($sendWhat == 'dirs') { $list = $dir_list; } else { $list = make_list($dir_list, $file_list); } $i = 0; $items['totalCount'] = count($list); $items['items'] = array(); $dirlist = array(); if ($sendWhat != 'dirs') { // Replaced array_splice, because it resets numeric indexes (like files or dirs with a numeric name) // Here we reduce the list to the range of $limit beginning at $start $a = 0; $output_array = array(); foreach ($list as $key => $value) { if ($a >= $GLOBALS['start'] && $a - $GLOBALS['start'] < $GLOBALS['limit']) { $output_array[$key] = $value; } $a++; } $list = $output_array; } while (list($item, $info) = each($list)) { // link to dir / file if (is_array($info)) { $abs_item = $info; if (extension_loaded('posix')) { $user_info = posix_getpwnam($info['user']); $file_info['uid'] = $user_info['uid']; $file_info['gid'] = $user_info['gid']; } } else { $abs_item = get_abs_item(ext_TextEncoding::fromUTF8($dir), $item); $file_info = @stat($abs_item); } $is_dir = get_is_dir($abs_item); if ($GLOBALS['use_mb']) { if (ext_isFTPMode()) { $items['items'][$i]['name'] = $item; } else { if (mb_detect_encoding($item) == 'ASCII') { $items['items'][$i]['name'] = ext_TextEncoding::toUTF8($item); } else { $items['items'][$i]['name'] = ext_TextEncoding::toUTF8($item); } } } else { $items['items'][$i]['name'] = ext_isFTPMode() ? $item : ext_TextEncoding::toUTF8($item); } $items['items'][$i]['is_file'] = get_is_file($abs_item); $items['items'][$i]['is_archive'] = ext_isArchive($item) && !ext_isFTPMode(); $items['items'][$i]['is_writable'] = $is_writable = @$GLOBALS['ext_File']->is_writable($abs_item); $items['items'][$i]['is_chmodable'] = $is_chmodable = @$GLOBALS['ext_File']->is_chmodable($abs_item); $items['items'][$i]['is_readable'] = $is_readable = @$GLOBALS['ext_File']->is_readable($abs_item); $items['items'][$i]['is_deletable'] = $is_deletable = @$GLOBALS['ext_File']->is_deletable($abs_item); $items['items'][$i]['is_editable'] = get_is_editable($abs_item); $items['items'][$i]['icon'] = _EXT_URL . "/images/" . get_mime_type($abs_item, "img"); $items['items'][$i]['size'] = parse_file_size(get_file_size($abs_item)); // type $items['items'][$i]['type'] = get_mime_type($abs_item, "type"); // modified $items['items'][$i]['modified'] = parse_file_date(get_file_date($abs_item)); // permissions $perms = get_file_perms($abs_item); if ($perms) { if (strlen($perms) > 3) { $perms = substr($perms, 2); } $items['items'][$i]['perms'] = $perms . ' (' . parse_file_perms($perms) . ')'; } else { $items['items'][$i]['perms'] = ' (unknown) '; } $items['items'][$i]['perms'] = $perms . ' (' . parse_file_perms($perms) . ')'; if (extension_loaded("posix")) { if ($file_info["uid"]) { $user_info = posix_getpwuid($file_info["uid"]); //$group_info = posix_getgrgid($file_info["gid"]); $items['items'][$i]['owner'] = $user_info["name"] . " (" . $file_info["uid"] . ")"; } else { $items['items'][$i]['owner'] = " (unknown) "; } } else { $items['items'][$i]['owner'] = 'n/a'; } if ($is_dir && $sendWhat != 'files') { $id = str_replace('/', $GLOBALS['separator'], $dir) . $GLOBALS['separator'] . $item; $id = str_replace($GLOBALS['separator'], '_RRR_', $id); $qtip = "<strong>" . ext_Lang::mime('dir', true) . "</strong><br /><strong>" . ext_Lang::msg('miscperms', true) . ":</strong> " . $perms . "<br />"; $qtip .= '<strong>' . ext_Lang::msg('miscowner', true) . ':</strong> ' . $items['items'][$i]['owner']; if ($GLOBALS['use_mb']) { if (ext_isFTPMode()) { $dirlist[] = array('text' => htmlspecialchars($item), 'id' => $id, 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } else { if (mb_detect_encoding($item) == 'ASCII') { $dirlist[] = array('text' => htmlspecialchars(ext_TextEncoding::toUTF8($item)), 'id' => utf8_encode($id), 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } else { $dirlist[] = array('text' => htmlspecialchars($item), 'id' => $id, 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } } } else { $dirlist[] = array('text' => htmlspecialchars(ext_isFTPMode() ? $item : ext_TextEncoding::toUTF8($item)), 'id' => ext_isFTPMode() ? $id : ext_TextEncoding::toUTF8($id), 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } } if (!$is_dir && $sendWhat == 'files' || $sendWhat == 'both') { $i++; } } while (@ob_end_clean()) { } if ($sendWhat == 'dirs') { $result = $dirlist; } else { $result = $items; } $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON'; $json = new $classname(); echo $json->encode($result); ext_exit(); }
function down_home($abs_dir) { // dir deeper than home? if (ext_isFTPMode()) { return true; } $real_home = @realpath($GLOBALS["home_dir"]); $real_dir = @realpath($abs_dir); if ($real_home === false || $real_dir === false) { if (@eregi("\\.\\.", $abs_dir)) { return false; } } else { if (strcmp($real_home, @substr($real_dir, 0, strlen($real_home)))) { return false; } } return true; }
function execAction($dir, $item) { // show file contents echo '<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;">' . $GLOBALS["messages"]["actview"] . ": " . $item . '</h3>'; echo '</div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div><hr />'; /*$index2_edit_link = str_replace('/index3.php', '/index2.php', make_link('edit', $dir, $item )); echo '<a name="top" class="componentheading" href="javascript:window.close();">[ '._PROMPT_CLOSE.' ]</a> '; $abs_item = get_abs_item($dir, $item); if( get_is_editable( $abs_item) && $GLOBALS['ext_File']->is_writable( $abs_item )) { // Edit the file in the PopUp echo '<a class="componentheading" href="'.make_link('edit', $dir, $item ).'&return_to='.urlencode($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'] ).'">[ '.$GLOBALS["messages"]["editlink"].' ]</a> '; // Edit the file in the parent window //echo '<a class="componentheading" href="javascript:opener.location=\''.$index2_edit_link.'\'; window.close();">[ '.$GLOBALS["messages"]["editlink"].' ]</a> '; } echo '<a class="componentheading" href="#bottom">[ '._CMN_BOTTOM.' ]</a>'; echo '<br /><br />'; */ if (@eregi($GLOBALS["images_ext"], $item)) { echo '<img src="' . make_link('get_image', $dir, rawurlencode($item)) . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />'; } else { $geshiFile = _EXT_PATH . '/libraries/geshi/geshi.php'; if (file_exists($geshiFile)) { ext_RaiseMemoryLimit('32M'); // GeSHi 1.0.7 is very memory-intensive include_once $geshiFile; // Create the GeSHi object that renders our source beautiful $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi'); $file = get_abs_item($dir, $item); $pathinfo = pathinfo($file); if (ext_isFTPMode()) { $file = ext_ftp_make_local_copy($file); } if (is_callable(array($geshi, 'load_from_file'))) { $geshi->load_from_file($file); } else { $geshi->set_source(file_get_contents($file)); } if (is_callable(array($geshi, 'getlanguagesuage_name_from_extension'))) { $lang = $geshi->getlanguagesuage_name_from_extension($pathinfo['extension']); } else { $pathinfo = pathinfo($item); $lang = $pathinfo['extension']; } $geshi->set_language($lang); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $text = $geshi->parse_code(); if (ext_isFTPMode()) { unlink($file); } echo $text; echo '<hr /><div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>'; } else { // When GeSHi is not available, just display the plain file contents echo '<div class="quote" style="text-align:left;">' . nl2br(htmlentities($GLOBALS['ext_File']->file_get_contents(get_abs_item($dir, $item)))) . '</div>'; } } //echo '<a href="#top" name="bottom" class="componentheading">[ '._CMN_TOP.' ]</a><br /><br />'; }
function execAction($dir, $item) { // rename directory or file if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["accessfunc"]); } if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $newitemname = $GLOBALS['__POST']["newitemname"]; $newitemname = trim(basename(stripslashes($newitemname))); if ($newitemname == '') { ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["miscnoname"]); } if (!ext_isFTPMode()) { $abs_old = get_abs_item($dir, $item); $abs_new = get_abs_item($dir, $newitemname); } else { $abs_old = get_item_info($dir, $item); $abs_new = get_item_info($dir, $newitemname); } if (@$GLOBALS['ext_File']->file_exists($abs_new)) { ext_Result::sendResult('rename', false, ext_TextEncoding::toUTF8($newitemname) . ": " . $GLOBALS["error_msg"]["itemdoesexist"]); } $perms_old = $GLOBALS['ext_File']->fileperms($abs_old); $ok = $GLOBALS['ext_File']->rename(get_abs_item($dir, $item), get_abs_item($dir, $newitemname)); if (ext_isFTPMode()) { $abs_new = get_item_info($dir, $newitemname); } $GLOBALS['ext_File']->chmod($abs_new, $perms_old); if ($ok === false || PEAR::isError($ok)) { ext_Result::sendResult('rename', false, 'Could not rename ' . $dir . '/' . $item . ' to ' . $newitemname); } $msg = sprintf($GLOBALS['messages']['success_rename_file'], $item, $newitemname); ext_Result::sendResult('rename', true, $msg); } $is_dir = get_is_dir(ext_isFTPMode() ? get_item_info($dir, $item) : get_abs_item($dir, $item)); ?> { "xtype": "form", "width": "350", "height": "150", "id": "simpleform", "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "dialogtitle": "<?php echo $GLOBALS['messages']['rename_file']; ?> ", "frame": true, "items": [{ "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('newname', true); ?> ", "name": "newitemname", "id": "newitemname", "value": "<?php echo str_replace("'", "\\'", stripslashes($item)); ?> ", "width":175, "allowBlank":false } ], "listeners": { "afterrender": { fn: function( form ) { form.findById("newitemname").focus(true); } } }, "buttons": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( 'Please wait...', true ); form = Ext.getCmp("simpleform").getForm(); form.submit({ //reset: true, reset: false, success: function(form, action) { <?php if ($is_dir) { ?> if( dirTree.getSelectionModel().getSelectedNode() ) { parentDir = dirTree.getSelectionModel().getSelectedNode().parentNode;parentDir.reload();parentDir.select(); } <?php } ?> datastore.reload(); statusBarMessage( action.result.message, false, true ); 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: { option: 'com_extplorer', action: 'rename', dir: '<?php echo stripslashes($dir); ?> ', item: '<?php echo stripslashes($item); ?> ', confirm: 'true' } }); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] } <?php }
/** * * Shows eXtplorer information */ function show_about() { //$sess = print_r($_SESSION,true); //echo str_replace(array("\r", "\n"),array('',''),$sess); echo "\n<div id=\"ext_footer\" style=\"text-align:center;\">\n\t<img src=\"" . _EXT_URL . "/images/eXtplorer_logo.png\" align=\"middle\" alt=\"eXtplorer Logo\" />\n\t<br />\n\t" . ext_Lang::msg('your_version') . ": <a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\">eXtplorer {$GLOBALS['ext_version']}</a>\n\t<br />\n (<a href=\"http://extplorer.net/version_check?myVersion=" . $GLOBALS['ext_version'] . "\" onclick=\"javascript:void window.open('http://extplorer.net/version_check?myVersion=" . $GLOBALS['ext_version'] . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=580,directories=no,location=no'); return false;\" title=\"" . $GLOBALS["messages"]["check_version"] . "\">" . $GLOBALS["messages"]["check_version"] . "</a>)\n\n\t"; $size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']); $free = parse_file_size($size); echo '<br />' . $GLOBALS["messages"]["miscfree"] . ": " . $free . " \n"; if (extension_loaded("posix")) { $owner_info = '<br /><br />' . ext_Lang::msg('current_user') . ' '; if (ext_isFTPMode()) { $my_user_info = posix_getpwnam($_SESSION['ftp_login']); $my_group_info = posix_getgrgid($my_user_info['gid']); } else { $my_user_info = posix_getpwuid(posix_geteuid()); $my_group_info = posix_getgrgid(posix_getegid()); } $owner_info .= $my_user_info['name'] . ' (' . $my_user_info['uid'] . '), ' . $my_group_info['name'] . ' (' . $my_group_info['gid'] . ')'; echo $owner_info; } echo "\n\t</div>"; }
function execAction($dir) { if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('upload', false, ext_Lang::err('accessfunc')); } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { if (isset($GLOBALS['__FILES']['Filedata'])) { // Re-Map the flash-uploaded file with the name "Filedata" to the "userfile" array $GLOBALS['__FILES']['userfile'] = array('name' => array($GLOBALS['__FILES']['Filedata']['name']), 'tmp_name' => array($GLOBALS['__FILES']['Filedata']['tmp_name']), 'size' => array($GLOBALS['__FILES']['Filedata']['size']), 'type' => array($GLOBALS['__FILES']['Filedata']['type']), 'error' => array($GLOBALS['__FILES']['Filedata']['error'])); } $cnt = count($GLOBALS['__FILES']['userfile']['name']); $err = false; $err_available = isset($GLOBALS['__FILES']['userfile']['error']); // upload files & check for errors for ($i = 0; $i < $cnt; $i++) { $errors[$i] = NULL; $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i]; $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]); if ($err_available) { $up_err = $GLOBALS['__FILES']['userfile']['error'][$i]; } else { $up_err = file_exists($tmp) ? 0 : 4; } $abs = get_abs_item($dir, $items[$i]); if ($items[$i] == "" || $up_err == 4) { continue; } if ($up_err == 1 || $up_err == 2) { $errors[$i] = ext_lang::err('miscfilesize'); $err = true; continue; } if ($up_err == 3) { $errors[$i] = ext_lang::err('miscfilepart'); $err = true; continue; } if (!@is_uploaded_file($tmp)) { $errors[$i] = ext_lang::err('uploadfile'); $err = true; continue; } if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) { $errors[$i] = ext_lang::err('itemdoesexist'); $err = true; continue; } // Upload $ok = @$GLOBALS['ext_File']->move_uploaded_file($tmp, $abs); if ($ok === false || PEAR::isError($ok)) { $errors[$i] = ext_lang::err('uploadfile'); if (PEAR::isError($ok)) { $errors[$i] .= ' [' . $ok->getMessage() . ']'; } $err = true; continue; } else { if (!ext_isFTPMode()) { @$GLOBALS['ext_File']->chmod($abs, 0644); } } } 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('upload', false, $err_msg); } ext_Result::sendResult('upload', true, ext_Lang::msg('upload_completed')); return; } ?> { "xtype": "tabpanel", "stateId": "upload_tabpanel", "activeTab": "uploadform", "dialogtitle": "<?php echo ext_Lang::msg('actupload'); ?> ", "stateful": "true", "stateEvents": ["tabchange"], "getState": function() { return { activeTab:this.items.indexOf(this.getActiveTab()) }; }, "listeners": { "resize": { "fn": function(panel) { panel.items.each( function(item) { item.setHeight(500);return true } ); } } }, "items": [ { "xtype": "swfuploadpanel", "title": "<?php echo Ext_Lang::msg('flashupload'); ?> ", "height": "300", "id": "swfuploader", viewConfig: { forceFit: true }, "listeners": { "allUploadsComplete": { "fn": function(panel) { datastore.reload(); panel.destroy(); Ext.getCmp("dialog").destroy(); statusBarMessage('<?php echo ext_Lang::msg('upload_completed', true); ?> ', false ); } } }, // Uploader Params "upload_url": "<?php echo _EXT_URL . '/uploadhandler.php'; ?> ", "post_params": { "<?php echo session_name(); ?> ": "<?php echo session_id(); ?> ", "<?php echo get_cfg_var('session.name'); ?> ": "<?php echo session_id(); ?> ", "session_name": "<?php echo session_name(); ?> ", "user_agent": "<?php echo addslashes($_SERVER['HTTP_USER_AGENT']); ?> ", "option": "com_extplorer", "action": "upload", "dir": datastore.directory, "requestType": "xmlhttprequest", "confirm": "true" }, <?php if ($_SERVER['SERVER_NAME'] == 'localhost') { echo '"debug": "true",'; } ?> "flash_url": "<?php echo _EXT_URL; ?> /scripts/extjs3-ext/ux.swfupload/swfupload.swf", "prevent_swf_caching": "false", "file_size_limit": "<?php echo get_max_file_size(); ?> B", // Custom Params "single_file_select": false, // Set to true if you only want to select one file from the FileDialog. "confirm_delete": false, // This will prompt for removing files from queue. "remove_completed": false // Remove file from grid after uploaded. }, { "xtype": "form", "autoScroll": "true", "autoHeight": "true", "id": "uploadform", "fileUpload": true, "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "title": "<?php echo ext_Lang::msg('standardupload'); ?> ", "tooltip": "<?php echo ext_Lang::msg('max_file_size') . ' = <strong>' . get_max_file_size() / 1024 / 1024 . ' MB<\\/strong><br \\/>' . ext_Lang::msg('max_post_size') . ' = <strong>' . get_max_upload_limit() / 1024 / 1024 . ' MB<\\/strong><br \\/>'; ?> ", "frame": true, "items": [ { "xtype": "displayfield", "value": "<?php echo ext_Lang::msg('max_file_size') . ' = <strong>' . get_max_file_size() / 1024 / 1024 . ' MB<\\/strong><br \\/>' . ext_Lang::msg('max_post_size') . ' = <strong>' . get_max_upload_limit() / 1024 / 1024 . ' MB<\\/strong><br \\/>'; ?> " }, <?php for ($i = 0; $i < 7; $i++) { echo '{ "xtype": "fileuploadfield", "fieldLabel": "' . ext_Lang::msg('file', true) . ' ' . ($i + 1) . '", "id": "userfile' . $i . '", "name": "userfile[' . $i . ']", "width":275, "buttonOnly": false },'; } ?> { "xtype": "checkbox", "fieldLabel": "<?php echo ext_Lang::msg('overwrite_files', true); ?> ", "name": "overwrite_files", "checked": true }], "buttons": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('upload_processing', true); ?> ', true ); form = Ext.getCmp("uploadform").getForm(); form.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); Ext.getCmp("dialog").destroy(); }, 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": form, // add some vars to the request, similar to hidden fields "params": { "option": "com_extplorer", "action": "upload", "dir": datastore.directory, "requestType": "xmlhttprequest", "confirm": "true" } }); } }, { "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] }, { "xtype": "form", "id": "transferform", "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "hidden": "true", "title": "<?php echo ext_Lang::msg('acttransfer'); ?> ", "autoHeight": "true", "labelWidth": 225, "frame": true, "items": [ <?php for ($i = 0; $i < 7; $i++) { echo '{ "xtype": "textfield", "fieldLabel": "' . ext_Lang::msg('url_to_file', true) . '", "name": "userfile[' . $i . ']", "width":275 },'; } ?> { "xtype": "checkbox", "fieldLabel": "<?php echo ext_Lang::msg('overwrite_files', true); ?> ", "name": "overwrite_files", "checked": true } ], "buttons": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('transfer_processing', true); ?> ', true ); transfer = Ext.getCmp("transferform").getForm(); transfer.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); Ext.getCmp("dialog").destroy(); }, 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: transfer, // add some vars to the request, similar to hidden fields params: { "option": "com_extplorer", "action": "transfer", "dir": datastore.directory, "confirm": 'true' } }); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] }] } <?php }
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 }
$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': case 'ssh2_authentication': case 'extplorer_authentication': $auth_info = explode('_', $action); $auth_classname = 'ext_' . $action; require_once _EXT_PATH . '/include/authentication/' . $auth_info[0] . '.php'; $auth_plugin = new $auth_classname(); $auth_plugin->onShowLoginForm(); break; default: require_once _EXT_PATH . "/include/list.php"; ext_List::execAction($dir); //------------------------------------------------------------------------------ } // end switch-statement } //------------------------------------------------------------------------------ // Disconnect from ftp server if (ext_isFTPMode() && is_object($GLOBALS['FTPCONNECTION'])) { $GLOBALS['FTPCONNECTION']->disconnect(); } // Empty the output buffer if this is a XMLHttpRequest if (ext_isXHR()) { ext_exit(); }
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 }
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(); }
function is_chmodable($file) { global $isWindows; if ($isWindows) { return true; } if (ext_isFTPMode()) { return $_SESSION['ftp_login'] == $file['user']; } else { return @$GLOBALS['ext_File']->fileowner($file) == @$GLOBALS['ext_File']->geteuid(); } }
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": " " }] },{ "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 }
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; } 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"]);
$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': case 'ssh2_authentication': case 'extplorer_authentication': $auth_info = explode('_', $action); $auth_classname = 'ext_' . $action; require_once _EXT_PATH . '/include/authentication/' . $auth_info[0] . '.php'; $auth_plugin = new $auth_classname(); $auth_plugin->onShowLoginForm(); break; default: require_once _EXT_PATH . "/include/list.php"; ext_List::execAction($dir); //------------------------------------------------------------------------------ } // end switch-statement } //------------------------------------------------------------------------------ // Disconnect from ftp server if (ext_isFTPMode()) { $GLOBALS['FTPCONNECTION']->disconnect(); } // Empty the output buffer if this is a XMLHttpRequest if (ext_isXHR()) { ext_exit(); }
function execAction($dir) { if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('upload', false, $GLOBALS["error_msg"]["accessfunc"]); } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $cnt = count($GLOBALS['__FILES']['userfile']['name']); $err = false; $err_available = isset($GLOBALS['__FILES']['userfile']['error']); // upload files & check for errors for ($i = 0; $i < $cnt; $i++) { $errors[$i] = NULL; $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i]; $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]); if ($err_available) { $up_err = $GLOBALS['__FILES']['userfile']['error'][$i]; } else { $up_err = file_exists($tmp) ? 0 : 4; } $abs = get_abs_item($dir, $items[$i]); if ($items[$i] == "" || $up_err == 4) { continue; } if ($up_err == 1 || $up_err == 2) { $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"]; $err = true; continue; } if ($up_err == 3) { $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"]; $err = true; continue; } if (!@is_uploaded_file($tmp)) { $errors[$i] = $GLOBALS["error_msg"]["uploadfile"]; $err = true; continue; } if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) { $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"]; $err = true; continue; } // Upload $ok = @$GLOBALS['ext_File']->move_uploaded_file($tmp, $abs); if ($ok === false || PEAR::isError($ok)) { $errors[$i] = $GLOBALS["error_msg"]["uploadfile"]; if (PEAR::isError($ok)) { $errors[$i] .= ' [' . $ok->getMessage() . ']'; } $err = true; continue; } else { if (!ext_isFTPMode()) { @$GLOBALS['ext_File']->chmod($abs, 0644); } } } 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('upload', false, $err_msg); } ext_Result::sendResult('upload', true, ext_Lang::msg('upload_completed')); return; } ?> <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('actupload'); ?> </h3> <?php echo '<br /> ' . ext_Lang::msg('max_file_size') . ' = <strong>' . get_max_file_size() / 1024 / 1024 . ' MB</strong><br /> ' . ext_Lang::msg('max_post_size') . ' = <strong>' . get_max_upload_limit() / 1024 / 1024 . ' MB</strong><br />'; ?> <div id="adminForm"> <div id="uploadForm"></div> <div id="transferForm"><h4><?php echo ext_Lang::msg('acttransfer'); ?> </h4></div> </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: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ', fileUpload: true }); simple.add( <?php for ($i = 0; $i < 7; $i++) { echo "new Ext.form.TextField({\n\t\t fieldLabel: '" . ext_Lang::msg('file', true) . ' ' . ($i + 1) . "',\n\t\t name: 'userfile[{$i}]',\n\t\t width:275,\n\t\t inputType: 'file'\n\t\t }),"; } ?> new Ext.form.Checkbox({ fieldLabel: '<?php echo ext_Lang::msg('overwrite_files', true); ?> ', name: 'overwrite_files', checked: true }) ); simple.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( '<?php echo ext_Lang::msg('upload_processing', true); ?> ', true ); simple.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); dialog.destroy(); }, 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: 'upload', dir: datastore.directory, requestType: 'xmlhttprequest', confirm: 'true'} }); }); simple.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.destroy(); } ); simple.render('uploadForm'); var transfer = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); transfer.add( <?php for ($i = 0; $i < 7; $i++) { echo "new Ext.form.TextField({\n\t\t fieldLabel: '" . ext_Lang::msg('url_to_file', true) . "',\n\t\t name: 'userfile[{$i}]',\n\t\t width:275\n\t\t }),"; } ?> new Ext.form.Checkbox({ fieldLabel: '<?php echo ext_Lang::msg('overwrite_files', true); ?> ', name: 'overwrite_files', checked: true }) ); transfer.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( '<?php echo ext_Lang::msg('transfer_processing', true); ?> ', true ); transfer.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); dialog.destroy(); }, 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: transfer, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'transfer', dir: datastore.directory, confirm: 'true' } }); }); transfer.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.destroy(); } ); transfer.render('transferForm'); var tabs = new Ext.TabPanel("adminForm"); tabs.addTab("uploadForm", '<?php echo ext_Lang::msg('actupload', true); ?> '); tabs.addTab("transferForm", '<?php echo ext_Lang::msg('acttransfer', true); ?> '); tabs.activate('uploadForm'); </script> <?php }