function dir_print($dir_list, $new_dir) { // print list of directories // this list is used to copy/move items to a specific location // Link to Parent Directory $dir_up = dirname($new_dir); if ($dir_up == ".") { $dir_up = ""; } echo "<tr><td><a href=\"javascript:NewDir('" . $dir_up; echo "');\"><img border=\"0\" width=\"16\" height=\"16\""; echo " align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/arrow_turn_left.png\" alt=\"\"> ..</a></td></tr>\n"; // Print List Of Target Directories if (!is_array($dir_list)) { return; } while (list($new_item, $info) = each($dir_list)) { if (is_array($info)) { $new_item = $info['name']; } $s_item = $new_item; if (strlen($s_item) > 40) { $s_item = substr($s_item, 0, 37) . "..."; } echo "<tr><td><a href=\"javascript:NewDir('" . get_rel_item($new_dir, $new_item) . "');\"><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" " . "src=\"" . _QUIXPLORER_URL . "/images/folder.png\" alt=\"\"> " . $s_item . "</a></td></tr>\n"; } }
function edit_file($dir, $item) { if (!permissions_grant($dir, $item, "change")) { show_error($GLOBALS["error_msg"]["accessfunc"]); } if (!get_is_file($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]); } $fname = get_abs_item($dir, $item); if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") { // Save / Save As $item = basename(stripslashes($GLOBALS['__POST']["fname"])); $fname2 = get_abs_item($dir, $item); if (!isset($item) || $item == "") { show_error($GLOBALS["error_msg"]["miscnoname"]); } if ($fname != $fname2 && @file_exists($fname2)) { show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]); } savefile($fname2); $fname = $fname2; } // open file $fp = @fopen($fname, "r"); if ($fp === false) { show_error($item . ": " . $GLOBALS["error_msg"]["openfile"]); } // header $s_item = get_rel_item($dir, $item); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item); // Wordwrap (works only in IE) ?> <script language="JavaScript1.2" type="text/javascript"> <!-- function chwrap() { if(document.editfrm.wrap.checked) { document.editfrm.code.wrap="soft"; } else { document.editfrm.code.wrap="off"; } } // --> </script> <script language="Javascript" type="text/javascript"> // initialisation editAreaLoader.init({ id: "txtedit" // id of the textarea to transform ,start_highlight: true // if start with highlight ,allow_resize: "both" //,min_width = 400 //,min_height = 100 //,allow_resize: "y" ,allow_toggle: true ,word_wrap: true ,language: "<?php echo $GLOBALS["language"]; ?> " ,syntax: "<?php echo get_mime_type($dir, $item, "ext"); ?> " }); </script> <?php // Form echo "<BR><FORM name=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n"; echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\">\n"; echo "<TEXTAREA NAME=\"code\" ID=\"txtedit\" rows=\"25\" cols=\"120\" wrap=\"off\">"; // Show File In TextArea $buffer = ""; while (!feof($fp)) { $buffer .= fgets($fp, 4096); } @fclose($fp); //echo htmlspecialchars($buffer); echo $buffer; echo "</TEXTAREA><BR>\n<TABLE><TR><TD>Wordwrap: (IE only)</TD><TD><INPUT type=\"checkbox\" name=\"wrap\" "; echo "onClick=\"javascript:chwrap();\" value=\"1\"></TD></TR></TABLE><BR>\n"; echo "<TABLE><TR><TD><INPUT type=\"text\" name=\"fname\" value=\"" . $item . "\"></TD>"; echo "<TD><input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnsave"]; echo "\"></TD>\n<TD><input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\"></TD>\n<TD>"; echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onClick=\"javascript:location='"; echo make_link("list", $dir, NULL) . "';\"></TD></TR></FORM></TABLE><BR>\n"; ?> <script language="JavaScript1.2" type="text/javascript"> <!-- if(document.editfrm) document.editfrm.code.focus(); // --> </script><?php }
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; }
function edit_file($dir, $item) { // edit file $mainframe =& JFactory::getApplication(); if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } $fname = get_abs_item($dir, $item); if (!get_is_file($fname)) { show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]); } if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") { // Save / Save As $item = basename(stripslashes($GLOBALS['__POST']["fname"])); $fname2 = get_abs_item($dir, $item); if (!isset($item) || $item == "") { show_error($GLOBALS["error_msg"]["miscnoname"]); } if ($fname != $fname2 && @$GLOBALS['nx_File']->file_exists($fname2)) { show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]); } savefile($fname2); $fname = $fname2; if (!empty($GLOBALS['__POST']['return_to'])) { $return_to = urldecode($GLOBALS['__POST']['return_to']); $mainframe->redirect($return_to); } elseif (!empty($GLOBALS['__POST']['return_to_dir'])) { $mainframe->redirect($_SERVER['PHP_SELF'] . '?option=com_osefileman&dir=' . $dir, 'The File ' . $item . ' was saved.'); } } // header $s_item = get_rel_item($dir, $item); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item); $s_info = pathinfo($s_item); $s_extension = str_replace('.', '', $s_info['extension']); switch (strtolower($s_extension)) { case 'txt': case 'ini': $cp_lang = 'text'; break; case 'cs': $cp_lang = 'csharp'; break; case 'css': $cp_lang = 'css'; break; case 'html': case 'htm': case 'xml': case 'xhtml': $cp_lang = 'html'; break; case 'java': $cp_lang = 'java'; break; case 'js': $cp_lang = 'javascript'; break; case 'pl': $cp_lang = 'perl'; break; case 'ruby': $cp_lang = 'ruby'; break; case 'sql': $cp_lang = 'sql'; break; case 'vb': case 'vbs': $cp_lang = 'vbscript'; break; case 'php': $cp_lang = 'php'; break; default: $cp_lang = 'generic'; } // Form echo '<script type="text/javascript" src="components/com_osefileman/scripts/codepress/codepress.js"></script>'; echo "<br/><form name=\"editfrm\" id=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n"; if (!empty($GLOBALS['__GET']['return_to'])) { $close_action = 'window.location=\'' . urldecode($GLOBALS['__GET']['return_to']) . '\';'; echo "<input type=\"hidden\" name=\"return_to\" value=\"" . $GLOBALS['__GET']['return_to'] . "\" />\n"; } else { $close_action = 'window.location=\'' . make_link('list', $dir, NULL) . "'"; } $submit_action = ' document.editfrm.code.value=codearea_ta.getCode();document.editfrm.submit();'; echo "\n<table class=\"adminform\">\n\t<tr>\n\t\t<td style=\"text-align: center;\">\n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnsave"] . "\" onclick=\"{$submit_action}\" /> \n\t\t\t<input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\" /> \n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onclick=\"javascript:{$close_action}\" />\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td >\n\t\t\t<div id=\"positionIndicator\" style=\"width: 20%;float:left;\">" . $GLOBALS["messages"]["line"] . ": <input type=\"text\" name=\"txtLine\" class=\"inputbox\" size=\"6\" onchange=\"setCaretPosition(document.editfrm.code, this.value);return false;\" /> " . $GLOBALS["messages"]["column"] . ": <input type=\"text\" name=\"txtColumn\" class=\"inputbox\" size=\"6\" readonly=\"readonly\" />\n </div>\n\t\t\t<div style=\"width:70%;text-align: center;float:left;\">\n\t\t\t\t<input type=\"checkbox\" value=\"1\" name=\"return_to_dir\" id=\"return_to_dir\" />\n\t\t\t\t<label for=\"return_to_dir\">" . $GLOBALS["messages"]["returndir"] . "</label>\n\t\t\t</div>"; echo "\n\t\t</td>\n\t</tr>\n\t<tr><td>"; echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\" />\n"; // Show File In TextArea $content = $GLOBALS['nx_File']->file_get_contents($fname); if (get_magic_quotes_runtime()) { $content = stripslashes($content); } $content = htmlspecialchars($content); echo '[<a href="javascript:;" onclick="positionIndicator.toggle(); codearea_ta.toggleEditor();return false;">' . $GLOBALS['messages']['editor_simple'] . ' / ' . $GLOBALS['messages']['editor_syntaxhighlight'] . '</a>]'; echo '<div id="editorarea"> <textarea class="codepress ' . $cp_lang . '" style="width:95%;" name="codearea" id="codearea" rows="25" cols="120" wrap="off" onmouseup="updatePosition(this)" onmousedown="updatePosition(this)" onkeyup="updatePosition(this)" onkeydown="updatePosition(this)" onfocus="updatePosition(this)">' . $content . '</textarea> <input type="hidden" name="code" value="" /> </div><br/>'; echo "\n\t</td>\n\t</tr>"; echo "\n\t<tr>\n\t\t<td align=\"right\">\n\t\t\t<label for=\"fname\">" . $GLOBALS["messages"]["copyfile"] . "</label>\n\t\t\t<input type=\"text\" name=\"fname\" value=\"" . $item . "\" size=\"40\" />\n\t\t</td>\n\t</tr>\n</table>\n<br/>"; echo "</form><br/>\n"; }
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] . " </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"; }
function execAction($dir, $item) { // edit file global $mainframe, $mosConfig_live_site; if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('edit', false, ext_Lang::err('accessfunc')); } $fname = ext_TextEncoding::fromUTF8(get_abs_item($dir, $item)); if (!get_is_file($fname)) { ext_Result::sendResult('edit', false, ext_TextEncoding::toUTF8($item) . ": " . ext_Lang::err('fileexist')); } if (!get_show_item($dir, $item)) { ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('accessfile')); } if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") { // Save / Save As $item = basename(stripslashes($GLOBALS['__POST']["fname"])); $fname2 = ext_TextEncoding::fromUTF8(get_abs_item($dir, $item)); if (!isset($item) || $item == "") { ext_Result::sendResult('edit', false, ext_Lang::err('miscnoname')); } if ($fname != $fname2 && @$GLOBALS['ext_File']->file_exists($fname2)) { ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('itemdoesexist')); } $this->savefile($fname2); $fname = $fname2; ext_Result::sendResult('edit', true, ext_Lang::msg('savefile') . ': ' . $item); } if (isset($GLOBALS['__POST']["doreopen"]) && $GLOBALS['__POST']["doreopen"] == "yes") { // File Reopen $extra = array(); $content = $GLOBALS['ext_File']->file_get_contents($fname); if (get_magic_quotes_runtime()) { $content = stripslashes($content); } $langs = $GLOBALS["language"]; if ($langs == "japanese") { $_encoding = $GLOBALS['__POST']["file_encoding"]; if ($content) { $content = mb_convert_encoding($content, "UTF-8", $_encoding); } $extra["file_encoding"] = $_encoding; } $extra["content"] = $content; ext_Result::sendResult('edit', true, ext_Lang::msg('reopenfile') . ': ' . $item, $extra); } // header $s_item = get_rel_item($dir, $item); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } $id_hash = substr('f' . md5($s_item), 0, 10); $s_info = pathinfo($s_item); $s_extension = str_replace('.', '', $s_info['extension']); switch (strtolower($s_extension)) { case 'txt': $cp_lang = 'text'; break; case 'cs': $cp_lang = 'csharp'; break; case 'css': $cp_lang = 'css'; break; case 'html': case 'htm': case 'xhtml': $cp_lang = 'html'; break; case 'java': $cp_lang = 'java'; break; case 'js': $cp_lang = 'js'; break; case 'pl': $cp_lang = 'perl'; break; case 'py': $cp_lang = 'python'; break; case 'ruby': $cp_lang = 'ruby'; break; case 'sql': $cp_lang = 'sql'; break; case 'vb': case 'vbs': $cp_lang = 'vb'; break; case 'php': $cp_lang = 'php'; break; case 'xml': $cp_lang = 'xml'; break; default: $cp_lang = ''; } $content = $GLOBALS['ext_File']->file_get_contents($fname); if (get_magic_quotes_runtime()) { $content = stripslashes($content); } $cw = 250; $langs = $GLOBALS["language"]; if ($langs == "japanese") { $cw = 200; if ($content) { $_encoding = strtoupper(mb_detect_encoding($content, array("ASCII", "ISO-2022-JP", "UTF-8", "EUCJP-WIN", "SJIS-WIN"), true)); $content = mb_convert_encoding($content, "UTF-8", $_encoding); if ($_encoding == "SJIS-WIN") { $_encoding_label = "SJIS"; } elseif ($_encoding == "EUCJP-WIN") { $_encoding_label = "EUC-JP"; } elseif ($_encoding == "ISO-2022-JP") { $_encoding_label = "JIS"; } elseif ($_encoding == "ASCII") { $_encoding_label = "UTF-8"; } else { $_encoding_label = $_encoding; } } else { $_encoding_label = "UTF-8"; } } ?> { "xtype": "form", "id": "<?php echo $id_hash; ?> ", "labelWidth": "300", "autoScroll": "true", "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "title": "<?php echo strlen($s_item) > 50 ? substr($s_item, strlen($s_item) - 30, 30) : $s_item; ?> ", "frame": "true", "closable": "true", "tbar": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('save_processing', true); ?> ', true ); form = Ext.getCmp("<?php echo $id_hash; ?> ").getForm(); form.submit({ waitMsg: 'Saving the File, please wait...', reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); }, failure: function(form, action) { statusBarMessage( action.result.error, false, false ); Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> !', action.result.error); }, scope: form, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'edit', code: editAreaLoader.getValue("ext_codefield<?php echo $id_hash; ?> "), dir: '<?php echo stripslashes($dir); ?> ', item: '<?php echo stripslashes($item); ?> ', dosave: 'yes' } }); }, "cls":"x-btn-text-icon", "icon": "<?php echo _EXT_URL; ?> /images/_save.png" },{ "text": "<?php echo ext_Lang::msg('btnreopen', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('reopen_processing', true); ?> ', true ); form = Ext.getCmp("<?php echo $id_hash; ?> ").getForm(); form.submit({ waitMsg: 'Processing Data, please wait...', reset: false, success: function(form, action) { statusBarMessage( action.result.message, false, true ); editAreaLoader.setValue("ext_codefield<?php echo $id_hash; ?> ", action.result.content); }, failure: function(form, action) { statusBarMessage( action.result.error, false, false ); Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> !', action.result.error); }, scope: form, // add some vars to the request, similar to hidden fields params: { option: 'com_extplorer', action: 'edit', dir: '<?php echo stripslashes($dir); ?> ', item: '<?php echo stripslashes($item); ?> ', doreopen: 'yes' } }); }, "cls":"x-btn-text-icon", "icon": "<?php echo _EXT_URL; ?> /images/_reload.png" }, { "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("mainpanel").remove( Ext.getCmp("mainpanel").getActiveTab() ); }, "cls":"x-btn-text-icon", "icon": "<?php echo _EXT_URL; ?> /images/_cancel.png" }], "items": [{ "xtype": "displayfield", "value": "<?php echo $GLOBALS["messages"]["actedit"] . ": {$s_item}"; ?> " }, { "xtype": "textarea", "hideLabel": true, "name": "thecode", "id": "ext_codefield<?php echo $id_hash; ?> ", "fieldClass": "x-form-field", "value": "<?php echo str_replace(array("\r", "\n"), array('\\r', '\\n'), addslashes($content)); ?> ", "width": "100%", "height": 500, "plugins": new Ext.ux.plugins.EditAreaEditor({ "id" : "ext_codefield<?php echo $id_hash; ?> ", "syntax": "<?php echo $cp_lang; ?> ", "start_highlight": true, "display": "later", "toolbar": "search, go_to_line, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, |, help" <?php if (array_key_exists($langs, $this->lang_tbl)) { ?> ,"language": "<?php echo $this->lang_tbl[$langs]; ?> " <?php } ?> }) }, { "width": "<?php echo $cw; ?> ", "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('copyfile', true); ?> ", "name": "fname", "value": "<?php echo $item; ?> ", "clear": "true" } <?php if ($langs == "japanese") { ?> ,{ "width": "<?php echo $cw; ?> ", "style":"margin-left:10px", "clear":"true", "xtype": "combo", "fieldLabel": "<?php echo ext_Lang::msg('fileencoding', true); ?> ", "name": "file_encoding", "store": [ ["UTF-8", "UTF-8"], ["SJIS-WIN", "SJIS"], ["EUCJP-WIN", "EUC-JP"], ["ISO-2022-JP","JIS"] ], "value" : "<?php echo $_encoding_label; ?> ", "typeAhead": "true", "mode": "local", "triggerAction": "all", "editable": "false", "forceSelection": "true" } <?php } ?> ] } <?php }
function print_table($dir, $list, $allow) { // print table of files global $dir_up; if (!is_array($list)) { return; } if ($dir != "" || strstr($dir, _EXT_PATH)) { echo "<tr class=\"sectiontableentry1\"><td valign=\"baseline\"><a href=\"" . make_link("list", $dir_up, NULL) . "\">"; echo "<img border=\"0\" align=\"absmiddle\" src=\"" . _EXT_URL . "/images/up.png\" "; echo "alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"/> ..</a></td>\n"; echo "<td> </td><td> </td><td> </td>"; echo "</tr>"; } $i = 0; while (list($item, ) = each($list)) { if ($item == 'index.html') { continue; } $abs_item = get_abs_item($dir, $item); $is_writable = is_writable($abs_item); $is_chmodable = $GLOBALS['ext_File']->is_chmodable($abs_item); $is_readable = is_readable($abs_item); $is_deletable = $GLOBALS['ext_File']->is_deletable($abs_item); $file_info = @stat($abs_item); $is_file = false; //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 = make_link("download", $dir, $item); $is_file = true; } //else $link = ""; $class = $i % 2 ? 'sectiontableentry1' : 'sectiontableentry2'; //echo "<tr class=\"rowdata\">" echo '<tr class="' . $class . '">'; // Icon + Link echo "<td nowrap=\"nowrap\">"; if ($is_readable) { echo "<a href=\"" . $link . "\""; if ($is_file) { echo " title=\"" . $GLOBALS["messages"]["downlink"] . ": " . $item . "\""; } echo ">"; } //else echo "<A>"; echo "<img border=\"0\" "; echo "align=\"absmiddle\" vspace=\"5\" hspace=\"5\" src=\"" . _EXT_URL . "/images/" . get_mime_type($abs_item, "img") . "\" alt=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } $s_item = htmlspecialchars($s_item); if (!$is_file) { echo '<strong>' . $s_item . '</strong>'; } else { echo $s_item; } 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"; // actions echo "</tr>\n"; $i++; } }
function execAction($dir, $item) { // edit file global $mainframe, $mosConfig_live_site; if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('edit', false, ext_Lang::err('accessfunc')); } $fname = get_abs_item($dir, $item); if (!get_is_file(utf8_decode($fname))) { ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('fileexist')); } if (!get_show_item($dir, $item)) { ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('accessfile')); } if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") { // Save / Save As $item = basename(stripslashes($GLOBALS['__POST']["fname"])); $fname2 = get_abs_item($dir, $item); if (!isset($item) || $item == "") { ext_Result::sendResult('edit', false, ext_Lang::err('miscnoname')); } if ($fname != $fname2 && @$GLOBALS['ext_File']->file_exists($fname2)) { ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('itemdoesexist')); } $this->savefile($fname2); $fname = $fname2; ext_Result::sendResult('edit', true, ext_Lang::msg('savefile') . ': ' . $item); } // header $s_item = get_rel_item($dir, $item); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } $s_info = pathinfo($s_item); $s_extension = str_replace('.', '', $s_info['extension']); switch (strtolower($s_extension)) { case 'txt': $cp_lang = 'text'; break; case 'cs': $cp_lang = 'csharp'; break; case 'css': $cp_lang = 'css'; break; case 'html': case 'htm': case 'xml': case 'xhtml': $cp_lang = 'html'; break; case 'java': $cp_lang = 'java'; break; case 'js': $cp_lang = 'javascript'; break; case 'pl': $cp_lang = 'perl'; break; case 'ruby': $cp_lang = 'ruby'; break; case 'sql': $cp_lang = 'sql'; break; case 'vb': case 'vbs': $cp_lang = 'vbscript'; break; case 'php': $cp_lang = 'php'; break; default: $cp_lang = 'generic'; } ?> <div style="width:auto;"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;"><?php echo $GLOBALS["messages"]["actedit"] . ": /" . $s_item . ' '; ?> </h3> <div id="adminForm"> </div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <?php // Show File In TextArea $content = $GLOBALS['ext_File']->file_get_contents($fname); if (get_magic_quotes_runtime()) { $content = stripslashes($content); } //$content = htmlspecialchars( $content ); ?> <script type="text/javascript">//<!-- dialog.setContentSize( 700, 500 ); simple = new Ext.form.Form({ labelAlign: 'top', url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); simple.add( new Ext.form.TextArea({ fieldLabel: 'File Contents', name: 'thecode', id: 'ext_codefield', fieldClass: 'x-form-field', value: '<?php echo str_replace(array("\r", "\n", '<', '>'), array('\\r', '\\n', '<', '>'), addslashes($content)); ?> ', width: '100%', height: 300 }) ); simple.column( {width: 250 }, new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('copyfile', true); ?> ', name: 'fname', value: '<?php echo $item; ?> ', width:175 }) ); simple.column( {width: 250, style:'margin-left:10px', clear:true }, new Ext.form.Checkbox({ fieldLabel: '<?php echo ext_Lang::msg('returndir', true); ?> ', name: 'return_to_dir', width:175 }) ); simple.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( '<?php echo ext_Lang::msg('save_processing', true); ?> ', true ); simple.submit({ //waitMsg: 'Processing Data, please wait...', //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); if( simple.findField('return_to_dir').getValue() ) { dialog.destroy(); } }, failure: function(form, action) { statusBarMessage( action.result.error, false, false ); Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> !', action.result.error); }, scope: simple, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'edit', code: editAreaLoader.getValue("ext_codefield"), dir: '<?php echo stripslashes($dir); ?> ', item: '<?php echo stripslashes($item); ?> ', dosave: 'yes' } }); }); simple.addButton('<?php echo ext_Lang::msg('btnclose', true); ?> ', function() { dialog.destroy(); } ); simple.render('adminForm'); simple.findField('thecode').setValue(simple.findField( 'thecode').getValue().replace( />/g, '>').replace( /</g, '<')); editAreaLoader.baseURL = "<?php echo _EXT_URL; ?> /scripts/editarea/"; editAreaLoader.init({ id : "ext_codefield" // textarea id ,syntax: "<?php echo $cp_lang; ?> " // syntax to be uses for highgliting ,start_highlight: true // to display with highlight mode on start-up ,display: "later" }); editAreaLoader.start("ext_codefield"); // --> </script><?php }
function chmod_item($dir, $item) { if (!permissions_grant($dir, NULL, "change")) { show_error($GLOBALS["error_msg"]["accessfunc"]); } if (!file_exists(get_abs_item($dir, $item))) { show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]); } // 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 (!@chmod(get_abs_item($dir, $item), bindec($bin))) { show_error($item . ": " . $GLOBALS["error_msg"]["permchange"]); } header("Location: " . make_link("link", $dir, NULL)); return; } $mode = parse_file_perms(get_file_perms($dir, $item)); if ($mode === false) { show_error($item . ": " . $GLOBALS["error_msg"]["permread"]); } $pos = "rwx"; $s_item = get_rel_item($dir, $item); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } show_header($GLOBALS["messages"]["actperms"] . ": /" . $s_item); // Form echo "<BR><TABLE width=\"175\"><FORM method=\"post\" action=\""; echo make_link("chmod", $dir, $item) . "\">\n"; echo "<INPUT type=\"hidden\" name=\"confirm\" value=\"true\">\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>" . $pos[$j] . " <INPUT type=\"checkbox\""; if ($mode[3 * $i + $j] != "-") { echo " checked"; } echo " name=\"r_" . $i . $j . "\" value=\"1\"></TD>"; } echo "</TR>\n"; } // Submit / Cancel echo "</TABLE>\n<BR><TABLE>\n<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 $QUIXPATH; $allow = ($GLOBALS["permissions"] & 01) == 01; $admin = ($GLOBALS["permissions"] & 04) == 04 || ($GLOBALS["permissions"] & 02) == 02; $dir_up = dirname($dir); 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 make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items); $s_dir = $dir; if (strlen($s_dir) > 50) { $s_dir = "..." . substr($s_dir, -47); } show_header($GLOBALS["messages"]["actdir"] . ": /" . get_rel_item("", $s_dir)); // Javascript functions: include $QUIXPATH . ".include/javascript.php"; // Sorting of items $_img = " <IMG width=\"10\" height=\"10\" border=\"0\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/"; if ($GLOBALS["srt"] == "yes") { $_srt = "no"; $_img .= "_arrowup.gif\" ALT=\"^\">"; } else { $_srt = "yes"; $_img .= "_arrowdown.gif\" ALT=\"v\">"; } // Toolbar echo "<BR><TABLE width=\"95%\"><TR><TD><TABLE><TR>\n"; // PARENT DIR echo "<TD><A HREF=\"" . make_link("list", $dir_up, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_up.gif\" "; echo "ALT=\"" . $GLOBALS["messages"]["uplink"] . "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></A></TD>\n"; // HOME DIR echo "<TD><A HREF=\"" . make_link("list", NULL, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_home.gif\" "; echo "ALT=\"" . $GLOBALS["messages"]["homelink"] . "\" TITLE=\"" . $GLOBALS["messages"]["homelink"] . "\"></A></TD>\n"; // RELOAD echo "<TD><A HREF=\"javascript:location.reload();\"><IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_refresh.gif\" ALT=\"" . $GLOBALS["messages"]["reloadlink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["reloadlink"] . "\"></A></TD>\n"; // SEARCH echo "<TD><A HREF=\"" . make_link("search", $dir, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_search.gif\" "; echo "ALT=\"" . $GLOBALS["messages"]["searchlink"] . "\" TITLE=\"" . $GLOBALS["messages"]["searchlink"]; echo "\"></A></TD>\n"; echo "<TD>::</TD>"; if ($allow) { // COPY echo "<TD><A HREF=\"javascript:Copy();\"><IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_copy.gif\" ALT=\"" . $GLOBALS["messages"]["copylink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["copylink"] . "\"></A></TD>\n"; // MOVE echo "<TD><A HREF=\"javascript:Move();\"><IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_move.gif\" ALT=\"" . $GLOBALS["messages"]["movelink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["movelink"] . "\"></A></TD>\n"; // DELETE echo "<TD><A HREF=\"javascript:Delete();\"><IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_delete.gif\" ALT=\"" . $GLOBALS["messages"]["dellink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["dellink"] . "\"></A></TD>\n"; // UPLOAD if (get_cfg_var("file_uploads")) { echo "<TD><A HREF=\"" . make_link("upload", $dir, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_upload.gif\" ALT=\"" . $GLOBALS["messages"]["uploadlink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></A></TD>\n"; } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_upload_.gif\" ALT=\"" . $GLOBALS["messages"]["uploadlink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></TD>\n"; } // ARCHIVE if ($GLOBALS["zip"] || $GLOBALS["tar"] || $GLOBALS["tgz"]) { echo "<TD><A HREF=\"javascript:Archive();\"><IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"../files/quixexplorer/_archive.gif\" ALT=\"" . $GLOBALS["messages"]["comprlink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["comprlink"] . "\"></A></TD>\n"; } } else { // COPY echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_copy_.gif\" ALT=\"" . $GLOBALS["messages"]["copylink"] . "\" TITLE=\""; echo $GLOBALS["messages"]["copylink"] . "\"></TD>\n"; // MOVE echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_move_.gif\" ALT=\"" . $GLOBALS["messages"]["movelink"] . "\" TITLE=\""; echo $GLOBALS["messages"]["movelink"] . "\"></TD>\n"; // DELETE echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_delete_.gif\" ALT=\"" . $GLOBALS["messages"]["dellink"] . "\" TITLE=\""; echo $GLOBALS["messages"]["dellink"] . "\"></TD>\n"; // UPLOAD echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_upload_.gif\" ALT=\"" . $GLOBALS["messages"]["uplink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></TD>\n"; } // ADMIN & LOGOUT if ($GLOBALS["require_login"]) { echo "<TD>::</TD>"; // ADMIN if ($admin) { echo "<TD><A HREF=\"" . make_link("admin", $dir, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_admin.gif\" ALT=\"" . $GLOBALS["messages"]["adminlink"] . "\" TITLE=\""; echo $GLOBALS["messages"]["adminlink"] . "\"></A></TD>\n"; } // LOGOUT echo "<TD><A HREF=\"" . make_link("logout", NULL, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"../files/quixexplorer/_logout.gif\" ALT=\"" . $GLOBALS["messages"]["logoutlink"] . "\" TITLE=\""; echo $GLOBALS["messages"]["logoutlink"] . "\"></A></TD>\n"; } echo "</TR></TABLE></TD>\n"; // Create File / Dir if ($allow) { echo "<TD align=\"right\"><TABLE><FORM action=\"" . make_link("mkitem", $dir, NULL) . "\" method=\"post\">\n<TR><TD>"; echo "<SELECT name=\"mktype\"><option value=\"file\">" . $GLOBALS["mimes"]["file"] . "</option>"; echo "<option value=\"dir\">" . $GLOBALS["mimes"]["dir"] . "</option></SELECT>\n"; echo "<INPUT name=\"mkname\" type=\"text\" size=\"15\">"; echo "<INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"]; echo "\"></TD></TR></FORM></TABLE></TD>\n"; } echo "</TR></TABLE>\n"; // End Toolbar // Begin Table + Form for checkboxes echo "<TABLE WIDTH=\"95%\"><FORM name=\"selform\" method=\"POST\" action=\"" . make_link("post", $dir, NULL) . "\">\n"; echo "<INPUT type=\"hidden\" name=\"do_action\"><INPUT type=\"hidden\" name=\"first\" value=\"y\">\n"; // Table Header echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR><TD WIDTH=\"2%\" class=\"header\">\n"; echo "<INPUT TYPE=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\"></TD>\n"; echo "<TD WIDTH=\"44%\" class=\"header\"><B>\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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"10%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"16%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"14%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD><TD WIDTH=\"8%\" class=\"header\"><B>" . $GLOBALS["messages"]["permheader"] . "</B>\n"; echo "</TD><TD WIDTH=\"6%\" class=\"header\"><B>" . $GLOBALS["messages"]["actionheader"] . "</B></TD></TR>\n"; echo "<TR><TD colspan=\"7\"><HR></TD></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=\"7\"><HR></TD></TR><TR>\n<TD class=\"header\"></TD>"; echo "<TD class=\"header\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " ("; if (function_exists("disk_free_space")) { $free = parse_file_size(disk_free_space(get_abs_dir($dir))); } elseif (function_exists("diskfreespace")) { $free = parse_file_size(diskfreespace(get_abs_dir($dir))); } else { $free = "?"; } // echo "Total: ".parse_file_size(disk_total_space(get_abs_dir($dir))).", "; echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</TD>\n"; echo "<TD class=\"header\">" . parse_file_size($tot_file_size) . "</TD>\n"; for ($i = 0; $i < 4; ++$i) { echo "<TD class=\"header\"></TD>"; } echo "</TR>\n<TR><TD colspan=\"7\"><HR></TD></TR></FORM></TABLE>\n"; ?> <script language="JavaScript1.2" 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; } } // --> </script><?php }
function dir_print($dir_list, $new_dir) { // print list of directories // this list is used to copy/move items to a specific location // Link to Parent Directory $dir_up = dirname($new_dir); if ($dir_up == ".") { $dir_up = ""; } /* echo "<TR><TD><A HREF=\"javascript:NewDir('" . $dir_up; echo "');\"><IMG border=\"0\" width=\"16\" height=\"16\""; echo " align=\"ABSMIDDLE\" src=\"" . $GLOBALS["baricons"]["up"] . "\" ALT=\"\"> ..</A></TD></TR>\n"; */ // Print List Of Target Directories if (!is_array($dir_list)) { return; } while (list($new_item, ) = each($dir_list)) { $s_item = $new_item; if (strlen($s_item) > 40) { $s_item = substr($s_item, 0, 37) . "..."; } if ($s_item == 'hn') { /* * echo "<TR><TD><A HREF=\"javascript:NewDir('" . get_rel_item($new_dir, $new_item) . "');\"><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" " . "src=\"_img/dir.gif\" ALT=\"\"> " . $s_item . "</A></TD></TR>\n"; */ echo "<TR><TD>"; echo "<A HREF=\"javascript:NewDir('" . get_rel_item($new_dir, $new_item) . "');\" style=\"color:#fff;background:#337ab7;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #2e6da4;border-radius:4px;\">Pokračovať</A>"; echo "<br><br>Chystáte sa rozbaľiť archív s názvom:</TD></TR>"; } } }
function edit_file($dir, $item) { // edit file global $mainframe, $mosConfig_live_site; if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } $fname = get_abs_item($dir, $item); if (!get_is_file($fname)) { show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]); } if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") { // Save / Save As $item = basename(stripslashes($GLOBALS['__POST']["fname"])); $fname2 = get_abs_item($dir, $item); if (!isset($item) || $item == "") { show_error($GLOBALS["error_msg"]["miscnoname"]); } if ($fname != $fname2 && @$GLOBALS['jx_File']->file_exists($fname2)) { show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]); } savefile($fname2); $fname = $fname2; if (!empty($GLOBALS['__POST']['return_to'])) { $return_to = urldecode($GLOBALS['__POST']['return_to']); mosRedirect($return_to); } elseif (!empty($GLOBALS['__POST']['return_to_dir'])) { mosRedirect($_SERVER['PHP_SELF'] . '?option=com_joomlaxplorer&dir=' . $dir, 'The File ' . $item . ' was saved.'); } } // header $s_item = get_rel_item($dir, $item); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item); $s_info = pathinfo($s_item); $s_extension = str_replace('.', '', $s_info['extension']); switch (strtolower($s_extension)) { case 'txt': $cp_lang = 'text'; break; case 'cs': $cp_lang = 'csharp'; break; case 'css': $cp_lang = 'css'; break; case 'html': case 'htm': case 'xml': case 'xhtml': $cp_lang = 'html'; break; case 'java': $cp_lang = 'java'; break; case 'js': $cp_lang = 'javascript'; break; case 'pl': $cp_lang = 'perl'; break; case 'ruby': $cp_lang = 'ruby'; break; case 'sql': $cp_lang = 'sql'; break; case 'vb': case 'vbs': $cp_lang = 'vbscript'; break; case 'php': $cp_lang = 'php'; break; default: $cp_lang = 'generic'; } // Form echo '<script type="text/javascript" src="components/com_joomlaxplorer/scripts/codepress/codepress.js"></script>'; echo "<br/><form name=\"editfrm\" id=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n"; if (!empty($GLOBALS['__GET']['return_to'])) { $close_action = 'window.location=\'' . urldecode($GLOBALS['__GET']['return_to']) . '\';'; echo "<input type=\"hidden\" name=\"return_to\" value=\"" . $GLOBALS['__GET']['return_to'] . "\" />\n"; } else { $close_action = 'window.location=\'' . make_link('list', $dir, NULL) . "'"; } $submit_action = 'document.editfrm.code.value=codearea.getCode();document.editfrm.submit();'; echo "\r\n<table class=\"adminform\">\r\n\t<tr>\r\n\t\t<td style=\"text-align: center;\">\r\n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnsave"] . "\" onclick=\"{$submit_action}\" /> \r\n\t\t\t<input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\" /> \r\n\t\t\t<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onclick=\"javascript:{$close_action}\" />\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td >\r\n\t\t\t<div id=\"positionIndicator\" style=\"width: 20%;float:left;\">" . $GLOBALS["messages"]["line"] . ": <input type=\"text\" name=\"txtLine\" class=\"inputbox\" size=\"6\" onchange=\"setCaretPosition(document.editfrm.code, this.value);return false;\" /> " . $GLOBALS["messages"]["column"] . ": <input type=\"text\" name=\"txtColumn\" class=\"inputbox\" size=\"6\" readonly=\"readonly\" />\r\n </div>\r\n\t\t\t<div style=\"width:70%;text-align: center;float:left;\">\r\n\t\t\t\t<input type=\"checkbox\" value=\"1\" name=\"return_to_dir\" id=\"return_to_dir\" />\r\n\t\t\t\t<label for=\"return_to_dir\">" . $GLOBALS["messages"]["returndir"] . "</label>\r\n\t\t\t</div>"; echo "\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr><td>"; echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\" />\n"; // Show File In TextArea $content = $GLOBALS['jx_File']->file_get_contents($fname); if (get_magic_quotes_runtime()) { $content = stripslashes($content); } $content = htmlspecialchars($content); echo '[<a href="javascript:;" onclick="positionIndicator.toggle(); codearea.toggleEditor();return false;">' . $GLOBALS['messages']['editor_simple'] . ' / ' . $GLOBALS['messages']['editor_syntaxhighlight'] . '</a>]'; echo '<div id="editorarea"> <textarea class="codepress ' . $cp_lang . '" style="width:95%;" name="codearea" id="codearea" rows="25" cols="120" wrap="off" onmouseup="updatePosition(this)" onmousedown="updatePosition(this)" onkeyup="updatePosition(this)" onkeydown="updatePosition(this)" onfocus="updatePosition(this)">' . $content . '</textarea> <input type="hidden" name="code" value="" /> </div><br/>'; echo "\r\n\t</td>\r\n\t</tr>"; echo "\r\n\t<tr>\r\n\t\t<td align=\"right\">\r\n\t\t\t<label for=\"fname\">" . $GLOBALS["messages"]["copyfile"] . "</label>\r\n\t\t\t<input type=\"text\" name=\"fname\" value=\"" . $item . "\" size=\"40\" />\r\n\t\t</td>\r\n\t</tr>\r\n</table>\r\n<br/>"; echo "\r\n</form>\r\n<br/>\n"; ?> <script type="text/javascript"> <!-- if(document.editfrm && document.editfrm.code) document.editfrm.code.focus(); positionIndicator = new Fx.Slide( 'positionIndicator' ).hide(); //http://www.bazon.net/mishoo/home.epl?NEWS_ID=1345 function doGetCaretPosition (textarea) { var txt = textarea.value; var len = txt.length; var erg = txt.split("\n"); var pos = -1; if(typeof textarea.selectionStart != "undefined") { // FOR MOZILLA pos = textarea.selectionStart; } else if(typeof document.selection != "undefined") { // FOR MSIE range_sel = document.selection.createRange(); range_obj = textarea.createTextRange(); range_obj.moveToBookmark(range_sel.getBookmark()); range_obj.moveEnd('character',textarea.value.length); pos = len - range_obj.text.length; } if(pos != -1) { var ind = 0; for(;erg.length;ind++) { len = erg[ind].length + 1; if(pos < len) break; pos -= len; } ind++; pos++; return [ind, pos]; // ind = LINE, pos = COLUMN } } /** * This function allows us to change the position of the caret * (cursor) in the textarea * Various workarounds for IE, Firefox and Opera are included * Firefox doesn't count empty lines, IE does... */ function setCaretPosition( textarea, linenum ) { if (isNaN(linenum)) { updatePosition( textarea ); return; } var txt = textarea.value; var len = txt.length; var erg = txt.split("\n"); var ind = 0; var pos = 0; var nonempty = -1; var empty = -1; for(;ind < linenum;ind++) { /*alert( "Springe zu Zeile: "+linenum +"\naktuelle Zeile: "+ (ind+1) + "\naktuelle Position: "+pos + "\nText in dieser Zeile: "+erg[ind]);*/ if( !erg[ind] && pos < len ) { empty++; pos++; continue; } else if( !erg[ind] ) break; pos += erg[ind].length; nonempty++; } try { pos -= erg[ind-1].length; } catch(e) {} textarea.focus(); if(textarea.setSelectionRange) { pos += nonempty; textarea.setSelectionRange(pos,pos); } else if (textarea.createTextRange) { pos -= empty; var range = textarea.createTextRange(); range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select(); } } /** * Updates the Position Indicator fields */ function updatePosition(textBox) { var posArray = doGetCaretPosition(textBox); document.forms[0].txtLine.value = posArray[0]; document.forms[0].txtColumn.value = posArray[1]; } // --> </script><?php }
/** print table of files */ function print_table($dir, $list) { if (!is_array($list)) { return; } while (list($item) = each($list)) { // link to dir / file $abs_item = get_abs_item($dir, $item); $target = ""; if (is_dir($abs_item)) { $link = make_link("list", get_rel_item($dir, $item), NULL); } else { $link = make_link("download", $dir, $item); $target = "_blank"; } echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\""; echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n"; // Icon + Link echo "<TD nowrap>"; if (permissions_grant($dir, $item, "read")) { echo "<A HREF=\"" . $link . "\">"; } //else echo "<A>"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } echo htmlspecialchars($s_item); if (permissions_grant($dir, $item, "read")) { echo "</A>"; } echo "</TD>\n"; // ...$extra... // Size echo '<TD>' . parse_file_size(get_file_size($dir, $item)) . sprintf("%10s", " ") . "</TD>\n"; // Type echo "<td>" . _get_link_info($dir, $item, "type") . "</td>\n"; // Modified echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n"; // Permissions echo "<TD>"; if (permissions_grant($dir, NULL, "change")) { echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\""; echo $GLOBALS["messages"]["permlink"] . "\">"; } echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item)); if (permissions_grant($dir, NULL, "change")) { echo "</A>"; } echo "</TD>\n"; // Actions echo "<TD>\n<TABLE>\n"; // EDIT if (get_is_editable($dir, $item)) { _print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item); } else { // UNZIP if (get_is_unzipable($dir, $item)) { _print_link("unzip", permissions_grant($dir, $item, "create"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } } // DOWNLOAD if (get_is_file($dir, $item)) { _print_link("download", permissions_grant($dir, $item, "read"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } echo "</TABLE>\n</TD></TR>\n"; } }
function list_dir($dir) { $dir_up = dirname($dir); 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 make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items); $s_dir = $dir; if (strlen($s_dir) > 50) { $s_dir = "..." . substr($s_dir, -47); } show_header($GLOBALS["messages"]["actdir"] . ": /" . get_rel_item("", $s_dir)); // Javascript functions: include MPATH_MIWOFTP_QX . "/_include/javascript.php"; // Sorting of items $_img = " <IMG width=\"10\" height=\"10\" border=\"0\" align=\"ABSMIDDLE\" src=\"_img/"; if ($GLOBALS["srt"] == "yes") { $_srt = "no"; $_img .= "_arrowup.gif\" ALT=\"^\">"; } else { $_srt = "yes"; $_img .= "_arrowdown.gif\" ALT=\"v\">"; } // Toolbar echo "<BR><TABLE width=\"95%\"><TR><TD><TABLE><TR>\n"; // PARENT DIR /* echo "<TD><A HREF=\"".make_link("list",$dir_up,NULL)."\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["baricons"]["up"]."\" "; echo "ALT=\"".$GLOBALS["messages"]["uplink"]."\" TITLE=\"".$GLOBALS["messages"]["uplink"]."\"></A></TD>\n"; */ // HOME DIR echo "<TD><A HREF=\"" . make_link("list", NULL, NULL) . "\" title='Koreňová zložka'>"; //echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["baricons"]["home"]."\" "; //echo "ALT=\"".$GLOBALS["messages"]["homelink"]."\" TITLE=\"".$GLOBALS["messages"]["homelink"]."\"></A></TD>\n"; echo "<span class='dashicons dashicons-admin-home' style='text-decoration:none;font-size:30px;padding:10px'></span></A></TD>\n"; // RELOAD /* echo "<TD><A HREF=\"javascript:location.reload();\"><IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"".$GLOBALS["baricons"]["reload"]."\" ALT=\"".$GLOBALS["messages"]["reloadlink"]; echo "\" TITLE=\"".$GLOBALS["messages"]["reloadlink"]."\"></A></TD>\n"; */ // SEARCH /* echo "<TD><A HREF=\"".make_link("search",$dir,NULL)."\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["baricons"]["search"]."\" "; echo "ALT=\"".$GLOBALS["messages"]["searchlink"]."\" TITLE=\"".$GLOBALS["messages"]["searchlink"]; echo "\"></A></TD>\n"; */ //echo "<TD>::</TD>"; // print the edit buttons _print_edit_buttons($dir); // ADMIN & LOGOUT if (login_ok()) { echo "<TD>::</TD>"; // ADMIN _print_link("admin", permissions_grant(NULL, NULL, "admin") || permissions_grant(NULL, NULL, "password"), $dir, NULL); // LOGOUT _print_link("logout", true, $dir, NULL); } //echo "<TD>::</TD>"; //Languages foreach ($GLOBALS["langs"] as $langs) { echo "<TD><A HREF=\"" . make_link("list", $dir, NULL, NULL, NULL, $langs[0]) . "\">"; if (!file_exists($langs[1])) { echo " {$langs['0']} "; } else { echo "<IMG border=\"0\" width=\"16\" height=\"11\" "; echo "align=\"ABSMIDDLE\" src=\"" . $langs[1] . "\" ALT=\"" . $langs[0]; echo "\" TITLE=\"" . $langs[2] . "\"/></A></TD>\n"; } //list($slang,$img,$ext,$type) = $mime; /*if(@eregi($ext,$item)) { $mime_type = $desc; $image = $img; if($query=="img"){ return $image;} else if($query=="ext"){ return $type;} else return $mime_type; */ } // echo "</TR></TABLE></TD>\n"; // Create File / Dir /* if (permissions_grant($dir, NULL, "create")) { echo "<TD align=\"right\"><TABLE><FORM action=\"".make_link("mkitem",$dir,NULL)."\" method=\"post\">\n<TR><TD>"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["baricons"]["add"]."\" />"; echo "<SELECT name=\"mktype\">"; echo "<option value=\"file\">".$GLOBALS["mimes"]["file"]."</option>"; echo "<option value=\"dir\">".$GLOBALS["mimes"]["dir"]."</option></SELECT>\n"; echo "<INPUT name=\"mkname\" type=\"text\" size=\"15\">"; echo "<INPUT type=\"submit\" value=\"".$GLOBALS["messages"]["btncreate"]; echo "\"></TD></TR></FORM></TABLE></TD>\n"; } */ echo "</TR></TABLE>\n"; // End Toolbar // Begin Table + Form for checkboxes echo "<TABLE WIDTH=\"95%\"><FORM name=\"selform\" method=\"POST\" action=\"" . make_link("post", $dir, NULL) . "\">\n"; echo "<INPUT type=\"hidden\" name=\"do_action\"><INPUT type=\"hidden\" name=\"first\" value=\"y\">\n"; // Table Header echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR><TD WIDTH=\"2%\" class=\"header\">\n"; echo "<INPUT TYPE=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\"></TD>\n"; echo "<TD WIDTH=\"44%\" class=\"header\"><B>\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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"10%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"16%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"14%\" class=\"header\"><B>"; 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 $_img; } //echo "</A></B></TD><TD WIDTH=\"8%\" class=\"header\"><B>".$GLOBALS["messages"]["permheader"]."</B>\n"; //echo "</TD><TD WIDTH=\"6%\" class=\"header\"><B>".$GLOBALS["messages"]["actionheader"]."</B></TD></TR>\n"; echo "</A></B></TD><TD WIDTH=\"6%\" class=\"header\"><B>" . $GLOBALS["messages"]["actionheader"] . "</B></TD></TR>\n"; echo "<TR><TD colspan=\"7\"><HR></TD></TR>\n"; // make & print Table using lists print_table($dir, make_list($dir_list, $file_list)); // print number of items & total filesize echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR>\n<TD class=\"header\"></TD>"; echo "<TD class=\"header\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " ("; // JA // //$free=parse_file_size(diskfreespace(get_abs_dir($dir))); if (function_exists("disk_free_space")) { $free = parse_file_size(disk_free_space($GLOBALS["home_dir"])); // $free=parse_file_size(disk_free_space(home_dir)); // $free=parse_file_size(disk_free_space(get_abs_dir($dir))); } elseif (function_exists("diskfreespace")) { $free = parse_file_size(diskfreespace($GLOBALS["home_dir"])); // $free=parse_file_size(diskfreespace(home_dir)); // $free=parse_file_size(diskfreespace(get_abs_dir($dir))); } else { $free = "?"; } // JA // echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</TD>\n"; echo "<TD class=\"header\">" . parse_file_size($tot_file_size) . "</TD>\n"; echo "<TD class=\"header\" colspan=4></TD>"; echo "</TR>\n<TR><TD colspan=\"7\"><HR></TD></TR></FORM></TABLE>\n"; ?> <script language="JavaScript1.2" 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; } } // --> </script><?php }
function search_items($dir) { // search for item if (isset($GLOBALS['__POST']["searchitem"])) { $searchitem = stripslashes($GLOBALS['__POST']["searchitem"]); $subdir = isset($GLOBALS['__POST']["subdir"]) && $GLOBALS['__POST']["subdir"] == "y"; $list = make_list($dir, $searchitem, $subdir); } else { $searchitem = NULL; $subdir = true; } $msg = $GLOBALS["messages"]["actsearchresults"]; if ($searchitem != NULL) { $msg .= ": (/" . get_rel_item($dir, $searchitem) . ")"; } show_header($msg); // Search Box echo "<BR><TABLE><FORM name=\"searchform\" action=\"" . make_link("search", $dir, NULL); echo "\" method=\"post\">\n<TR><TD><INPUT name=\"searchitem\" type=\"text\" size=\"25\" value=\""; echo $searchitem . "\"><INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btnsearch"]; echo "\"> <input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"]; echo "\" onClick=\"javascript:location='" . make_link("list", $dir, NULL); echo "';\"></TD></TR><TR><TD><INPUT type=\"checkbox\" name=\"subdir\" value=\"y\""; echo ($subdir ? " checked>" : ">") . $GLOBALS["messages"]["miscsubdirs"] . "</TD></TR></FORM></TABLE>\n"; // Results if ($searchitem != NULL) { echo "<TABLE width=\"95%\"><TR><TD colspan=\"2\"><HR></TD></TR>\n"; if (count($list) > 0) { // Table Header echo "<TR>\n<TD WIDTH=\"42%\" class=\"header\"><B>" . $GLOBALS["messages"]["nameheader"]; echo "</B></TD>\n<TD WIDTH=\"58%\" class=\"header\"><B>" . $GLOBALS["messages"]["pathheader"]; echo "</B></TD></TR>\n<TR><TD colspan=\"2\"><HR></TD></TR>\n"; // make & print table of found items print_table($list); echo "<TR><TD colspan=\"2\"><HR></TD></TR>\n<TR><TD class=\"header\">" . count($list) . " "; echo $GLOBALS["messages"]["miscitems"] . ".</TD><TD class=\"header\"></TD></TR>\n"; } else { echo "<TR><TD>" . $GLOBALS["messages"]["miscnoresult"] . "</TD></TR>"; } echo "<TR><TD colspan=\"2\"><HR></TD></TR></TABLE>\n"; } ?> <script language="JavaScript1.2" type="text/javascript"> <!-- if(document.searchform) document.searchform.searchitem.focus(); // --> </script><?php }
function execAction($dir, $item) { // change permissions if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]); } if (!empty($GLOBALS['__POST']["selitems"])) { $cnt = count($GLOBALS['__POST']["selitems"]); } else { $GLOBALS['__POST']["selitems"][] = $item; $cnt = 1; } if (!empty($GLOBALS['__POST']['do_recurse'])) { $do_recurse = true; } else { $do_recurse = false; } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $bin = ''; for ($i = 0; $i < 3; $i++) { for ($j = 0; $j < 3; $j++) { $tmp = "r_" . $i . $j; if (!empty($GLOBALS['__POST'][$tmp])) { $bin .= '1'; } else { $bin .= '0'; } } } if ($bin == '0') { // Changing permissions to "none" is not allowed ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed')); } $old_bin = $bin; for ($i = 0; $i < $cnt; ++$i) { if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } $item = $GLOBALS['__POST']["selitems"][$i]; if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $item); } else { $abs_item = get_abs_item($dir, $item); } if (!$GLOBALS['ext_File']->file_exists($abs_item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]); } if ($do_recurse) { $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode); } else { if (get_is_dir($abs_item)) { // when we chmod a directory we must care for the permissions // to prevent that the directory becomes not readable (when the "execute bits" are removed) $bin = substr_replace($bin, '1', 2, 1); // set 1st x bit to 1 $bin = substr_replace($bin, '1', 5, 1); // set 2nd x bit to 1 $bin = substr_replace($bin, '1', 8, 1); // set 3rd x bit to 1 if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } } //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd()); $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode); } $bin = $old_bin; } if ($ok === false || PEAR::isError($ok)) { $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"]; $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : ''; ext_Result::sendResult('chmod', false, $msg); } ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange')); return; } if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]); } else { $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]); $abs_item = utf8_decode($abs_item); } $mode = parse_file_perms(get_file_perms($abs_item)); if ($mode === false) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]); } $pos = "rwx"; $text = ""; for ($i = 0; $i < $cnt; ++$i) { $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } $text .= $s_item . ($i + 1 < $cnt ? ', ' : ''); } ?> <div style="width:auto;"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;"><?php echo ext_Lang::msg('actperms'); ?> </h3> <?php echo $text; ?> <div id="adminForm"> </div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <script type="text/javascript"> var form = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); <?php // print table with current perms & checkboxes to change for ($i = 0; $i < 3; ++$i) { ?> form.column( {width:70, style:'margin-left:10px', clear:true} ); form.fieldset( {legend:'<?php echo ext_Lang::msg(array('miscchmod' => $i), true); ?> ', hideLabels:true}, <?php for ($j = 0; $j < 3; ++$j) { ?> new Ext.form.Checkbox({ boxLabel:'<?php echo $pos[$j]; ?> ', <?php if ($mode[3 * $i + $j] != "-") { echo 'checked:true,'; } ?> name:'<?php echo "r_" . $i . $j; ?> ' }) <?php if ($j < 2) { echo ','; } } ?> ); form.end(); <?php } ?> form.column( {width:400, style:'margin-left:10px', clear:true} ); form.add(new Ext.form.Checkbox({ fieldLabel:'<?php echo ext_Lang::msg('recurse_subdirs', true); ?> ', name:'do_recurse' })); form.end(); form.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( '<?php echo ext_Lang::msg('permissions_processing', true); ?> ', true ); form.submit({ //reset: true, reset: false, success: function(form, action) { statusBarMessage( action.result.message, false, true ); datastore.reload(); dialog.hide(); dialog.destroy(); }, failure: function(form, action) { statusBarMessage( action.result.error, false, false ); Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); }, scope: form, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'chmod', dir: '<?php echo stripslashes($GLOBALS['__POST']["dir"]); ?> ', 'selitems[]': ['<?php echo implode("','", $GLOBALS['__POST']["selitems"]); ?> '], confirm: 'true'} }); }); form.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.hide();dialog.destroy(); } ); form.render('adminForm'); </script> <?php }
function 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> </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"] . "\"/> ..</a>\n\t \t\t\t</td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>"; if (extension_loaded("posix")) { echo "<td> </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=\"\" /> "; $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++; } }
function list_dir($dir) { $dir_up = dirname($dir); 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 make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items); $s_dir = $dir; if (strlen($s_dir) > 50) { $s_dir = "..." . substr($s_dir, -47); } show_header("<a href='javascript:history.go(-1);'><font color=#0a0a0a>Go Back to Problem List</font></a><br>" . $GLOBALS["messages"]["actdir"] . ": /" . get_rel_item("", $s_dir)); // Javascript functions: include "./.include/javascript.php"; // Sorting of items $_img = " <IMG width=\"10\" height=\"10\" border=\"0\" align=\"ABSMIDDLE\" src=\"_img/"; if ($GLOBALS["srt"] == "yes") { $_srt = "no"; $_img .= "_arrowup.gif\" ALT=\"^\">"; } else { $_srt = "yes"; $_img .= "_arrowdown.gif\" ALT=\"v\">"; } // Toolbar echo "<BR><TABLE width=\"95%\"><TR><TD><TABLE><TR>\n"; // PARENT DIR echo "<TD><A HREF=\"" . make_link("list", $dir_up, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_up.gif\" "; echo "ALT=\"" . $GLOBALS["messages"]["uplink"] . "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></A></TD>\n"; // HOME DIR echo "<TD><A HREF=\"" . make_link("list", NULL, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_home.gif\" "; echo "ALT=\"" . $GLOBALS["messages"]["homelink"] . "\" TITLE=\"" . $GLOBALS["messages"]["homelink"] . "\"></A></TD>\n"; // RELOAD echo "<TD><A HREF=\"javascript:location.reload();\"><IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"_img/_refresh.gif\" ALT=\"" . $GLOBALS["messages"]["reloadlink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["reloadlink"] . "\"></A></TD>\n"; // SEARCH echo "<TD><A HREF=\"" . make_link("search", $dir, NULL) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_search.gif\" "; echo "ALT=\"" . $GLOBALS["messages"]["searchlink"] . "\" TITLE=\"" . $GLOBALS["messages"]["searchlink"]; echo "\"></A></TD>\n"; echo "<TD>::</TD>"; // print the edit buttons _print_edit_buttons($dir); // ADMIN & LOGOUT if (login_ok()) { echo "<TD>::</TD>"; // ADMIN _print_link("admin", permissions_grant(NULL, NULL, "admin") || permissions_grant(NULL, NULL, "password"), $dir, NULL); // LOGOUT _print_link("logout", true, $dir, NULL); } echo "</TR></TABLE></TD>\n"; // Create File / Dir if (permissions_grant($dir, NULL, "create")) { echo "<TD align=\"right\"><TABLE><FORM action=\"" . make_link("mkitem", $dir, NULL) . "\" method=\"post\">\n<TR><TD>"; echo "<SELECT name=\"mktype\"><option value=\"file\">" . $GLOBALS["mimes"]["file"] . "</option>"; echo "<option value=\"dir\">" . $GLOBALS["mimes"]["dir"] . "</option></SELECT>\n"; echo "<INPUT name=\"mkname\" type=\"text\" size=\"15\">"; echo "<INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"]; echo "\"></TD></TR></FORM></TABLE></TD>\n"; } echo "</TR></TABLE>\n"; // End Toolbar // Begin Table + Form for checkboxes echo "<TABLE WIDTH=\"95%\"><FORM name=\"selform\" method=\"POST\" action=\"" . make_link("post", $dir, NULL) . "\">\n"; echo "<INPUT type=\"hidden\" name=\"do_action\"><INPUT type=\"hidden\" name=\"first\" value=\"y\">\n"; // Table Header echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR><TD WIDTH=\"2%\" class=\"header\">\n"; echo "<INPUT TYPE=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\"></TD>\n"; echo "<TD WIDTH=\"44%\" class=\"header\"><B>\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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"10%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"16%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD>\n<TD WIDTH=\"14%\" class=\"header\"><B>"; 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 $_img; } echo "</A></B></TD><TD WIDTH=\"8%\" class=\"header\"><B>" . $GLOBALS["messages"]["permheader"] . "</B>\n"; echo "</TD><TD WIDTH=\"6%\" class=\"header\"><B>" . $GLOBALS["messages"]["actionheader"] . "</B></TD></TR>\n"; echo "<TR><TD colspan=\"7\"><HR></TD></TR>\n"; // make & print Table using lists print_table($dir, make_list($dir_list, $file_list)); // print number of items & total filesize echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR>\n<TD class=\"header\"></TD>"; echo "<TD class=\"header\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " ("; if (function_exists("disk_free_space")) { $free = parse_file_size(disk_free_space(get_abs_dir($dir))); } elseif (function_exists("diskfreespace")) { $free = parse_file_size(diskfreespace(get_abs_dir($dir))); } else { $free = "?"; } // echo "Total: ".parse_file_size(disk_total_space(get_abs_dir($dir))).", "; echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</TD>\n"; echo "<TD class=\"header\">" . parse_file_size($tot_file_size) . "</TD>\n"; for ($i = 0; $i < 4; ++$i) { echo "<TD class=\"header\"></TD>"; } echo "</TR>\n<TR><TD colspan=\"7\"><HR></TD></TR></FORM></TABLE>\n"; ?> <script language="JavaScript1.2" 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; } } // --> </script><?php }
function execAction($dir, $item) { // change permissions if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]); } if (!empty($GLOBALS['__POST']["selitems"])) { $cnt = count($GLOBALS['__POST']["selitems"]); } else { $GLOBALS['__POST']["selitems"][] = $item; $cnt = 1; } if (!empty($GLOBALS['__POST']['do_recurse'])) { $do_recurse = true; } else { $do_recurse = false; } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $bin = ''; for ($i = 0; $i < 3; $i++) { for ($j = 0; $j < 3; $j++) { $tmp = "r_" . $i . $j; if (!empty($GLOBALS['__POST'][$tmp])) { $bin .= '1'; } else { $bin .= '0'; } } } if ($bin == '0') { // Changing permissions to "none" is not allowed ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed')); } $old_bin = $bin; for ($i = 0; $i < $cnt; ++$i) { if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } $item = $GLOBALS['__POST']["selitems"][$i]; if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $item); } else { $abs_item = get_abs_item($dir, $item); } if (!$GLOBALS['ext_File']->file_exists($abs_item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]); } if ($do_recurse) { $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode); } else { if (get_is_dir($abs_item)) { // when we chmod a directory we must care for the permissions // to prevent that the directory becomes not readable (when the "execute bits" are removed) $bin = substr_replace($bin, '1', 2, 1); // set 1st x bit to 1 $bin = substr_replace($bin, '1', 5, 1); // set 2nd x bit to 1 $bin = substr_replace($bin, '1', 8, 1); // set 3rd x bit to 1 if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } } //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd()); $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode); } $bin = $old_bin; } if ($ok === false || PEAR::isError($ok)) { $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"]; $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : ''; ext_Result::sendResult('chmod', false, $msg); } ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange')); return; } if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]); } else { $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]); $abs_item = utf8_decode($abs_item); } $mode = parse_file_perms(get_file_perms($abs_item)); if ($mode === false) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]); } $pos = "rwx"; $text = ""; for ($i = 0; $i < $cnt; ++$i) { $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } $text .= $s_item . ($i + 1 < $cnt ? ', ' : ''); } ?> { "xtype": "form", "id": "simpleform", "width": "300", "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "dialogtitle": "<?php echo ext_Lang::msg('actperms'); ?> ", "title" : "<?php echo $text; ?> ", "frame": true, "items": [{ "layout": "column", "items": [{ <?php // print table with current perms & checkboxes to change for ($i = 0; $i < 3; ++$i) { ?> "width":80, "title":"<?php echo ext_Lang::msg(array('miscchmod' => $i), true); ?> ", "items": [{ <?php for ($j = 0; $j < 3; ++$j) { ?> "xtype": "checkbox", "boxLabel":"<?php echo $pos[$j]; ?> ", <?php if ($mode[3 * $i + $j] != "-") { echo '"checked":true,'; } ?> "name":"<?php echo "r_" . $i . $j; ?> " } <?php if ($j < 2) { echo ',{'; } } ?> ] } <?php if ($i < 2) { echo ',{'; } } ?> ,{ "width":400, "style":"margin-left:10px", "clear":true, "html": " " }] },{ "xtype": "checkbox", "fieldLabel":"<?php echo ext_Lang::msg('recurse_subdirs', true); ?> ", "name":"do_recurse" }], "buttons": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('permissions_processing', true); ?> ', true ); form = Ext.getCmp("simpleform").getForm(); form.submit({ //reset: true, reset: false, success: function(form, action) { statusBarMessage( action.result.message, false, true ); datastore.reload(); Ext.getCmp("dialog").destroy(); }, failure: function(form, action) { statusBarMessage( action.result.error, false, false ); Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); }, scope: form, params: { "option": "com_extplorer", "action": "chmod", "dir": "<?php echo stripslashes($GLOBALS['__POST']["dir"]); ?> ", "selitems[]": ['<?php echo implode("','", $GLOBALS['__POST']["selitems"]); ?> '], confirm: 'true' } }); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] } <?php }
function dir_print($dir_list, $new_dir) { // print list of directories // this list is used to copy/move items to a specific location // Link to Parent Directory $dir_up = dirname($new_dir); if ($dir_up == ".") { $dir_up = ""; } echo "<TR><TD><A HREF=\"javascript:NewDir('" . $dir_up; echo "');\"><IMG border=\"0\" width=\"16\" height=\"16\""; echo " align=\"ABSMIDDLE\" src=\"" . $GLOBALS["baricons"]["up"] . "\" ALT=\"\"> ..</A><BR></BR></TD></TR>\n"; // Print List Of Target Directories if (!is_array($dir_list)) { return; } while (list($new_item, ) = each($dir_list)) { $s_item = $new_item; if (strlen($s_item) > 40) { $s_item = substr($s_item, 0, 37) . "..."; } echo "<TR><TD><A HREF=\"javascript:NewDir('" . get_rel_item($new_dir, $new_item) . "');\"><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" " . "src=\"_img/dir.gif\" ALT=\"\"> " . $s_item . "</A></TD></TR>\n"; } }
function edit_file($dir, $item) { // edit file if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } if (!get_is_file($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]); } $fname = get_abs_item($dir, $item); if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") { // Save / Save As $item = base_name(stripslashes($GLOBALS['__POST']["fname"])); $fname2 = get_abs_item($dir, $item); if (!isset($item) || $item == "") { show_error($GLOBALS["error_msg"]["miscnoname"]); } if ($fname != $fname2 && @file_exists($fname2)) { show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]); } savefile($fname2); $fname = $fname2; } // open file $fp = @fopen($fname, "r"); if ($fp === false) { show_error($item . ": " . $GLOBALS["error_msg"]["openfile"]); } // header $s_item = get_rel_item($dir, $item); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item); // Wordwrap (works only in IE) ?> <script language="JavaScript1.2" type="text/javascript"> <!-- function chwrap() { if(document.editfrm.wrap.checked) { document.editfrm.code.wrap="soft"; } else { document.editfrm.code.wrap="off"; } } // --> </script><?php // Form echo "<BR><FORM name=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n"; echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\">\n"; echo "<TEXTAREA NAME=\"code\" rows=\"25\" cols=\"120\" wrap=\"off\">"; // Show File In TextArea $buffer = ""; while (!feof($fp)) { $buffer .= fgets($fp, 4096); } @fclose($fp); echo htmlspecialchars($buffer); echo "</TEXTAREA><BR>\n<TABLE><TR><TD>Wordwrap: (IE only)</TD><TD><INPUT type=\"checkbox\" name=\"wrap\" "; echo "onClick=\"javascript:chwrap();\" value=\"1\"></TD></TR></TABLE><BR>\n"; echo "<TABLE><TR><TD><INPUT type=\"text\" name=\"fname\" value=\"" . $item . "\"></TD>"; echo "<TD><input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnsave"]; echo "\"></TD>\n<TD><input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\"></TD>\n<TD>"; echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onClick=\"javascript:location='"; echo make_link("list", $dir, NULL) . "';\"></TD></TR></FORM></TABLE><BR>\n"; ?> <script language="JavaScript1.2" type="text/javascript"> <!-- if(document.editfrm) document.editfrm.code.focus(); // --> </script><?php }
function search_items($dir) { // search for item if (isset($GLOBALS['__POST']["searchitem"])) { $searchitem = stripslashes($GLOBALS['__POST']["searchitem"]); $subdir = !empty($GLOBALS['__POST']["subdir"]); $list = make_list($dir, $searchitem, $subdir); } else { $searchitem = NULL; $subdir = true; } if (!empty($searchitem)) { $msg = $GLOBALS["messages"]["actsearchresults"]; $msg .= ": (/" . get_rel_item($dir, $searchitem) . ")"; } else { $msg = $GLOBALS["messages"]["searchlink"]; } // Search Box $response = ' <div> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;">' . $msg . '</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 form = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:\'' . basename($GLOBALS['script_name']) . '\' }); form.add( new Ext.form.TextField({ fieldLabel: \'' . ext_Lang::msg('nameheader', true) . '\', name: \'searchitem\', width:175, allowBlank:false }), new Ext.form.Checkbox({ fieldLabel: \'' . ext_Lang::msg('miscsubdirs', true) . '?\', name: \'subdir\', checked: true }) ); form.addButton({ text: "' . ext_Lang::msg('btnsearch', true) . '", type: "submit" }, function() { form.submit({ waitMsg: \'' . ext_Lang::msg('search_processing', true) . '\', //reset: true, reset: false, success: function(form, action) { dialog_panel.setContent( action.result.message, true ); }, failure: function(form, action) {Ext.MessageBox.alert(\'' . ext_Lang::err('error') . '!\', action.result.error);}, scope: form, // add some vars to the request, similar to hidden fields params: { option: \'com_extplorer\', action: \'search\', dir: \'' . $GLOBALS['__POST']["dir"] . '\' } }); }); form.addButton("' . ext_Lang::msg('btncancel', true) . '", function() { dialog.hide();dialog.destroy(); } ); form.render("adminForm"); </script>'; // Results if ($searchitem != NULL) { $response .= "<table width=\"95%\"><tr><td colspan=\"2\"><hr></td></tr>\n"; if (count($list) > 0) { // table header $response .= "<tr>\n<td width=\"42%\" class=\"header\"><b>" . $GLOBALS["messages"]["nameheader"]; $response .= "</b></td>\n<td width=\"58%\" class=\"header\"><b>" . $GLOBALS["messages"]["pathheader"]; $response .= "</b></td></tr>\n<tr><td colspan=\"2\"><hr></td></tr>\n"; // make & print table of found items $response .= get_result_table($list); $response .= "<tr><td colspan=\"2\"><hr></td></tr>\n<tr><td class=\"header\">" . count($list) . " "; $response .= $GLOBALS["messages"]["miscitems"] . ".</td><td class=\"header\"></td></tr>\n"; } else { $response .= "<tr><td>" . $GLOBALS["messages"]["miscnoresult"] . "</td></tr>"; } $response .= "<tr><td colspan=\"2\"><hr></td></tr></table>\n"; } if (empty($searchitem)) { echo $response; } else { while (@ob_end_clean()) { } ext_Result::sendResult('search', true, $response); } }