Kaynağa Gözat

Update sms.php (#168)

* Update sms.php

* Delete root.php

* Update sms_broadcast.php

* Update sms_broadcast_edit.php

* Update sms_broadcast_process.php

* Update sms_delete.php

* Update sms_edit.php

* Update sms_hook_common.php

* Update sms_broadcast_process.php

* Update sms_mdr.php

* Update sms_hook_bandwidth.php

* Update sms_hook_didww.php

* Update sms_hook_flowroute.php

* Update sms_hook_twilio.php

* Update sms_hook_thinq.php

* Update sms_hook_telnyx.php

* Update sms_hook_peerless.php

* Update sms_hook_plivo.php

* Update sms_hook_teli.php

* Update sms_hook_bandwidth.php

* Update sms_hook_didww.php

* Update sms_hook_flowroute.php

* Update sms_hook_telnyx.php

* Update sms_hook_thinq.php

* Update sms_hook_twilio.php
Alex 2 yıl önce
ebeveyn
işleme
e7f12aa19e

+ 6 - 2
sms/hook/sms_hook_bandwidth.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -24,4 +27,5 @@ if (check_acl()) {
 	error_log('ACCESS DENIED [SMS]: ' .  print_r($_SERVER['REMOTE_ADDR'], true));
 	die("access denied");
 }
-?>
+
+?>

+ 6 - 2
sms/hook/sms_hook_didww.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -19,4 +22,5 @@ $sms_to_did_no=$_POST['to'];
 route_and_send_sms($sms_from, $sms_to_did_no, $sms_text);
 
 die("no");
-?>
+
+?>

+ 4 - 1
sms/hook/sms_hook_flowroute.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 

+ 5 - 1
sms/hook/sms_hook_peerless.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -40,4 +43,5 @@ endforeach;
 	error_log('ACCESS DENIED [SMS]: ' .  print_r($_SERVER['REMOTE_ADDR'], true));
 	die("access denied");
 //}
+
 ?>

+ 6 - 2
sms/hook/sms_hook_plivo.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -18,4 +21,5 @@ if (check_acl()) {
 	error_log('ACCESS DENIED [SMS]: ' .  print_r($_SERVER['REMOTE_ADDR'], true));
 	die("access denied");
 }
-?>
+
+?>

+ 6 - 2
sms/hook/sms_hook_teli.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -14,4 +17,5 @@ if(check_acl()) {
 	error_log('ACCESS DENIED [SMS]: ' .  print_r($_SERVER['REMOTE_ADDR'], true));
 	die("access denied");
 }
-?>
+
+?>

+ 6 - 2
sms/hook/sms_hook_telnyx.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -20,4 +23,5 @@ if (check_acl()) {
 	error_log('ACCESS DENIED [SMS]: ' .  print_r($_SERVER['REMOTE_ADDR'], true));
 	die("access denied");
 }
-?>
+
+?>

+ 5 - 1
sms/hook/sms_hook_thinq.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -18,4 +21,5 @@ if (check_acl()) {
 	error_log('ACCESS DENIED [SMS]: ' .  print_r($_SERVER['REMOTE_ADDR'], true));
 	die("access denied");
 }
+
 ?>

+ 5 - 1
sms/hook/sms_hook_twilio.php

@@ -1,7 +1,10 @@
 <?php
 
-include "../root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
 
+//includes files
 require_once "resources/require.php";
 require_once "../sms_hook_common.php";
 
@@ -20,4 +23,5 @@ if (check_acl()) {
 	error_log('ACCESS DENIED [SMS]: ' .  print_r($_SERVER['REMOTE_ADDR'], true));
 	die("access denied");
 }
+
 ?>

+ 0 - 205
sms/root.php

@@ -1,205 +0,0 @@
-<?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 <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2012
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J Crane <[email protected]>
-*/
-
-// make sure the PATH_SEPARATOR is defined
-	umask(2);
-	if (!defined("PATH_SEPARATOR")) {
-		if (strpos($_ENV["OS"], "Win") !== false) {
-			define("PATH_SEPARATOR", ";");
-		} else {
-			define("PATH_SEPARATOR", ":");
-		}
-	}
-
-	if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
-
-	// make sure the document_root is set
-	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
-	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
-		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
-		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
-		if (file_exists('/project_root.php')) {
-			$path = '/';
-		} else {
-			$i    = 1;
-			$path = '';
-			while ($i < count($dirs)) {
-				$path .= '/' . $dirs[$i];
-				if (file_exists($path. '/project_root.php')) {
-					break;
-				}
-				$i++;
-			}
-		}
-		$_SERVER["DOCUMENT_ROOT"] = $path;
-	}else{
-		$_SERVER["DOCUMENT_ROOT"]   = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
-	}
-	$_SERVER["DOCUMENT_ROOT"]   = realpath($_SERVER["DOCUMENT_ROOT"]);
-// try to detect if a project path is being used
-	if (!defined('PROJECT_PATH')) {
-		if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
-			define('PROJECT_PATH', '/fusionpbx');
-		} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
-			define('PROJECT_PATH', '');
-		} else {
-			$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
-			$i    = 1;
-			$path = $_SERVER["DOCUMENT_ROOT"];
-			while ($i < count($dirs)) {
-				$path .= '/' . $dirs[$i];
-				if (file_exists($path. '/project_root.php')) {
-					break;
-				}
-				$i++;
-			}
-			if(!file_exists($path. '/project_root.php')){
-				die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
-			}
-			$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
-			define('PROJECT_PATH', $project_path);
-		}
-		$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
-		set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
-	}
-
-if (!class_exists('IP4Filter')) {
-	class IP4Filter {
-
-		private static $_IP_TYPE_SINGLE = 'single';
-		private static $_IP_TYPE_WILDCARD = 'wildcard';
-		private static $_IP_TYPE_MASK = 'mask';
-		private static $_IP_TYPE_CIDR = 'CIDR';
-		private static $_IP_TYPE_SECTION = 'section';
-		private $_allowed_ips = array();
-
-		public function __construct($allowed_ips) {
-			$this->_allowed_ips = $allowed_ips;
-		}
-
-		public function check($ip, $allowed_ips = null) {
-			$allowed_ips = $allowed_ips ? $allowed_ips : $this->_allowed_ips;
-
-			foreach ($allowed_ips as $allowed_ip) {
-				$type = $this->_judge_ip_type($allowed_ip);
-				$sub_rst = call_user_func(array($this, '_sub_checker_' . $type), $allowed_ip, $ip);
-
-				if ($sub_rst) {
-					return true;
-				}
-			}
-
-			return false;
-		}
-
-		private function _judge_ip_type($ip) {
-			if (strpos($ip, '*')) {
-				return self :: $_IP_TYPE_WILDCARD;
-			}
-
-			if (strpos($ip, '/')) {
-				$tmp = explode('/', $ip);
-				if (strpos($tmp[1], '.')) {
-					return self :: $_IP_TYPE_MASK;
-				} else {
-					return self :: $_IP_TYPE_CIDR;
-				}
-			}
-
-			if (strpos($ip, '-')) {
-				return self :: $_IP_TYPE_SECTION;
-			}
-
-			if (ip2long($ip)) {
-				return self :: $_IP_TYPE_SINGLE;
-			}
-
-			return false;
-		}
-
-		private function _sub_checker_single($allowed_ip, $ip) {
-			return (ip2long($allowed_ip) == ip2long($ip));
-		}
-
-		private function _sub_checker_wildcard($allowed_ip, $ip) {
-			$allowed_ip_arr = explode('.', $allowed_ip);
-			$ip_arr = explode('.', $ip);
-			for ($i = 0; $i < count($allowed_ip_arr); $i++) {
-				if ($allowed_ip_arr[$i] == '*') {
-					return true;
-				} else {
-					if (false == ($allowed_ip_arr[$i] == $ip_arr[$i])) {
-						return false;
-					}
-				}
-			}
-		}
-
-		private function _sub_checker_mask($allowed_ip, $ip) {
-			list($allowed_ip_ip, $allowed_ip_mask) = explode('/', $allowed_ip);
-			$begin = (ip2long($allowed_ip_ip) & ip2long($allowed_ip_mask)) + 1;
-			$end = (ip2long($allowed_ip_ip) | (~ ip2long($allowed_ip_mask))) + 1;
-			$ip = ip2long($ip);
-			return ($ip >= $begin && $ip <= $end);
-		}
-
-		private function _sub_checker_section($allowed_ip, $ip) {
-			list($begin, $end) = explode('-', $allowed_ip);
-			$begin = ip2long($begin);
-			$end = ip2long($end);
-			$ip = ip2long($ip);
-			return ($ip >= $begin && $ip <= $end);
-		}
-
-		private function _sub_checker_CIDR($CIDR, $IP) {
-			list ($net, $mask) = explode('/', $CIDR);
-			return ( ip2long($IP) & ~((1 << (32 - $mask)) - 1) ) == ip2long($net);
-		}
-
-	}
-
-	function check_acl(){
-		global $db, $debug, $domain_uuid, $domain_name;
-
-		//select node_cidr from v_access_control_nodes where node_cidr != '';
-		$sql = "select node_cidr from v_access_control_nodes where node_cidr != '' and node_type = 'allow'";
-		$prep_statement = $db->prepare(check_sql($sql));
-		$prep_statement->execute();
-		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
-		if (count($result) == 0) {
-			die("No ACL's");
-		}
-		foreach ($result as &$row) {
-			$allowed_ips[] = $row['node_cidr'];
-		}
-
-		$acl = new IP4Filter($allowed_ips);
-
-		return $acl->check($_SERVER['REMOTE_ADDR'],$allowed_ips);
-	}
-}
-?>

