Changeset 10626
- Timestamp:
- 11/29/10 10:19:02 (2 years ago)
- Files:
-
- modules/branches/bootstrap-2.9/backup/bin/ampbackup.php (modified) (4 diffs)
- modules/branches/bootstrap-2.9/backup/bin/dumpastdb.php (modified) (2 diffs)
- modules/branches/bootstrap-2.9/backup/bin/restoreastdb.php (modified) (2 diffs)
- modules/branches/bootstrap-2.9/callback/bin/callback (modified) (4 diffs)
- modules/branches/bootstrap-2.9/directory/agi-bin/directory.lib.php (modified) (1 diff)
- modules/branches/bootstrap-2.9/queues/agi-bin/queue_devstate.agi (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/bootstrap-2.9/backup/bin/ampbackup.php
r10452 r10626 28 28 */ 29 29 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 30 require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 37 31 38 32 switch (true){ … … 103 97 //if the ssh completed with exit code 0, copy backup over to this server 104 98 if($execok==0){ 105 mkdir($opts['budir'].'/'.$opts['name'] , 0755, true);//ensure dir structure99 mkdir($opts['budir'].'/'.$opts['name']);//ensure dir structure 106 100 $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']; 107 101 exec($exec,$ret); … … 265 259 } 266 260 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 278 261 function getOpts(){ 279 262 array_shift($_SERVER['argv']); … … 287 270 } 288 271 289 290 function dbug(){291 $opts=func_get_args();292 //call_user_func_array('freepbx_debug',$opts);293 $dump=0;294 //sort arguments295 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 timestamp316 dbug_write($txt,1);317 if($dump==1){//force output via var_dump318 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_size334 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 342 272 ?> modules/branches/bootstrap-2.9/backup/bin/dumpastdb.php
r10577 r10626 17 17 // along with FreePBX. If not, see <http://www.gnu.org/licenses/>. 18 18 // 19 19 require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 20 20 global $argv; 21 21 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);34 22 35 23 if (!isset($amp_conf["ASTMANAGERHOST"])) { … … 40 28 } 41 29 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 }49 30 50 31 if (!$argv[1] || strstr($argv[1], "/") || strstr($argv[1], "..")) { modules/branches/bootstrap-2.9/backup/bin/restoreastdb.php
r9537 r10626 18 18 // 19 19 20 require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 20 21 global $argv; 21 22 … … 33 34 ); 34 35 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 configuration46 $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 }64 36 65 37 if (!$argv[1] || strstr($argv[1], "/") || strstr($argv[1], "..")) { modules/branches/bootstrap-2.9/callback/bin/callback
r10565 r10626 2 2 <?php 3 3 /* 4 This Callback script takes 7arguments:4 This Callback script takes 3 arguments: 5 5 1- number to dial 6 6 2- context.exten.priority to dump number into 7 7 3- 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 12 9 13 10 eg: callback 14032448089 ext-meetme.200.1 … … 29 26 // You should have received a copy of the GNU General Public License 30 27 // along with FreePBX. If not, see <http://www.gnu.org/licenses/>. 31 ?>32 28 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"); 29 require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 30 if ($args != 4) { 31 fatal("Wrong number of arguments, should be:\n".$argv[0]." callback_number callback_destination delay_seconds\n"); 37 32 } 38 33 echo "args: $argc\n"; … … 41 36 $callback_destination = $argv[2]; 42 37 $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 functions50 include $amp_conf['AMPWEBROOT'].'/admin/common/php-asmanager.php';51 38 52 39 if($pause_seconds) … … 71 58 $data = ""; 72 59 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); 86 61 87 62 ?> modules/branches/bootstrap-2.9/directory/agi-bin/directory.lib.php
r9923 r10626 1 1 <?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 2 5 class Dir{ 3 6 //agi class handler modules/branches/bootstrap-2.9/queues/agi-bin/queue_devstate.agi
r9649 r10626 1 1 #!/usr/bin/php -q 2 2 <?php 3 3 //neds to be test before enabling 4 //require_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.php'); 4 5 require_once "phpagi.php"; 5 6 require_once "phpagi-asmanager.php";
