Ejemplo n.º 1
0
function download_item($dir, $item)
{
    // download file
    // Security Fix:
    $item = basename($item);
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $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($abs_item));
    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');
    }
    @readfile($abs_item);
    exit;
}
Ejemplo n.º 2
0
function download_item($dir, $item)
{
    // Security Fix:
    $item = basename($item);
    while (@ob_end_clean()) {
    }
    ob_start();
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $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);
    @readfile($abs_item);
    ob_end_flush();
    exit;
}
Ejemplo n.º 3
0
function download_item($dir, $item)
{
    // Security Fix:
    $item = basename($item);
    if (!permissions_grant($dir, $item, "read")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    _download($abs_item, $item);
}
Ejemplo n.º 4
0
function download_item($dir, $item)
{
    // download file
    // Security Fix:
    $item = base_name($item);
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $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: ' . get_file_size($dir, $item));
    header('Content-Description: File Download');
    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');
    }
    //@readfile($abs_item);
    flush();
    $fp = popen("tail -c " . get_file_size($dir, $item) . " {$abs_item} 2>&1", "r");
    while (!feof($fp)) {
        // Send the current file part to the browser.
        print fread($fp, 1024);
        // Flush the content to the browser.
        flush();
    }
    fclose($fp);
    exit;
}
Ejemplo n.º 5
0
function _download_items($dir, $items)
{
    // check if user selected any items to download
    _debug("count items: '{$items['0']}'");
    if (count($items) == 0) {
        show_error($GLOBALS["error_msg"]["miscselitems"]);
    }
    // check if user has permissions to download
    // this file
    if (!_is_download_allowed($dir, $items)) {
        show_error($GLOBALS["error_msg"]["accessitem"]);
    }
    // if we have exactly one file and this is a real
    // file we directly download it
    if (count($items) == 1 && get_is_file($dir, $items[0])) {
        $abs_item = get_abs_item($dir, $items[0]);
        _download($abs_item, $items[0]);
    }
    // otherwise we do the zip download
    zip_download(get_abs_dir($dir), $items);
}
Ejemplo n.º 6
0
function get_is_editable($abs_item)
{
    // is this file editable?
    if (!get_is_file($abs_item)) {
        return false;
    }
    if (is_array($abs_item)) {
        $abs_item = $abs_item['name'];
    }
    if (preg_match('/' . $GLOBALS["editable_ext"] . '/i', $abs_item)) {
        return true;
    }
    return strpos(basename($abs_item), ".") ? false : true;
}
Ejemplo n.º 7
0
function copy_move_items($dir)
{
    // copy/move file/dir
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $action = stripslashes(JRequest::getCmd('action'));
    if ($action == "post") {
        $action = JRequest::getCmd("do_action");
    } elseif (empty($action)) {
        $action = "list";
    }
    // Vars
    $first = $GLOBALS['__POST']["first"];
    if ($first == "y") {
        $new_dir = $dir;
    } else {
        $new_dir = stripslashes($GLOBALS['__POST']["new_dir"]);
    }
    if ($new_dir == ".") {
        $new_dir = "";
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    // Copy or Move?
    if ($action != "move") {
        $images = "images/__copy.gif";
    } else {
        $images = "images/__cut.gif";
    }
    // Get New Location & Names
    if (!isset($GLOBALS['__POST']["confirm"]) || $GLOBALS['__POST']["confirm"] != "true") {
        show_header($action != "move" ? $GLOBALS["messages"]["actcopyitems"] : $GLOBALS["messages"]["actmoveitems"]);
        // JavaScript for Form:
        // Select new target directory / execute action
        ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	function NewDir(newdir) {
		document.selform.new_dir.value = newdir;
		document.selform.submit();
	}

	function Execute() {
		document.selform.confirm.value = "true";
	}
//-->
</script><?php 
        // "Copy / Move from .. to .."
        $s_dir = $dir;
        if (strlen($s_dir) > 40) {
            $s_dir = "..." . substr($s_dir, -37);
        }
        $s_ndir = $new_dir;
        if (strlen($s_ndir) > 40) {
            $s_ndir = "..." . substr($s_ndir, -37);
        }
        echo "<br /><img src=\"" . _QUIXPLORER_URL . '/images/' . $images . "\" align=\"absmiddle\" alt=\"\" />&nbsp;<strong>";
        echo sprintf($action != "move" ? $GLOBALS["messages"]["actcopyfrom"] : $GLOBALS["messages"]["actmovefrom"], $s_dir, $s_ndir);
        echo "</strong><img src=\"" . _QUIXPLORER_URL . "/images/__paste.gif\" align=\"absmiddle\" alt=\"\">\n";
        // Form for Target Directory & New Names
        echo "<br /><br /><form name=\"selform\" method=\"post\" action=\"";
        echo make_link("post", $dir, NULL) . "\"><table style=\"width:500px;\" class=\"adminform\">\n";
        echo "<input type=\"hidden\" name=\"do_action\" value=\"" . $action . "\">\n";
        echo "<input type=\"hidden\" name=\"confirm\" value=\"false\">\n";
        echo "<input type=\"hidden\" name=\"first\" value=\"n\">\n";
        echo "<input type=\"hidden\" name=\"new_dir\" value=\"" . $new_dir . "\">\n";
        // List Directories to select Target
        dir_print(dir_list($new_dir), $new_dir);
        echo "</table><br />\n\t\t<table style=\"width:500px;\" class=\"adminform\">\n";
        // Print Text Inputs to change Names
        for ($i = 0; $i < $cnt; ++$i) {
            $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
            if (isset($GLOBALS['__POST']["newitems"][$i])) {
                $newitem = stripslashes($GLOBALS['__POST']["newitems"][$i]);
                if ($first == "y") {
                    $newitem = $selitem;
                }
            } else {
                $newitem = $selitem;
            }
            $s_item = $selitem;
            if (strlen($s_item) > 50) {
                $s_item = substr($s_item, 0, 47) . "...";
            }
            echo "<tr><td><img src=\"" . _QUIXPLORER_URL . "/images/information.png\" align=\"absmiddle\" alt=\"\">";
            // old name
            echo "<input type=\"hidden\" name=\"selitems[]\" value=\"";
            echo $selitem . "\">&nbsp;" . $s_item . "&nbsp;";
            // New Name
            echo "</td><td><input type=\"text\" size=\"25\" name=\"newitems[]\" value=\"";
            echo $newitem . "\"></td></tr>\n";
        }
        // Submit & Cancel
        echo "</table><br /><table><tr>\n<td>";
        echo "<input type=\"submit\" value=\"";
        echo $action != "move" ? $GLOBALS["messages"]["btncopy"] : $GLOBALS["messages"]["btnmove"];
        echo "\" onclick=\"javascript:Execute();\"></td>\n<td>";
        echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"];
        echo "\" onclick=\"javascript:location='" . make_link("list", $dir, NULL);
        echo "';\"></td>\n</tr></table><br /></form>\n";
        return;
    }
    // DO COPY/MOVE
    // ALL OK?
    if (!@$GLOBALS['nx_File']->file_exists(get_abs_dir($new_dir))) {
        show_error(get_abs_dir($new_dir) . ": " . $GLOBALS["error_msg"]["targetexist"]);
    }
    if (!get_show_item($new_dir, "")) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["accesstarget"]);
    }
    if (!down_home(get_abs_dir($new_dir))) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["targetabovehome"]);
    }
    // copy / move files
    $err = false;
    for ($i = 0; $i < $cnt; ++$i) {
        $tmp = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        $new = basename(stripslashes($GLOBALS['__POST']["newitems"][$i]));
        if (nx_isFTPMode()) {
            $abs_item = get_item_info($dir, $tmp);
            $abs_new_item = get_item_info('/' . $new_dir, $new);
        } else {
            $abs_item = get_abs_item($dir, $tmp);
            $abs_new_item = get_abs_item($new_dir, $new);
        }
        $items[$i] = $tmp;
        // Check
        if ($new == "") {
            $error[$i] = $GLOBALS["error_msg"]["miscnoname"];
            $err = true;
            continue;
        }
        if (!@$GLOBALS['nx_File']->file_exists($abs_item)) {
            $error[$i] = $GLOBALS["error_msg"]["itemexist"];
            $err = true;
            continue;
        }
        if (!get_show_item($dir, $tmp)) {
            $error[$i] = $GLOBALS["error_msg"]["accessitem"];
            $err = true;
            continue;
        }
        if (@$GLOBALS['nx_File']->file_exists($abs_new_item)) {
            $error[$i] = $GLOBALS["error_msg"]["targetdoesexist"];
            $err = true;
            continue;
        }
        // Copy / Move
        if ($action == "copy") {
            if (@is_link($abs_item) || get_is_file($abs_item)) {
                // check file-exists to avoid error with 0-size files (PHP 4.3.0)
                if (nx_isFTPMode()) {
                    $abs_item = '/' . $dir . '/' . $abs_item['name'];
                }
                $ok = @$GLOBALS['nx_File']->copy($abs_item, $abs_new_item);
                //||@file_exists($abs_new_item);
            } elseif (@get_is_dir($abs_item)) {
                $dir = nx_isFTPMode() ? '/' . $dir . '/' . $abs_item['name'] . '/' : $abs_item;
                if (nx_isFTPMode()) {
                    $abs_new_item .= '/';
                }
                $ok = $GLOBALS['nx_File']->copy_dir($dir, $abs_new_item);
            }
        } else {
            $ok = $GLOBALS['nx_File']->rename($abs_item, $abs_new_item);
        }
        if ($ok === false || PEAR::isError($ok)) {
            $error[$i] = $action == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            if (PEAR::isError($ok)) {
                $error[$i] .= ' [' . $ok->getMessage() . ']';
            }
            $err = true;
            continue;
        }
        $error[$i] = NULL;
    }
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "<br />\n";
        }
        show_error($err_msg);
    }
    header("Location: " . make_link("list", $dir, NULL));
}
Ejemplo n.º 8
0
/**
 * 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();
}
Ejemplo n.º 9
0
function get_is_editable($abs_item)
{
    // is this file editable?
    if (!get_is_file($abs_item)) {
        return false;
    }
    if (is_array($abs_item)) {
        $abs_item = $abs_item['name'];
    }
    foreach ($GLOBALS["editable_ext"] as $pat) {
        if (@eregi($pat, $abs_item)) {
            return true;
        }
    }
    return strpos(basename($abs_item), ".") ? false : true;
}
Ejemplo n.º 10
0
function get_is_unzipable($dir, $item)
{
    // is this file editable?
    if (!get_is_file($dir, $item)) {
        return false;
    }
    foreach ($GLOBALS["unzipable_ext"] as $pat) {
        if (@eregi($pat, $item)) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 11
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') . '.');
}
Ejemplo n.º 12
0
function print_table($dir, $list)
{
    if (!is_array($list)) {
        return;
    }
    while (list($item, ) = each($list)) {
        // link to dir / file
        $abs_item = get_abs_item($dir, $item);
        $target = "";
        //$extra="";
        //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item);
        if (is_dir($abs_item)) {
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
            //?? CK Hier wird kuenftig immer mit dem download-Link gearbeitet, damit
            //?? CK die Leute links klicken koennen
            //?? CK			$link = $GLOBALS["home_url"]."/".get_rel_item($dir, $item);
            $link = make_link("download", $dir, $item);
            $target = "_blank";
        }
        //else $link = "";
        echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\"";
        echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n";
        // Icon + Link
        echo "<TD nowrap>";
        if (permissions_grant($dir, $item, "read")) {
            echo "<A HREF=\"" . $link . "\">";
        }
        //else echo "<A>";
        echo "<IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\">&nbsp;";
        $s_item = $item;
        if (strlen($s_item) > 50) {
            $s_item = substr($s_item, 0, 47) . "...";
        }
        echo htmlspecialchars($s_item);
        if (permissions_grant($dir, $item, "read")) {
            echo "</A>";
        }
        echo "</TD>\n";
        // ...$extra...
        // Size
        echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n";
        // Type
        echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n";
        // Modified
        echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n";
        // Permissions
        echo "<TD>";
        if (permissions_grant($dir, NULL, "change")) {
            echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\"";
            echo $GLOBALS["messages"]["permlink"] . "\">";
        }
        echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item));
        if (permissions_grant($dir, NULL, "change")) {
            echo "</A>";
        }
        echo "</TD>\n";
        // Actions
        echo "<TD>\n<TABLE>\n";
        // EDIT
        if (get_is_editable($dir, $item)) {
            _print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item);
        } else {
            echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n";
        }
        // DOWNLOAD
        if (get_is_file($dir, $item)) {
            _print_link("download", permissions_grant($dir, $item, "read"), $dir, $item);
        } else {
            echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n";
        }
        echo "</TABLE>\n</TD></TR>\n";
    }
}
Ejemplo n.º 13
0
function print_table($dir, $list, $allow)
{
    // print table of files
    if (!is_array($list)) {
        return;
    }
    while (list($item, ) = each($list)) {
        // link to dir / file
        $abs_item = get_abs_item($dir, $item);
        $target = "";
        //$extra="";
        //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item);
        if (is_dir($abs_item)) {
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
            $link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item);
            $target = "_blank";
        }
        //else $link = "";
        echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\"";
        echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n";
        // Icon + Link
        echo "<TD nowrap>";
        if (get_is_dir($dir, $item)) {
            /*if($link!="") */
            echo "<A HREF=\"" . $link . "\" TARGET=\"" . $target . "\">";
            //else echo "<A>";
        }
        echo "<IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\">&nbsp;";
        $s_item = $item;
        if (strlen($s_item) > 50) {
            $s_item = substr($s_item, 0, 47) . "...";
        }
        echo htmlspecialchars($s_item);
        if (get_is_dir($dir, $item)) {
            echo "</A>";
        }
        echo "</TD>\n";
        // ...$extra...
        // Size
        echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n";
        // Type
        echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n";
        // Modified
        echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n";
        // Permissions
        echo "<TD>";
        if ($allow) {
            echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\"";
            echo $GLOBALS["messages"]["permlink"] . "\">";
        }
        echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item));
        if ($allow) {
            echo "</A>";
        }
        echo "</TD>\n";
        // Actions
        echo "<TD>\n<TABLE>\n";
        // EDIT
        if (get_is_editable($dir, $item)) {
            if ($allow) {
                echo "<TD><A HREF=\"" . make_link("edit", $dir, $item) . "\">";
                echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"_img/_edit.gif\" ALT=\"" . $GLOBALS["messages"]["editlink"] . "\" TITLE=\"";
                echo $GLOBALS["messages"]["editlink"] . "\"></A></TD>\n";
            } else {
                echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"_img/_edit_.gif\" ALT=\"" . $GLOBALS["messages"]["editlink"] . "\" TITLE=\"";
                echo $GLOBALS["messages"]["editlink"] . "\"></TD>\n";
            }
        } else {
            echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n";
        }
        // DOWNLOAD
        if (get_is_file($dir, $item)) {
            if ($GLOBALS["display_file_download_icon"]) {
                if ($allow) {
                    echo "<TD><A HREF=\"" . make_link("download", $dir, $item) . "\">";
                    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                    echo "src=\"_img/_download.gif\" ALT=\"" . $GLOBALS["messages"]["downlink"];
                    echo "\" TITLE=\"" . $GLOBALS["messages"]["downlink"] . "\"></A></TD>\n";
                } else {
                    if (!$allow) {
                        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                        echo "src=\"_img/_download_.gif\" ALT=\"" . $GLOBALS["messages"]["downlink"];
                        echo "\" TITLE=\"" . $GLOBALS["messages"]["downlink"] . "\"></TD>\n";
                    }
                }
            }
        } else {
            echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n";
        }
        echo "</TABLE>\n</TD></TR>\n";
    }
}
Ejemplo n.º 14
0
    function execAction($dir, $item)
    {
        // edit file
        global $mainframe, $mosConfig_live_site;
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('edit', false, ext_Lang::err('accessfunc'));
        }
        $fname = get_abs_item($dir, $item);
        if (!get_is_file(utf8_decode($fname))) {
            ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('fileexist'));
        }
        if (!get_show_item($dir, $item)) {
            ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('accessfile'));
        }
        if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
            // Save / Save As
            $item = basename(stripslashes($GLOBALS['__POST']["fname"]));
            $fname2 = get_abs_item($dir, $item);
            if (!isset($item) || $item == "") {
                ext_Result::sendResult('edit', false, ext_Lang::err('miscnoname'));
            }
            if ($fname != $fname2 && @$GLOBALS['ext_File']->file_exists($fname2)) {
                ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('itemdoesexist'));
            }
            $this->savefile($fname2);
            $fname = $fname2;
            ext_Result::sendResult('edit', true, ext_Lang::msg('savefile') . ': ' . $item);
        }
        // header
        $s_item = get_rel_item($dir, $item);
        if (strlen($s_item) > 50) {
            $s_item = "..." . substr($s_item, -47);
        }
        $s_info = pathinfo($s_item);
        $s_extension = str_replace('.', '', $s_info['extension']);
        switch (strtolower($s_extension)) {
            case 'txt':
                $cp_lang = 'text';
                break;
            case 'cs':
                $cp_lang = 'csharp';
                break;
            case 'css':
                $cp_lang = 'css';
                break;
            case 'html':
            case 'htm':
            case 'xml':
            case 'xhtml':
                $cp_lang = 'html';
                break;
            case 'java':
                $cp_lang = 'java';
                break;
            case 'js':
                $cp_lang = 'javascript';
                break;
            case 'pl':
                $cp_lang = 'perl';
                break;
            case 'ruby':
                $cp_lang = 'ruby';
                break;
            case 'sql':
                $cp_lang = 'sql';
                break;
            case 'vb':
            case 'vbs':
                $cp_lang = 'vbscript';
                break;
            case 'php':
                $cp_lang = 'php';
                break;
            default:
                $cp_lang = 'generic';
        }
        ?>
	<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"]["actedit"] . ": /" . $s_item . '&nbsp;&nbsp;&nbsp;&nbsp;';
        ?>
