function Changeblacklist($phones, $reason)
{
    $user_id = $_SESSION['USERID'];
    foreach ($phones as $phone) {
        $asterisk = new asterisk("213.131.56.86", "5038", "admin", "amp111", 300);
        $result = $asterisk->blackListAdd($phone);
        if ($result == 1) {
            $req = mysql_query("SELECT incomming_call.id \r\n                              FROM   incomming_call\r\n                              WHERE  incomming_call.actived=1 \r\n                              AND    incomming_call.call_status_id = 3 \r\n                              AND    incomming_call.phone = '{$phone}'");
            while ($aRow = mysql_fetch_assoc($req)) {
                mysql_query("UPDATE `incomming_call` \r\n                            \tSET \r\n                                    `fan_status` = '2'\r\n                             WHERE  `id`         = '{$aRow['id']}'");
            }
            mysql_query("INSERT INTO `blacklis`\r\n                                     (`user_id`, `date`, `phone`, `reason`)\r\n                               VALUES\r\n                                     ('{$user_id}', NOW(), '{$phone}', '{$reason}');");
        } else {
            global $error;
            $error = 'დაბლოკვა არ მოხდა';
        }
    }
}
/**
*  function to verify user data
*	
*  	@param $aFormValues	(array)			login form data
															$aFormValues['username']
															$aFormValues['password']
															$aFormValues['locate']
*	@return $objResponse
*  @session
															$_SESSION['curuser']['username']
															$_SESSION['curuser']['extension']
															$_SESSION['curuser']['extensions']
															$_SESSION['curuser']['country']
															$_SESSION['curuser']['language']
															$_SESSION['curuser']['channel']
															$_SESSION['curuser']['accountcode']
*/
function processAccountData($aFormValues)
{
    global $db, $config;
    list($_SESSION['curuser']['country'], $_SESSION['curuser']['language']) = split("_", $aFormValues['locate']);
    //get locate parameter
    $locate = new Localization($_SESSION['curuser']['country'], $_SESSION['curuser']['language'], 'login');
    $objResponse = new xajaxResponse();
    /* check whether the pear had been installed */
    $pear_exists_result = class_exists('PEAR');
    if (empty($pear_exists_result)) {
        $objResponse->addAlert($locate->Translate("Please install php pear"));
        $objResponse->addAssign("loginButton", "value", $locate->Translate("submit"));
        $objResponse->addAssign("loginButton", "disabled", false);
        return $objResponse;
    }
    if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
        if ($_SERVER["HTTP_CLIENT_IP"]) {
            $proxy = $_SERVER["HTTP_CLIENT_IP"];
        } else {
            $proxy = $_SERVER["REMOTE_ADDR"];
        }
    } else {
        if (isset($_SERVER["HTTP_CLIENT_IP"])) {
            $ip = $_SERVER["HTTP_CLIENT_IP"];
        } else {
            $ip = $_SERVER["REMOTE_ADDR"];
        }
    }
    $query = "SELECT * FROM account_log WHERE ip='" . $ip . "' AND action='login' ORDER BY id DESC LIMIT 1";
    $res = $db->query($query);
    if ($res->fetchInto($this_ip_log)) {
        $failedtimes = $this_ip_log['failedtimes'];
    }
    $log = array();
    $log['action'] = 'login';
    $log['ip'] = $ip;
    $log['username'] = $aFormValues['username'];
    if ($failedtimes >= $config['system']['max_incorrect_login'] && $config['system']['max_incorrect_login'] > 0) {
        $objResponse->addAlert($locate->Translate("login failed,your ip is locked for login"));
        $objResponse->addAssign("loginButton", "value", $locate->Translate("submit"));
        $objResponse->addAssign("loginButton", "disabled", false);
        return $objResponse;
    }
    $bError = false;
    $loginError = false;
    if (!$bError) {
        $query = "SELECT account.*, accountgroup.accountcode,accountgroup.allowcallback as allowcallbackgroup,resellergroup.allowcallback as allowcallbackreseller,accountgroup.limittype FROM account LEFT JOIN accountgroup ON accountgroup.id = account.groupid LEFT JOIN resellergroup ON resellergroup.id = account.resellerid WHERE username='******'username'] . "'";
        $res = $db->query($query);
        if ($res->fetchInto($list)) {
            $log['account_id'] = $list['id'];
            $log['usertype'] = $list['usertype'];
            if ($list['password'] == $aFormValues['password']) {
                $log['status'] = 'success';
                $log['failedtimes'] = 0;
                if ($aFormValues['rememberme'] == "forever") {
                    // set cookies for three years
                    setcookie("username", $aFormValues['username'], time() + 94608000);
                    setcookie("password", $aFormValues['password'], time() + 94608000);
                    setcookie("language", $aFormValues['locate'], time() + 94608000);
                    setcookie("pagestyle", $aFormValues['pagestyle'], time() + 94608000);
                } else {
                    // destroy cookies
                    setcookie("username", "", time() - 3600);
                    setcookie("password", "", time() - 3600);
                    setcookie("language", "", time() - 3600);
                    setcookie("pagestyle", $aFormValues['pagestyle'], time() + 94608000);
                    $username = '';
                    $password = '';
                    $language = 'en_US';
                    $checked = false;
                }
                $_SESSION = array();
                $_SESSION['curuser']['username'] = trim($aFormValues['username']);
                $_SESSION['curuser']['usertype'] = $list['usertype'];
                $_SESSION['curuser']['ipaddress'] = $_SERVER["REMOTE_ADDR"];
                $_SESSION['curuser']['userid'] = $list['id'];
                $_SESSION['curuser']['groupid'] = $list['groupid'];
                $_SESSION['curuser']['resellerid'] = $list['resellerid'];
                $_SESSION['curuser']['limittype'] = $list['limittype'];
                $configstatus = common::read_ini_file($config['system']['astercc_path'] . '/astercc.conf', $asterccConfig);
                if ($configstatus == -2) {
                    $html = "(fail to read " . $config['system']['astercc_path'] . "/astercc.conf)";
                    return $html;
                } else {
                    $billingfield = trim($asterccConfig['system']['billingfield']);
                    if ($billingfield == 'accountcode') {
                        $_SESSION['curuser']['billingfield'] = $billingfield;
                    }
                }
                $res = astercrm::getCalleridListByID($list['groupid']);
                while ($res->fetchInto($row)) {
                    $_SESSION['curuser']['extensions'][] = $row['clid'];
                }
                if (!is_array($_SESSION['curuser']['extensions'])) {
                    $_SESSION['curuser']['extensions'] = array();
                }
                if ($list['usertype'] == 'reseller') {
                    $_SESSION['curuser']['allowcallback'] = $list['allowcallbackreseller'];
                } else {
                    $_SESSION['curuser']['allowcallback'] = $list['allowcallbackgroup'];
                }
                $_SESSION['curuser']['accountcode'] = $list['accountcode'];
                //				if ($list['extensions'] != ''){
                //					$_SESSION['curuser']['extensions'] = split(',',$list['extensions']);
                //				}
                //				else{
                //				}
                list($_SESSION['curuser']['country'], $_SESSION['curuser']['language']) = split("_", $aFormValues['locate']);
                /*
                	if you dont want check manager status and show device status when user login 
                	please uncomment these three line
                */
                //				$objResponse->addAlert($locate->Translate("login_success"));
                if ($_SESSION['curuser']['usertype'] == 'groupadmin' || $_SESSION['curuser']['usertype'] == 'operator') {
                    if ($aFormValues['pagestyle'] == 'classic') {
                        $objResponse->addScript('window.location.href="systemstatus.php";');
                    } else {
                        $objResponse->addScript('window.location.href="systemstatus_simple.php";');
                    }
                } else {
                    $objResponse->addScript('window.location.href="account.php";');
                }
                astercrm::insertAccountLog($log);
                return $objResponse;
                //check AMI connection
                $myAsterisk = new Asterisk();
                $myAsterisk->config['asmanager'] = $config['asterisk'];
                $res = $myAsterisk->connect();
                $html .= $locate->Translate("server_connection_test");
                if ($res) {
                    $html .= '<font color=green>' . $locate->Translate("pass") . '</font><br>';
                    $html .= '<b>' . $_SESSION['curuser']['extension'] . ' ' . $locate->Translate("device_status") . '</b><br>';
                    $html .= asterisk::getPeerIP($_SESSION['curuser']['extension']) . '<br>';
                    $html .= asterisk::getPeerStatus($_SESSION['curuser']['extension']) . '<br>';
                } else {
                    $html .= '<font color=red>' . $locate->Translate("no_pass") . '</font>';
                }
                if ($aFormValues['pagestyle'] == 'classic') {
                    $html .= '<input type="button" value="' . $locate->Translate("continue") . '" id="btnContinue" name="btnContinue" onclick="window.location.href=\'systemstatus.php\';">';
                } else {
                    $html .= '<input type="button" value="' . $locate->Translate("continue") . '" id="btnContinue" name="btnContinue" onclick="window.location.href=\'systemstatus_simple.php\';">';
                }
                $objResponse->addAssign("formDiv", "innerHTML", $html);
                $objResponse->addClear("titleDiv", "innerHTML");
                $objResponse->addScript("xajax.\$('btnContinue').focus();");
            } else {
                //$log['account_id'] = 0;
                $log['failedtimes'] = $failedtimes + 1;
                $log['status'] = 'failed';
                $log['failedcause'] = 'incorrect password';
                $loginError = true;
            }
        } else {
            $log['failedtimes'] = $failedtimes + 1;
            $log['account_id'] = 0;
            $log['usertype'] = 'manager_login';
            $log['status'] = 'failed';
            $log['failedcause'] = 'notexistent user';
            $loginError = true;
        }
        astercrm::insertAccountLog($log);
        if (!$loginError) {
            return $objResponse;
        } else {
            $objResponse->addAlert($locate->Translate("login failed"));
            $objResponse->addAssign("loginButton", "value", $locate->Translate("submit"));
            $objResponse->addAssign("loginButton", "disabled", false);
            return $objResponse;
        }
    } else {
        $objResponse->addAssign("loginButton", "value", $locate->Translate("submit"));
        $objResponse->addAssign("loginButton", "disabled", false);
    }
    return $objResponse;
}
function Addblacklist($user_id, $phone, $reason)
{
    $check_phone = mysql_fetch_assoc(mysql_query("SELECT 1 AS check_phone\r\n                                                  FROM   blacklis\r\n                                                  WHERE  phone='{$phone}' \r\n                                                  AND    actived=1 \r\n                                                  LIMIT 1"));
    if ($check_phone[check_phone] != 1) {
        $asterisk = new asterisk("213.131.56.86", "5038", "admin", "amp111", 300);
        $result = $asterisk->blackListAdd($phone);
        if ($result == 1) {
            mysql_query("INSERT INTO `blacklis`\r\n                                    (`user_id`, `date`, `phone`, `reason`)\r\n                              VALUES\r\n                                    ('{$user_id}', NOW(), '{$phone}', '{$reason}');");
        } else {
            global $error;
            $error = 'ნომერი არ დაიბლოკა';
        }
    } else {
        global $error;
        $error = 'ნომერი უკვე დაბლოკილია';
    }
}
Exemple #4
0
/**
*  initialize page elements
*  @return	objResponse		object		xajax response object
*/
function showChannelsInfo()
{
    global $locate, $config, $db;
    $aDyadicArray[] = array($locate->Translate("src"), $locate->Translate("dst"), $locate->Translate("srcchan"), $locate->Translate("dstchan"), $locate->Translate("starttime"), $locate->Translate("answertime"), $locate->Translate("disposition"));
    $objResponse = new xajaxResponse();
    if ($config['system']['eventtype'] == 'curcdr') {
        if ($_SESSION['curuser']['usertype'] == 'admin') {
            $curcdr = astercrm::getAll("curcdr");
        } else {
            //print_r($_SESSION['curuser']['memberExtens']);exit;
            $curcdr = astercrm::getGroupCurcdr();
        }
        while ($curcdr->fetchInto($row)) {
            $systemCDR[] = array($row["src"], $row["dst"], $row["srcchan"], $row["dstchan"], $row["starttime"], $row["answertime"], $row["disposition"]);
        }
        $activeCalls = "&nbsp;&nbsp;" . count($systemCDR) . "&nbsp;" . $locate->Translate("active calls");
        $objResponse->addAssign("divActiveCalls", "innerHTML", $activeCalls);
        $systemChannels = common::generateTabelHtml(array_merge($aDyadicArray, $systemCDR));
        $objResponse->addAssign("channels", "innerHTML", nl2br(trim($systemChannels)));
        return $objResponse;
    }
    $channels = split(chr(13), asterisk::getCommandData('show channels verbose'));
    /*
    	if ($channels == null){
    			$objResponse->addAssign("channels", "innerHTML", "can not connect to AMI, please check config.php");
    			return $objResponse;
    	}
    */
    $channels = split(chr(10), $channels[1]);
    //trim the first two records and the last three records
    //	array_pop($channels);
    array_pop($channels);
    $activeCalls = array_pop($channels);
    $activeChannels = array_pop($channels);
    array_shift($channels);
    $title = array_shift($channels);
    $title = split("_", implode("_", array_filter(split(" ", $title))));
    $myInfo[] = $title;
    foreach ($channels as $channel) {
        if (strstr($channel, " Dial")) {
            $myItem = split("_", implode("_", array_filter(split(" ", $channel))));
            $myInfo[] = $myItem;
        }
    }
    $myChannels = common::generateTabelHtml($myInfo);
    $objResponse->addAssign("divActiveCalls", "innerHTML", $activeCalls);
    $objResponse->addAssign("channels", "innerHTML", nl2br(trim($myChannels)));
    return $objResponse;
}
Exemple #5
0
<?php

