This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
forked from FreePBX/superfecta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
49 lines (47 loc) · 1.79 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
if(file_exists("/etc/freepbx.conf")) {
//This is FreePBX 2.9+
require("/etc/freepbx.conf");
} elseif(file_exists("/etc/asterisk/freepbx.conf")) {
//This is FreePBX 2.9+
require("/etc/asterisk/freepbx.conf");
} else {
//This is > FreePBX 2.8
$functions_location = str_replace("modules/superfecta", "", dirname(__FILE__))."functions.inc.php";
require_once($functions_location);
require_once 'DB.php';
define("AMP_CONF", "/etc/amportal.conf");
$amp_conf = parse_amportal_conf(AMP_CONF);
if(count($amp_conf) == 0) {
fatal("FAILED");
}
$dsn = array(
'phptype' => 'mysql', // Looks like we are assuming mysql -- is this safe? (jkiel - 01/04/2011)
'username' => $amp_conf['AMPDBUSER'],
'password' => $amp_conf['AMPDBPASS'],
'hostspec' => $amp_conf['AMPDBHOST'],
'database' => $amp_conf['AMPDBNAME'],
);
$options = array();
$db =& DB::connect($dsn, $options);
if(PEAR::isError($db)){
die($db->getMessage());
}
//connect to the asterisk manager
$phpasman_location = str_replace("modules/superfecta", "", dirname(__FILE__))."common/php-asmanager.php";
if(!file_exists($phpasman_location)) {
die('Please update line 57 of config.php to reflect proper astman location');
}
require_once($phpasman_location);
$astman = new AGI_AsteriskManager();
// attempt to connect to asterisk manager proxy
if(!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !$res = $astman->connect("127.0.0.1:".$amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], 'off'))
{
// attempt to connect directly to asterisk, if no proxy or if proxy failed
if (!$res = $astman->connect("127.0.0.1:".$amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], 'off'))
{
// couldn't connect at all
die('Could Not Connect to Asterisk Manager!');
}
}
}