Changeset 8270

Show
Ignore:
Timestamp:
09/02/09 09:43:41 (1 year ago)
Author:
p_lindheimer
Message:

fixes #3850 adds dahdi (though some real dahdi testing is necessary, tried to get labels right), also moves retrieve_op_conf_from_mysql.php to an include file no longer stand-alone executable re #3837

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.6/amp_conf/bin/retrieve_conf

    r8218 r8270  
    717717} 
    718718 
    719 include("libfreepbx.confgen.php"); 
    720  
    721719// script to write op_server.cfg file from mysql  
    722720// 
    723721if(!$amp_conf['FOPDISABLE'])  { 
     722  if (!@include("retrieve_op_conf_from_mysql.php")) { 
     723                error(_("error running retrieve_op_conf_from_mysql.php")); 
     724  } 
     725  /* 
    724726        $script = $amp_conf['AMPBIN'].'/retrieve_op_conf_from_mysql.php'; 
    725727        if (is_executable($script)) { 
     
    733735                error(_("retrieve_op_conf_from_mysql.php does not exist or is not executable")); 
    734736        } 
     737  */ 
    735738} 
    736739// generate configuration files 
  • freepbx/branches/2.6/amp_conf/bin/retrieve_op_conf_from_mysql.php

    r8255 r8270  
    1 #!/usr/bin/php -q 
    21<?php 
    32 
    43# Retrieves the sip user/peer entries from the database for the flash operator panel 
    54 
    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  
    115################### BEGIN OF CONFIGURATION #################### 
    126 
    137global $zapataconfdir; 
    14 $zapataconfdir = "/etc/asterisk/"; 
    15 $amportalconf = "/etc/amportal.conf"; 
     8global $amp_conf; 
     9global $db; 
     10global $chan_dahdi; 
     11 
     12$zapataconfdir = $amp_conf['ASTETCDIR']."/"; 
    1613$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"; 
     15if ($chan_dadhi) { 
     16  $zapataconf = $zapataconfdir . $dahdiconf; 
     17} else { 
     18  $zapataconf = $zapataconfdir . $zapataconf; 
     19
    2520 
    2621######## LAYOUT INFO ######### 
     
    10095        global $istrunk; 
    10196        global $lastlabelnum; 
     97  global $chan_dahdi; 
    10298 
    10399        if (!isset($ampwildcard)) {$ampwildcard=0;} 
    104         if (!isset($zaplabel)) {$zaplabel="Zap %c";} 
     100        if (!isset($zaplabel)) {$zaplabel= $chan_dadhi ? "DAHDI %c" : "Zap %c";} 
    105101        if (!isset($istrunk)) {$istrunk=0;} 
    106102        if (!isset($lastlabelnum)) {$lastlabelnum=0;} 
     
    214210 
    215211# cool hack by Julien BLACHE <jblache@debian.org> 
    216 $ampconf = parse_amportal_conf( $amportalconf ); 
    217212# WARNING: this file will be substituted by the output of this program 
    218 $op_conf = $ampconf["AMPWEBROOT"]."/panel/op_buttons_additional.cfg"; 
     213$op_conf = $amp_conf["AMPWEBROOT"]."/panel/op_buttons_additional.cfg"; 
    219214# username to connect to the database 
    220 $username = $ampconf["AMPDBUSER"]; 
     215$username = $amp_conf["AMPDBUSER"]; 
    221216# password to connect to the database 
    222 $password = $ampconf["AMPDBPASS"]; 
     217$password = $amp_conf["AMPDBPASS"]; 
    223218# the name of the box the MySQL database is running on 
    224 $hostname = $ampconf["AMPDBHOST"]; 
     219$hostname = $amp_conf["AMPDBHOST"]; 
    225220# the name of the database our tables are kept 
    226 $database = $ampconf["AMPDBNAME"]; 
     221$database = $amp_conf["AMPDBNAME"]; 
    227222#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 
    236225################### END OF CONFIGURATION ####################### 
    237226 
     
    240229; all modifications must be done from the web gui 
    241230"; 
    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 connection 
    252                 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" => 0666 
    266                 ); 
    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 } 
    282231 
    283232# Get layout-info from a "panel" table in the freepbx database