Skip to content

Commit

Permalink
finish new look, cleanup unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
tm1000 committed Jan 3, 2015
1 parent b79d888 commit a43b413
Show file tree
Hide file tree
Showing 18 changed files with 1,428 additions and 4,135 deletions.
638 changes: 416 additions & 222 deletions Superfecta.class.php

Large diffs are not rendered by default.

1,023 changes: 0 additions & 1,023 deletions agi/phpagi-asmanager.php

This file was deleted.

1,803 changes: 0 additions & 1,803 deletions agi/phpagi.php

This file was deleted.

92 changes: 46 additions & 46 deletions agi/superfecta.agi
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/usr/bin/php -q
<?php
$base_dir = dirname(dirname(__FILE__));
require_once($base_dir . '/agi/phpagi.php');
require_once "phpagi.php";
$agi = new AGI();
$agi->verbose("CID Superfecta is Answering the Channel");
$scheme_return = $agi->get_variable("CIDSFSCHEME");

if (($scheme_return['result']) && (trim(base64_decode($scheme_return['data'])) != '')) {
$scheme = base64_decode($scheme_return['data']);
$scheme = base64_decode($scheme_return['data']);
} else {
$scheme = 'base_Default';
$scheme = 'base_Default';
}

if ($scheme == 'ALL|ALL') {
$sn[1] = 'ALL';
$sn[1] = 'ALL';
} else {
$sn = explode("_", $scheme, 2);
$sn = explode("_", $scheme, 2);
}

//Remove leading +1-9 on numbers.
Expand All @@ -34,54 +34,54 @@ $trunk_info = base64_encode(serialize($agi->request));
chdir($base_dir . '/sources'); //I don't think this is needed

if (!preg_match('/\D/i', $agi->request['agi_callerid'])) {
$agi->verbose("CID Superfecta: Executing Scheme..");
//Uncomment below when debugging.
//$agi->verbose('CID Superfecta: EXEC SCRIPT: /usr/bin/php ' . $base_dir . '/includes/callerid.php -s ' . $sn[1] . ' -t ' . $trunk_info);
$agi->verbose("CID Superfecta: Executing Scheme..");
//Uncomment below when debugging.
//$agi->verbose('CID Superfecta: EXEC SCRIPT: /usr/bin/php ' . $base_dir . '/includes/callerid.php -s ' . $sn[1] . ' -t ' . $trunk_info);

$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);

$process = proc_open('/usr/bin/php ' . $base_dir . '/includes/callerid.php -s ' . $sn[1] . ' -t ' . $trunk_info, $descriptorspec, $pipes, $base_dir, NULL);
$status = proc_get_status($process);
$process = proc_open('/usr/bin/php ' . $base_dir . '/includes/callerid.php -s ' . $sn[1] . ' -t ' . $trunk_info, $descriptorspec, $pipes, $base_dir, NULL);
$status = proc_get_status($process);

while (is_resource($process) && $status['running']) {
$stream_data = stream_get_line($pipes[1], 0, ',');
if (!empty($stream_data)) {
$data = unserialize(base64_decode(trim($stream_data)));
if (isset($data['message'])) {
$agi->verbose("CID Superfecta: " . $data['message']);
} elseif (isset($data['success'])) {
if ($data['success']) {
// Display issues on phones and CDR with special characters
while (is_resource($process) && $status['running']) {
$stream_data = stream_get_line($pipes[1], 0, ',');
if (!empty($stream_data)) {
$data = unserialize(base64_decode(trim($stream_data)));
if (isset($data['message'])) {
$agi->verbose("CID Superfecta: " . $data['message']);
} elseif (isset($data['success'])) {
if ($data['success']) {
// Display issues on phones and CDR with special characters
// convert CNAM to UTF-8 to fix
if (function_exists('mb_convert_encoding')) {
$agi->verbose("Converting result to UTF-8");
$data['cid'] = mb_convert_encoding($data['cid'], "UTF-8");
}
$agi->verbose("CID Superfecta: CID Determined to be: '" . trim($data['cid']) . "'");
$agi->verbose("CID Superfecta: Attempting to set lookupcid");
$agi->set_variable("lookupcid", trim($data['cid']));
$tmp = $agi->get_variable("lookupcid");
($tmp['data'] == trim($data['cid'])) ? $agi->verbose("CID Superfecta: Success!") : $agi->verbose("CID Superfecta: Failure!");
if (!empty($data['destination'])) {
$agi->verbose("CID Superfecta: Call destination detected!");
$parts = explode(",", $data['destination']);
$agi->verbose("CID Superfecta: Sending call to " . $data['destination']);
$agi->goto_dest($parts[0], $parts[1], $parts[2]);
}
}
}
}
$status = proc_get_status($process);
}
$agi->verbose("CID Superfecta: CID Determined to be: '" . trim($data['cid']) . "'");
$agi->verbose("CID Superfecta: Attempting to set lookupcid");
$agi->set_variable("lookupcid", trim($data['cid']));
$tmp = $agi->get_variable("lookupcid");
($tmp['data'] == trim($data['cid'])) ? $agi->verbose("CID Superfecta: Success!") : $agi->verbose("CID Superfecta: Failure!");
if (!empty($data['destination'])) {
$agi->verbose("CID Superfecta: Call destination detected!");
$parts = explode(",", $data['destination']);
$agi->verbose("CID Superfecta: Sending call to " . $data['destination']);
$agi->goto_dest($parts[0], $parts[1], $parts[2]);
}
}
}
}
$status = proc_get_status($process);
}

if (is_resource($process)) {
fclose($pipes[1]);
$return_value = proc_close($process);
}
if (is_resource($process)) {
fclose($pipes[1]);
$return_value = proc_close($process);
}
} else {
$agi->verbose("CID Superfecta: Not a valid number");
}
$agi->verbose("CID Superfecta: Not a valid number");
}
9 changes: 0 additions & 9 deletions ajax.html.php

This file was deleted.

Loading

0 comments on commit a43b413

Please sign in to comment.