+ 9 - 3
sms/sms.php

@@ -23,9 +23,15 @@
 	Contributor(s):
 	Mark J Crane <[email protected]>
 */
-include "root.php";
-require_once "resources/require.php";
-require_once "resources/check_auth.php";
+
+//set the include path
+	$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+	set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+
 if (permission_exists('sms_view')) {
 	//access granted
 }

+ 6 - 3
sms/sms_broadcast.php

@@ -24,8 +24,11 @@
 	Mark J Crane <[email protected]>
 */
 
-//includes
-	require_once "root.php";
+//set the include path
+	$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+	set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
 	require_once "resources/require.php";
 	require_once "resources/check_auth.php";
 	require_once "resources/paging.php";
@@ -191,4 +194,4 @@
 //include the footer
 	require_once "resources/footer.php";
 
-?>
+?>

+ 6 - 3
sms/sms_broadcast_edit.php

@@ -25,8 +25,11 @@
 	Luis Daniel Lucio Quiroz <[email protected]>
 */
 
-//includes
-	include "root.php";
+//set the include path
+	$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+	set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
 	require_once "resources/require.php";
 	require_once "resources/check_auth.php";
 
@@ -336,4 +339,4 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 //include the footer
 	require_once "resources/footer.php";
 
-?>
+?>

