Commit d9782def authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) cleanup requires/includes

parent 07012cc7
......@@ -41,11 +41,13 @@ require_once("globals.inc");
/* include globals from notices.inc /utility/XML parser files */
require_once('config.lib.inc');
require_once("notices.inc");
require_once("util.inc");
require_once("IPv6.inc");
require_once("xmlparse.inc");
require_once("crypt.inc");
require_once("certs.inc");
require_once("radius.inc");
$config = parse_config();
//
......@@ -654,7 +656,6 @@ function ldap_test_connection($authcfg)
function ldap_setup_caenv($authcfg)
{
require_once("certs.inc");
unset($caref);
......@@ -1135,8 +1136,6 @@ function radius_backed($username, $passwd, $authcfg, &$attributes = array())
global $config;
$ret = false;
require_once("radius.inc");
$rauth = new Auth_RADIUS_PAP($username, $passwd);
if ($authcfg) {
$radiusservers = array();
......
......@@ -5,6 +5,7 @@
Copyright (C) 2005-2006 Bill Marquette <bill.marquette@gmail.com>
Copyright (C) 2006 Paul Taylor <paultaylor@winn-dixie.com>.
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
(from priv.inc) Copyright (C) 2008 Shrew Soft Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -29,9 +30,91 @@
POSSIBILITY OF SUCH DAMAGE.
*/
include_once("auth.inc");
include_once("priv.inc");
require_once("auth.inc");
require_once("filter.inc");
require_once("functions.inc");
require_once("globals.inc");
// provided via legacy_bindings.inc
global $priv_list;
$acl = new OPNsense\Core\ACL();
$priv_list = $acl->getLegacyPrivList();
function cmp_page_matches($page, & $matches, $fullwc = true) {
if (!is_array($matches))
return false;
/* skip any leading fwdslash */
$test = strpos($page, "/");
if ($test !== false && $test == 0)
$page = substr($page, 1);
/* look for a match */
foreach ($matches as $match) {
/* possibly ignore full wildcard match */
if (!$fullwc && !strcmp($match ,"*"))
continue;
/* compare exact or wildcard match */
$match = str_replace(array(".", "*","?"), array("\.", ".*","\?"), $match);
$result = preg_match("@^/{$match}$@", "/{$page}");
if ($result)
return true;
}
return false;
}
function isAllowed($username, $page)
{
global $_SESSION;
if (!isset($username)) {
return false;
}
/* root access check */
$user = getUserEntry($username);
if (isset($user)) {
if (isset($user['uid'])) {
if ($user['uid'] == 0) {
return true;
}
}
}
/* user privelege access check */
if (cmp_page_matches($page, $_SESSION['page-match'])) {
return true;
}
return false;
}
function isAllowedPage($page)
{
if (!isset($_SESSION['Username'])) {
return false;
}
/* root access check */
$user = getUserEntry($_SESSION['Username']);
if (isset($user)) {
if (isset($user['uid'])) {
if ($user['uid'] == 0) {
return true;
}
}
}
/* user privelege access check */
return cmp_page_matches($page, $_SESSION['page-match']);
}
function getPrivPages(& $entry, & $allowed_pages) {
global $priv_list;
......@@ -233,8 +316,7 @@ $allowedpages = getAllowedPages($_SESSION['Username']);
if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
if (count($allowedpages) > 0) {
$page = str_replace('*', '', $allowedpages[0]);
require_once("functions.inc");
redirectHeader("/{$page}");
header("Location: /{$page}");
$username = empty($_SESSION["Username"]) ? "(system)" : $_SESSION['Username'];
if (!empty($_SERVER['REMOTE_ADDR'])) {
......@@ -306,7 +388,6 @@ function display_error_form($http_code, $desc)
function display_login_form()
{
require_once("globals.inc");
global $config, $g;
$g['theme'] = get_current_theme();
......
......@@ -42,7 +42,6 @@ require_once("radius.inc");
require_once("captiveportal.radius_accounting.inc");
require_once("captiveportal.radius_authentication.inc");
require_once("voucher.inc");
require_once("script/load_phalcon.php");
function get_include_contents($filename) {
if (is_file($filename)) {
......
......@@ -61,8 +61,6 @@ function RADIUS_ACCOUNTING_START($ruleno, $username, $sessionid, $radiusservers,
break;
default:
if (!function_exists('getNasIP'))
require_once("captiveportal.inc");
$calledstationid = getNasIP();
$callingstationid = $clientmac;
break;
......
......@@ -62,8 +62,6 @@ function RADIUS_AUTHENTICATION($username,$password,$radiusservers,$clientip,$cli
$callingstationid = $clientip;
break;
default:
if (!function_exists('getNasIP'))
require_once("captiveportal.inc");
$calledstationid = getNasIP();
$callingstationid = $clientmac;
break;
......
......@@ -39,10 +39,9 @@ if(php_uname("m") == "amd64") {
}
/* include globals from notices.inc /utility/XML parser files */
require_once("notices.inc");
require_once('config.lib.inc');
require_once("util.inc");
require_once("IPv6.inc");
require_once('config.lib.inc');
require_once("xmlparse.inc");
require_once("crypt.inc");
require_once("globals.inc");
......
......@@ -33,7 +33,8 @@ require_once("globals.inc");
require_once("xmlparse.inc");
require_once("crypt.inc");
require_once("util.inc");
require_once("script/load_phalcon.php");
require_once("notices.inc");
require_once("legacy_bindings.inc");
/* make a global alias table (for faster lookups) */
function alias_make_table($config)
......
......@@ -27,98 +27,6 @@
POSSIBILITY OF SUCH DAMAGE.
*/
/* BEGIN compatibility goo with HEAD */
if (!function_exists('gettext')) {
function gettext($text)
{
return $text;
}
}
if (!function_exists('redirectHeader')) {
function redirectHeader($text)
{
global $_SERVER;
if (isAjax()) {
if ($_SERVER['HTTPS'] == 'on') {
$protocol = 'https';
} else {
$protocol = 'http';
}
$port = '';
if (
!($_SERVER['SERVER_PORT'] == '80' && $protocol == 'http') &&
!($_SERVER['SERVER_PORT'] == '443' && $protocol == 'https')
) {
$port = ":{$_SERVER['SERVER_PORT']}";
}
echo "\ndocument.location.href = '{$protocol}://{$_SERVER['SERVER_NAME']}{$port}/{$text}';\n";
} else {
header("Location: $text");
}
}
}
/* END compatibility goo with HEAD */
function get_menu_messages()
{
global $config;
$menu_messages = '';
if (are_notices_pending()) {
$notices = get_notices();
$requests = array();
## Get Query Arguments from URL ###
foreach ($_REQUEST as $key => $value) {
if ($key != "PHPSESSID") {
$requests[] = $key.'='.$value;
}
}
if (is_array($requests)) {
$request_string = implode("&", $requests);
}
if (is_array($notices)) {
$notice_msgs = "<ul class=\"dropdown-menu\" role=\"menu\">";
$notice_msgs .= "<li><a href=\"#\" onclick=\"notice_action('acknowledge','all');\" >".gettext("Acknowledge All Notices")."</a></li><li class=\"divider\"></li>";
foreach ($notices as $key => $value) {
$date = date("m-d-y H:i:s", $key);
$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
$noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg);
$alert_action ="onclick=\"notice_action('acknowledge','{$key}'); jQuery(this).parent().parent().remove();\"";
$notice_msgs .= "<li><a href=\"#\" {$alert_action}>{$date} [ ".htmlspecialchars($noticemsg)."]</a></li>";
}
$notice_msgs .="</ul>";
if (count($notices) == 1) {
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice");
} else {
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices");
}
$menu_messages.="<a href=\"/\" class=\"dropdown-toggle \" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\"><span class=\"text-primary\">{$msg}&nbsp;</span><span class=\"caret text-primary\"></span></a>{$notice_msgs}\n";
}
} else {
$menu_messages .= sprintf(
'<a href="#">%s@%s.%s</a>',
$_SESSION['Username'],
$config['system']['hostname'],
$config['system']['domain']
);
}
return ($menu_messages);
}
/* include all configuration functions */
require_once("interfaces.inc");
require_once("gwlb.inc");
......
......@@ -27,7 +27,6 @@
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("config.inc");
require_once("rrd.inc");
/* Returns an array of default values used for apinger.conf */
......
<?php
/**
* Copyright (C) 2015 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
require_once("script/load_phalcon.php");
/**
* wrap config run
*/
function configd_run($cmd, $detach = false)
{
require_once("script/load_phalcon.php");
$backend = new OPNsense\Core\Backend();
return $backend->configdRun("{$cmd}", $detach);
}
<?php
require_once("util.inc");
require_once("config.inc");
require_once("functions.inc");
/* MiniUPnPd */
......
......@@ -138,18 +138,6 @@ function setup_polling()
}
}
function set_language($lang)
{
$lang_encoding = $lang . '.UTF-8';
$textdomain = 'OPNsense';
putenv('LANG=' . $lang_encoding);
setlocale(LC_ALL, $lang_encoding);
textdomain($textdomain);
bindtextdomain($textdomain, '/usr/local/share/locale');
bind_textdomain_codeset($textdomain, $lang_encoding);
}
/****f* legacy/setup_microcode
* NAME
* enumerates all interfaces and calls enable_hardware_offloading which
......
<?php
/*
Copyright (C) 2008 Shrew Soft Inc
Copyright (C) 2007-2008 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2005-2006 Bill Marquette <bill.marquette@gmail.com>
Copyright (C) 2006 Paul Taylor <paultaylor@winn-dixie.com>
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("script/load_phalcon.php");
global $priv_list;
$acl = new OPNsense\Core\ACL();
$priv_list = $acl->getLegacyPrivList();
function cmp_page_matches($page, & $matches, $fullwc = true) {
if (!is_array($matches))
return false;
/* skip any leading fwdslash */
$test = strpos($page, "/");
if ($test !== false && $test == 0)
$page = substr($page, 1);
/* look for a match */
foreach ($matches as $match) {
/* possibly ignore full wildcard match */
if (!$fullwc && !strcmp($match ,"*"))
continue;
/* compare exact or wildcard match */
$match = str_replace(array(".", "*","?"), array("\.", ".*","\?"), $match);
$result = preg_match("@^/{$match}$@", "/{$page}");
if ($result)
return true;
}
return false;
}
function isAllowed($username, $page)
{
global $_SESSION;
if (!isset($username)) {
return false;
}
/* root access check */
$user = getUserEntry($username);
if (isset($user)) {
if (isset($user['uid'])) {
if ($user['uid'] == 0) {
return true;
}
}
}
/* user privelege access check */
if (cmp_page_matches($page, $_SESSION['page-match'])) {
return true;
}
return false;
}
function isAllowedPage($page)
{
if (!isset($_SESSION['Username'])) {
return false;
}
/* root access check */
$user = getUserEntry($_SESSION['Username']);
if (isset($user)) {
if (isset($user['uid'])) {
if ($user['uid'] == 0) {
return true;
}
}
}
/* user privelege access check */
return cmp_page_matches($page, $_SESSION['page-match']);
}
?>
......@@ -112,13 +112,6 @@ function unlock($cfglckkey = 0)
fclose($cfglckkey);
}
function configd_run($cmd, $detach = false)
{
require_once("script/load_phalcon.php");
$backend = new OPNsense\Core\Backend();
return $backend->configdRun("{$cmd}", $detach);
}
function is_module_loaded($module_name) {
$module_name = str_replace(".ko", "", $module_name);
$running = 0;
......
......@@ -29,7 +29,6 @@
require_once("functions.inc");
require_once("config.inc");
require_once("notices.inc");
require_once("openvpn.inc");
require_once("interfaces.inc");
......
......@@ -29,7 +29,6 @@
require_once("functions.inc");
require_once("config.inc");
require_once("notices.inc");
require_once("openvpn.inc");
require_once("interfaces.inc");
......
......@@ -29,7 +29,6 @@
require_once("config.inc");
require_once("functions.inc");
require_once("notices.inc");
$arguments = getopt("egm:");
......
......@@ -2,7 +2,6 @@
<?php
require_once('config.inc');
require_once("script/load_phalcon.php");
$cnf = OPNsense\Core\Config::getInstance();
$confvers = $cnf->getBackups(true);
......
......@@ -27,7 +27,6 @@
*/
require_once("config.inc");
require_once("notices.inc");
require_once("globals.inc");
require_once("gmirror.inc");
......
......@@ -27,7 +27,6 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("script/load_phalcon.php");
/* Allow additional execution time 0 = no limit. */
ini_set('max_execution_time', '0');
......
......@@ -30,7 +30,6 @@
require_once("config.lib.inc");
require_once("guiconfig.inc");
require_once("script/load_phalcon.php");
// list backups
$cnf = OPNsense\Core\Config::getInstance();
......
......@@ -32,7 +32,6 @@ require_once("globals.inc");
require_once("functions.inc");
require_once("shortcuts.inc");
require_once("services.inc");
require_once("script/load_phalcon.php");
function find_service_by_name($name) {
$services = get_services();
......
......@@ -27,7 +27,9 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("config.inc");
require_once("csrf/csrf-magic.php");
/* Include authentication routines */
/* THIS MUST BE ABOVE ALL OTHER CODE */
if(isset($nocsrf) && !$nocsrf) {
......@@ -37,10 +39,22 @@ function csrf_startup() {
$timeout_minutes = isset($config['system']['webgui']['session_timeout']) ? $config['system']['webgui']['session_timeout'] : 240;
csrf_conf('expires', $timeout_minutes * 60);
}
require_once("csrf/csrf-magic.php");
}
function set_language($lang)
{
$lang_encoding = $lang . '.UTF-8';
$textdomain = 'OPNsense';
putenv('LANG=' . $lang_encoding);
setlocale(LC_ALL, $lang_encoding);
textdomain($textdomain);
bindtextdomain($textdomain, '/usr/local/share/locale');
bind_textdomain_codeset($textdomain, $lang_encoding);
}
/* make sure nothing is cached */
if (isset($omit_nocacheheaders) && $omit_nocacheheaders) {
header("Expires: 0");
......@@ -52,9 +66,6 @@ if (isset($omit_nocacheheaders) && $omit_nocacheheaders) {
header("X-Frame-Options: SAMEORIGIN");
/* parse the configuration and include all configuration functions */
require_once("functions.inc");
$g['theme'] = get_current_theme();
/* Set the default interface language */
......@@ -635,3 +646,85 @@ function get_crash_report($pedantic = false)
return $savemsg;
}
function redirectHeader($text)
{
global $_SERVER;
if (isAjax()) {
if ($_SERVER['HTTPS'] == 'on') {
$protocol = 'https';
} else {
$protocol = 'http';
}
$port = '';
if (
!($_SERVER['SERVER_PORT'] == '80' && $protocol == 'http') &&
!($_SERVER['SERVER_PORT'] == '443' && $protocol == 'https')
) {
$port = ":{$_SERVER['SERVER_PORT']}";
}
echo "\ndocument.location.href = '{$protocol}://{$_SERVER['SERVER_NAME']}{$port}/{$text}';\n";
} else {
header("Location: $text");
}
}
function get_menu_messages()
{
global $config;
$menu_messages = '';
if (are_notices_pending()) {
$notices = get_notices();
$requests = array();
## Get Query Arguments from URL ###
foreach ($_REQUEST as $key => $value) {
if ($key != "PHPSESSID") {
$requests[] = $key.'='.$value;
}
}
if (is_array($requests)) {
$request_string = implode("&", $requests);
}
if (is_array($notices)) {
$notice_msgs = "<ul class=\"dropdown-menu\" role=\"menu\">";
$notice_msgs .= "<li><a href=\"#\" onclick=\"notice_action('acknowledge','all');\" >".gettext("Acknowledge All Notices")."</a></li><li class=\"divider\"></li>";
foreach ($notices as $key => $value) {
$date = date("m-d-y H:i:s", $key);
$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
$noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg);
$alert_action ="onclick=\"notice_action('acknowledge','{$key}'); jQuery(this).parent().parent().remove();\"";
$notice_msgs .= "<li><a href=\"#\" {$alert_action}>{$date} [ ".htmlspecialchars($noticemsg)."]</a></li>";
}
$notice_msgs .="</ul>";
if (count($notices) == 1) {
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice");
} else {
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices");
}
$menu_messages.="<a href=\"/\" class=\"dropdown-toggle \" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\"><span class=\"text-primary\">{$msg}&nbsp;</span><span class=\"caret text-primary\"></span></a>{$notice_msgs}\n";
}
} else {
$menu_messages .= sprintf(
'<a href="#">%s@%s.%s</a>',
$_SESSION['Username'],
$config['system']['hostname'],
$config['system']['domain']
);
}
return ($menu_messages);
}
......@@ -37,7 +37,6 @@ ob_start(null, "1000");
## Load Essential Includes
require_once('guiconfig.inc');
require_once('notices.inc');
if (isset($_REQUEST['closenotice'])) {
close_notice($_REQUEST['closenotice']);
......
......@@ -27,7 +27,6 @@
*/
require_once("guiconfig.inc");
require_once("notices.inc");
// Growl
$pconfig['disable_growl'] = isset($config['notifications']['growl']['disable']);
......
......@@ -31,9 +31,7 @@
require_once("functions.inc");
require_once("guiconfig.inc");
require_once('notices.inc');
include_once("includes/functions.inc.php");
require_once("script/load_phalcon.php");
if (isset($_REQUEST['getupdatestatus'])) {
$pkg_json = trim(configd_run('firmware pkgstatus'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment