function del_items($dir) { $mainframe =& JFactory::getApplication(); // delete files/dirs if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } $cnt = count($GLOBALS['__POST']["selitems"]); $err = false; // delete files & check for errors for ($i = 0; $i < $cnt; ++$i) { $items[$i] = stripslashes($GLOBALS['__POST']["selitems"][$i]); if (nx_isFTPMode()) { $abs = get_item_info($dir, $items[$i]); } else { $abs = get_abs_item($dir, $items[$i]); } if (!@$GLOBALS['nx_File']->file_exists($abs)) { $error[$i] = $GLOBALS["error_msg"]["itemexist"]; $err = true; continue; } if (!get_show_item($dir, $items[$i])) { $error[$i] = $GLOBALS["error_msg"]["accessitem"]; $err = true; continue; } // Delete if (nx_isFTPMode()) { $abs = get_abs_item($dir, $abs); } $ok = $GLOBALS['nx_File']->remove($abs); if ($ok === false || PEAR::isError($ok)) { $error[$i] = $GLOBALS["error_msg"]["delitem"]; if (PEAR::isError($ok)) { $error[$i] .= ' [' . $ok->getMessage() . ']'; } $err = true; continue; } $error[$i] = NULL; } if ($err) { // there were errors $err_msg = ""; for ($i = 0; $i < $cnt; ++$i) { if ($error[$i] == NULL) { continue; } $err_msg .= $items[$i] . " : " . $error[$i] . "<br/>\n"; } show_error($err_msg); } $mainframe->redirect(make_link("list", $dir, null), $GLOBALS['messages']['success_delete_file']); }
function download_item($dir, $item, $unlink = false) { // download file global $action; // Security Fix: $item = basename($item); while (@ob_end_clean()) { } ob_start(); if (nx_isFTPMode()) { $abs_item = $dir . '/' . $item; } else { $abs_item = get_abs_item($dir, $item); if (!strstr($abs_item, realpath($GLOBALS['home_dir']))) { $abs_item = realpath($GLOBALS['home_dir']) . $abs_item; } } if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } if (!$GLOBALS['nx_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 (nx_isFTPMode()) { $abs_item = nx_ftp_make_local_copy($abs_item); $unlink = true; } $browser = id_browser(); header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream')); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize(realpath($abs_item))); //header("Content-Encoding: none"); if ($browser == 'IE') { header('Content-Disposition: attachment; filename="' . $item . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $item . '"'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); } @set_time_limit(0); @readFileChunked($abs_item); if ($unlink == true) { unlink($abs_item); } ob_end_flush(); nx_exit(); }
function rename_item($dir, $item) { // rename directory or file $mainframe =& JFactory::getApplication(); if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $newitemname = $GLOBALS['__POST']["newitemname"]; $newitemname = trim(basename(stripslashes($newitemname))); if ($newitemname == '') { show_error($GLOBALS["error_msg"]["miscnoname"]); } if (!nx_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['nx_File']->file_exists($abs_new)) { show_error($newitemname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]); } $perms_old = $GLOBALS['nx_File']->fileperms($abs_old); $ok = $GLOBALS['nx_File']->rename(get_abs_item($dir, $item), get_abs_item($dir, $newitemname)); if (nx_isFTPMode()) { $abs_new = get_item_info($dir, $newitemname); } $GLOBALS['nx_File']->chmod($abs_new, $perms_old); if ($ok === false || PEAR::isError($ok)) { show_error('Could not rename ' . $item . ' to ' . $newitemname); } $msg = sprintf($GLOBALS['messages']['success_rename_file'], $item, $newitemname); $mainframe->redirect(make_link("list", $dir, null), $msg); } show_header($GLOBALS['messages']['rename_file']); // Form echo '<br /><form method="post" action="'; echo make_link("rename", $dir, $item) . "\">\n"; echo "<input type=\"hidden\" name=\"confirm\" value=\"true\" />\n"; echo "<input type=\"hidden\" name=\"item\" value=\"" . stripslashes($GLOBALS['__GET']["item"]) . "\" />\n"; // Submit / Cancel echo "<table>\n<tr><tr><td colspan=\"2\">\n"; echo "<label for=\"newitemname\">" . $GLOBALS["messages"]["newname"] . ":</label> <input name=\"newitemname\" id=\"newitemname\" type=\"text\" size=\"60\" value=\"" . stripslashes($_GET['item']) . "\" /><br /><br /><br /></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"; }
function list_dir($dir) { // list directory contents global $dir_up, $_VERSION; //print_r('<br/>$dir: '.$dir); ?> <script type="text/javascript" src="<?php echo JURI::root(); ?> /includes/js/overlib_mini.js"></script> <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div> <?php $allow = ($GLOBALS["permissions"] & 01) == 01; $admin = ($GLOBALS["permissions"] & 04) == 04 || ($GLOBALS["permissions"] & 02) == 02; $dir_up = dirname($dir); //print_r('<br/>$dir_up: '.$dir_up); if ($dir_up == ".") { $dir_up = ""; } if (!get_show_item($dir_up, basename($dir))) { show_error($dir . " : " . $GLOBALS["error_msg"]["accessdir"]); } // make file & dir tables, & get total filesize & number of items $dir_list = array(); $file_list = array(); $tot_file_size = 0; $num_items = 0; make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items); $dirs = explode("/", $dir); $implode = ""; $dir_links = "<a href=\"" . make_link("list", "", null) . "\">..</a>/"; foreach ($dirs as $directory) { if ($directory != "") { $implode .= $directory . "/"; $dir_links .= "<a href=\"" . make_link("list", $implode, null) . "\">{$directory}</a>/"; } } show_header($GLOBALS["messages"]["actdir"] . ": " . $dir_links); // Javascript functions: include _QUIXPLORER_PATH . "/include/javascript.php"; // Sorting of items $images = " <img width=\"10\" height=\"10\" border=\"0\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/"; if ($GLOBALS["srt"] == "yes") { $_srt = "no"; $images .= "_arrowup.gif\" alt=\"^\">"; } else { $_srt = "yes"; $images .= "_arrowdown.gif\" alt=\"v\">"; } // Toolbar echo "<br><table width=\"95%\"><tr><td><table class='toolbar'><tr>\n"; // PARENT DIR echo "<td width='10px'>"; if ($dir != "") { echo "<a href=\"" . make_link("list", $dir_up, NULL) . "\">"; echo "<img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/arrow_turn_left.png\" "; echo "alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"></a>"; } echo "</td>\n"; // HOME DIR echo "<td width='10px'><a href=\"" . make_link("list", NULL, NULL) . "\">"; echo "<img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/home.png\" "; echo "alt=\"" . $GLOBALS["messages"]["homelink"] . "\" title=\"" . $GLOBALS["messages"]["homelink"] . "\"></a></td>\n"; // RELOAD echo "<td width='10px'><a href=\"javascript:location.reload();\"><img border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/arrow_refresh.png\" alt=\"" . $GLOBALS["messages"]["reloadlink"]; echo "\" title=\"" . $GLOBALS["messages"]["reloadlink"] . "\"></A></td>\n"; // SEARCH if (!nx_isFTPMode()) { echo "<td width='10px'><a href=\"" . make_link("search", $dir, NULL) . "\">"; echo "<img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/zoom.png\" "; echo "alt=\"" . $GLOBALS["messages"]["searchlink"] . "\" title=\"" . $GLOBALS["messages"]["searchlink"]; echo "\"></a></td>\n"; } echo "<td width='3px'><img src=\"images/menu_divider.png\" height=\"22\" width=\"2\" border=\"0\" alt=\"|\" /></td>"; // Joomla Sysinfo echo "<td width='10px'><a href=\"" . make_link("sysinfo", $dir, NULL) . "\">"; echo "<img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/server_chart.png\" "; echo "alt=\"" . $GLOBALS['messages']['mossysinfolink'] . "\" title=\"" . $GLOBALS['messages']['mossysinfolink'] . "\"></a></td>\n"; echo "<td width='3px'><img src=\"images/menu_divider.png\" height=\"22\" width=\"2\" border=\"0\" alt=\"|\" /></td>"; if ($allow) { // COPY echo "<td width='10px'><a href=\"javascript:Copy();\"><img border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/page_copy.png\" alt=\"" . $GLOBALS["messages"]["copylink"]; echo "\" title=\"" . $GLOBALS["messages"]["copylink"] . "\"></a></td>\n"; // MOVE echo "<td width='10px'><a href=\"javascript:Move();\"><img border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/folder_go.png\" alt=\"" . $GLOBALS["messages"]["movelink"]; echo "\" title=\"" . $GLOBALS["messages"]["movelink"] . "\"></A></td>\n"; // DELETE echo "<td width='10px'><a href=\"javascript:Delete();\"><img border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/delete.png\" alt=\"" . $GLOBALS["messages"]["dellink"]; echo "\" title=\"" . $GLOBALS["messages"]["dellink"] . "\"></A></td>\n"; // CHMOD echo "<td width='10px'><a href=\"javascript:Chmod();\"><img border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/chmod.png\" alt=\"chmod\" title=\"" . $GLOBALS['messages']['chmodlink'] . "\"></a></td>\n"; // UPLOAD if (ini_get("file_uploads")) { echo "<td width='10px'><a href=\"" . make_link("upload", $dir, NULL) . "\">"; echo "<img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_upload.gif\" alt=\"" . $GLOBALS["messages"]["uploadlink"]; echo "\" title=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></A></td>\n"; } else { echo "<td width='10px'><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_upload_.gif\" alt=\"" . $GLOBALS["messages"]["uploadlink"]; echo "\" title=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></td>\n"; } // ARCHIVE if (($GLOBALS["zip"] || $GLOBALS["tar"] || $GLOBALS["tgz"]) && !nx_isFTPMode()) { echo "<td width='10px'><a href=\"javascript:Archive();\"><img border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/compress.png\" alt=\"" . $GLOBALS["messages"]["comprlink"]; echo "\" title=\"" . $GLOBALS["messages"]["comprlink"] . "\"></a></td>\n"; } } else { // COPY echo "<td width='10px'><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_copy_.gif\" alt=\"" . $GLOBALS["messages"]["copylink"] . "\" title=\""; echo $GLOBALS["messages"]["copylink"] . "\"></td>\n"; // MOVE echo "<td width='10px'><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_move_.gif\" alt=\"" . $GLOBALS["messages"]["movelink"] . "\" title=\""; echo $GLOBALS["messages"]["movelink"] . "\"></td>\n"; // DELETE echo "<td width='10px'><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_delete_.gif\" alt=\"" . $GLOBALS["messages"]["dellink"] . "\" title=\""; echo $GLOBALS["messages"]["dellink"] . "\"></td>\n"; // UPLOAD echo "<td width='10px'><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_upload_.gif\" alt=\"" . $GLOBALS["messages"]["uplink"]; echo "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"></td>\n"; } if (file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_ose_cpu' . DS . 'filescan' . DS . 'filescan.php')) { echo "<td id='filescanerToolbar'>"; echo "<button id=\"cfgupdate\" class='button' onClick='DBInitialize()'>" . JText::_('Initialise DB with the selected directory') . "</button>"; echo "</td>"; } // ADMIN & LOGOUT if ($GLOBALS["require_login"]) { echo "<td width='10px'>::</td>"; // ADMIN if ($admin) { echo "<td width='10px'><a href=\"" . make_link("admin", $dir, NULL) . "\">"; echo "<img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_admin.gif\" alt=\"" . $GLOBALS["messages"]["adminlink"] . "\" title=\""; echo $GLOBALS["messages"]["adminlink"] . "\"></A></td>\n"; } // LOGOUT echo "<td width='10px'><a href=\"" . make_link("logout", NULL, NULL) . "\">"; echo "<img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_logout.gif\" alt=\"" . $GLOBALS["messages"]["logoutlink"] . "\" title=\""; echo $GLOBALS["messages"]["logoutlink"] . "\"></a></td>\n"; } // Create File / Dir if ($allow && @$GLOBALS['nx_File']->is_writable(get_abs_dir($dir))) { echo "<td align=\"right\">\n\t\t\t\t<form action=\"" . make_link("mkitem", $dir, NULL) . "\" method=\"post\" name=\"mkitemform\">\n\n\t\t\t\t<table><tr><td>\n\t\t\t\t\t<select name=\"mktype\" onchange=\"checkMkitemForm(this.options[this.selectedIndex])\">\n\t\t\t\t\t\t<option value=\"file\">" . $GLOBALS["mimes"]["file"] . "</option>\n\t\t\t\t\t\t<option value=\"dir\">" . $GLOBALS["mimes"]["dir"] . "</option>"; if (!nx_isFTPMode() && !$GLOBALS['isWindows']) { echo "\t\t\t<option value=\"symlink\">" . $GLOBALS["mimes"]["symlink"] . "</option>\n"; } echo "\t\t</select>\n\t\t\t\t\t<input name=\"symlink_target\" type=\"hidden\" size=\"25\" title=\"{$GLOBALS['messages']['symlink_target']}\" value=\"" . JPATH_BASE . "\" />\n\t\t\t\t\t<input name=\"mkname\" type=\"text\" size=\"15\" title=\"{$GLOBALS['messages']['nameheader']}\" />\n\t\t\t\t\t<input type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"] . "\" />\n\t\t\t\t\t</td></tr>\n\t\t\t\t\t<tr><td id=\"quick_jumpto\">" . list_bookmarks($dir) . "</td></tr>\n\t\t\t\t</table>\n\t\t\t\t<script type=\"text/javascript\">function checkMkitemForm( el ) { if( el.value =='symlink' ) document.mkitemform.symlink_target.type='text'; else document.mkitemform.symlink_target.type='hidden';} </script>\n\t\t\t\t</form>\n\t\t\t </td>\n"; } else { echo "<td align=\"right\">\n\t\t\t\t<table><tr><td id=\"quick_jumpto\">" . list_bookmarks($dir) . "</td></tr></table>\n\t\t\t </td>"; } echo "</tr></table>\n"; // End Toolbar // Begin Table + Form for checkboxes echo "<form name=\"selform\" method=\"post\" action=\"" . make_link("post", $dir, null) . "\">\n\t<input type=\"hidden\" name=\"do_action\" /><input type=\"hidden\" name=\"first\" value=\"y\" />\n\t<table class=\"adminlist\" width=\"95%\">\n"; if (extension_loaded("posix")) { $owner_info = '<th width="15%" class="title">' . $GLOBALS['messages']['miscowner'] . ' '; if (nx_isFTPMode()) { $my_user_info = posix_getpwnam($_SESSION['ftp_login']); $my_group_info = posix_getgrgid($my_user_info['gid']); } else { if (function_exists('posix_getpwuid')) { $my_user_info = posix_getpwuid(posix_geteuid()); $my_group_info = posix_getgrgid(posix_getegid()); } else { $my_user_info = "UID: " . posix_geteuid(); $my_group_info = "GID: " . posix_getegid(); } } $owner_info .= mosTooltip(mysql_escape_string(sprintf($GLOBALS['messages']['miscownerdesc'], $my_user_info['name'], $my_user_info['uid'], $my_group_info['name'], $my_group_info['gid']))); // new [mic] $owner_info .= "</th>\n"; $colspan = 8; } else { $owner_info = ""; $colspan = 7; } // Table Header echo "<tr>\n\t<th width=\"2%\" class=\"title\">\n\t\t<input type=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\" />\n\t</th>\n\t<th width=\"34%\" class=\"title\">\n"; if ($GLOBALS["order"] == "name") { $new_srt = $_srt; } else { $new_srt = "yes"; } echo "<a href=\"" . make_link("list", $dir, NULL, "name", $new_srt) . "\">" . $GLOBALS["messages"]["nameheader"]; if ($GLOBALS["order"] == "name") { echo $images; } echo '</a>'; echo "</th>\n\t<th width=\"10%\" class=\"title\">"; if ($GLOBALS["order"] == "size") { $new_srt = $_srt; } else { $new_srt = "yes"; } echo "<a href=\"" . make_link("list", $dir, NULL, "size", $new_srt) . "\">" . $GLOBALS["messages"]["sizeheader"]; if ($GLOBALS["order"] == "size") { echo $images; } echo "</a></th>\n\t<th width=\"14%\" class=\"title\">"; if ($GLOBALS["order"] == "type") { $new_srt = $_srt; } else { $new_srt = "yes"; } echo "<a href=\"" . make_link("list", $dir, NULL, "type", $new_srt) . "\">" . $GLOBALS["messages"]["typeheader"]; if ($GLOBALS["order"] == "type") { echo $images; } echo "</a></th>\n\t<th width=\"14%\" class=\"title\">"; if ($GLOBALS["order"] == "mod") { $new_srt = $_srt; } else { $new_srt = "yes"; } echo "<a href=\"" . make_link("list", $dir, NULL, "mod", $new_srt) . "\">" . $GLOBALS["messages"]["modifheader"]; if ($GLOBALS["order"] == "mod") { echo $images; } echo "</a></th>\n\t<th width=\"2%\" class=\"title\">" . $GLOBALS["messages"]["permheader"] . "\n"; echo "</th>"; echo $owner_info; echo "<th width=\"10%\" class=\"title\">" . $GLOBALS["messages"]["actionheader"] . "</th>\n\n\t</tr>\n"; // make & print Table using lists print_table($dir, make_list($dir_list, $file_list), $allow); // print number of items & total filesize echo "<tr><td colspan=\"{$colspan}\"><hr/></td></tr><tr>\n<td class=\"title\"></td>"; echo "<td class=\"title\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " ("; if (function_exists("disk_free_space")) { $size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']); $free = parse_file_size($size); } elseif (function_exists("diskfreespace")) { $size = diskfreespace($GLOBALS['home_dir'] . $GLOBALS['separator']); $free = parse_file_size($size); } else { $free = "?"; } echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</td>\n"; echo "<td class=\"title\">" . parse_file_size($tot_file_size) . "</td>\n"; for ($i = 0; $i < $colspan - 3; ++$i) { echo "<td class=\"title\"></td>"; } echo "</tr>\n<tr><td colspan=\"{$colspan}\"><hr/></td></tr></table>\n\t\t</form>"; ?> <script type="text/javascript"><!-- // Uncheck all items (to avoid problems with new items) var ml = document.selform; var len = ml.elements.length; for(var i=0; i<len; ++i) { var e = ml.elements[i]; if(e.name == "selitems[]" && e.checked == true) { e.checked=false; } } opacity('nx_logo', 10, 60, 2000); // --></script> <?php }
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=\"\" /> <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 . "\"> " . $s_item . " "; // 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)); }
function is_chmodable($file) { global $isWindows; if ($isWindows) { return true; } if (nx_isFTPMode()) { return $_SESSION['ftp_login'] == $file['user']; } else { return @$GLOBALS['nx_File']->fileowner($file) == @$GLOBALS['nx_File']->geteuid(); } }
$task = JArrayHelper::getValue($_REQUEST, 'task'); require _QUIXPLORER_PATH . '/include/fun_bookmarks.php'; modify_bookmark($task, $dir); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case 'show_error': show_error(''); break; //------------------------------------------------------------------------------ // DEFAULT: LIST FILES & DIRS //------------------------------------------------------------------------------ // DEFAULT: LIST FILES & DIRS case "list": default: require _QUIXPLORER_PATH . "/include/fun_list.php"; list_dir($dir); //------------------------------------------------------------------------------ } // end switch-statement //------------------------------------------------------------------------------ show_footer(); // Disconnect from ftp server if (nx_isFTPMode()) { $GLOBALS['FTPCONNECTION']->disconnect(); } // Empty the output buffer if this is a XMLHttpRequest if (nx_isXHR()) { nx_exit(); } //------------------------------------------------------------------------------
if (!isset($_REQUEST['dir'])) { $GLOBALS["dir"] = $dir = $arrayHelper->getValue($_SESSION, 'nx_' . $GLOBALS['file_mode'] . 'dir', ''); if (!empty($dir)) { $dir = @$dir[0] == '/' ? substr($dir, 1) : $dir; } $try_this = nx_isFTPMode() ? '/' . $dir : $GLOBALS['home_dir'] . '/' . $dir; if (!empty($dir) && !$GLOBALS['nx_File']->file_exists($try_this)) { $dir = ''; } } else { $GLOBALS["dir"] = $dir = urldecode(stripslashes($arrayHelper->getValue($_REQUEST, "dir"))); } if ($dir == 'nx_root') { $GLOBALS["dir"] = $dir = ''; } if (nx_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"]);
function down_home($abs_dir) { // dir deeper than home? if (nx_isFTPMode()) { return true; } $real_home = @realpath($GLOBALS["home_dir"]); $real_dir = @realpath($abs_dir); if ($real_home === false || $real_dir === false) { if (@eregi("\\.\\.", $abs_dir)) { return false; } } else { if (strcmp($real_home, @substr($real_dir, 0, strlen($real_home)))) { return false; } } return true; }
function upload_items($dir) { // upload file if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $cnt = count($GLOBALS['__FILES']['userfile']['name']); $err = false; $err_avaliable = isset($GLOBALS['__FILES']['userfile']['error']); // upload files & check for errors for ($i = 0; $i < $cnt; $i++) { $errors[$i] = NULL; $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i]; $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]); if ($err_avaliable) { $up_err = $GLOBALS['__FILES']['userfile']['error'][$i]; } else { $up_err = file_exists($tmp) ? 0 : 4; } $abs = get_abs_item($dir, $items[$i]); if ($items[$i] == "" || $up_err == 4) { continue; } if ($up_err == 1 || $up_err == 2) { $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"]; $err = true; continue; } if ($up_err == 3) { $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"]; $err = true; continue; } if (!@is_uploaded_file($tmp)) { $errors[$i] = $GLOBALS["error_msg"]["uploadfile"]; $err = true; continue; } if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) { $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"]; $err = true; continue; } // Upload $ok = @$GLOBALS['nx_File']->move_uploaded_file($tmp, $abs); if ($ok === false || PEAR::isError($ok)) { $errors[$i] = $GLOBALS["error_msg"]["uploadfile"]; if (PEAR::isError($ok)) { $errors[$i] .= ' [' . $ok->getMessage() . ']'; } $err = true; continue; } elseif (!nx_isFTPMode()) { @$GLOBALS['nx_File']->chmod($abs, 0644); } } if ($err) { // there were errors $err_msg = ""; for ($i = 0; $i < $cnt; $i++) { if ($errors[$i] == NULL) { continue; } $err_msg .= $items[$i] . " : " . $errors[$i] . "<BR>\n"; } show_error($err_msg); } header("Location: " . make_link("list", $dir, NULL)); return; } show_header($GLOBALS["messages"]["actupload"]); // List echo "<br /><form enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL) . "\" method=\"post\">\n\t\t\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"" . get_max_file_size() . "\" />\n\t\t\t<input type=\"hidden\" name=\"confirm\" value=\"true\" />\n\t\t<table style=\"width:60%;\" border=\"1\" class=\"adminform\">\n\t\t\t<tr><td class=\"quote\" colspan=\"2\">Maximum File Size = <strong>" . get_max_file_size() / 1024 / 1024 . " MB</strong><br />\n\t\t\t\tMaximum Upload Limit = <strong>" . get_max_upload_limit() / 1024 / 1024 . " MB</strong>\n\t\t\t</td></tr>\n\t\t\t"; for ($i = 0; $i < 10; $i++) { $class = $i % 2 ? 'row0' : 'row1'; echo "<tr class=\"{$class}\"><td colspan=\"2\">"; echo "<input name=\"userfile[]\" type=\"file\" size=\"50\" class=\"inputbox\" /></td></tr>\n"; } echo "<tr><td colspan=\"2\">\n\t\t\t\t<input type=\"checkbox\" checked=\"checked\" value=\"1\" name=\"overwrite_files\" id=\"overwrite_files\" /><label for=\"overwrite_files\">" . $GLOBALS["messages"]["overwrite_files"] . "</label>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td width=\"40%\" style=\"text-align:right;\">\n\t\t\t\t\t<input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnupload"] . "\" class=\"button\" /> \n\t\t\t\t</td>\n\t\t\t\t<td width=\"60%\" style=\"text-align:left;\"> \n\t\t\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"] . "\" class=\"button\" onclick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\" />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form><br />\n"; return; }
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 (nx_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } $item = $GLOBALS['__POST']["selitems"][$i]; if (nx_isFTPMode()) { $abs_item = get_item_info($dir, $item); } else { $abs_item = get_abs_item($dir, $item); } if (!$GLOBALS['nx_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['nx_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 (nx_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } } $ok = @$GLOBALS['nx_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 (nx_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] . " </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"; }