コード例 #1
0
ファイル: unzip.php プロジェクト: sdoney/nas4free
function dir_list($dir)
{
    // make list of directories
    // this list is used to copy/move items to a specific location
    $dir_list = array();
    $handle = @opendir(get_abs_dir($dir));
    if ($handle === false) {
        return;
    }
    // unable to open dir
    while (($new_item = readdir($handle)) !== false) {
        //if(!@file_exists(get_abs_item($dir, $new_item))) continue;
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        if (!get_is_dir($dir, $new_item)) {
            continue;
        }
        $dir_list[$new_item] = $new_item;
    }
    // sort
    if (is_array($dir_list)) {
        ksort($dir_list);
    }
    return $dir_list;
}
コード例 #2
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));
}
コード例 #3
0
ファイル: list.php プロジェクト: kostya1017/our
/**
 * 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();
}
コード例 #4
0
ファイル: functions.php プロジェクト: BACKUPLIB/mwenhanced
/**
* Utility function to read the files in a directory
* @param string The file system path
* @param string A filter for the names
* @param boolean Recurse search into sub-directories
* @param boolean True if to prepend the full path to the file name
*/
function extReadDirectory($path, $filter = '.', $recurse = false, $fullpath = false)
{
    $arr = array();
    if (!@get_is_dir($path)) {
        return $arr;
    }
    $handle = ext_File::opendir($path);
    while ($file = ext_File::readdir($handle)) {
        if (is_array($file)) {
            $file = $file['name'];
        }
        $dir = extPathName($path . '/' . $file, false);
        $isDir = @get_is_dir($dir);
        if ($file != "." && $file != "..") {
            if (preg_match("/{$filter}/", $file)) {
                if ($fullpath) {
                    $arr[] = trim(extPathName($path . '/' . $file, false));
                } else {
                    $arr[] = trim($file);
                }
            }
            if ($recurse && $isDir) {
                $arr2 = extReadDirectory($dir, $filter, $recurse, $fullpath);
                $arr = array_merge($arr, $arr2);
            }
        }
    }
    ext_File::closedir($handle);
    asort($arr);
    return $arr;
}
コード例 #5
0
ファイル: rename.php プロジェクト: BACKUPLIB/mwenhanced
    function execAction($dir, $item)
    {
        // rename directory or file
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            $newitemname = $GLOBALS['__POST']["newitemname"];
            $newitemname = trim(basename(stripslashes($newitemname)));
            if ($newitemname == '') {
                ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            if (!ext_isFTPMode()) {
                $abs_old = get_abs_item($dir, $item);
                $abs_new = get_abs_item($dir, $newitemname);
            } else {
                $abs_old = get_item_info($dir, $item);
                $abs_new = get_item_info($dir, $newitemname);
            }
            if (@$GLOBALS['ext_File']->file_exists($abs_new)) {
                ext_Result::sendResult('rename', false, $newitemname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
            }
            $perms_old = $GLOBALS['ext_File']->fileperms($abs_old);
            $ok = $GLOBALS['ext_File']->rename(get_abs_item($dir, $item), get_abs_item($dir, $newitemname));
            if (ext_isFTPMode()) {
                $abs_new = get_item_info($dir, $newitemname);
            }
            $GLOBALS['ext_File']->chmod($abs_new, $perms_old);
            if ($ok === false || PEAR::isError($ok)) {
                ext_Result::sendResult('rename', false, 'Could not rename ' . $dir . '/' . $item . ' to ' . $newitemname);
            }
            $msg = sprintf($GLOBALS['messages']['success_rename_file'], $item, $newitemname);
            ext_Result::sendResult('rename', true, $msg);
        }
        $is_dir = get_is_dir(ext_isFTPMode() ? get_item_info($dir, $item) : get_abs_item($dir, $item));
        ?>
	<div style="width:auto;">
	    <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
	    <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
	
	        <h3 style="margin-bottom:5px;"><?php 
        echo $GLOBALS['messages']['rename_file'];
        ?>
</h3>
	        <div id="adminForm">
	
	        </div>
	    </div></div></div>
	    <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
	</div>
	<script type="text/javascript">
	var simple = new Ext.form.Form({
	    labelWidth: 75, // label settings here cascade unless overridden
	    url:'<?php 
        echo basename($GLOBALS['script_name']);
        ?>
'
	});
	simple.add(
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
        echo ext_Lang::msg('newname', true);
        ?>
',
	        name: 'newitemname',
	        value: '<?php 
        echo str_replace("'", "\\'", stripslashes($item));
        ?>
',
	        width:175,
	        allowBlank:false
	    })
	    );
	
	simple.addButton('<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
', function() {
		statusBarMessage( 'Please wait...', true );
	    simple.submit({
	        //reset: true,
	        reset: false,
	        success: function(form, action) {
	        	<?php 
        if ($is_dir) {
            ?>
	        		parentDir = dirTree.getSelectionModel().getSelectedNode().parentNode;
	        		parentDir.reload();
	        		parentDir.select();
	    		<?php 
        } else {
            ?>
		    		datastore.reload();
		        	<?php 
        }
        ?>
	    		statusBarMessage( action.result.message, false, true );
	        	dialog.destroy();
	        },
	        failure: function(form, action) {	        	
	        	if( !action.result ) return;
	        	Ext.MessageBox.alert('Error!', action.result.error);
	        	statusBarMessage( action.result.error, false, false );
	        },
	        scope: simple,
	        // add some vars to the request, similar to hidden fields
	        params: {option: 'com_extplorer', 
	        		action: 'rename', 
	        		dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
	        		item: '<?php 
        echo stripslashes($item);
        ?>
', 
	        		confirm: 'true'}
	    });
	});
	simple.addButton('<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
', function() { dialog.destroy(); } );
	simple.render('adminForm');
	</script>
	<?php 
    }
