//------------------------------------------------------------------------------
 // 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' => ext_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':
 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();
Example #2
0
/**
 * Adds a new bookmark to the bookmark ini file
 *
 * @param string $dir
 */
function ext_modify_bookmark($task, $dir)
{
    global $my, $user, $mainframe;
    $alias = substr(extGetParam($_REQUEST, 'alias'), 0, 150);
    // CSRF Security Check
    if (!ext_checkToken($GLOBALS['__POST']["token"])) {
        ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
    }
    $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 ext_list_bookmarks($dir);
    exit;
}