Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions resources/asterisk/AuthenticateAgi.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public static function authenticateUser($agi, $MAGNUS)
$agi->verbose('AuthenticateUser ' . $MAGNUS->accountcode, 15);
$authentication = false;

/* AUTHENTICATE BY ARG */
$authentication = AuthenticateAgi::argAuthenticate($MAGNUS, $agi, $authentication);

/* TRY WITH THE CALLERID AUTHENTICATION*/
$authentication = AuthenticateAgi::callerIdAuthenticate($MAGNUS, $agi, $authentication);

Expand Down Expand Up @@ -72,6 +75,25 @@ public static function authenticateUser($agi, $MAGNUS)
return $authentication;
}

public static function argAuthenticate(&$MAGNUS, &$agi, $authentication)
{
if($authentication == false && count($_SERVER['argv']) > 1 ) {
$accountcode = $_SERVER['argv'][1];
$agi->verbose('Try ARG authentication ' . $accountcode, 16);

$sql = "SELECT *, u.id id, u.id_user id_user FROM pkg_user u INNER JOIN pkg_plan p ON u.id_plan = p.id WHERE username = '$accountcode' LIMIT 1";
$modelUser = $agi->query($sql)->fetch(PDO::FETCH_OBJ);

if (isset($modelUser->id)) {
AuthenticateAgi::setMagnusAttrubutes($MAGNUS, $agi, $modelUser);
$agi->verbose("AUTHENTICATION BY ARG:" . $MAGNUS->username, 6);
$authentication = true;
}
}

return $authentication;
}

public static function callerIdAuthenticate(&$MAGNUS, &$agi, $authentication)
{
if ($authentication == false && $MAGNUS->agiconfig['cid_enable'] == 1 && is_numeric($MAGNUS->CallerID) && $MAGNUS->CallerID > 0) {
Expand Down