コード例 #6
0
function make_tables($dir, &$dir_list, &$file_list, &$tot_file_size, &$num_items)
{
    // make table of files in dir
    // make tables & place results in reference-variables passed to function
    // also 'return' total filesize & total number of items
    $homedir = realpath($GLOBALS['home_dir']);
    $tot_file_size = $num_items = 0;
    // Open directory
    $handle = @opendir(get_abs_dir($dir));
    if ($handle === false && $dir == "") {
        $handle = @opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('', false, $dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    // Read directory
    while (($new_item = readdir($handle)) !== false) {
        $abs_new_item = get_abs_item($dir, $new_item);
        if ($new_item == "." || $new_item == "..") {
            continue;
        }
        if (!file_exists($abs_new_item)) {
            //ext_Result::sendResult('', false, $dir."/$abs_new_item: ".$GLOBALS["error_msg"]["readdir"]);
            if (!get_show_item($dir, $new_item)) {
                continue;
            }
        }
        $new_file_size = @filesize($abs_new_item);
        $tot_file_size += $new_file_size;
        $num_items++;
        if (get_is_dir($abs_new_item)) {
            if ($GLOBALS["order"] == "mod") {
                $dir_list[$new_item] = @filemtime($abs_new_item);
            } else {
                // order == "size", "type" or "name"
                $dir_list[$new_item] = $new_item;
            }
        } else {
            if ($GLOBALS["order"] == "size") {
                $file_list[$new_item] = $new_file_size;
            } elseif ($GLOBALS["order"] == "mod") {
                $file_list[$new_item] = @filemtime($abs_new_item);
            } elseif ($GLOBALS["order"] == "type") {
                $file_list[$new_item] = get_mime_type($abs_new_item, "type");
            } else {
                // order == "name"
                $file_list[$new_item] = $new_item;
            }
        }
    }
    closedir($handle);
    // sort
    if (is_array($dir_list)) {
        if ($GLOBALS["order"] == "mod") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($dir_list);
            } else {
                asort($dir_list);
            }
        } else {
            // order == "size", "type" or "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($dir_list);
            } else {
                krsort($dir_list);
            }
        }
    }
    // sort
    if (is_array($file_list)) {
        if ($GLOBALS["order"] == "mod") {
            if ($GLOBALS["direction"] == "ASC") {
                arsort($file_list);
            } else {
                asort($file_list);
            }
        } elseif ($GLOBALS["order"] == "size" || $GLOBALS["order"] == "type") {
            if ($GLOBALS["direction"] == "ASC") {
                asort($file_list);
            } else {
                arsort($file_list);
            }
        } else {
            // order == "name"
            if ($GLOBALS["direction"] == "ASC") {
                ksort($file_list);
            } else {
                krsort($file_list);
            }
        }
    }
}
コード例 #7
0
ファイル: init.php プロジェクト: RangerWalt/ecci
    }
} else {
    $GLOBALS["dir"] = $dir = urldecode(stripslashes(mosGetParam($_REQUEST, "dir")));
}
if ($dir == 'jx_root') {
    $GLOBALS["dir"] = $dir = '';
}
if (jx_isFTPMode() && $dir != '') {
    $GLOBALS['FTPCONNECTION']->cd($dir);
}
$abs_dir = get_abs_dir($GLOBALS["dir"]);
if (!file_exists($GLOBALS["home_dir"])) {
    if (!file_exists($GLOBALS["home_dir"] . $GLOBALS["separator"])) {
        if ($GLOBALS["require_login"]) {
            $extra = "<a href=\"" . make_link("logout", NULL, NULL) . "\">" . $GLOBALS["messages"]["btnlogout"] . "</A>";
        } else {
            $extra = NULL;
        }
        show_error($GLOBALS["error_msg"]["home"] . " (" . $GLOBALS["home_dir"] . ")", $extra);
    }
}
if (!down_home($abs_dir)) {
    show_error($GLOBALS["dir"] . " : " . $GLOBALS["error_msg"]["abovehome"]);
    $dir = '';
}
if (!get_is_dir($abs_dir) && !get_is_dir($abs_dir . $GLOBALS["separator"])) {
    show_error($abs_dir . " : " . $GLOBALS["error_msg"]["direxist"]);
    $dir = '';
}
$_SESSION['jx_' . $GLOBALS['file_mode'] . 'dir'] = $dir;
//------------------------------------------------------------------------------
コード例 #8
0
ファイル: fun_list.php プロジェクト: Caojunkai/arcticfox
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++;
    }
}
コード例 #9
0
function nx_ftp_make_local_copy($abs_item, $use_filehandle = false)
{
    if (get_is_dir($abs_item)) {
        $tmp_dir = _QUIXPLORER_FTPTMP_PATH . '/' . uniqid('nx_tmpdir_') . '/';
        $res = $GLOBALS['FTPCONNECTION']->getRecursive($abs_item, $tmp_dir, true);
        if (PEAR::isError($res)) {
            show_error('Failed to fetch the directory via FTP: ' . $res->getMessage());
        }
        return $tmp_dir;
    }
    if (!$use_filehandle) {
        $tmp_file = tempnam(_QUIXPLORER_FTPTMP_PATH, 'nx_ftp_dl_');
        if ($tmp_file == 'false') {
            show_error('The /ftp_tmp Directory must be writable in order to use this functionality in FTP Mode.');
        }
        $res = $GLOBALS['FTPCONNECTION']->get('/' . $abs_item, $tmp_file, true);
        if (PEAR::isError($res)) {
            show_error('Failed to fetch the file via filehandle from FTP: ' . $res->getMessage());
        }
    } else {
        $tmp_file = tmpfile();
        $res = $GLOBALS['FTPCONNECTION']->fget('/' . $abs_item, $tmp_file, true);
        if (PEAR::isError($res)) {
            show_error('Failed to fetch the file via FTP: ' . $res->getMessage());
        }
        rewind($tmp_file);
    }
    return $tmp_file;
}
コード例 #10
0
ファイル: fun_search.php プロジェクト: RangerWalt/ecci
function print_table($list)
{
    // print table of found items
    if (!is_array($list)) {
        return;
    }
    $cnt = count($list);
    for ($i = 0; $i < $cnt; ++$i) {
        $dir = $list[$i][0];
        $item = $list[$i][1];
        $s_dir = $dir;
        if (strlen($s_dir) > 65) {
            $s_dir = substr($s_dir, 0, 62) . "...";
        }
        $s_item = $item;
        if (strlen($s_item) > 45) {
            $s_item = substr($s_item, 0, 42) . "...";
        }
        $link = "";
        $target = "";
        if (get_is_dir($dir, $item)) {
            $img = "dir.png";
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            $img = get_mime_type($dir, $item, "img");
            //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
            $link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item);
            $target = "_blank";
            //}
        }
        echo "<tr><td>" . "<img border=\"0\" width=\"22\" height=\"22\" ";
        echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/" . $img . "\" alt=\"\">&nbsp;";
        /*if($link!="")*/
        echo "<a href=\"" . $link . "\" target=\"" . $target . "\">";
        //else echo "<a>";
        echo $s_item . "</a></td><td><a href=\"" . make_link("list", $dir, null) . "\"> /";
        echo $s_dir . "</a></td></tr>\n";
    }
}
コード例 #11
0
ファイル: chmod.php プロジェクト: shamblett/janitor
    function execAction($dir, $item)
    {
        // change permissions
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (!empty($GLOBALS['__POST']["selitems"])) {
            $cnt = count($GLOBALS['__POST']["selitems"]);
        } else {
            $GLOBALS['__POST']["selitems"][] = $item;
            $cnt = 1;
        }
        if (!empty($GLOBALS['__POST']['do_recurse'])) {
            $do_recurse = true;
        } else {
            $do_recurse = false;
        }
        // Execute
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            $bin = '';
            for ($i = 0; $i < 3; $i++) {
                for ($j = 0; $j < 3; $j++) {
                    $tmp = "r_" . $i . $j;
                    if (!empty($GLOBALS['__POST'][$tmp])) {
                        $bin .= '1';
                    } else {
                        $bin .= '0';
                    }
                }
            }
            if ($bin == '0') {
                // Changing permissions to "none" is not allowed
                ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed'));
            }
            $old_bin = $bin;
            for ($i = 0; $i < $cnt; ++$i) {
                if (ext_isFTPMode()) {
                    $mode = decoct(bindec($bin));
                } else {
                    $mode = bindec($bin);
                }
                $item = $GLOBALS['__POST']["selitems"][$i];
                if (ext_isFTPMode()) {
                    $abs_item = get_item_info($dir, $item);
                } else {
                    $abs_item = get_abs_item($dir, $item);
                }
                if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
                }
                if (!get_show_item($dir, $item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
                }
                if ($do_recurse) {
                    $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode);
                } else {
                    if (get_is_dir($abs_item)) {
                        // when we chmod a directory we must care for the permissions
                        // to prevent that the directory becomes not readable (when the "execute bits" are removed)
                        $bin = substr_replace($bin, '1', 2, 1);
                        // set 1st x bit to 1
                        $bin = substr_replace($bin, '1', 5, 1);
                        // set  2nd x bit to 1
                        $bin = substr_replace($bin, '1', 8, 1);
                        // set 3rd x bit to 1
                        if (ext_isFTPMode()) {
                            $mode = decoct(bindec($bin));
                        } else {
                            $mode = bindec($bin);
                        }
                    }
                    //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd());
                    $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode);
                }
                $bin = $old_bin;
            }
            if ($ok === false || PEAR::isError($ok)) {
                $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"];
                $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : '';
                ext_Result::sendResult('chmod', false, $msg);
            }
            ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange'));
            return;
        }
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]);
        } else {
            $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]);
            $abs_item = utf8_decode($abs_item);
        }
        $mode = parse_file_perms(get_file_perms($abs_item));
        if ($mode === false) {
            ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]);
        }
        $pos = "rwx";
        $text = "";
        for ($i = 0; $i < $cnt; ++$i) {
            $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]);
            if (strlen($s_item) > 50) {
                $s_item = "..." . substr($s_item, -47);
            }
            $text .= $s_item . ($i + 1 < $cnt ? ', ' : '');
        }
        ?>
	<div style="width:auto;">
	    <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
	    <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
	
	        <h3 style="margin-bottom:5px;"><?php 
        echo ext_Lang::msg('actperms');
        ?>
