Skip to content

Commit

Permalink
Fixed directory issues on 2.8 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
tm1000 committed Jul 19, 2011
1 parent 7e9ddc3 commit f36da27
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
62 changes: 32 additions & 30 deletions agi/bwlist.agi
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
#!/usr/bin/php -q
<?php
require('config.php');
require('/var/lib/asterisk/agi-bin/phpagi.php');

$agi = new AGI();
$thenumber = $agi->request['agi_callerid'];

$sql = 'SELECT * FROM `sak_bwlist` ORDER BY `sort` ASC';

$list = $db->getAll($sql,array(), DB_FETCHMODE_ASSOC);

$matchfound = false;
foreach($list as $data) {
$count = 0;
if(preg_match("/".$data['nn']."/",$thenumber,$matches)) {
if($matches[0] == $thenumber) {
if($data['permit']) {
$matchfound = true;
$sql = 'SELECT count FROM sak_bwlist WHERE id = '.$data['id'];
$count = $db->getOne($sql);
$count++;
$sql = "UPDATE sak_bwlist SET count = '".$count."' WHERE id = ".$data['id'];
$db->query($sql);
break;
} else {
$agi->hangup();
break;
}
chdir(dirname(__FILE__));
require('../config.php');
require('/var/lib/asterisk/agi-bin/phpagi.php');

$agi = new AGI();
$thenumber = $agi->request['agi_callerid'];

$sql = 'SELECT * FROM `sak_bwlist` ORDER BY `sort` ASC';

$list = $db->getAll($sql,array(), DB_FETCHMODE_ASSOC);

$matchfound = false;
foreach($list as $data) {
$count = 0;
if(preg_match("/".$data['nn']."/",$thenumber,$matches)) {
if($matches[0] == $thenumber) {
if($data['permit']) {
$matchfound = true;
$sql = 'SELECT count FROM sak_bwlist WHERE id = '.$data['id'];
$count = $db->getOne($sql);
$count++;
$sql = "UPDATE sak_bwlist SET count = '".$count."' WHERE id = ".$data['id'];
$db->query($sql);
break;
} else {
$agi->hangup();
break;
}
}
}

if(!$matchfound) {
$agi->hangup();
}
}

if(!$matchfound) {
$agi->hangup();
}


2 changes: 1 addition & 1 deletion agi/config.php → config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require("/etc/asterisk/freepbx.conf");
} else {
//This is > FreePBX 2.8
require_once("../../../functions.inc.php");
require_once("../../functions.inc.php");
require_once 'DB.php';
define("AMP_CONF", "/etc/amportal.conf");
$amp_conf = parse_amportal_conf(AMP_CONF);
Expand Down

0 comments on commit f36da27

Please sign in to comment.