From d26edddbc1b911c1e02543fb3038e4287dd0a0dc Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 19 Sep 2017 11:26:11 -0600 Subject: [PATCH] Update filelist.php --- app/edit/filelist.php | 113 ++++++++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 49 deletions(-) diff --git a/app/edit/filelist.php b/app/edit/filelist.php index 2b90bf9c31..d599fead78 100644 --- a/app/edit/filelist.php +++ b/app/edit/filelist.php @@ -17,23 +17,27 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2016 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ -include "root.php"; -require_once "resources/require.php"; -require_once "resources/check_auth.php"; -if (permission_exists('script_editor_view')) { - //access granted -} -else { - echo "access denied"; - exit; -} + +//includes + include "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + +//check permissions + if (permission_exists('script_editor_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } //add css and javascript require_once "header.php"; @@ -96,6 +100,51 @@ else { return $htmldirlist ."\n". $htmlfilelist; } +//get the directory + if (!isset($_SESSION)) { session_start(); } + switch ($_SESSION["app"]["edit"]["dir"]) { + case 'scripts': + $edit_directory = $_SESSION['switch']['scripts']['dir']; + break; + case 'php': + $edit_directory = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH; + break; + case 'grammer': + $edit_directory = $_SESSION['switch']['grammar']['dir']; + break; + case 'provision': + switch (PHP_OS) { + case "Linux": + if (file_exists('/etc/fusionpbx/resources/templates/provision')) { + $edit_directory = '/etc/fusionpbx/resources/templates/provision'; + } + else { + $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/"; + } + break; + case "FreeBSD": + if (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) { + $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/"; + } + else { + $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/"; + } + break; + case "NetBSD": + $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/"; + break; + case "OpenBSD": + $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/"; + break; + default: + $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision/"; + } + break; + case 'xml': + $edit_directory = $_SESSION['switch']['conf']['dir']; + break; + } + echo "