Changeset 10626

Show
Ignore:
Timestamp:
11/29/10 10:19:02 (2 years ago)
Author:
mbrevda
Message:

re #4566 - merge bootstrap settings in to proper modules branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/bootstrap-2.9/backup/bin/ampbackup.php

    r10452 r10626  
    2828*/ 
    2929 
    30  
    31 //get options 
    32 $amp_conf=getconf((isset($_ENV['FREEPBXCONFIG']) && strlen($_ENV['FREEPBXCONFIG']))?$_ENV['FREEPBXCONFIG']:'/etc/amportal.conf'); 
    33 $ast_conf=getconf((isset($_ENV['ASTERISKCONFIG']) && strlen($_ENV['ASTERISKCONFIG']))?$_ENV['ASTERISKCONFIG']:'/etc/asterisk/asterisk.conf'); 
    34 //connect to database 
    35 include_once('DB.php'); 
    36 if(!isset($db)){$db = DB::connect('mysql://'.$amp_conf['AMPDBUSER'].':'.$amp_conf['AMPDBPASS'].'@'.$amp_conf['AMPDBHOST'].'/'.$amp_conf['AMPDBNAME']);} // attempt connection 
     30require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 
    3731 
    3832switch (true){ 
     
    10397  //if the ssh completed with exit code 0, copy backup over to this server 
    10498  if($execok==0){ 
    105     mkdir($opts['budir'].'/'.$opts['name'], 0755, true);//ensure dir structure 
     99    mkdir($opts['budir'].'/'.$opts['name']);//ensure dir structure 
    106100    $exec='/usr/bin/scp -i '.$opts['remotesshkey'].' -c blowfish '.$user.$opts['remotesshhost'].':'.$rbudir[0].'/backups/'.$opts['name'].'/'.$opts['now'].'.tar.gz '.$opts['budir'].'/'.$opts['name']; 
    107101    exec($exec,$ret); 
     
    265259} 
    266260 
    267 function getconf($filename) { 
    268   $file = file($filename); 
    269   foreach($file as $line => $cont){ 
    270     if(substr($cont,0,1)!='#'){ 
    271       $d=explode('=',$cont); 
    272       if(isset($d['0'])&& isset($d['1'])){$conf[trim($d['0'])]=trim($d['1']);} 
    273     } 
    274   } 
    275   return $conf; 
    276 } 
    277  
    278261function getOpts(){ 
    279262  array_shift($_SERVER['argv']); 
     
    287270} 
    288271 
    289  
    290 function dbug(){ 
    291   $opts=func_get_args(); 
    292   //call_user_func_array('freepbx_debug',$opts); 
    293   $dump=0; 
    294   //sort arguments 
    295   switch(count($opts)){ 
    296     case 1: 
    297       $msg=$opts[0]; 
    298     break; 
    299     case 2: 
    300       if(is_array($opts[0])||is_object($opts[0])){ 
    301         $msg=$opts[0]; 
    302         $dump=$opts[1]; 
    303       }else{ 
    304         $disc=$opts[0]; 
    305         $msg=$opts[1]; 
    306       } 
    307     break; 
    308     case 3: 
    309       $disc=$opts[0]; 
    310       $msg=$opts[1]; 
    311       $dump=$opts[2]; 
    312     break;   
    313   } 
    314   if($disc){$disc=' \''.$disc.'\':';} 
    315   $txt=date("Y-M-d H:i:s").$disc."\n"; //add timestamp 
    316   dbug_write($txt,1); 
    317   if($dump==1){//force output via var_dump 
    318     ob_start(); 
    319     var_dump($msg); 
    320     $msg=ob_get_contents(); 
    321     ob_end_clean(); 
    322     dbug_write($msg."\n"); 
    323   }elseif(is_array($msg)||is_object($msg)){ 
    324     dbug_write(print_r($msg,true)."\n"); 
    325   }else{ 
    326     dbug_write($msg."\n"); 
    327   } 
    328 } 
    329  
    330 function dbug_write($txt,$check=''){ 
    331   global $amp_conf; 
    332   $append=FILE_APPEND; 
    333   //optionaly ensure that dbug file is smaller than $max_size 
    334   if($check){ 
    335     $max_size=52428800;//hardcoded to 50MB. is that bad? not enough? 
    336     $size=filesize('/tmp/freepbx_debug.log'); 
    337     $append=(($size > $max_size)?'':FILE_APPEND); 
    338   } 
    339   file_put_contents('/tmp/freepbx_debug.log',$txt, $append); 
    340 } 
    341  
    342272?> 
  • modules/branches/bootstrap-2.9/backup/bin/dumpastdb.php

    r10577 r10626  
    1717//    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>. 
    1818// 
    19  
     19require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 
    2020global $argv; 
    2121 
    22 function getconf($filename) { 
    23         $file = file($filename); 
    24         foreach ($file as $line) { 
    25                 if (preg_match("/^\s*([\w]+)\s*=\s*\"?([\w\/\:\.\%-]*)\"?\s*([;#].*)?/",$line,$matches)) { 
    26                         $conf[ $matches[1] ] = $matches[2]; 
    27                 } 
    28         } 
    29         return $conf; 
    30 } 
    31  
    32 $amportalconf = (isset($_ENV["FREEPBXCONFIG"]) && strlen($_ENV["FREEPBXCONFIG"])) ? $_ENV["FREEPBXCONFIG"] : "/etc/amportal.conf"; 
    33 $amp_conf = getconf($amportalconf); 
    3422 
    3523if (!isset($amp_conf["ASTMANAGERHOST"])) { 
     
    4028} 
    4129 
    42 require_once($amp_conf['AMPWEBROOT']."/admin/functions.inc.php"); 
    43 require_once($amp_conf['AMPWEBROOT']."/admin/common/php-asmanager.php"); 
    44 $astman         = new AGI_AsteriskManager(); 
    45 if (! $res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":".$amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
    46         unset( $astman ); 
    47         echo "failed to open using".$amp_conf["ASTMANAGERHOST"] .":".$amp_conf["ASTMANAGERPORT"]." ". $amp_conf["AMPMGRUSER"] ." ". $amp_conf["AMPMGRPASS"]."\n"; 
    48 } 
    4930 
    5031if (!$argv[1] || strstr($argv[1], "/") || strstr($argv[1], "..")) { 
  • modules/branches/bootstrap-2.9/backup/bin/restoreastdb.php

    r9537 r10626  
    1818// 
    1919 
     20require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 
    2021global $argv; 
    2122 
     
    3334); 
    3435 
    35 function getconf($filename) { 
    36         $file = file($filename); 
    37         foreach ($file as $line) { 
    38                 if (preg_match("/^\s*([\w]+)\s*=\s*\"?([\w\/\:\.\%-]*)\"?\s*([;#].*)?/",$line,$matches)) { 
    39                         $conf[ $matches[1] ] = $matches[2]; 
    40                 } 
    41         } 
    42         return $conf; 
    43 } 
    44  
    45 # Get configuration 
    46 $amportalconf = (isset($_ENV["FREEPBXCONFIG"]) && strlen($_ENV["FREEPBXCONFIG"])) ? $_ENV["FREEPBXCONFIG"] : "/etc/amportal.conf"; 
    47 $amp_conf = getconf($amportalconf); 
    48  
    49 if (!isset($amp_conf["ASTMANAGERHOST"])) { 
    50   $amp_conf["ASTMANAGERHOST"] = '127.0.0.1'; 
    51 } 
    52 if (!isset($amp_conf["ASTMANAGERPORT"])) { 
    53   $amp_conf["ASTMANAGERPORT"] = '5038'; 
    54 } 
    55  
    56 require_once($amp_conf['AMPWEBROOT']."/admin/functions.inc.php"); 
    57 require_once($amp_conf['AMPWEBROOT']."/admin/common/php-asmanager.php"); 
    58  
    59 $astman         = new AGI_AsteriskManager(); 
    60 if (! $res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":".$amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
    61   unset( $astman ); 
    62   exit(10); 
    63 } 
    6436 
    6537if (!$argv[1] || strstr($argv[1], "/") || strstr($argv[1], "..")) { 
  • modules/branches/bootstrap-2.9/callback/bin/callback

    r10565 r10626  
    22<?php 
    33/* 
    4 This Callback script takes 7 arguments: 
     4This Callback script takes 3 arguments: 
    551- number to dial 
    662- context.exten.priority to dump number into 
    773- time in seconds to sleep before calling back 
    8 4- path to the AMPWEBROOT 
    9 5- path to the ASTETCDIR 
    10 6- AMI USER 
    11 6- AMI PASSWORD 
     8 
    129 
    1310eg: callback 14032448089 ext-meetme.200.1 
     
    2926//    You should have received a copy of the GNU General Public License 
    3027//    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>. 
    31 ?> 
    3228 
    33 <?php 
    34  
    35 if ($args != 8) { 
    36   fatal("Wrong number of arguments, should be:\n".$argv[0]." callback_number callback_destination delay_seconds AMPWEBROOT ASTETCDIR AMPMGRUSER AMPMGRPASS\n"); 
     29require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php');  
     30if ($args != 4) { 
     31  fatal("Wrong number of arguments, should be:\n".$argv[0]." callback_number callback_destination delay_seconds\n"); 
    3732} 
    3833echo "args: $argc\n"; 
     
    4136$callback_destination = $argv[2]; 
    4237$pause_seconds = $argv[3]; 
    43  
    44 $amp_conf['AMPWEBROOT'] = $argv[4]; 
    45 $amp_conf['ASTETCDIR']  = $argv[5]; 
    46 $amp_conf['AMPMGRUSER'] = $argv[6]; 
    47 $amp_conf['AMPMGRPASS'] = $argv[7]; 
    48  
    49 // include manager functions 
    50 include $amp_conf['AMPWEBROOT'].'/admin/common/php-asmanager.php'; 
    5138 
    5239if($pause_seconds) 
     
    7158$data = ""; 
    7259 
    73 //connect to manager and dial 
    74 $astman = new AGI_AsteriskManager(); 
    75 if ($res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
    76   $astman->Originate($channel, $exten, $context, $priority, $timeout, $callerid, $variable, $account, $application, $data); 
    77 } else { 
    78   fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
    79 
    80 $astman->disconnect(); 
    81  
    82 function fatal($text) { 
    83   echo "[FATAL] ".$text."\n"; 
    84   exit(1); 
    85 
     60$astman->Originate($channel, $exten, $context, $priority, $timeout, $callerid, $variable, $account, $application, $data); 
    8661 
    8762?> 
  • modules/branches/bootstrap-2.9/directory/agi-bin/directory.lib.php

    r9923 r10626  
    11<?php 
     2//will be enabled when I (or someone) gose through this to ensure that we dont break anything 
     3//require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 
     4 
    25class Dir{ 
    36  //agi class handler 
  • modules/branches/bootstrap-2.9/queues/agi-bin/queue_devstate.agi

    r9649 r10626  
    11#!/usr/bin/php -q 
    22<?php 
    3  
     3  //neds to be test before enabling 
     4  //require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 
    45  require_once "phpagi.php"; 
    56  require_once "phpagi-asmanager.php";