2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
|
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2012-11-24 06:23:48 +01:00
|
|
|
James Rose <james.o.rose@gmail.com>
|
2012-06-04 16:58:40 +02:00
|
|
|
*/
|
|
|
|
|
include "root.php";
|
2013-07-06 08:03:27 +02:00
|
|
|
require_once "resources/require.php";
|
2013-07-06 07:50:55 +02:00
|
|
|
require_once "resources/check_auth.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
if (permission_exists('script_editor_view')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2012-11-24 06:23:48 +01:00
|
|
|
|
2012-11-24 07:53:38 +01:00
|
|
|
//add css and javascript
|
|
|
|
|
require_once "header.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2012-11-24 07:53:38 +01:00
|
|
|
//define function recure_dir
|
|
|
|
|
function recur_dir($dir) {
|
|
|
|
|
clearstatcache();
|
|
|
|
|
$htmldirlist = '';
|
|
|
|
|
$htmlfilelist = '';
|
|
|
|
|
$dirlist = opendir($dir);
|
|
|
|
|
$dir_array = array();
|
2015-07-03 01:25:41 +02:00
|
|
|
while (false !== ($file = readdir($dirlist))) {
|
2012-11-24 07:53:38 +01:00
|
|
|
if ($file != "." AND $file != ".."){
|
|
|
|
|
$newpath = $dir.'/'.$file;
|
|
|
|
|
$level = explode('/',$newpath);
|
2016-02-24 20:28:35 +01:00
|
|
|
if (
|
|
|
|
|
substr(strtolower($newpath), -4) == ".svn" ||
|
|
|
|
|
substr(strtolower($newpath), -4) == ".git" ||
|
|
|
|
|
substr(strtolower($newpath), -3) == ".db" ||
|
|
|
|
|
substr(strtolower($newpath), -4) == ".jpg" ||
|
|
|
|
|
substr(strtolower($newpath), -4) == ".gif" ||
|
|
|
|
|
substr(strtolower($newpath), -4) == ".png" ||
|
|
|
|
|
substr(strtolower($newpath), -4) == ".ico" ||
|
|
|
|
|
substr(strtolower($newpath), -4) == ".ttf"
|
|
|
|
|
) {
|
|
|
|
|
//ignore certain files (and folders)
|
2012-11-24 07:53:38 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$dir_array[] = $newpath;
|
|
|
|
|
}
|
|
|
|
|
if ($x > 1000) { break; };
|
|
|
|
|
$x++;
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-24 07:53:38 +01:00
|
|
|
asort($dir_array);
|
|
|
|
|
foreach ($dir_array as $newpath){
|
|
|
|
|
$level = explode('/',$newpath);
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2012-11-24 07:53:38 +01:00
|
|
|
if (is_dir($newpath)) {
|
|
|
|
|
$dirname = end($level);
|
2016-02-24 20:28:35 +01:00
|
|
|
$htmldirlist .= "
|
|
|
|
|
<table border=0 cellpadding='0' cellspacing='0'>
|
|
|
|
|
<tr>
|
|
|
|
|
<td nowrap style='padding-left: 16px;'>
|
|
|
|
|
<a onclick='Toggle(this);' style='cursor: pointer;'><img src='resources/images/icon_folder.png' border='0' align='absmiddle' style='margin: 1px 2px 3px 0px;'>".$dirname."</a><div style='display:none'>".recur_dir($newpath)."</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>\n";
|
2012-11-24 07:53:38 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$filename = end($level);
|
|
|
|
|
$filesize = round(filesize($newpath)/1024, 2);
|
2016-02-24 20:28:35 +01:00
|
|
|
$newpath = str_replace ('//', '/', $newpath);
|
|
|
|
|
$newpath = str_replace ("\\", "/", $newpath);
|
|
|
|
|
$htmlfilelist .= "
|
|
|
|
|
<table border=0 cellpadding='0' cellspacing='0'>
|
|
|
|
|
<tr>
|
|
|
|
|
<td nowrap align='bottom' style='padding-left: 16px;'>
|
|
|
|
|
<a href='javascript:void(0);' onclick=\"parent.document.getElementById('filepath').value='".$newpath."'; parent.document.getElementById('current_file').value = '".$newpath."'; makeRequest('fileread.php','file=".urlencode($newpath)."');\" title='".$newpath." ".$filesize." KB'><img src='resources/images/icon_file.png' border='0' align='absmiddle' style='margin: 1px 2px 3px -1px;'>".$filename."</a>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>\n";
|
2012-11-24 07:53:38 +01:00
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2016-02-24 20:28:35 +01:00
|
|
|
|
2012-11-24 07:53:38 +01:00
|
|
|
closedir($dirlist);
|
|
|
|
|
return $htmldirlist ."\n". $htmlfilelist;
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "<script type=\"text/javascript\" language=\"javascript\">\n";
|
|
|
|
|
echo " function makeRequest(url, strpost) {\n";
|
|
|
|
|
echo " var http_request = false;\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " if (window.XMLHttpRequest) { // Mozilla, Safari, ...\n";
|
|
|
|
|
echo " http_request = new XMLHttpRequest();\n";
|
|
|
|
|
echo " if (http_request.overrideMimeType) {\n";
|
|
|
|
|
echo " http_request.overrideMimeType('text/xml');\n";
|
|
|
|
|
echo " // See note below about this line\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " } else if (window.ActiveXObject) { // IE\n";
|
|
|
|
|
echo " try {\n";
|
|
|
|
|
echo " http_request = new ActiveXObject(\"Msxml2.XMLHTTP\");\n";
|
|
|
|
|
echo " } catch (e) {\n";
|
|
|
|
|
echo " try {\n";
|
|
|
|
|
echo " http_request = new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
|
|
|
|
|
echo " } catch (e) {}\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " if (!http_request) {\n";
|
2012-11-24 06:23:48 +01:00
|
|
|
echo " alert('".$text['message-give-up']."');\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " return false;\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " http_request.onreadystatechange = function() { returnContent(http_request); };\n";
|
|
|
|
|
echo " if (http_request.overrideMimeType) {\n";
|
|
|
|
|
echo " http_request.overrideMimeType('text/html');\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " http_request.open('POST', url, true);\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " if (strpost.length == 0) {\n";
|
|
|
|
|
echo " //http_request.send(null);\n";
|
|
|
|
|
echo " http_request.send('name=value&foo=bar');\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " else {\n";
|
|
|
|
|
echo " http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');\n";
|
|
|
|
|
echo " http_request.send(strpost);\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " function returnContent(http_request) {\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " if (http_request.readyState == 4) {\n";
|
|
|
|
|
echo " if (http_request.status == 200) {\n";
|
2016-02-24 20:28:35 +01:00
|
|
|
echo " parent.document.getElementById('editor_source').value=http_request.responseText;";
|
|
|
|
|
echo " parent.editor.getSession().setValue(parent.document.getElementById('editor_source').value);";
|
|
|
|
|
echo " parent.editor.gotoLine(1);";
|
|
|
|
|
echo " parent.editor.scrollToLine(1, true, true, function() {});";
|
|
|
|
|
echo " parent.editor.focus();";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " else {\n";
|
2012-11-24 06:23:48 +01:00
|
|
|
echo " alert('".$text['message-problem']."');\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " }\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo "</script>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n";
|
|
|
|
|
//echo "// ---------------------------------------------\n";
|
|
|
|
|
//echo "// --- http://www.codeproject.com/jscript/dhtml_treeview.asp\n";
|
|
|
|
|
//echo "// --- Name: Easy DHTML Treeview --\n";
|
|
|
|
|
//echo "// --- Author: D.D. de Kerf --\n";
|
|
|
|
|
//echo "// --- Version: 0.2 Date: 13-6-2001 --\n";
|
|
|
|
|
//echo "// ---------------------------------------------\n";
|
|
|
|
|
echo "function Toggle(node) {\n";
|
|
|
|
|
echo " // Unfold the branch if it isn't visible\n";
|
2016-02-24 20:28:35 +01:00
|
|
|
echo " if (node.nextSibling.style.display == 'none') {\n";
|
|
|
|
|
echo " node.nextSibling.style.display = 'block';\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " }\n";
|
|
|
|
|
echo " // Collapse the branch if it IS visible\n";
|
2016-02-24 20:28:35 +01:00
|
|
|
echo " else {\n";
|
|
|
|
|
echo " node.nextSibling.style.display = 'none';\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " }\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "}\n";
|
|
|
|
|
echo "</SCRIPT>";
|
|
|
|
|
|
2016-02-24 20:28:35 +01:00
|
|
|
// keyboard shortcut bindings
|
|
|
|
|
echo "<script language='JavaScript' type='text/javascript' src='".PROJECT_PATH."/resources/jquery/jquery-1.11.1.js'></script>\n";
|
|
|
|
|
echo "<script>\n";
|
|
|
|
|
echo " $(window).keypress(function(event) {\n";
|
|
|
|
|
echo " //save file [Ctrl+S]\n";
|
|
|
|
|
echo " if ((event.which == 115 && event.ctrlKey) || (event.which == 19)) {\n";
|
|
|
|
|
echo " parent.$('form#frm_edit').submit();\n";
|
|
|
|
|
echo " return false;\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " //open file manager/clip library pane [Ctrl+Q]\n";
|
|
|
|
|
echo " else if ((event.which == 113 && event.ctrlKey) || (event.which == 19)) {\n";
|
|
|
|
|
echo " parent.toggle_sidebar();\n";
|
|
|
|
|
echo " parent.focus_editor();\n";
|
|
|
|
|
echo " return false;\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " //block backspace\n";
|
|
|
|
|
echo " else if (event.which == 8) {\n";
|
|
|
|
|
echo " return false;\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " //otherwise, default action\n";
|
|
|
|
|
echo " else {\n";
|
|
|
|
|
echo " return true;\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " });\n";
|
|
|
|
|
echo "</script>";
|
|
|
|
|
|
|
|
|
|
echo "</head>\n";
|
|
|
|
|
echo "<body style='margin: 0px; padding: 0px;'>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<div align='center' valign='1'>";
|
|
|
|
|
echo "<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='2'>\n";
|
|
|
|
|
echo "<tr class='border'>\n";
|
|
|
|
|
echo " <td align=\"left\" valign='top' nowrap>\n";
|
|
|
|
|
|
|
|
|
|
echo "\n";
|
2016-02-24 20:28:35 +01:00
|
|
|
echo " <table border=0 cellpadding='0' cellspacing='0'><tr><td><a href='javascript:void(0);' onclick=\"window.open('fileoptions.php?folder=".urlencode($_SERVER["DOCUMENT_ROOT"])."','filewin','left=20,top=20,width=310,height=350,toolbar=0,resizable=0');\" style='text-decoration:none;' title='Manage Files'><img src='resources/images/icon_gear.png' border='0' align='absmiddle' style='margin: 0px 2px 4px 0px;'>".$text['label-files']."</a><div>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2015-12-22 04:52:54 +01:00
|
|
|
//start the session
|
|
|
|
|
ini_set("session.cookie_httponly", True);
|
2013-05-28 07:16:40 +02:00
|
|
|
session_start();
|
2013-05-25 18:19:40 +02:00
|
|
|
if ($_SESSION["app"]["edit"]["dir"] == "scripts") {
|
|
|
|
|
echo recur_dir($_SESSION['switch']['scripts']['dir']);
|
|
|
|
|
}
|
|
|
|
|
if ($_SESSION["app"]["edit"]["dir"] == "php") {
|
|
|
|
|
echo recur_dir($_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH);
|
|
|
|
|
}
|
|
|
|
|
if ($_SESSION["app"]["edit"]["dir"] == "grammar") {
|
|
|
|
|
echo recur_dir($_SESSION['switch']['grammar']['dir']);
|
|
|
|
|
}
|
|
|
|
|
if ($_SESSION["app"]["edit"]["dir"] == "provision") {
|
2015-07-03 01:25:41 +02:00
|
|
|
|
2014-02-21 18:20:35 +01:00
|
|
|
switch (PHP_OS) {
|
|
|
|
|
case "Linux":
|
2014-06-03 19:45:24 +02:00
|
|
|
if (file_exists('/etc/fusionpbx/resources/templates/provision')) {
|
|
|
|
|
echo recur_dir('/etc/fusionpbx/resources/templates/provision');
|
2014-02-21 18:20:35 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo recur_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "FreeBSD":
|
|
|
|
|
//if the FreeBSD port is installed use the following paths by default.
|
2014-06-03 19:45:24 +02:00
|
|
|
if (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) {
|
2014-02-21 18:20:35 +01:00
|
|
|
echo recur_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo recur_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "NetBSD":
|
|
|
|
|
echo recur_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/");
|
|
|
|
|
break;
|
|
|
|
|
case "OpenBSD":
|
|
|
|
|
echo recur_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
echo recur_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/");
|
|
|
|
|
}
|
2013-05-25 18:19:40 +02:00
|
|
|
}
|
|
|
|
|
if ($_SESSION["app"]["edit"]["dir"] == "xml") {
|
|
|
|
|
echo recur_dir($_SESSION['switch']['conf']['dir']);
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
echo "</div></td></tr></table>\n";
|
|
|
|
|
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo "</table>\n";
|
|
|
|
|
echo "</div>";
|
|
|
|
|
|
|
|
|
|
require_once "footer.php";
|
|
|
|
|
|
|
|
|
|
unset ($result_count);
|
|
|
|
|
unset ($result);
|
|
|
|
|
unset ($key);
|
|
|
|
|
unset ($val);
|
|
|
|
|
unset ($c);
|
|
|
|
|
?>
|