set_time_limit(0);
require_once 'asterisk.class.php';
mysql_connect('192.168.11.10', 'root', 'Gl-1114');
mysql_selectdb('test');
$ast = new asterisk('212.72.155.175', 5038, 'admin', 'elastixsudo', 480);
global $status;
$status = 0;
while (true) {
    sleep(1);
    foreach ($ast->getExtensions() as $key => $value) {
        $array = $ast->getExtension($key);
        foreach ($array as $key => $val) {
            if ($status != $val) {
                mysql_query("INSERT INTO `test` (`date`, `ext`, `status`) VALUES (NOW(), '{$key}', '{$val}')");
            }
            $status = $val;
        }
    }
}
// foreach ($ast->getExtensions() as $key => $value) {
//     print_r($ast->getExtension($key));
// }
<?php

require_once '../../includes/classes/asterisk.class.php';
$asterisk = new asterisk("212.72.155.176", "5038", "admin", "sudobash", 300);
$data = '';
$action = $_REQUEST['act'];
switch ($action) {
    case 'black_list_add':
        $phone = $_REQUEST['phone'];
        $data['error'] = "ნომერი დაემატა შავ სიას";
        echo json_encode($data);
        $asterisk->blackListAdd($phone);
        break;
    case 'black_list_remove':
        $phone = $_REQUEST['phone'];
        $data['error'] = "ნომერი ამოიშალა  შავი სიიდან";
        echo json_encode($data);
        $asterisk->blackListRemove($phone);
        break;
    default:
        break;
}