+ 6 - 2
sms/sms_broadcast_process.php

@@ -1,6 +1,10 @@
 <?php
 
-include "root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
 require_once "resources/require.php";
 require_once "resources/classes/text.php";
 
@@ -55,4 +59,4 @@ foreach ($result as $sms_broadcast) {
 
 die();
 
-?>
+?>

+ 10 - 4
sms/sms_delete.php

@@ -25,9 +25,15 @@
 
 	Call Block is written by Gerrit Visser <[email protected]>
 */
-include "root.php";
-require_once "resources/require.php";
-require_once "resources/check_auth.php";
+
+//set the include path
+	$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+	set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+
 if (permission_exists('sms_delete')) {
 	//access granted
 }
@@ -62,4 +68,4 @@ else {
 		header("Location: sms.php");
 		return;
 
-?>
+?>

+ 9 - 4
sms/sms_edit.php

@@ -31,9 +31,14 @@
 
 */
 
-include "root.php";
-require_once "resources/require.php";
-require_once "resources/check_auth.php";
+//set the include path
+	$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+	set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+
 if (permission_exists('sms_add') || permission_exists('sms_edit')) {
 	//access granted
 }
@@ -285,4 +290,4 @@ else {
 
 //show the footer
 	require_once "resources/footer.php";
-?>
+?>

+ 7 - 3
sms/sms_hook_common.php

@@ -30,15 +30,18 @@
 	James Rose <[email protected]>
 
 */
-include "root.php";
+//set the include path
+$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
+require_once "resources/require.php";
 include "app/sms/sms_email.php";
 
 //luarun /var/www/html/app/sms/sms.lua TO FROM 'BODY'
 
 $debug = true;
 
-require_once "resources/require.php";
-
 function route_and_send_sms($from, $to, $body, $media = "") {
 	global $db, $debug, $domain_uuid, $domain_name, $mailsent;
 
@@ -197,4 +200,5 @@ function route_and_send_sms($from, $to, $body, $media = "") {
 				unset ($prep_statement);
 		}
 }
+
 ?>

+ 5 - 2
sms/sms_mdr.php

@@ -31,8 +31,11 @@
 
 */
 
-//includes
-	include "root.php";
+//set the include path
+	$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+	set_include_path(parse_ini_file($conf[0])['document.root']);
+
+//includes files
 	require_once "resources/require.php";
 	require_once "resources/check_auth.php";