Changeset 8270
- Timestamp:
- 09/02/09 09:43:41 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/2.6/amp_conf/bin/retrieve_conf
r8218 r8270 717 717 } 718 718 719 include("libfreepbx.confgen.php");720 721 719 // script to write op_server.cfg file from mysql 722 720 // 723 721 if(!$amp_conf['FOPDISABLE']) { 722 if (!@include("retrieve_op_conf_from_mysql.php")) { 723 error(_("error running retrieve_op_conf_from_mysql.php")); 724 } 725 /* 724 726 $script = $amp_conf['AMPBIN'].'/retrieve_op_conf_from_mysql.php'; 725 727 if (is_executable($script)) { … … 733 735 error(_("retrieve_op_conf_from_mysql.php does not exist or is not executable")); 734 736 } 737 */ 735 738 } 736 739 // generate configuration files freepbx/branches/2.6/amp_conf/bin/retrieve_op_conf_from_mysql.php
r8255 r8270 1 #!/usr/bin/php -q2 1 <?php 3 2 4 3 # Retrieves the sip user/peer entries from the database for the flash operator panel 5 4 6 //include("/var/www/html/admin/functions.inc.php");7 //include("DB.php");8 require_once("/var/www/html/admin/functions.inc.php");9 require_once("DB.php");10 11 5 ################### BEGIN OF CONFIGURATION #################### 12 6 13 7 global $zapataconfdir; 14 $zapataconfdir = "/etc/asterisk/"; 15 $amportalconf = "/etc/amportal.conf"; 8 global $amp_conf; 9 global $db; 10 global $chan_dahdi; 11 12 $zapataconfdir = $amp_conf['ASTETCDIR']."/"; 16 13 $zapataconf = "zapata.conf"; 17 18 if ($argc == 2) 19 { 20 $amportalconf = $argv[0]; 21 $zapataconfdir = $argv[1]."/"; 22 } 23 24 $zapataconf = $zapataconfdir . $zapataconf; 14 $dahdiconf = "chan_dahdi.conf"; 15 if ($chan_dadhi) { 16 $zapataconf = $zapataconfdir . $dahdiconf; 17 } else { 18 $zapataconf = $zapataconfdir . $zapataconf; 19 } 25 20 26 21 ######## LAYOUT INFO ######### … … 100 95 global $istrunk; 101 96 global $lastlabelnum; 97 global $chan_dahdi; 102 98 103 99 if (!isset($ampwildcard)) {$ampwildcard=0;} 104 if (!isset($zaplabel)) {$zaplabel= "Zap %c";}100 if (!isset($zaplabel)) {$zaplabel= $chan_dadhi ? "DAHDI %c" : "Zap %c";} 105 101 if (!isset($istrunk)) {$istrunk=0;} 106 102 if (!isset($lastlabelnum)) {$lastlabelnum=0;} … … 214 210 215 211 # cool hack by Julien BLACHE <jblache@debian.org> 216 $ampconf = parse_amportal_conf( $amportalconf );217 212 # WARNING: this file will be substituted by the output of this program 218 $op_conf = $amp conf["AMPWEBROOT"]."/panel/op_buttons_additional.cfg";213 $op_conf = $amp_conf["AMPWEBROOT"]."/panel/op_buttons_additional.cfg"; 219 214 # username to connect to the database 220 $username = $amp conf["AMPDBUSER"];215 $username = $amp_conf["AMPDBUSER"]; 221 216 # password to connect to the database 222 $password = $amp conf["AMPDBPASS"];217 $password = $amp_conf["AMPDBPASS"]; 223 218 # the name of the box the MySQL database is running on 224 $hostname = $amp conf["AMPDBHOST"];219 $hostname = $amp_conf["AMPDBHOST"]; 225 220 # the name of the database our tables are kept 226 $database = $amp conf["AMPDBNAME"];221 $database = $amp_conf["AMPDBNAME"]; 227 222 #sort option: extension or lastname 228 $sortoption = $ampconf["FOPSORT"]; 229 230 # the engine to be used for the SQL queries, 231 # if none supplied, backfall to mysql 232 $db_engine = "mysql"; 233 if (isset($ampconf["AMPDBENGINE"])){ 234 $db_engine = $ampconf["AMPDBENGINE"]; 235 } 223 $sortoption = $amp_conf["FOPSORT"]; 224 236 225 ################### END OF CONFIGURATION ####################### 237 226 … … 240 229 ; all modifications must be done from the web gui 241 230 "; 242 243 switch ($db_engine)244 {245 case "pgsql":246 case "mysql":247 /* datasource in in this style:248 dbengine://username:password@host/database */249 250 $datasource = $db_engine.'://'.$username.':'.$password.'@'.$hostname.'/'.$database;251 $db = DB::connect($datasource); // attempt connection252 break;253 254 case "sqlite":255 require_once('DB/sqlite.php');256 257 if (!isset($amp_conf["AMPDBFILE"]))258 die("You must setup properly AMPDBFILE in /etc/amportal.conf");259 260 if (isset($amp_conf["AMPDBFILE"]) == "")261 die("AMPDBFILE in /etc/amportal.conf cannot be blank");262 263 $DSN = array (264 "database" => $amp_conf["AMPDBFILE"],265 "mode" => 0666266 );267 268 $db = new DB_sqlite();269 $db->connect( $DSN );270 break;271 272 default:273 die( "Unknown SQL engine: [$db_engine]");274 }275 276 if(DB::isError($db)) {277 echo("FAILED\n");278 echo("Cannot connect to database\n");279 die($db->getMessage());280 281 }282 231 283 232 # Get layout-info from a "panel" table in the freepbx database
