Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('edit_view')) { //access granted } else { echo "access denied"; exit; } //create the settings object if (!$settings) { $settings = new settings(); } //add css and javascript require_once "header.php"; //define function recur_dir function recur_dir($dir) { clearstatcache(); $html_dir_list = ''; $html_file_list = ''; $dir_handle = opendir($dir); $dir_array = array(); if (($dir_handle)) { $x = 0; while (false !== ($file = readdir($dir_handle))) { if ($file != "." AND $file != "..") { $newpath = $dir.'/'.$file; $level = explode('/',$newpath); 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) } else { $dir_array[] = $newpath; } if ($x > 1000) { break; } $x++; } } } asort($dir_array); foreach ($dir_array as $newpath){ $level = explode('/',$newpath); if (is_dir($newpath)) { $dirname = end($level); $html_dir_list .= "
\n"; $html_dir_list .= "".$dirname.""; $html_dir_list .= "
".recur_dir($newpath)."
\n"; $html_dir_list .= "
\n"; } else { $filename = end($level); $filesize = round(filesize($newpath)/1024, 2); $newpath = str_replace ('//', '/', $newpath); $newpath = str_replace ("\\", "/", $newpath); $html_file_list .= "
\n"; $html_file_list .= ""; $html_file_list .= "".$filename."\n"; $html_file_list .= "
\n"; } } closedir($dir_handle); return $html_dir_list ."\n". $html_file_list; } //get the directory if (!isset($_SESSION)) { session_start(); } switch ($_SESSION["app"]["edit"]["dir"]) { case 'scripts': $edit_directory = $settings->get('switch', 'scripts'); break; case 'php': $edit_directory = dirname(__DIR__, 2); break; case 'grammar': $edit_directory = $settings->get('switch', 'grammar'); break; case 'provision': switch (PHP_OS) { case "Linux": if (file_exists('/usr/share/fusionpbx/templates/provision')) { $edit_directory = '/usr/share/fusionpbx/templates/provision'; } elseif (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/share/fusionpbx/templates/provision')) { $edit_directory = '/usr/share/fusionpbx/templates/provision'; } elseif (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) { $edit_directory = '/usr/local/etc/fusionpbx/resources/templates/provision'; } else { $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision"; } break; case "NetBSD": if (file_exists('/usr/local/share/fusionpbx/templates/provision')) { $edit_directory = '/usr/share/fusionpbx/templates/provision'; } else { $edit_directory = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision"; } break; case "OpenBSD": if (file_exists('/usr/local/share/fusionpbx/templates/provision')) { $edit_directory = '/usr/share/fusionpbx/templates/provision'; } else { $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 = $settings->get('switch', 'conf'); break; default: //do not allow unknown settings exit(); } // keyboard shortcut bindings echo "\n"; echo "\n"; //save file key_press('ctrl+s', 'down', 'window', null, null, "$('form#frm_edit').submit(); return false;", true); //open file manager/clip library pane key_press('ctrl+q', 'down', 'window', null, null, 'toggle_sidebar(); focus_editor(); return false;', true); //prevent backspace (browser history back) key_press('backspace', 'down', 'window', null, null, 'return false;', true); echo "\n"; echo "\n"; echo "
".$text['label-files']."
\n"; echo "
\n"; if (file_exists($edit_directory)) { $edit_html_list = recur_dir($edit_directory); echo $edit_html_list; } echo "
\n";