</h3>
	        <?php 
        echo $text;
        ?>
	        <div id="adminForm">
	
	        </div>
	    </div></div></div>
	    <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
	</div>
	<script type="text/javascript">
	var form = new Ext.form.Form({
	    labelWidth: 125, // label settings here cascade unless overridden
	    url:'<?php 
        echo basename($GLOBALS['script_name']);
        ?>
'
	});
	
	<?php 
        // print table with current perms & checkboxes to change
        for ($i = 0; $i < 3; ++$i) {
            ?>
			form.column(
		        {width:70, style:'margin-left:10px', clear:true}
		    );
			form.fieldset(
			        {legend:'<?php 
            echo ext_Lang::msg(array('miscchmod' => $i), true);
            ?>
', hideLabels:true},
			        <?php 
            for ($j = 0; $j < 3; ++$j) {
                ?>
				        new Ext.form.Checkbox({
				            boxLabel:'<?php 
                echo $pos[$j];
                ?>
',
				            <?php 
                if ($mode[3 * $i + $j] != "-") {
                    echo 'checked:true,';
                }
                ?>
				            name:'<?php 
                echo "r_" . $i . $j;
                ?>
'
				        })     <?php 
                if ($j < 2) {
                    echo ',';
                }
            }
            ?>
   );
	    	form.end();
	    <?php 
        }
        ?>
	form.column(
	        {width:400, style:'margin-left:10px', clear:true}
	    );
	form.add(new Ext.form.Checkbox({
		fieldLabel:'<?php 
        echo ext_Lang::msg('recurse_subdirs', true);
        ?>
',
		name:'do_recurse'
	}));
	form.end();
	
	form.addButton('<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
', function() {
		statusBarMessage( '<?php 
        echo ext_Lang::msg('permissions_processing', true);
        ?>
', true );
	    form.submit({
	        //reset: true,
	        reset: false,
	        success: function(form, action) {
	        	statusBarMessage( action.result.message, false, true );
	        	datastore.reload();
	    		dialog.hide();
	        	dialog.destroy();
	        },
	        failure: function(form, action) {
	        	statusBarMessage( action.result.error, false, false );
	        	Ext.MessageBox.alert('<?php 
        echo ext_Lang::err('error', true);
        ?>
', action.result.error);
	        },
	        scope: form,
	        // add some vars to the request, similar to hidden fields
	        params: {option: 'com_extplorer', 
	        		action: 'chmod', 
	        		dir: '<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
', 
	        		'selitems[]': ['<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
'], 
	        		confirm: 'true'}
	    });
	});
	form.addButton('<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
', function() { dialog.hide();dialog.destroy(); } );
	form.render('adminForm');
	</script>
	
		<?php 
    }
コード例 #12
0
ファイル: fun_list.php プロジェクト: ZenaVault/FreeNAS-Source
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";
    }
}
コード例 #13
0
ファイル: fun_extra.php プロジェクト: Caojunkai/arcticfox
function get_dir_list($dir = '')
{
    $files = mosReadDirectory(get_abs_dir($dir), '.', false, true);
    $dirs = array();
    foreach ($files as $item) {
        $item = str_replace('\\', '/', $item);
        if (get_is_dir($item)) {
            $index = str_replace($GLOBALS['home_dir'] . $GLOBALS['separator'], '', $item);
            $dirs[$index] = basename($index);
        }
    }
    return $dirs;
}
コード例 #14
0
ファイル: rename.php プロジェクト: chajianku/admin_eXtplorer
    function execAction($dir, $item)
    {
        // rename directory or file
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            $newitemname = $GLOBALS['__POST']["newitemname"];
            $newitemname = trim(basename(stripslashes($newitemname)));
            if ($newitemname == '') {
                ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            if (!ext_isFTPMode()) {
                $abs_old = get_abs_item($dir, $item);
                $abs_new = get_abs_item($dir, $newitemname);
            } else {
                $abs_old = get_item_info($dir, $item);
                $abs_new = get_item_info($dir, $newitemname);
            }
            if (@$GLOBALS['ext_File']->file_exists($abs_new)) {
                ext_Result::sendResult('rename', false, ext_TextEncoding::toUTF8($newitemname) . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
            }
            $perms_old = $GLOBALS['ext_File']->fileperms($abs_old);
            $ok = $GLOBALS['ext_File']->rename(get_abs_item($dir, $item), get_abs_item($dir, $newitemname));
            if (ext_isFTPMode()) {
                $abs_new = get_item_info($dir, $newitemname);
            }
            $GLOBALS['ext_File']->chmod($abs_new, $perms_old);
            if ($ok === false || PEAR::isError($ok)) {
                ext_Result::sendResult('rename', false, 'Could not rename ' . $dir . '/' . $item . ' to ' . $newitemname);
            }
            $msg = sprintf($GLOBALS['messages']['success_rename_file'], $item, $newitemname);
            ext_Result::sendResult('rename', true, $msg);
        }
        $is_dir = get_is_dir(ext_isFTPMode() ? get_item_info($dir, $item) : get_abs_item($dir, $item));
        ?>
{
	"xtype": "form",
	"width": "350",
	"height": "150",
	"id": "simpleform",
	"labelWidth": 125,
	"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
	"dialogtitle": "<?php 
        echo $GLOBALS['messages']['rename_file'];
        ?>
",
	"frame": true,
	"items": [{
	
		"xtype": "textfield",
		"fieldLabel": "<?php 
        echo ext_Lang::msg('newname', true);
        ?>
",
		"name": "newitemname",
		"id": "newitemname",
		"value": "<?php 
        echo str_replace("'", "\\'", stripslashes($item));
        ?>
",
		"width":175,
		"allowBlank":false
		}
	],
	"listeners": { "afterrender": { 
						fn: function( form ) {
							form.findById("newitemname").focus(true);
						}
					}
	},
	"buttons": [{
		"text": "<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( 'Please wait...', true );
			form = Ext.getCmp("simpleform").getForm();
			form.submit({
				//reset: true,
				reset: false,
				success: function(form, action) {
					<?php 
        if ($is_dir) {
            ?>
						if( dirTree.getSelectionModel().getSelectedNode() ) {
							parentDir = dirTree.getSelectionModel().getSelectedNode().parentNode;parentDir.reload();parentDir.select();
						}
					<?php 
        }
        ?>
					datastore.reload();
					statusBarMessage( action.result.message, false, true );
					Ext.getCmp("dialog").destroy();
				},
				failure: function(form, action) {
					if( !action.result ) return;
					Ext.MessageBox.alert('Error!', action.result.error);
					statusBarMessage( action.result.error, false, false );
				},
				scope: form,
				// add some vars to the request, similar to hidden fields
				params: {
					option: 'com_extplorer', 
					action: 'rename', 
					dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
					item: '<?php 
        echo stripslashes($item);
        ?>
', 
					confirm: 'true'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); } 
	}]
}
	
	<?php 
    }
コード例 #15
0
function print_table($list)
{
    // print table of found items
    if (!is_array($list)) {
        return;
    }
    $cnt = count($list);
    for ($i = 0; $i < $cnt; ++$i) {
        $dir = $list[$i][0];
        $item = $list[$i][1];
        $s_dir = $dir;
        if (strlen($s_dir) > 65) {
            $s_dir = substr($s_dir, 0, 62) . "...";
        }
        $s_item = $item;
        if (strlen($s_item) > 45) {
            $s_item = substr($s_item, 0, 42) . "...";
        }
        $link = "";
        $target = "";
        if (get_is_dir($dir, $item)) {
            $img = "dir.gif";
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            $img = get_mime_type($dir, $item, "img");
            $link = make_link("download", $dir, $item);
        }
        echo "<TR><TD>" . "<IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"_img/" . $img . "\" ALT=\"\">&nbsp;";
        /*if($link!="")*/
        echo "<A HREF=\"" . $link . "\" TARGET=\"" . $target . "\">";
        //else echo "<A>";
        echo $s_item . "</A></TD><TD><A HREF=\"" . make_link("list", $dir, NULL) . "\"> /";
        echo $s_dir . "</A></TD></TR>\n";
    }
}
コード例 #16
0
ファイル: fun_chmod.php プロジェクト: Caojunkai/arcticfox
function chmod_item($dir, $item)
{
    // change permissions
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!empty($GLOBALS['__POST']["selitems"])) {
        $cnt = count($GLOBALS['__POST']["selitems"]);
    } else {
        $GLOBALS['__POST']["selitems"][] = $item;
        $cnt = 1;
    }
    if (!empty($GLOBALS['__POST']['do_recurse'])) {
        $do_recurse = true;
    } else {
        $do_recurse = false;
    }
    // Execute
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $bin = '';
        for ($i = 0; $i < 3; $i++) {
            for ($j = 0; $j < 3; $j++) {
                $tmp = "r_" . $i . $j;
                if (isset($GLOBALS['__POST'][$tmp]) && $GLOBALS['__POST'][$tmp] == "1") {
                    $bin .= '1';
                } else {
                    $bin .= '0';
                }
            }
        }
        if ($bin == '0') {
            // Changing permissions to "none" is not allowed
            show_error($item . ": " . $GLOBALS["error_msg"]["permchange"]);
        }
        $old_bin = $bin;
        for ($i = 0; $i < $cnt; ++$i) {
            if (jx_isFTPMode()) {
                $mode = decoct(bindec($bin));
            } else {
                $mode = bindec($bin);
            }
            $item = $GLOBALS['__POST']["selitems"][$i];
            if (jx_isFTPMode()) {
                $abs_item = get_item_info($dir, $item);
            } else {
                $abs_item = get_abs_item($dir, $item);
            }
            if (!$GLOBALS['jx_File']->file_exists($abs_item)) {
                show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
            }
            if (!get_show_item($dir, $item)) {
                show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
            }
            if ($do_recurse) {
                $ok = $GLOBALS['jx_File']->chmodRecursive($abs_item, $mode);
            } else {
                if (get_is_dir($abs_item)) {
                    // when we chmod a directory we must care for the permissions
                    // to prevent that the directory becomes not readable (when the "execute bits" are removed)
                    $bin = substr_replace($bin, '1', 2, 1);
                    // set 1st x bit to 1
                    $bin = substr_replace($bin, '1', 5, 1);
                    // set  2nd x bit to 1
                    $bin = substr_replace($bin, '1', 8, 1);
                    // set 3rd x bit to 1
                    if (jx_isFTPMode()) {
                        $mode = decoct(bindec($bin));
                    } else {
                        $mode = bindec($bin);
                    }
                }
                $ok = @$GLOBALS['jx_File']->chmod($abs_item, $mode);
            }
            $bin = $old_bin;
        }
        if (!$ok || PEAR::isError($ok)) {
            show_error($abs_item . ": " . $GLOBALS["error_msg"]["permchange"]);
        }
        header("Location: " . make_link("link", $dir, NULL));
        return;
    }
    if (jx_isFTPMode()) {
        $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]);
    } else {
        $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]);
    }
    $mode = parse_file_perms(get_file_perms($abs_item));
    if ($mode === false) {
        show_error($GLOBALS['__POST']["selitems"][0] . ": " . $GLOBALS["error_msg"]["permread"]);
    }
    $pos = "rwx";
    $text = "";
    for ($i = 0; $i < $cnt; ++$i) {
        $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]);
        if (strlen($s_item) > 50) {
            $s_item = "..." . substr($s_item, -47);
        }
        $text .= ", " . $s_item;
    }
    show_header($GLOBALS["messages"]["actperms"]);
    echo "<br/><br/><div style=\"max-height: 200px; max-width: 800px;overflow:auto;\">/" . $text . '</div>';
    // Form
    echo '<br /><form method="post" action="' . make_link("chmod", $dir, $item) . "\">\n\t<input type=\"hidden\" name=\"confirm\" value=\"true\" />";
    if ($cnt > 1 || empty($GLOBALS['__GET']["item"])) {
        for ($i = 0; $i < $cnt; ++$i) {
            echo "<input type=\"hidden\" name=\"selitems[]\" value=\"" . stripslashes($GLOBALS['__POST']["selitems"][$i]) . "\" />\n";
        }
    } else {
        echo "<input type=\"hidden\" name=\"item\" value=\"" . stripslashes($GLOBALS['__GET']["item"]) . "\" />\n";
    }
    echo "\n\t<table class=\"adminform\" style=\"width:175px;\">\n";
    // print table with current perms & checkboxes to change
    for ($i = 0; $i < 3; ++$i) {
        echo "<tr><td>" . $GLOBALS["messages"]["miscchmod"][$i] . "</td>";
        for ($j = 0; $j < 3; ++$j) {
            echo "<td><label for=\"r_" . $i . $j . "\"\">" . $pos[$j] . "&nbsp;</label><input type=\"checkbox\"";
            if ($mode[3 * $i + $j] != "-") {
                echo " checked=\"checked\"";
            }
            echo " name=\"r_" . $i . $j . "\" id=\"r_" . $i . $j . "\" value=\"1\" /></td>";
        }
        echo "</tr>\n";
    }
    // Submit / Cancel
    echo "</table>\n<br/>";
    echo "<table>\n<tr><tr><td colspan=\"2\">\n<input name=\"do_recurse\" id=\"do_recurse\" type=\"checkbox\" value=\"1\" /><label for=\"do_recurse\">" . $GLOBALS["messages"]["recurse_subdirs"] . "</label></td></tr>\n";
    echo "<tr><tr><td>\n<input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnchange"];
    echo "\"></td>\n<td><input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"];
    echo "\" onclick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\">\n</td></tr></form></table><br />\n";
}
コード例 #17
0
ファイル: functions.php プロジェクト: kosmosby/medicine-prof
function get_dir_list($dir = '')
{
    if (ext_isFTPMode()) {
        $files = getCachedFTPListing(empty($dir) ? '.' : $dir);
    } else {
        $files = extReadDirectory(get_abs_dir($dir), '.', false, true);
    }
    $dirs = array();
    foreach ($files as $item) {
        $itemname = ext_isFTPMode() ? (empty($dir) ? '' : $dir . '/') . $item['name'] : $item;
        $itemname = str_replace('\\', '/', $itemname);
        if (get_is_dir($item)) {
            $index = str_replace(str_replace('\\', '/', $GLOBALS['home_dir'] . $GLOBALS['separator']), '', $itemname);
            $dirs[$index] = basename($index);
        }
    }
    return $dirs;
}
コード例 #18
0
function ext_ftp_make_local_copy($abs_item, $use_filehandle = false)
{
    if (get_is_dir($abs_item)) {
        $tmp_dir = _EXT_FTPTMP_PATH . '/' . uniqid('ext_tmpdir_') . '/';
        $res = $GLOBALS['FTPCONNECTION']->getRecursive($abs_item, $tmp_dir, true);
        if (PEAR::isError($res)) {
            ext_Result::sendResult('list', false, 'Failed to fetch the directory via FTP: ' . $res->getMessage());
        }
        return $tmp_dir;
    }
    $abs_item = str_replace("\\", '/', $abs_item);
    if ($abs_item[0] != '/') {
        $abs_item = '/' . $abs_item;
    }
    if (!$use_filehandle) {
        $tmp_file = tempnam(_EXT_FTPTMP_PATH, 'ext_ftp_dl_');
        if ($tmp_file == 'false') {
            ext_Result::sendResult('list', false, 'The /ftp_tmp Directory must be writable in order to use this functionality in FTP Mode.');
        }
        $res = $GLOBALS['FTPCONNECTION']->get($abs_item, $tmp_file, true);
        if (PEAR::isError($res)) {
            ext_Result::sendResult('list', false, 'Failed to fetch the file via filehandle from FTP: ' . $res->getMessage());
        }
    } else {
        $tmp_file = tmpfile();
        $res = $GLOBALS['FTPCONNECTION']->fget('/' . $abs_item, $tmp_file, true);
        if (PEAR::isError($res)) {
            ext_Result::sendResult('list', false, 'Failed to fetch the file via FTP: ' . $res->getMessage());
        }
        rewind($tmp_file);
    }
    return $tmp_file;
}
コード例 #19
0
ファイル: copy_move.php プロジェクト: shamblett/janitor
/**
 * 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') . '.');
}
コード例 #20
0
ファイル: init.php プロジェクト: shamblett/janitor
    }
} else {
    $GLOBALS["dir"] = $dir = urldecode(stripslashes(extGetParam($_REQUEST, "dir")));
}
if ($dir == 'ext_root') {
    $GLOBALS["dir"] = $dir = '';
}
if (ext_isFTPMode() && $dir != '') {
    $GLOBALS['FTPCONNECTION']->cd($dir);
}
$abs_dir = get_abs_dir($GLOBALS["dir"]);
if (!file_exists($GLOBALS["home_dir"])) {
    if (!file_exists($GLOBALS["home_dir"] . $GLOBALS["separator"])) {
        if ($GLOBALS["require_login"]) {
            $extra = "<a href=\"" . make_link("logout", NULL, NULL) . "\">" . $GLOBALS["messages"]["btnlogout"] . "</a>";
        } else {
            $extra = NULL;
        }
        ext_Result::sendResult('', false, $GLOBALS["error_msg"]["home"] . " (" . $GLOBALS["home_dir"] . ")", $extra);
    }
}
if (!down_home($abs_dir)) {
    ext_Result::sendResult('', false, $GLOBALS["dir"] . " : " . $GLOBALS["error_msg"]["abovehome"]);
    $dir = '';
}
if (!get_is_dir(utf8_decode($abs_dir)) && !get_is_dir($abs_dir . $GLOBALS["separator"])) {
    ext_Result::sendResult('', false, $abs_dir . " : " . $GLOBALS["error_msg"]["direxist"]);
    $dir = '';
}
$_SESSION['ext_' . $GLOBALS['file_mode'] . 'dir'] = $dir;
//------------------------------------------------------------------------------
コード例 #21
0
ファイル: chmod.php プロジェクト: Gninety/Microweber
    function execAction($dir, $item)
    {
        // change permissions
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (!empty($GLOBALS['__POST']["selitems"])) {
            $cnt = count($GLOBALS['__POST']["selitems"]);
        } else {
            $GLOBALS['__POST']["selitems"][] = $item;
            $cnt = 1;
        }
        if (!empty($GLOBALS['__POST']['do_recurse'])) {
            $do_recurse = true;
        } else {
            $do_recurse = false;
        }
        // Execute
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            $bin = '';
            for ($i = 0; $i < 3; $i++) {
                for ($j = 0; $j < 3; $j++) {
                    $tmp = "r_" . $i . $j;
                    if (!empty($GLOBALS['__POST'][$tmp])) {
                        $bin .= '1';
                    } else {
                        $bin .= '0';
                    }
                }
            }
            if ($bin == '0') {
                // Changing permissions to "none" is not allowed
                ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed'));
            }
            $old_bin = $bin;
            for ($i = 0; $i < $cnt; ++$i) {
                if (ext_isFTPMode()) {
                    $mode = decoct(bindec($bin));
                } else {
                    $mode = bindec($bin);
                }
                $item = $GLOBALS['__POST']["selitems"][$i];
                if (ext_isFTPMode()) {
                    $abs_item = get_item_info($dir, $item);
                } else {
                    $abs_item = get_abs_item($dir, $item);
                }
                if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
                }
                if (!get_show_item($dir, $item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
                }
                if ($do_recurse) {
                    $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode);
                } else {
                    if (get_is_dir($abs_item)) {
                        // when we chmod a directory we must care for the permissions
                        // to prevent that the directory becomes not readable (when the "execute bits" are removed)
                        $bin = substr_replace($bin, '1', 2, 1);
                        // set 1st x bit to 1
                        $bin = substr_replace($bin, '1', 5, 1);
                        // set  2nd x bit to 1
                        $bin = substr_replace($bin, '1', 8, 1);
                        // set 3rd x bit to 1
                        if (ext_isFTPMode()) {
                            $mode = decoct(bindec($bin));
                        } else {
                            $mode = bindec($bin);
                        }
                    }
                    //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd());
                    $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode);
                }
                $bin = $old_bin;
            }
            if ($ok === false || PEAR::isError($ok)) {
                $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"];
                $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : '';
                ext_Result::sendResult('chmod', false, $msg);
            }
            ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange'));
            return;
        }
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]);
        } else {
            $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]);
            $abs_item = utf8_decode($abs_item);
        }
        $mode = parse_file_perms(get_file_perms($abs_item));
        if ($mode === false) {
            ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]);
        }
        $pos = "rwx";
        $text = "";
        for ($i = 0; $i < $cnt; ++$i) {
            $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]);
            if (strlen($s_item) > 50) {
                $s_item = "..." . substr($s_item, -47);
            }
            $text .= $s_item . ($i + 1 < $cnt ? ', ' : '');
        }
        ?>
		{
		"xtype": "form",
		"id": "simpleform",
		"width": "300",
		"labelWidth": 125,
		"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		"dialogtitle": "<?php 
        echo ext_Lang::msg('actperms');
        ?>
",
		"title" : "<?php 
        echo $text;
        ?>
",
		"frame": true,
		"items": [{
			"layout": "column",
			"items": [{
	<?php 
        // print table with current perms & checkboxes to change
        for ($i = 0; $i < 3; ++$i) {
            ?>
			"width":80, 
			"title":"<?php 
            echo ext_Lang::msg(array('miscchmod' => $i), true);
            ?>
",					
			"items": [{
				<?php 
            for ($j = 0; $j < 3; ++$j) {
                ?>
					"xtype": "checkbox",
					"boxLabel":"<?php 
                echo $pos[$j];
                ?>
",
					<?php 
                if ($mode[3 * $i + $j] != "-") {
                    echo '"checked":true,';
                }
                ?>
						"name":"<?php 
                echo "r_" . $i . $j;
                ?>
"
					}	<?php 
                if ($j < 2) {
                    echo ',{';
                }
            }
            ?>
	
				]
			}
		<?php 
            if ($i < 2) {
                echo ',{';
            }
        }
        ?>
,{
			"width":400, 
			"style":"margin-left:10px", 
			"clear":true,
			"html": "&nbsp;"
		}]

	},{
		"xtype": "checkbox",
		"fieldLabel":"<?php 
        echo ext_Lang::msg('recurse_subdirs', true);
        ?>
",
		"name":"do_recurse"
	}],
	"buttons": [{
		"text": "<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( '<?php 
        echo ext_Lang::msg('permissions_processing', true);
        ?>
', true );
			form = Ext.getCmp("simpleform").getForm();
			form.submit({
				//reset: true,
				reset: false,
				success: function(form, action) {
					statusBarMessage( action.result.message, false, true );
					datastore.reload();
					Ext.getCmp("dialog").destroy();
				},
				failure: function(form, action) {
					statusBarMessage( action.result.error, false, false );
					Ext.Msg.alert('<?php 
        echo ext_Lang::err('error', true);
        ?>
', action.result.error);
				},
				scope: form,
				params: {
					"option": "com_extplorer", 
					"action": "chmod", 
					"dir": "<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
", 
					"selitems[]": ['<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
'], 
					confirm: 'true'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); }
	}]
}
	
		<?php 
    }
コード例 #22
0
ファイル: search.php プロジェクト: ejailesb/repo_empr
function get_result_array($list)
{
    // print table of found items
    if (!is_array($list)) {
        return;
    }
    $cnt = count($list);
    $array = array();
    for ($i = 0; $i < $cnt; ++$i) {
        $dir = $list[$i][0];
        $item = $list[$i][1];
        $s_dir = str_replace($GLOBALS['home_dir'], '', $dir);
        if (strlen($s_dir) > 65) {
            $s_dir = substr($s_dir, 0, 62) . "...";
        }
        $s_item = $item;
        if (strlen($s_item) > 45) {
            $s_item = substr($s_item, 0, 42) . "...";
        }
        $link = "";
        $target = "";
        if (get_is_dir($dir, $item)) {
            $img = "dir.png";
            $link = ext_make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            $img = get_mime_type($item, "img");
            //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
            $link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item);
            $target = "_blank";
            //}
        }
        $array[$i]['last_mtime'] = ext_isFTPMode() ? $GLOBALS['ext_File']->filemtime($GLOBALS['home_dir'] . '/' . $dir . '/' . $item) : filemtime($dir . '/' . $item);
        $array[$i]['file_id'] = md5($s_dir . $s_item);
        $array[$i]['dir'] = str_replace($GLOBALS['home_dir'], '', $dir);
        $array[$i]['s_dir'] = empty($s_dir) ? '' : $s_dir;
        $array[$i]['file'] = $s_item;
        $array[$i]['link'] = $link;
        $array[$i]['icon'] = _EXT_URL . "/images/{$img}";
    }
    return $array;
}
コード例 #23
0
function get_mime_type($dir, $item, $query)
{
    // get file's mimetype
    if (get_is_dir($dir, $item)) {
        // directory
        $mime_type = $GLOBALS["super_mimes"]["dir"][0];
        $image = $GLOBALS["super_mimes"]["dir"][1];
        if ($query == "img") {
            return $image;
        } else {
            return $mime_type;
        }
    }
    // mime_type
    foreach ($GLOBALS["used_mime_types"] as $mime) {
        list($desc, $img, $ext, $type) = $mime;
        if (preg_match('/' . $ext . '/i', $item)) {
            $mime_type = $desc;
            $image = $img;
            if ($query == "img") {
                return $image;
            } else {
                if ($query == "ext") {
                    return $type;
                } else {
                    return $mime_type;
                }
            }
        }
    }
    if (function_exists("is_executable") && @is_executable(get_abs_item($dir, $item)) || preg_match('/' . $GLOBALS["super_mimes"]["exe"][2] . '/i', $item)) {
        // executable
        $mime_type = $GLOBALS["super_mimes"]["exe"][0];
        $image = $GLOBALS["super_mimes"]["exe"][1];
    } else {
        // unknown file
        $mime_type = $GLOBALS["super_mimes"]["file"][0];
        $image = $GLOBALS["super_mimes"]["file"][1];
    }
    if ($query == "img") {
        return $image;
    } else {
        return $mime_type;
    }
}
コード例 #24
0
ファイル: appFolderAjax.php プロジェクト: rrsc/processmaker
function get_abs_item($dir, $item)
{
    // get absolute file+path
    if (is_array($item)) {
        // FTP Mode
        $abs_item = '/' . get_abs_dir($dir)."/".$item['name'];
        if (get_is_dir($item)) {
            $abs_item.='/';
        }
        return extPathName($abs_item);
    }
    return extPathName(get_abs_dir($dir)."/".$item);
}