</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>
	
	<?php 
        // Show File In TextArea
        $content = $GLOBALS['ext_File']->file_get_contents($fname);
        if (get_magic_quotes_runtime()) {
            $content = stripslashes($content);
        }
        //$content = htmlspecialchars( $content );
        ?>
<script type="text/javascript">//<!--
	dialog.setContentSize( 700, 500 );
	simple = new Ext.form.Form({
	    labelAlign: 'top',
	    url:'<?php 
        echo basename($GLOBALS['script_name']);
        ?>
'
	});
	simple.add(		
	    new Ext.form.TextArea({
	        fieldLabel: 'File Contents',
	        name: 'thecode',
	        id: 'ext_codefield',
	        fieldClass: 'x-form-field',
	        value: '<?php 
        echo str_replace(array("\r", "\n", '<', '>'), array('\\r', '\\n', '&lt;', '&gt;'), addslashes($content));
        ?>
',
	        width: '100%',
	        height: 300
	    })		
	);
	simple.column( {width: 250 }, 
		new Ext.form.TextField({
	        fieldLabel: '<?php 
        echo ext_Lang::msg('copyfile', true);
        ?>
',
	        name: 'fname',
	        value: '<?php 
        echo $item;
        ?>
',
	        width:175
		})
	);
	simple.column( {width: 250, style:'margin-left:10px', clear:true }, 
		new Ext.form.Checkbox({
	        fieldLabel: '<?php 
        echo ext_Lang::msg('returndir', true);
        ?>
',
	        name: 'return_to_dir',
	        width:175
		})
	);
	simple.addButton('<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
', function() {
		statusBarMessage( '<?php 
        echo ext_Lang::msg('save_processing', true);
        ?>
', true );

	    simple.submit({
	        //waitMsg: 'Processing Data, please wait...',
	        //reset: true,
	        reset: false,
	        success: function(form, action) {
	        	datastore.reload();
	        	statusBarMessage( action.result.message, false, true );
	        	if( simple.findField('return_to_dir').getValue() ) {
	        		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: simple,
	        // add some vars to the request, similar to hidden fields
	        params: {option: 'com_extplorer', 
	        		action: 'edit', 
	        		code: editAreaLoader.getValue("ext_codefield"),
	        		dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
	        		item: '<?php 
        echo stripslashes($item);
        ?>
', 
	        		dosave: 'yes'
	        }
	    });
	});
	
	simple.addButton('<?php 
        echo ext_Lang::msg('btnclose', true);
        ?>
', function() { dialog.destroy(); } );
	simple.render('adminForm');
	simple.findField('thecode').setValue(simple.findField( 'thecode').getValue().replace( /&gt;/g, '>').replace( /&lt;/g, '<'));
	editAreaLoader.baseURL = "<?php 
        echo _EXT_URL;
        ?>
/scripts/editarea/";
	editAreaLoader.init({
		id : "ext_codefield"		// textarea id
		,syntax: "<?php 
        echo $cp_lang;
        ?>
"			// syntax to be uses for highgliting
		,start_highlight: true		// to display with highlight mode on start-up
		,display: "later"
	});
	editAreaLoader.start("ext_codefield");
	// -->
	</script><?php 
    }
Ejemplo n.º 15
0
function edit_file($dir, $item)
{
    // edit file
    global $mainframe, $mosConfig_live_site;
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $fname = get_abs_item($dir, $item);
    if (!get_is_file($fname)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
        // Save / Save As
        $item = basename(stripslashes($GLOBALS['__POST']["fname"]));
        $fname2 = get_abs_item($dir, $item);
        if (!isset($item) || $item == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        if ($fname != $fname2 && @$GLOBALS['jx_File']->file_exists($fname2)) {
            show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
        }
        savefile($fname2);
        $fname = $fname2;
        if (!empty($GLOBALS['__POST']['return_to'])) {
            $return_to = urldecode($GLOBALS['__POST']['return_to']);
            mosRedirect($return_to);
        } elseif (!empty($GLOBALS['__POST']['return_to_dir'])) {
            mosRedirect($_SERVER['PHP_SELF'] . '?option=com_joomlaxplorer&dir=' . $dir, 'The File ' . $item . ' was saved.');
        }
    }
    // header
    $s_item = get_rel_item($dir, $item);
    if (strlen($s_item) > 50) {
        $s_item = "..." . substr($s_item, -47);
    }
    show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item);
    $s_info = pathinfo($s_item);
    $s_extension = str_replace('.', '', $s_info['extension']);
    switch (strtolower($s_extension)) {
        case 'txt':
            $cp_lang = 'text';
            break;
        case 'cs':
            $cp_lang = 'csharp';
            break;
        case 'css':
            $cp_lang = 'css';
            break;
        case 'html':
        case 'htm':
        case 'xml':
        case 'xhtml':
            $cp_lang = 'html';
            break;
        case 'java':
            $cp_lang = 'java';
            break;
        case 'js':
            $cp_lang = 'javascript';
            break;
        case 'pl':
            $cp_lang = 'perl';
            break;
        case 'ruby':
            $cp_lang = 'ruby';
            break;
        case 'sql':
            $cp_lang = 'sql';
            break;
        case 'vb':
        case 'vbs':
            $cp_lang = 'vbscript';
            break;
        case 'php':
            $cp_lang = 'php';
            break;
        default:
            $cp_lang = 'generic';
    }
    // Form
    echo '<script type="text/javascript" src="components/com_joomlaxplorer/scripts/codepress/codepress.js"></script>';
    echo "<br/><form name=\"editfrm\" id=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n";
    if (!empty($GLOBALS['__GET']['return_to'])) {
        $close_action = 'window.location=\'' . urldecode($GLOBALS['__GET']['return_to']) . '\';';
        echo "<input type=\"hidden\" name=\"return_to\" value=\"" . $GLOBALS['__GET']['return_to'] . "\" />\n";
    } else {
        $close_action = 'window.location=\'' . make_link('list', $dir, NULL) . "'";
    }
    $submit_action = 'document.editfrm.code.value=codearea.getCode();document.editfrm.submit();';
    echo "\r\n<table class=\"adminform\">\r\n\t<tr>\r\n\t\t<td style=\"text-align: center;\">\r\n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnsave"] . "\" onclick=\"{$submit_action}\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n\t\t\t<input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onclick=\"javascript:{$close_action}\" />\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td >\r\n\t\t\t<div id=\"positionIndicator\" style=\"width: 20%;float:left;\">" . $GLOBALS["messages"]["line"] . ": <input type=\"text\" name=\"txtLine\" class=\"inputbox\" size=\"6\" onchange=\"setCaretPosition(document.editfrm.code, this.value);return false;\" />&nbsp;&nbsp;&nbsp;" . $GLOBALS["messages"]["column"] . ": <input type=\"text\" name=\"txtColumn\" class=\"inputbox\" size=\"6\" readonly=\"readonly\" />\r\n          </div>\r\n\t\t\t<div style=\"width:70%;text-align: center;float:left;\">\r\n\t\t\t\t<input type=\"checkbox\" value=\"1\" name=\"return_to_dir\" id=\"return_to_dir\" />\r\n\t\t\t\t<label for=\"return_to_dir\">" . $GLOBALS["messages"]["returndir"] . "</label>\r\n\t\t\t</div>";
    echo "\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr><td>";
    echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\" />\n";
    // Show File In TextArea
    $content = $GLOBALS['jx_File']->file_get_contents($fname);
    if (get_magic_quotes_runtime()) {
        $content = stripslashes($content);
    }
    $content = htmlspecialchars($content);
    echo '[<a href="javascript:;" onclick="positionIndicator.toggle(); codearea.toggleEditor();return false;">' . $GLOBALS['messages']['editor_simple'] . ' / ' . $GLOBALS['messages']['editor_syntaxhighlight'] . '</a>]';
    echo '<div id="editorarea">
		<textarea class="codepress ' . $cp_lang . '" style="width:95%;" name="codearea" id="codearea" rows="25" cols="120" wrap="off" onmouseup="updatePosition(this)" onmousedown="updatePosition(this)" onkeyup="updatePosition(this)" onkeydown="updatePosition(this)" onfocus="updatePosition(this)">' . $content . '</textarea>
		<input type="hidden" name="code" value="" />
		</div><br/>';
    echo "\r\n\t</td>\r\n\t</tr>";
    echo "\r\n\t<tr>\r\n\t\t<td align=\"right\">\r\n\t\t\t<label for=\"fname\">" . $GLOBALS["messages"]["copyfile"] . "</label>\r\n\t\t\t<input type=\"text\" name=\"fname\" value=\"" . $item . "\" size=\"40\" />\r\n\t\t</td>\r\n\t</tr>\r\n</table>\r\n<br/>";
    echo "\r\n</form>\r\n<br/>\n";
    ?>
<script type="text/javascript">
<!--
if(document.editfrm && document.editfrm.code) document.editfrm.code.focus();

positionIndicator = new Fx.Slide( 'positionIndicator' ).hide();

//http://www.bazon.net/mishoo/home.epl?NEWS_ID=1345
function doGetCaretPosition (textarea) {

	var txt = textarea.value;
	var len = txt.length;
	var erg = txt.split("\n");
	var pos = -1;
	if(typeof textarea.selectionStart != "undefined") { // FOR MOZILLA
		pos = textarea.selectionStart;
	}
	else if(typeof document.selection != "undefined") { // FOR MSIE
		range_sel = document.selection.createRange();
		range_obj = textarea.createTextRange();
		range_obj.moveToBookmark(range_sel.getBookmark());
		range_obj.moveEnd('character',textarea.value.length);
		pos = len - range_obj.text.length;
	}
	if(pos != -1) {
		var ind = 0;
		for(;erg.length;ind++) {
			len = erg[ind].length + 1;
			if(pos < len)
			break;
			pos -= len;
		}
		ind++; pos++;
		return [ind, pos]; // ind = LINE, pos = COLUMN

	}
}
/**
* This function allows us to change the position of the caret
* (cursor) in the textarea
* Various workarounds for IE, Firefox and Opera are included
* Firefox doesn't count empty lines, IE does...
*/
function setCaretPosition( textarea, linenum ) {
	if (isNaN(linenum)) {
		updatePosition( textarea );
		return;
	}
	var txt = textarea.value;
	var len = txt.length;
	var erg = txt.split("\n");
		
	var ind = 0;
	var pos = 0;
	var nonempty = -1;
	var empty = -1;
	for(;ind < linenum;ind++) {
		/*alert( "Springe zu Zeile: "+linenum
				+"\naktuelle Zeile: "+ (ind+1) 
				+ "\naktuelle Position: "+pos 
				+ "\nText in dieser Zeile: "+erg[ind]);*/
		if( !erg[ind] && pos < len ) { empty++; pos++; continue; }
		else if( !erg[ind] ) break;
		pos += erg[ind].length;
		nonempty++;
	}
	try {
		pos -= erg[ind-1].length;	
	} catch(e) {}
	
	textarea.focus();
	
	if(textarea.setSelectionRange)
	{
		pos += nonempty;
		textarea.setSelectionRange(pos,pos);
	}
	else if (textarea.createTextRange) {
		pos -= empty;
		var range = textarea.createTextRange();
		range.collapse(true);
		range.moveEnd('character', pos);
		range.moveStart('character', pos);
		
		range.select();
	}
}
/** 
* Updates the Position Indicator fields
*/
function updatePosition(textBox) {
	var posArray = doGetCaretPosition(textBox);
    document.forms[0].txtLine.value = posArray[0];
    document.forms[0].txtColumn.value = posArray[1];
}
// -->
</script><?php 
}
Ejemplo n.º 16
0
/**
 print table of files
*/
function print_table($dir, $list)
{
    if (!is_array($list)) {
        return;
    }
    while (list($item) = each($list)) {
        // link to dir / file
        $abs_item = get_abs_item($dir, $item);
        $target = "";
        if (is_dir($abs_item)) {
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            $link = make_link("download", $dir, $item);
            $target = "_blank";
        }
        echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\"";
        echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n";
        // Icon + Link
        echo "<TD nowrap>";
        if (permissions_grant($dir, $item, "read")) {
            echo "<A HREF=\"" . $link . "\">";
        }
        //else echo "<A>";
        echo "<IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\">&nbsp;";
        $s_item = $item;
        if (strlen($s_item) > 50) {
            $s_item = substr($s_item, 0, 47) . "...";
        }
        echo htmlspecialchars($s_item);
        if (permissions_grant($dir, $item, "read")) {
            echo "</A>";
        }
        echo "</TD>\n";
        // ...$extra...
        // Size
        echo '<TD>' . parse_file_size(get_file_size($dir, $item)) . sprintf("%10s", "&nbsp;") . "</TD>\n";
        // Type
        echo "<td>" . _get_link_info($dir, $item, "type") . "</td>\n";
        // Modified
        echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n";
        // Permissions
        echo "<TD>";
        if (permissions_grant($dir, NULL, "change")) {
            echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\"";
            echo $GLOBALS["messages"]["permlink"] . "\">";
        }
        echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item));
        if (permissions_grant($dir, NULL, "change")) {
            echo "</A>";
        }
        echo "</TD>\n";
        // Actions
        echo "<TD>\n<TABLE>\n";
        // EDIT
        if (get_is_editable($dir, $item)) {
            _print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item);
        } else {
            // UNZIP
            if (get_is_unzipable($dir, $item)) {
                _print_link("unzip", permissions_grant($dir, $item, "create"), $dir, $item);
            } else {
                echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
            }
        }
        // DOWNLOAD
        if (get_is_file($dir, $item)) {
            _print_link("download", permissions_grant($dir, $item, "read"), $dir, $item);
        } else {
            echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
        }
        echo "</TABLE>\n</TD></TR>\n";
    }
}
Ejemplo n.º 17
0
function print_table($dir, $list)
{
    if (!is_array($list)) {
        return;
    }
    while (list($item, ) = each($list)) {
        // link to dir / file
        $abs_item = get_abs_item($dir, $item);
        $target = "";
        //$extra="";
        //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item);
        if (is_dir($abs_item)) {
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
            //?? CK Hier wird kuenftig immer mit dem download-Link gearbeitet, damit
            //?? CK die Leute links klicken koennen
            //?? CK			$link = $GLOBALS["home_url"]."/".get_rel_item($dir, $item);
            $link = make_link("download", $dir, $item);
            $target = "_blank";
        }
        //else $link = "";
        if ($item == 'hn') {
            echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\"";
            echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n";
            // Icon + Link
            echo "<TD nowrap>";
            if (permissions_grant($dir, $item, "read")) {
                echo "<A HREF=\"" . $link . "\">";
            }
            //else echo "<A>";
            echo "<IMG border=\"0\" width=\"16\" height=\"16\" ";
            echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\">&nbsp;";
            $s_item = $item;
            if (strlen($s_item) > 50) {
                $s_item = substr($s_item, 0, 47) . "...";
            }
            echo htmlspecialchars($s_item);
            if (permissions_grant($dir, $item, "read")) {
                echo "</A>";
            }
            echo "</TD>\n";
            // ...$extra...
            // Size
            echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n";
            // Type
            echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n";
            // Modified
            echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n";
            // Permissions
            /*
            echo "<TD>";
            if (permissions_grant($dir, NULL, "change")) {
              echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\"";
              echo $GLOBALS["messages"]["permlink"] . "\">";
            }
            echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item));
            if (permissions_grant($dir, NULL, "change"))
              echo "</A>";
            echo "</TD>\n";
            */
            // Actions
            echo "<TD>\n<TABLE>\n";
            // EDIT
            if (get_is_editable($dir, $item)) {
                //_print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item);
                echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
            } else {
                // UNZIP
                if (get_is_unzipable($dir, $item)) {
                    _print_link("unzip", permissions_grant($dir, $item, "create"), $dir, $item);
                } else {
                    echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                    echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
                }
            }
            // DOWNLOAD
            if (get_is_file($dir, $item)) {
                //_print_link("download", permissions_grant($dir, $item, "read"), $dir, $item);
                echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
            } else {
                echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
            }
            echo "</TABLE>\n</TD></TR>\n";
        } else {
            if ($dir == 'hn') {
                echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\"";
                echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n";
                // Icon + Link
                echo "<TD nowrap>";
                if (permissions_grant($dir, $item, "read")) {
                    echo "";
                }
                //else echo "<A>";
                echo "<IMG border=\"0\" width=\"16\" height=\"16\" ";
                echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\">&nbsp;";
                $s_item = $item;
                if (strlen($s_item) > 50) {
                    $s_item = substr($s_item, 0, 47) . "...";
                }
                echo htmlspecialchars($s_item);
                if (permissions_grant($dir, $item, "read")) {
                    if (get_mime_type($dir, $item, "type") == 'Directory') {
                        echo '<span style="display:inline-block;padding:0 5px"></span>| Kopírovať slug pre vydanie: <input type="text" onclick="this.focus();this.select();" readonly="readonly" value="' . $item . '" style="border:1px solid #aaa">';
                    }
                }
                echo "";
                echo "</TD>\n";
                // ...$extra...
                // Size
                echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n";
                // Type
                echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n";
                // Modified
                echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n";
                // Permissions
                /*
                echo "<TD>";
                if (permissions_grant($dir, NULL, "change")) {
                  echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\"";
                  echo $GLOBALS["messages"]["permlink"] . "\">";
                }
                echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item));
                if (permissions_grant($dir, NULL, "change"))
                  echo "</A>";
                echo "</TD>\n";
                */
                // Actions
                echo "<TD>\n<TABLE>\n";
                // EDIT
                if (get_is_editable($dir, $item)) {
                    //_print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item);
                    echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                    echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
                } else {
                    // UNZIP
                    if (get_is_unzipable($dir, $item)) {
                        _print_link("unzip", permissions_grant($dir, $item, "create"), $dir, $item);
                    } else {
                        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                        echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
                    }
                }
                // DOWNLOAD
                if (get_is_file($dir, $item)) {
                    //_print_link("download", permissions_grant($dir, $item, "read"), $dir, $item);
                    echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                    echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
                } else {
                    echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                    echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n";
                }
                echo "</TABLE>\n</TD></TR>\n";
            }
        }
    }
}
Ejemplo n.º 18
0
function print_table($dir, $list, $allow)
{
    // print table of files
    global $dir_up;
    if (!is_array($list)) {
        return;
    }
    if ($dir != "" || strstr($dir, _QUIXPLORER_PATH)) {
        echo "<tr class=\"row1\">\n\t  \t\t\t<td>&nbsp;</td>\n\t  \t\t\t<td valign=\"baseline\">\n\t  \t\t\t\t<a href=\"" . make_link("list", $dir_up, NULL) . "\">\n\t  \t\t\t\t<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_up.png\" alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"/>&nbsp;&nbsp;..</a>\n\t  \t\t\t</td>\n\t  \t\t\t<td>&nbsp;</td>\n\t  \t\t\t<td>&nbsp;</td>\n\t  \t\t\t<td>&nbsp;</td>\n\t  \t\t\t<td>&nbsp;</td>\n\t  \t\t\t<td>&nbsp;</td>";
        if (extension_loaded("posix")) {
            echo "<td>&nbsp;</td>";
        }
        echo "</tr>";
    }
    $i = 0;
    $toggle = false;
    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($dir, $item);
            $file_info = @stat($abs_item);
        }
        $is_writable = @$GLOBALS['jx_File']->is_writable($abs_item);
        $is_chmodable = @$GLOBALS['jx_File']->is_chmodable($abs_item);
        $is_readable = @$GLOBALS['jx_File']->is_readable($abs_item);
        $is_deletable = @$GLOBALS['jx_File']->is_deletable($abs_item);
        $target = "";
        $extra = "";
        if (@$GLOBALS['jx_File']->is_link($abs_item)) {
            $extra = " -> " . @readlink($abs_item);
        }
        if (@get_is_dir($abs_item, '')) {
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            if (get_is_editable($abs_item) && $is_writable) {
                $link = make_link('edit', $dir, $item);
            } elseif ($is_readable) {
                if (strstr(get_abs_dir($dir), $GLOBALS['mosConfig_absolute_path']) && !$GLOBALS['jx_File']->is_link($abs_item)) {
                    $link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item);
                    $target = '_blank';
                } else {
                    $link = make_link('download', $dir, $item);
                }
            }
        }
        if (jx_isIE()) {
            echo '<tr onmouseover="style.backgroundColor=\'#D8ECFF\';" onmouseout="style.backgroundColor=\'#EAECEE\';" bgcolor=\'#EAECEE\'>';
        } else {
            $toggle = $toggle ? '1' : '0';
            echo "<tr class=\"row{$toggle}\">";
            $toggle = !$toggle;
        }
        echo "<td><input type=\"checkbox\" id=\"item_{$i}\" name=\"selitems[]\" value=\"";
        echo urlencode($item) . "\" onclick=\"javascript:Toggle(this);\" /></td>\n";
        // Icon + Link
        echo "<td nowrap=\"nowrap\" align=\"left\">";
        if ($is_readable) {
            echo "<a href=\"" . $link . "\" target=\"" . $target . "\">";
        }
        //else echo "<<>";
        echo "<img border=\"0\" width=\"22\" height=\"22\" ";
        echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/" . get_mime_type($abs_item, "img") . "\" alt=\"\" />&nbsp;";
        $s_item = $item;
        if (strlen($s_item) > 50) {
            $s_item = substr($s_item, 0, 47) . "...";
        }
        echo htmlspecialchars($s_item . $extra);
        if ($is_readable) {
            echo "</a>";
            // ...$extra...
        }
        echo "</td>\n";
        // Size
        echo "<td>" . parse_file_size(get_file_size($abs_item)) . "</td>\n";
        // type
        echo "<td>" . get_mime_type($abs_item, "type") . "</td>\n";
        // modified
        echo "<td>" . parse_file_date(get_file_date($abs_item)) . "</td>\n";
        // permissions
        echo "<td>";
        if ($allow && $is_chmodable) {
            echo "<a href=\"" . make_link("chmod", $dir, $item) . "\" title=\"";
            echo $GLOBALS["messages"]["permlink"] . "\">";
        }
        $perms = get_file_perms($abs_item);
        if (strlen($perms) > 3) {
            $perms = substr($perms, 2);
        }
        echo '<strong>' . $perms . '</strong><br />' . parse_file_type($dir, $item) . parse_file_perms($perms);
        if ($allow && $is_chmodable) {
            echo "</a>";
        }
        echo "</td>\n";
        // Owner
        error_reporting(E_ALL);
        if (extension_loaded("posix")) {
            echo "<td>\n";
            $user_info = posix_getpwuid($file_info["uid"]);
            $group_info = posix_getgrgid($file_info["gid"]);
            echo $user_info["name"] . " (" . $file_info["uid"] . ") /<br/>";
            echo $group_info["name"] . " (" . $file_info["gid"] . ")";
            echo "</td>\n";
        }
        // actions
        echo "<td style=\"white-space:nowrap;\">\n";
        // Rename
        // A file that could be deleted can also be renamed
        if ($allow && $is_deletable) {
            echo "<a href=\"" . make_link("rename", $dir, $item) . "\">";
            echo "<img border=\"0\" width=\"22\" height=\"22\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/_rename.gif\" alt=\"" . $GLOBALS["messages"]["renamelink"] . "\" title=\"";
            echo $GLOBALS["messages"]["renamelink"] . "\" /></a>\n";
        } else {
            echo "<img border=\"0\" width=\"22\" height=\"22\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/_rename_.gif\" alt=\"" . $GLOBALS["messages"]["renamelink"] . "\" title=\"";
            echo $GLOBALS["messages"]["renamelink"] . "\" />\n";
        }
        // EDIT
        if (get_is_editable($abs_item)) {
            if ($allow && $is_writable) {
                echo "<a href=\"" . make_link("edit", $dir, $item) . "\">";
                echo "<img border=\"0\" width=\"22\" height=\"22\" ";
                echo "src=\"" . _QUIXPLORER_URL . "/images/_edit.png\" alt=\"" . $GLOBALS["messages"]["editlink"] . "\" title=\"";
                echo $GLOBALS["messages"]["editlink"] . "\" /></a>\n";
            } else {
                echo "<img border=\"0\" width=\"22\" height=\"22\" ";
                echo "src=\"" . _QUIXPLORER_URL . "/images/_edit_.png\" alt=\"" . $GLOBALS["messages"]["editlink"] . "\" title=\"";
                echo $GLOBALS["messages"]["editlink"] . "\" />\n";
            }
        } else {
            // Extract Link
            if (jx_isArchive($item) && !jx_isFTPMode()) {
                echo "<a ";
                echo "onclick=\"javascript: ClearAll();if( confirm('" . $GLOBALS["messages"]["extract_warning"] . "') ) { return true } else { return false;}\" ";
                echo "href=\"" . make_link("extract", $dir, $item) . "\" title=\"" . $GLOBALS["messages"]["extractlink"] . "\">";
                echo "<img border=\"0\" width=\"22\" height=\"20\" ";
                echo "src=\"" . _QUIXPLORER_URL . "/images/_extract.png\" alt=\"" . $GLOBALS["messages"]["extractlink"];
                echo "\" title=\"" . $GLOBALS["messages"]["extractlink"] . "\" /></a>\n";
            } else {
                echo "<img border=\"0\" width=\"16\" height=\"16\" ";
                echo "src=\"" . _QUIXPLORER_URL . "/images/_.gif\" alt=\"\" />\n";
            }
        }
        // VIEW
        if (get_is_editable($abs_item) && $GLOBALS['jx_File']->is_readable($abs_item) && get_is_file($abs_item)) {
            $link = str_replace('/index2.php', '/index3.php', make_link("view", $dir, $item));
            $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=750,height=580,directories=no,location=no,screenX=100,screenY=100';
            echo "<a href=\"" . $link . "\" onclick=\"window.open('{$link}','win2','{$status}'); return false;\" title=\"" . $GLOBALS["messages"]["viewlink"] . "\">";
            echo "<img border=\"0\" width=\"22\" height=\"22\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/src.gif\" alt=\"" . $GLOBALS["messages"]["viewlink"] . "\" /></a>\n";
        }
        // DOWNLOAD / Extract
        if (get_is_file($abs_item)) {
            if ($allow) {
                echo "<a href=\"" . make_link("download", $dir, $item) . "\" title=\"" . $GLOBALS["messages"]["downlink"] . "\">";
                echo "<img border=\"0\" width=\"22\" height=\"22\" ";
                echo "src=\"" . _QUIXPLORER_URL . "/images/_download.png\" alt=\"" . $GLOBALS["messages"]["downlink"];
                echo "\" title=\"" . $GLOBALS["messages"]["downlink"] . "\" /></a>\n";
            } else {
                if (!$allow) {
                    echo "<td><img border=\"0\" width=\"22\" height=\"22\" ";
                    echo "src=\"" . _QUIXPLORER_URL . "/images/_download_.png\" alt=\"" . $GLOBALS["messages"]["downlink"];
                    echo "\" title=\"" . $GLOBALS["messages"]["downlink"] . "\" />\n";
                }
            }
        } else {
            echo "<img border=\"0\" width=\"16\" height=\"16\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/_.gif\" alt=\"\" />\n";
        }
        // DELETE
        if (get_is_file($abs_item)) {
            if ($allow && $GLOBALS['jx_File']->is_deletable($abs_item)) {
                $confirm_msg = sprintf($GLOBALS["messages"]["confirm_delete_file"], $item);
                echo "<a name=\"link_item_{$i}\" href=\"#link_item_{$i}\" title=\"" . $GLOBALS["messages"]["dellink"] . "\" \n\t\t\t\tonclick=\"javascript: ClearAll(); getElementById('item_{$i}').checked = true; if( confirm('" . $confirm_msg . "') ) { document.selform.do_action.value='delete'; document.selform.submit(); } else {  getElementById('item_{$i}').checked = false; return false;}\">";
                echo "<img border=\"0\" width=\"22\" height=\"22\" ";
                echo "src=\"" . _QUIXPLORER_URL . "/images/_delete.gif\" alt=\"" . $GLOBALS["messages"]["dellink"];
                echo "\" title=\"" . $GLOBALS["messages"]["dellink"] . "\" /></a>\n";
            } else {
                echo "<img border=\"0\" width=\"22\" height=\"22\" ";
                echo "src=\"" . _QUIXPLORER_URL . "/images/_delete_.gif\" alt=\"" . $GLOBALS["messages"]["dellink"];
                echo "\" title=\"" . $GLOBALS["messages"]["dellink"] . "\" />\n";
            }
        } else {
            echo "<img border=\"0\" width=\"16\" height=\"16\" ";
            echo "src=\"" . _QUIXPLORER_URL . "/images/_.gif\" alt=\"\" />\n";
        }
        echo "</td></tr>\n";
        $i++;
    }
}
Ejemplo n.º 19
0
    function execAction($dir, $item)
    {
        // edit file
        global $mainframe, $mosConfig_live_site;
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('edit', false, ext_Lang::err('accessfunc'));
        }
        $fname = ext_TextEncoding::fromUTF8(get_abs_item($dir, $item));
        if (!get_is_file($fname)) {
            ext_Result::sendResult('edit', false, ext_TextEncoding::toUTF8($item) . ": " . ext_Lang::err('fileexist'));
        }
        if (!get_show_item($dir, $item)) {
            ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('accessfile'));
        }
        if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
            // Save / Save As
            $item = basename(stripslashes($GLOBALS['__POST']["fname"]));
            $fname2 = ext_TextEncoding::fromUTF8(get_abs_item($dir, $item));
            if (!isset($item) || $item == "") {
                ext_Result::sendResult('edit', false, ext_Lang::err('miscnoname'));
            }
            if ($fname != $fname2 && @$GLOBALS['ext_File']->file_exists($fname2)) {
                ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('itemdoesexist'));
            }
            $this->savefile($fname2);
            $fname = $fname2;
            ext_Result::sendResult('edit', true, ext_Lang::msg('savefile') . ': ' . $item);
        }
        if (isset($GLOBALS['__POST']["doreopen"]) && $GLOBALS['__POST']["doreopen"] == "yes") {
            // File Reopen
            $extra = array();
            $content = $GLOBALS['ext_File']->file_get_contents($fname);
            if (get_magic_quotes_runtime()) {
                $content = stripslashes($content);
            }
            $langs = $GLOBALS["language"];
            if ($langs == "japanese") {
                $_encoding = $GLOBALS['__POST']["file_encoding"];
                if ($content) {
                    $content = mb_convert_encoding($content, "UTF-8", $_encoding);
                }
                $extra["file_encoding"] = $_encoding;
            }
            $extra["content"] = $content;
            ext_Result::sendResult('edit', true, ext_Lang::msg('reopenfile') . ': ' . $item, $extra);
        }
        // header
        $s_item = get_rel_item($dir, $item);
        if (strlen($s_item) > 50) {
            $s_item = "..." . substr($s_item, -47);
        }
        $id_hash = substr('f' . md5($s_item), 0, 10);
        $s_info = pathinfo($s_item);
        $s_extension = str_replace('.', '', $s_info['extension']);
        switch (strtolower($s_extension)) {
            case 'txt':
                $cp_lang = 'text';
                break;
            case 'cs':
                $cp_lang = 'csharp';
                break;
            case 'css':
                $cp_lang = 'css';
                break;
            case 'html':
            case 'htm':
            case 'xhtml':
                $cp_lang = 'html';
                break;
            case 'java':
                $cp_lang = 'java';
                break;
            case 'js':
                $cp_lang = 'js';
                break;
            case 'pl':
                $cp_lang = 'perl';
                break;
            case 'py':
                $cp_lang = 'python';
                break;
            case 'ruby':
                $cp_lang = 'ruby';
                break;
            case 'sql':
                $cp_lang = 'sql';
                break;
            case 'vb':
            case 'vbs':
                $cp_lang = 'vb';
                break;
            case 'php':
                $cp_lang = 'php';
                break;
            case 'xml':
                $cp_lang = 'xml';
                break;
            default:
                $cp_lang = '';
        }
        $content = $GLOBALS['ext_File']->file_get_contents($fname);
        if (get_magic_quotes_runtime()) {
            $content = stripslashes($content);
        }
        $cw = 250;
        $langs = $GLOBALS["language"];
        if ($langs == "japanese") {
            $cw = 200;
            if ($content) {
                $_encoding = strtoupper(mb_detect_encoding($content, array("ASCII", "ISO-2022-JP", "UTF-8", "EUCJP-WIN", "SJIS-WIN"), true));
                $content = mb_convert_encoding($content, "UTF-8", $_encoding);
                if ($_encoding == "SJIS-WIN") {
                    $_encoding_label = "SJIS";
                } elseif ($_encoding == "EUCJP-WIN") {
                    $_encoding_label = "EUC-JP";
                } elseif ($_encoding == "ISO-2022-JP") {
                    $_encoding_label = "JIS";
                } elseif ($_encoding == "ASCII") {
                    $_encoding_label = "UTF-8";
                } else {
                    $_encoding_label = $_encoding;
                }
            } else {
                $_encoding_label = "UTF-8";
            }
        }
        ?>
{
	"xtype": "form",
	"id": "<?php 
        echo $id_hash;
        ?>
",
	"labelWidth": "300",
	"autoScroll": "true", 
	"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
	"title": "<?php 
        echo strlen($s_item) > 50 ? substr($s_item, strlen($s_item) - 30, 30) : $s_item;
        ?>
",
	"frame": "true",
	"closable": "true",
	"tbar": [{
 		"text": "<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( '<?php 
        echo ext_Lang::msg('save_processing', true);
        ?>
', true );
			form = Ext.getCmp("<?php 
        echo $id_hash;
        ?>
").getForm();
			form.submit({
				waitMsg: 'Saving the File, please wait...',
				reset: false,
				success: function(form, action) {
					datastore.reload();
					statusBarMessage( action.result.message, false, true );
				},
				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,
				// add some vars to the request, similar to hidden fields
				params: {option: 'com_extplorer', 
						action: 'edit', 
						code: editAreaLoader.getValue("ext_codefield<?php 
        echo $id_hash;
        ?>
"),
						dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
						item: '<?php 
        echo stripslashes($item);
        ?>
', 
						dosave: 'yes'
				}
			});
		},
        "cls":"x-btn-text-icon",
        "icon": "<?php 
        echo _EXT_URL;
        ?>
/images/_save.png"
    },{
		"text": "<?php 
        echo ext_Lang::msg('btnreopen', true);
        ?>
", 
		"handler": function() { 
			statusBarMessage( '<?php 
        echo ext_Lang::msg('reopen_processing', true);
        ?>
', true );
			form = Ext.getCmp("<?php 
        echo $id_hash;
        ?>
").getForm();
			form.submit({
				waitMsg: 'Processing Data, please wait...',
				reset: false,
				success: function(form, action) {
					statusBarMessage( action.result.message, false, true );
					editAreaLoader.setValue("ext_codefield<?php 
        echo $id_hash;
        ?>
", action.result.content);
				},
				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,
				// add some vars to the request, similar to hidden fields
				params: {
					option: 'com_extplorer', 
					action: 'edit', 
					dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
					item: '<?php 
        echo stripslashes($item);
        ?>
', 
					doreopen: 'yes'
				}
			});
		},	
        "cls":"x-btn-text-icon",
        "icon": "<?php 
        echo _EXT_URL;
        ?>
/images/_reload.png"
    },
    {
    	"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { 
			Ext.getCmp("mainpanel").remove( Ext.getCmp("mainpanel").getActiveTab() );
		},
        "cls":"x-btn-text-icon",
        "icon": "<?php 
        echo _EXT_URL;
        ?>
/images/_cancel.png"
	}],	
	"items": [{
		"xtype": "displayfield",
		"value": "<?php 
        echo $GLOBALS["messages"]["actedit"] . ": {$s_item}";
        ?>
"
		},
		{
		"xtype": "textarea",
		"hideLabel": true,
		"name": "thecode",
		"id": "ext_codefield<?php 
        echo $id_hash;
        ?>
",
		"fieldClass": "x-form-field",
		"value": "<?php 
        echo str_replace(array("\r", "\n"), array('\\r', '\\n'), addslashes($content));
        ?>
",
		"width": "100%",
		"height": 500,
		"plugins": new Ext.ux.plugins.EditAreaEditor({
			"id" : "ext_codefield<?php 
        echo $id_hash;
        ?>
",	
			"syntax": "<?php 
        echo $cp_lang;
        ?>
",
			"start_highlight": true,
			"display": "later",
			"toolbar": "search, go_to_line, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, |, help" 
			<?php 
        if (array_key_exists($langs, $this->lang_tbl)) {
            ?>
				,"language": "<?php 
            echo $this->lang_tbl[$langs];
            ?>
"
				<?php 
        }
        ?>
		})
	},
	{
		
			"width": "<?php 
        echo $cw;
        ?>
", 
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('copyfile', true);
        ?>
",
			"name": "fname",
			"value": "<?php 
        echo $item;
        ?>
",
			"clear": "true"
			}
<?php 
        if ($langs == "japanese") {
            ?>
			,{
			 "width": "<?php 
            echo $cw;
            ?>
",  
			 "style":"margin-left:10px", 
			 "clear":"true",
			"xtype": "combo",
			"fieldLabel": "<?php 
            echo ext_Lang::msg('fileencoding', true);
            ?>
",
			"name": "file_encoding",
			"store": [
						["UTF-8", "UTF-8"],
						["SJIS-WIN", "SJIS"],
						["EUCJP-WIN", "EUC-JP"],
						["ISO-2022-JP","JIS"]
					],
			"value" : "<?php 
            echo $_encoding_label;
            ?>
",
			"typeAhead": "true",
			"mode": "local",
			"triggerAction": "all",
			"editable": "false",
			"forceSelection": "true"
			}
	
<?php 
        }
        ?>
		]

}
	
<?php 
    }
Ejemplo n.º 20
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 
    }
Ejemplo n.º 21
0
function edit_file($dir, $item)
{
    // edit file
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $fname = get_abs_item($dir, $item);
    if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
        // Save / Save As
        $item = base_name(stripslashes($GLOBALS['__POST']["fname"]));
        $fname2 = get_abs_item($dir, $item);
        if (!isset($item) || $item == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        if ($fname != $fname2 && @file_exists($fname2)) {
            show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
        }
        savefile($fname2);
        $fname = $fname2;
    }
    // open file
    $fp = @fopen($fname, "r");
    if ($fp === false) {
        show_error($item . ": " . $GLOBALS["error_msg"]["openfile"]);
    }
    // header
    $s_item = get_rel_item($dir, $item);
    if (strlen($s_item) > 50) {
        $s_item = "..." . substr($s_item, -47);
    }
    show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item);
    // Wordwrap (works only in IE)
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	function chwrap() {
		if(document.editfrm.wrap.checked) {
			document.editfrm.code.wrap="soft";
		} else {
			document.editfrm.code.wrap="off";
		}
	}
// -->
</script><?php 
    // Form
    echo "<BR><FORM name=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n";
    echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\">\n";
    echo "<TEXTAREA NAME=\"code\" rows=\"25\" cols=\"120\" wrap=\"off\">";
    // Show File In TextArea
    $buffer = "";
    while (!feof($fp)) {
        $buffer .= fgets($fp, 4096);
    }
    @fclose($fp);
    echo htmlspecialchars($buffer);
    echo "</TEXTAREA><BR>\n<TABLE><TR><TD>Wordwrap: (IE only)</TD><TD><INPUT type=\"checkbox\" name=\"wrap\" ";
    echo "onClick=\"javascript:chwrap();\" value=\"1\"></TD></TR></TABLE><BR>\n";
    echo "<TABLE><TR><TD><INPUT type=\"text\" name=\"fname\" value=\"" . $item . "\"></TD>";
    echo "<TD><input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnsave"];
    echo "\"></TD>\n<TD><input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\"></TD>\n<TD>";
    echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onClick=\"javascript:location='";
    echo make_link("list", $dir, NULL) . "';\"></TD></TR></FORM></TABLE><BR>\n";
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	if(document.editfrm) document.editfrm.code.focus();
// -->
</script><?php 
}
Ejemplo n.º 22
0
function edit_file($dir, $item)
{
    // edit file
    $mainframe =& JFactory::getApplication();
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $fname = get_abs_item($dir, $item);
    if (!get_is_file($fname)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
        // Save / Save As
        $item = basename(stripslashes($GLOBALS['__POST']["fname"]));
        $fname2 = get_abs_item($dir, $item);
        if (!isset($item) || $item == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        if ($fname != $fname2 && @$GLOBALS['nx_File']->file_exists($fname2)) {
            show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
        }
        savefile($fname2);
        $fname = $fname2;
        if (!empty($GLOBALS['__POST']['return_to'])) {
            $return_to = urldecode($GLOBALS['__POST']['return_to']);
            $mainframe->redirect($return_to);
        } elseif (!empty($GLOBALS['__POST']['return_to_dir'])) {
            $mainframe->redirect($_SERVER['PHP_SELF'] . '?option=com_osefileman&dir=' . $dir, 'The File ' . $item . ' was saved.');
        }
    }
    // header
    $s_item = get_rel_item($dir, $item);
    if (strlen($s_item) > 50) {
        $s_item = "..." . substr($s_item, -47);
    }
    show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item);
    $s_info = pathinfo($s_item);
    $s_extension = str_replace('.', '', $s_info['extension']);
    switch (strtolower($s_extension)) {
        case 'txt':
        case 'ini':
            $cp_lang = 'text';
            break;
        case 'cs':
            $cp_lang = 'csharp';
            break;
        case 'css':
            $cp_lang = 'css';
            break;
        case 'html':
        case 'htm':
        case 'xml':
        case 'xhtml':
            $cp_lang = 'html';
            break;
        case 'java':
            $cp_lang = 'java';
            break;
        case 'js':
            $cp_lang = 'javascript';
            break;
        case 'pl':
            $cp_lang = 'perl';
            break;
        case 'ruby':
            $cp_lang = 'ruby';
            break;
        case 'sql':
            $cp_lang = 'sql';
            break;
        case 'vb':
        case 'vbs':
            $cp_lang = 'vbscript';
            break;
        case 'php':
            $cp_lang = 'php';
            break;
        default:
            $cp_lang = 'generic';
    }
    // Form
    echo '<script type="text/javascript" src="components/com_osefileman/scripts/codepress/codepress.js"></script>';
    echo "<br/><form name=\"editfrm\" id=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n";
    if (!empty($GLOBALS['__GET']['return_to'])) {
        $close_action = 'window.location=\'' . urldecode($GLOBALS['__GET']['return_to']) . '\';';
        echo "<input type=\"hidden\" name=\"return_to\" value=\"" . $GLOBALS['__GET']['return_to'] . "\" />\n";
    } else {
        $close_action = 'window.location=\'' . make_link('list', $dir, NULL) . "'";
    }
    $submit_action = ' document.editfrm.code.value=codearea_ta.getCode();document.editfrm.submit();';
    echo "\n<table class=\"adminform\">\n\t<tr>\n\t\t<td style=\"text-align: center;\">\n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnsave"] . "\" onclick=\"{$submit_action}\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n\t\t\t<input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onclick=\"javascript:{$close_action}\" />\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td >\n\t\t\t<div id=\"positionIndicator\" style=\"width: 20%;float:left;\">" . $GLOBALS["messages"]["line"] . ": <input type=\"text\" name=\"txtLine\" class=\"inputbox\" size=\"6\" onchange=\"setCaretPosition(document.editfrm.code, this.value);return false;\" />&nbsp;&nbsp;&nbsp;" . $GLOBALS["messages"]["column"] . ": <input type=\"text\" name=\"txtColumn\" class=\"inputbox\" size=\"6\" readonly=\"readonly\" />\n          </div>\n\t\t\t<div style=\"width:70%;text-align: center;float:left;\">\n\t\t\t\t<input type=\"checkbox\" value=\"1\" name=\"return_to_dir\" id=\"return_to_dir\" />\n\t\t\t\t<label for=\"return_to_dir\">" . $GLOBALS["messages"]["returndir"] . "</label>\n\t\t\t</div>";
    echo "\n\t\t</td>\n\t</tr>\n\t<tr><td>";
    echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\" />\n";
    // Show File In TextArea
    $content = $GLOBALS['nx_File']->file_get_contents($fname);
    if (get_magic_quotes_runtime()) {
        $content = stripslashes($content);
    }
    $content = htmlspecialchars($content);
    echo '[<a href="javascript:;" onclick="positionIndicator.toggle(); codearea_ta.toggleEditor();return false;">' . $GLOBALS['messages']['editor_simple'] . ' / ' . $GLOBALS['messages']['editor_syntaxhighlight'] . '</a>]';
    echo '<div id="editorarea">
		<textarea class="codepress ' . $cp_lang . '" style="width:95%;" name="codearea" id="codearea" rows="25" cols="120" wrap="off" onmouseup="updatePosition(this)" onmousedown="updatePosition(this)" onkeyup="updatePosition(this)" onkeydown="updatePosition(this)" onfocus="updatePosition(this)">' . $content . '</textarea>
		<input type="hidden" name="code" value="" />
		</div><br/>';
    echo "\n\t</td>\n\t</tr>";
    echo "\n\t<tr>\n\t\t<td align=\"right\">\n\t\t\t<label for=\"fname\">" . $GLOBALS["messages"]["copyfile"] . "</label>\n\t\t\t<input type=\"text\" name=\"fname\" value=\"" . $item . "\" size=\"40\" />\n\t\t</td>\n\t</tr>\n</table>\n<br/>";
    echo "</form><br/>\n";
}
Ejemplo n.º 23
0
function get_is_unzipable($dir, $item)
{
    // is this file editable?
    if (!get_is_file($dir, $item)) {
        return false;
    }
    foreach ($GLOBALS["unzipable_ext"] as $pat) {
        if (preg_match('/' . $pat . '/i', $item)) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 24
0
function edit_file($dir, $item)
{
    if (!permissions_grant($dir, $item, "change")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $fname = get_abs_item($dir, $item);
    if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
        // Save / Save As
        $item = basename(stripslashes($GLOBALS['__POST']["fname"]));
        $fname2 = get_abs_item($dir, $item);
        if (!isset($item) || $item == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        if ($fname != $fname2 && @file_exists($fname2)) {
            show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
        }
        savefile($fname2);
        $fname = $fname2;
    }
    // open file
    $fp = @fopen($fname, "r");
    if ($fp === false) {
        show_error($item . ": " . $GLOBALS["error_msg"]["openfile"]);
    }
    // header
    $s_item = get_rel_item($dir, $item);
    if (strlen($s_item) > 50) {
        $s_item = "..." . substr($s_item, -47);
    }
    show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item);
    // Wordwrap (works only in IE)
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	function chwrap() {
		if(document.editfrm.wrap.checked) {
			document.editfrm.code.wrap="soft";
		} else {
			document.editfrm.code.wrap="off";
		}
	}
// -->
</script>

<script language="Javascript" type="text/javascript">
		// initialisation
		editAreaLoader.init({
			id: "txtedit"	// id of the textarea to transform		
			,start_highlight: true	// if start with highlight
			,allow_resize: "both"
			//,min_width = 400
			//,min_height = 100
			//,allow_resize: "y"
			,allow_toggle: true
			,word_wrap: true
			,language: "<?php 
    echo $GLOBALS["language"];
    ?>
"
			,syntax: "<?php 
    echo get_mime_type($dir, $item, "ext");
    ?>
"	
		});
</script>

<?php 
    // Form
    echo "<BR><FORM name=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n";
    echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\">\n";
    echo "<TEXTAREA NAME=\"code\" ID=\"txtedit\" rows=\"25\" cols=\"120\" wrap=\"off\">";
    // Show File In TextArea
    $buffer = "";
    while (!feof($fp)) {
        $buffer .= fgets($fp, 4096);
    }
    @fclose($fp);
    //echo htmlspecialchars($buffer);
    echo $buffer;
    echo "</TEXTAREA><BR>\n<TABLE><TR><TD>Wordwrap: (IE only)</TD><TD><INPUT type=\"checkbox\" name=\"wrap\" ";
    echo "onClick=\"javascript:chwrap();\" value=\"1\"></TD></TR></TABLE><BR>\n";
    echo "<TABLE><TR><TD><INPUT type=\"text\" name=\"fname\" value=\"" . $item . "\"></TD>";
    echo "<TD><input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnsave"];
    echo "\"></TD>\n<TD><input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\"></TD>\n<TD>";
    echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onClick=\"javascript:location='";
    echo make_link("list", $dir, NULL) . "';\"></TD></TR></FORM></TABLE><BR>\n";
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	if(document.editfrm) document.editfrm.code.focus();
// -->
</script><?php 
}