| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/controllers/ |
Upload File : |
<?php
class CallCenterController extends Catabatic_ValidateCustomer {
public $ExtensionNo;
public function init() {
parent::init();
$this->ExtensionNo = isset(Travel_Model_AgencyAuth::getIdentity()->ExtensionNo) ? "SIP/" . trim(Travel_Model_AgencyAuth::getIdentity()->ExtensionNo) : '';
}
public function indexAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$IsCallCenter = Travel_Model_AgencyAuth::getIdentity()->IsCallCenter;
$AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$call_number = $this->getRequest()->getPost("contact", null);
$agentNo = Travel_Model_AgencyAuth::getIdentity()->ExtensionNo;
$response = array("status" => false);
if (($call_number) && (($IsCallCenter == 1) && ($agentNo != ''))) {
$agencyMdl = new Travel_Model_TblAgency();
$getCallCenterToken = $agencyMdl->getCallCenterAPIKey($AgencySysId);
if (is_array($getCallCenterToken) && (isset($getCallCenterToken['Type']) && $getCallCenterToken['Type'] == 1)) {
if (isset($getCallCenterToken['AccessToken']) && $getCallCenterToken['AccessToken'] != "") {
$call_number = substr($call_number, -10);
$agentNo = substr($agentNo, -10);
$request = array("caller" => trim($call_number), "agent" => trim($agentNo));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://airson.co.in/secureapi/api/client/click-2-call',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($request),
CURLOPT_HTTPHEADER => array(
'token:' . $getCallCenterToken['AccessToken'],
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
}
} else if (is_array($getCallCenterToken) && (isset($getCallCenterToken['Type']) && $getCallCenterToken['Type'] == 2)) {
$url = 'http://103.90.44.18:4079/EnjayAsteriskAPI/synapseactions.php?actiondetails={"action":"Originate","extension":"' . trim($this->ExtensionNo) . '","number":"' . $call_number . '","context":"DLPN_all"}';
$response = $this->sendInfoB2C($url);
// if ($response == '') {
// $response = "call successfully connected";
// }
}
}
echo json_encode($response);
exit;
}
public function sendInfoWithOutSSL($data, $url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
public function sendInfoB2C($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
public function callBackAction() {
$replcesString = $_REQUEST;
$word = '1B344264-4D32-49D9-A9C6-C13025AC24C9';
if (strpos($replcesString['id'], $word) !== false) {
$arraySt = str_replace("1B344264-4D32-49D9-A9C6-C13025AC24C9?eventdetails=", "", $replcesString['id']);
$arrayF = json_decode(trim($arraySt), true);
if (is_array($arrayF)) {
echo $direction = isset($arrayF['direction']) ? $arrayF['direction'] : '';
if ($direction == 'Outgoing') {
$insertdata = array(
"security_key" => '1B344264-4D32-49D9-A9C6-C13025AC24C9',
"duration" => isset($arrayF['duration']) ? $arrayF['duration'] : '',
"date_time" => isset($arrayF['starttime']) ? $arrayF['starttime'] : date('Y-m-d H:i:s'),
'unique_id' => isset($arrayF['uniqueid']) ? $arrayF['uniqueid'] : '',
'recording_url' => isset($arrayF['recordlink']) ? $arrayF['recordlink'] : '',
'caller_id' => isset($arrayF['number']) ? substr($arrayF['number'], -10) : '',
'received_id' => isset($arrayF['extension']) ? substr($arrayF['extension'], -10) : '',
'call_type' => $direction,
"status" => 2,
"call_status" => isset($arrayF['event']) ? $arrayF['event'] : '',
);
} else {
$insertdata = array(
"security_key" => '1B344264-4D32-49D9-A9C6-C13025AC24C9',
"duration" => isset($arrayF['duration']) ? $arrayF['duration'] : '',
"date_time" => isset($arrayF['starttime']) ? $arrayF['starttime'] : date('Y-m-d H:i:s'),
'unique_id' => isset($arrayF['uniqueid']) ? $arrayF['uniqueid'] : '',
'recording_url' => isset($arrayF['recordlink']) ? $arrayF['recordlink'] : '',
'caller_id' => isset($arrayF['extension']) ? substr($arrayF['extension'], -10) : '',
'received_id' => isset($arrayF['number']) ? substr($arrayF['number'], -10) : '',
'call_type' => $direction,
"status" => 2,
"call_status" => isset($arrayF['event']) ? $arrayF['event'] : '',
);
}
$insertArray["extension"] = $insertdata['received_id'];
$data['mobile'] = $insertdata['caller_id'];
$data['SequiryKey'] = $insertdata['security_key'];
$urlTest = "https://globaltravelexchange.com/gtxwebservices/customerapi/checkandgetcustomerdetailwithsequirykey";
if (strlen($data['mobile']) > 9) {
$returnRequest = $this->sendInfoWithOutSSL($data, $urlTest);
$returnArray = json_decode($returnRequest, true);
$IsCustomer = false;
$CustomerName = '';
$MobileNumber = substr(trim($data['mobile']), -10);
$CustomerId = '';
if (isset($returnArray['status']) && $returnArray['status'] == true) {
$IsCustomer = true;
$IsApi = "second";
$CustomerName = trim($returnArray['FirstName']) . ' ' . trim($returnArray['LastName']);
$CustomerId = trim($returnArray['CustomerSysId']);
$data['AgencySysId'] = $returnArray['AgencySysId'];
} else {
$urlTest1 = "https://globaltravelexchange.com/gtxwebservices/customerapi/get-agency-sys-id";
$data1['SequiryKey'] = $insertdata['security_key'];
$returnRequest1 = $this->sendInfoWithOutSSL($data1, $urlTest1);
$returnArray1 = json_decode($returnRequest1, true);
$IsCustomer = false;
$CustomerName = '';
if (isset($returnArray1['status']) && $returnArray1['status'] == true) {
$data['AgencySysId'] = $returnArray1['AgencySysId'];
}
}
$url = 'https://logs.hellogtx.com/api/v1/call-center/';
$data_stringh = json_encode($insertdata);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print_r($outputH);
exit;
}
}
}
echo "sdsds";
exit;
}
}