De-obfuscate PHP malware/viruses and tampering code on Wordpress to original readable code.
*Please note that not all obfuscation codes can be decoded.<?php
/* __________________________________________________
| Built by Clearly IP Inc. |
| on 2023-01-02 21:42:57 |
|__________________________________________________|
*/
namespace FreePBX\modules\Clearlysp\CIP\Controllers\v1; use FreePBX\modules\Clearlysp\CIP\Controllers\Base; use DOMDocument; class Provisioning extends Base { private $usePostOnly = true; private $provisioningData = array("\143\154\x6f\x75\x64\x5f\x75\x73\145\x72\x6e\141\155\145" => "\45\x61\x63\x63\157\x75\x6e\164\133\x63\154\x6f\165\144\137\165\163\145\162\x6e\x61\x6d\145\135\x25", "\143\154\157\x75\144\137\x70\141\163\x73\x77\157\162\144" => "\45\x61\143\x63\157\165\x6e\164\133\x63\154\x6f\x75\144\137\x70\x61\x73\x73\167\x6f\162\x64\x5d\45", "\x63\154\x6f\165\x64\x5f\151\144" => "\45\146\165\154\154\x63\157\144\145\45", "\144\x65\166\151\x63\x65\x5f\x70\154\141\x74\146\157\162\x6d" => "\45\160\154\x61\x74\146\157\162\x6d\x25"); private $pushTokenData = array("\x63\154\x6f\165\x64\137\x75\163\x65\162\x6e\141\x6d\145" => "\x25\141\x63\x63\157\x75\x6e\x74\133\143\154\157\165\144\x5f\165\x73\145\x72\x6e\x61\x6d\145\x5d\45", "\143\x6c\x6f\x75\144\x5f\x70\141\163\x73\x77\x6f\162\x64" => "\x25\x61\143\143\x6f\165\x6e\164\133\143\x6c\157\165\144\137\160\141\x73\x73\x77\157\x72\144\135\x25", "\x74\157\x6b\x65\x6e\137\x63\x61\x6c\154\163" => "\x25\160\165\163\150\x54\x6f\x6b\145\x6e\x49\x6e\x63\x6f\155\151\156\x67\x43\141\x6c\154\45", "\164\157\x6b\145\156\137\x6d\163\147\x73" => "\x25\160\x75\163\150\124\157\x6b\145\156\x4f\164\x68\x65\162\x25", "\x73\x65\x6c\x65\143\164\157\162" => "\x25\x73\x65\x6c\145\143\164\157\162\45", "\x61\160\160\151\x64\137\x63\x61\154\x6c\x73" => "\45\x70\x75\163\150\x61\160\160\x69\x64\137\x69\156\x63\x6f\155\151\x6e\147\x5f\143\x61\154\x6c\x25", "\141\x70\x70\151\x64\x5f\x6d\163\147\163" => "\x25\x70\x75\163\x68\141\160\x70\x69\x64\x5f\x6f\x74\x68\145\162\45", "\x63\x6c\157\x75\144\137\x69\x64" => "\x25\x66\x75\154\154\143\157\x64\145\45", "\151\x6e\163\x74\x61\154\x6c\x5f\x69\144" => "\45\151\x6e\x73\x74\141\154\x6c\151\x64\45", "\144\x65\x76\151\143\145\137\x69\x64" => "\x25\165\x6e\151\161\165\x65\151\144\45", "\x64\145\166\151\143\145\137\160\154\141\164\x66\x6f\162\155" => "\x25\160\x6c\141\x74\x66\157\x72\x6d\45", "\144\145\x76\151\x63\145\137\166\x65\162\x73\151\x6f\x6e" => "\45\x70\154\141\164\146\x6f\x72\x6d\166\x65\162\x73\151\157\x6e\x25", "\144\x65\166\x69\x63\145\137\144\145\x73\x63\x72\151\160\x74\151\157\x6e" => "\45\x64\145\166\x69\x63\x65\x25"); private $fetchSmsData = array("\x63\x6c\x6f\165\x64\137\x75\163\145\162\156\x61\x6d\x65" => "\45\x61\x63\143\157\x75\x6e\164\133\x63\154\157\165\x64\137\x75\163\145\x72\x6e\x61\155\x65\135\45", "\143\154\x6f\x75\x64\137\x70\141\163\163\x77\157\x72\144" => "\x25\141\143\x63\x6f\165\x6e\x74\x5b\x63\x6c\x6f\165\144\x5f\160\x61\x73\x73\167\x6f\x72\x64\x5d\45", "\154\x61\x73\x74\x5f\151\x64" => "\x25\154\141\163\164\137\153\x6e\x6f\167\x6e\137\x73\x6d\x73\137\151\x64\x25", "\x6c\141\x73\x74\x5f\163\145\156\x74\x5f\151\x64" => "\45\154\x61\163\164\x5f\x6b\156\157\x77\x6e\137\x73\x65\156\164\137\163\x6d\x73\x5f\151\144\45", "\x64\x65\166\x69\x63\x65" => "\45\151\x6e\x73\164\x61\x6c\x6c\x69\x64\x25", "\143\x6c\157\x75\x64\x5f\151\144" => "\x25\x66\x75\x6c\x6c\143\x6f\144\x65\x25", "\144\x65\166\x69\143\145\137\151\x64" => "\x25\x75\156\151\161\x75\145\151\x64\x25", "\144\145\x76\x69\143\145\137\x70\x6c\x61\164\146\x6f\162\155" => "\x25\x70\x6c\x61\x74\146\x6f\162\155\x25"); private $sendSmsData = array("\x63\154\157\165\144\x5f\x75\x73\x65\162\156\x61\x6d\145" => "\x25\141\x63\143\157\165\x6e\164\x5b\143\154\x6f\165\144\137\165\x73\145\x72\156\141\155\145\x5d\x25", "\x63\x6c\157\x75\144\x5f\160\141\163\x73\x77\x6f\162\144" => "\45\x61\143\x63\x6f\165\156\164\133\143\154\x6f\165\144\x5f\x70\x61\163\x73\x77\157\x72\x64\135\45", "\x73\155\163\137\164\157" => "\x25\x73\x6d\x73\x5f\164\x6f\45", "\163\x6d\163\137\142\x6f\x64\171" => "\45\x73\155\x73\x5f\142\157\144\x79\x25", "\143\154\x6f\165\x64\137\151\x64" => "\45\x66\165\x6c\154\x63\157\x64\145\x25", "\x64\x65\x76\151\143\x65\137\x69\x64" => "\x25\x75\156\151\161\165\x65\151\x64\x25", "\144\x65\x76\x69\x63\145\137\x70\x6c\x61\x74\146\x6f\x72\x6d" => "\x25\x70\154\x61\164\x66\157\162\155\x25"); private $globalProvisioningData = array("\143\x6c\x6f\x75\x64\x5f\x75\x73\x65\x72\156\x61\x6d\x65" => "\45\141\143\x63\157\x75\156\x74\x5b\x63\x6c\x6f\x75\144\137\x75\163\x65\162\156\x61\x6d\145\x5d\45", "\x63\x6c\157\165\144\x5f\160\141\x73\163\167\157\x72\144" => "\45\141\x63\143\x6f\165\156\164\x5b\x63\x6c\157\x75\144\137\160\x61\163\163\167\x6f\162\x64\135\45", "\143\x6c\157\x75\144\x5f\151\x64" => "\x25\146\x75\154\x6c\143\x6f\x64\145\x25", "\144\x65\x76\151\143\x65\x5f\x70\154\141\164\146\157\x72\x6d" => "\45\x70\154\x61\x74\x66\x6f\162\155\x25"); private $codec = array("\165\x6c\x61\167" => 0, "\147\163\x6d" => 3, "\141\x6c\141\x77" => 8, "\147\67\x32\62" => 9, "\151\154\142\143" => 102, "\x67\x37\62\71" => 18, "\x6f\x70\165\163" => 103); public function magicRedirect($request, $response, $args) { goto S7DwE; Ostvf: return $response->withRedirect($csc, 301); goto NDg2m; S7DwE: $csc = base64_decode($request->getQueryParam("\x63\x73\x63")); goto Zv0D9; Zv0D9: if (!(strpos($csc, "\143\x73\143\x3a") === 0)) { goto inDuD; } goto Ostvf; NDg2m: inDuD: goto XSHqu; XSHqu: } public function provision($request, $response, $args) { goto bdosH; Orgwr: $mapping = $this->FreePBX->Clearlysp->getClientMapping($usermanUser["\151\144"]); goto iD5V5; bdosH: $tokendata = $this->FreePBX->Clearlysp->getTokenData(); goto UYRg_; jX2RU: $cloudid = $body["\x63\x6c\x6f\x75\x64\x5f\151\x64"]; goto biOSl; kBUjt: if ($usermanUser) { goto XeyK5; } goto cyHZR; MF6Bp: ToHUN: goto gkBMK; ABfNs: Q8He9: goto n4oQv; vS08R: if (in_array($device["\164\145\143\150"], array("\163\x69\160", "\x70\152\x73\x69\x70"))) { goto ToHUN; } goto yFiIw; FcNGS: goto Q8He9; goto UJZHH; biOSl: $user = $body["\143\154\157\165\144\x5f\x75\x73\x65\x72\156\141\155\x65"]; goto BfaVG; cyHZR: return self::returnError($response, _("\x49\x6e\x76\x61\154\x69\x64\40\143\x72\145\144\x65\x6e\x74\x69\141\x6c\163"), 403); goto zRwB3; dYaoV: $user = $request->getQueryParam("\143\x6c\157\x75\x64\137\165\x73\145\x72\156\x61\155\x65"); goto uvWla; r4trF: return self::returnError($response, _("\x55\x6e\x61\142\x6c\145\40\164\157\x20\x63\x6f\x6d\160\x6c\145\164\x65\40\x79\x6f\x75\x72\40\x72\x65\x71\165\x65\163\164\54\40\160\154\x65\x61\163\145\x20\x63\x6f\x6e\164\141\x63\164\40\x63\x75\x73\164\x6f\x6d\145\162\40\143\141\x72\145\x2e"), 400); goto H80U5; m1A34: return self::returnError($response, _("\x53\x6f\x66\164\x70\150\x6f\x6e\x65\x20\156\x6f\164\40\145\x6e\141\142\x6c\145\144\x20\x66\x6f\x72\x20\164\150\x69\x73\40\165\x73\145\162"), 404); goto ykSv0; vI22z: return self::returnAsXML($response, $payload); goto YIW_z; ykSv0: uSbbu: goto LFm1D; AxPMa: $body = $request->getParsedBody(); goto jX2RU; UYRg_: if ($tokendata["\x73\165\142\163\143\162\151\160\x74\x69\x6f\156"]) { goto J58WF; } goto rxTww; uxEnC: if ($request->isGet()) { goto TDWOy; } goto AxPMa; gkBMK: $payload = $this->getConfigPayload($usermanUser, $device, $mapping, $credentials); goto vI22z; IqYet: $usermanUser = $this->validateUser($user, $pass); goto kBUjt; Jzi6g: AGHOQ: goto mi3Xx; uvWla: $pass = $request->getQueryParam("\143\154\157\x75\144\x5f\x70\x61\x73\163\167\157\x72\144"); goto ABfNs; L_04U: if (!(empty($usermanUser["\x64\x65\x66\x61\x75\154\x74\x5f\145\170\x74\x65\156\163\x69\157\x6e"]) || $usermanUser["\x64\x65\x66\x61\165\x6c\x74\137\x65\170\164\145\x6e\163\151\157\x6e"] === "\156\x6f\156\x65")) { goto AGHOQ; } goto pvofU; UJZHH: TDWOy: goto rY1I1; yFiIw: return self::returnError($response, _("\123\x6f\x66\164\160\150\x6f\x6e\145\x20\x69\163\40\165\156\x61\166\141\151\154\141\x62\x6c\145\x2c\40\160\x6c\145\x61\x73\145\x20\143\150\x65\143\153\40\171\x6f\165\x72\x20\x65\170\x74\x65\x6e\163\x69\157\156\40\x63\157\x6e\146\x69\x67\x75\x72\141\164\x69\x6f\156\x20\x74\157\40\x65\x6e\x73\165\x72\145\40\151\164\x20\x69\163\x20\x76\x61\x6c\151\x64"), 404); goto MF6Bp; pvofU: return self::returnError($response, _("\111\156\166\x61\x6c\151\144\x20\125\163\145\162\40\103\157\156\x66\x69\x67\x75\x72\141\x74\x69\157\x6e"), 404); goto Jzi6g; CRjIt: J58WF: goto uxEnC; mi3Xx: $device = $this->FreePBX->Core->getDevice($usermanUser["\144\145\146\x61\x75\154\x74\x5f\x65\170\164\x65\156\x73\x69\157\156"]); goto Orgwr; BfaVG: $pass = $body["\x63\154\157\x75\x64\x5f\160\141\x73\163\x77\x6f\x72\144"]; goto FcNGS; zRwB3: XeyK5: goto L_04U; uXjqS: $credentials = array("\165\x73\145\x72\156\x61\x6d\x65" => base64_encode($usermanUser["\x75\x73\x65\x72\x6e\141\155\145"] . "\174" . $tokendata["\x63\x6c\151\x65\156\x74\x73"]["\144\x6f\x6d\x61\151\x6e"]), "\160\141\x73\x73\167\x6f\x72\x64" => $pass, "\x64\157\155\x61\151\156" => $tokendata["\143\x6c\x69\145\x6e\164\x73"]["\x64\x6f\155\141\x69\156"], "\x61\160\151" => array("\165\x72\x6c" => $tokendata["\x63\154\151\145\x6e\x74\x73"]["\141\x70\151\x55\162\x6c"], "\x74\x6f\x6b\145\156" => $tokendata["\164\x6f\x6b\145\156"])); goto vS08R; iD5V5: $permissions = $this->FreePBX->Clearlysp->isAllowed($usermanUser["\151\x64"]); goto ZN6pC; H80U5: UXlCT: goto IqYet; rY1I1: $cloudid = $request->getQueryParam("\x63\154\x6f\x75\x64\137\x69\x64"); goto dYaoV; rxTww: return self::returnError($response, _("\x53\157\146\164\160\x68\x6f\x6e\145\x20\163\165\142\x73\x63\x72\151\x70\164\x69\x6f\x6e\x20\151\163\40\x6e\157\164\x20\141\x63\164\x69\166\x65"), 404); goto CRjIt; ZN6pC: if (!($permissions["\145\x6e\x61\142\x6c\145\x64"] !== "\145\156\x61\x62\154\145\x64")) { goto uSbbu; } goto m1A34; n4oQv: if (!(strpos($cloudid, "\x43\x4c\105\x41\x52\x4c\131\111\120") !== 0)) { goto UXlCT; } goto r4trF; LFm1D: $mapping["\x70\x65\x72\155\151\x73\x73\151\x6f\x6e\x73"] = $permissions; goto uXjqS; YIW_z: } public function getConfigPayload($user, $device, $mapping, $credentials) { goto IngYy; jgpOx: $sendSmsUrl = $provServer . "\57\163\x65\x6e\x64\x5f\x6d\145\163\163\x61\147\x65"; goto KvdUE; ndg_3: goto P2ojC; goto Nquq6; lSmpi: $account->appendChild($xml->createElement("\x61\154\154\x6f\x77\101\x75\x74\x6f\101\x6e\163\x77\145\162", 1)); goto iPQHE; V4fNh: $account->appendChild($xml->createElement("\x74\162\141\x6e\x73\x70\x6f\162\x74", $transport)); goto XDM1y; eOBHT: if (!(!empty($mapping["\160\145\x72\x6d\151\163\163\151\x6f\x6e\163"]["\x73\x74\165\156\x75\x72\x6c"]) && $mapping["\160\x65\162\155\x69\x73\163\151\157\x6e\x73"]["\x73\x74\165\x6e\x75\162\x6c"] !== "\x69\x6e\150\145\162\151\x74")) { goto CdMFl; } goto UQ1Ac; bXKO0: if (!(isset($mapping["\160\145\162\155\x69\x73\x73\x69\x6f\156\x73"]["\x70\141\147\145\141\x75\x74\157\141\156\163\167\x65\x72"]) && $mapping["\160\x65\162\x6d\x69\x73\163\151\157\156\x73"]["\160\x61\x67\145\141\x75\x74\157\x61\156\163\x77\x65\x72"] === "\x65\x6e\141\142\x6c\x65\x64")) { goto WZs7d; } goto lSmpi; KvdUE: $sendSmsQuery = $this->buildQuery($this->sendSmsData); goto NJd6M; FncLX: $account->appendChild($xml->createElement("\143\157\x64\145\143\117\x72\x64\x65\x72", $this->getCodecOrder($wifiCodecs, $filterCodecs))); goto hqOhy; r_9HC: ujBop: goto ebCPe; ebCPe: $transport = !empty($device["\x74\x72\141\156\x73\x70\x6f\x72\x74"]) ? $device["\x74\x72\141\156\x73\160\157\x72\164"] : "\165\144\x70"; goto a2WGo; XxNCM: $provServer = self::$defaultProvisionServer . "\57\x61\x70\x70"; goto upskK; hqOhy: $account->appendChild($xml->createElement("\x63\157\x64\x65\x63\117\162\x64\x65\x72\63\107", $this->getCodecOrder($cellularCodecs, $filterCodecs))); goto bXKO0; sPdS5: $account->appendChild($xml->createElement("\x65\x78\x74\120\x72\157\x76\120\x6f\163\x74\104\141\x74\141", $provisioningQuery)); goto KCPxZ; sha4Q: $host = sprintf("\x25\x73\x3a\x25\x73", $this->getHost(), $port); goto JcrUN; Z5vKm: $account->appendChild($xml->createElement("\x70\x75\x73\x68\124\x6f\153\x65\156\122\145\160\x6f\x72\164\145\162\x43\157\156\164\145\x6e\164\124\x79\x70\x65", "\141\160\160\154\151\143\141\x74\151\157\x6e\57\x6a\x73\157\156")); goto L9TjZ; SckdM: if ($this->usePostOnly) { goto LtlfJ; } goto cVS0x; ZEAVA: $account->appendChild($xml->createElement("\143\x6c\157\165\144\137\x75\x73\x65\x72\x6e\141\x6d\x65", $credentials["\165\x73\145\162\x6e\141\x6d\x65"])); goto sqo1x; KCPxZ: VJppa: goto N2lUv; kiPp7: $account->appendChild($vpnStartupUrl); goto PPSHA; yA3PO: $account->appendChild($xml->createElement("\147\145\156\145\162\151\x63\x53\155\x73\x46\145\164\143\150\x50\x6f\x73\x74\x44\141\x74\141", $fetchSmsQuery)); goto Glrb5; mx0Ir: $account->appendChild($xml->createElement("\160\165\x73\x68\124\x6f\153\145\156\122\145\160\x6f\162\164\145\x72\x50\x6f\x73\164\x44\x61\164\x61", $pushTokenDataJSON)); goto Z5vKm; UU5Wb: $account->appendChild($xml->createElement("\x70\x75\163\x68\126\157\x69\143\x65\155\x61\x69\x6c", 1)); goto qEgc9; r0kFt: $account->appendChild($xml->createElement("\147\145\156\145\x72\x69\143\x53\155\x73\x53\x65\156\144\120\157\x73\x74\104\x61\164\141", $sendSmsQuery)); goto qocJW; Glrb5: $account->appendChild($xml->createElement("\x67\x65\x6e\145\x72\151\143\123\x6d\x73\x53\x65\x6e\x64\125\162\154", $sendSmsUrl)); goto F2o90; KY1EU: $provisioningInterval = $provisioningInterval ? $provisioningInterval : 3600; goto e4yDu; Luspp: LtlfJ: goto aLG8b; lg3y5: mWPuV: goto Cuean; KH04X: $account->appendChild($xml->createElement("\x75\163\145\162\x44\151\163\160\154\x61\x79\116\x61\155\x65", htmlentities($user["\144\151\163\x70\x6c\x61\171\156\x61\155\145"], ENT_XML1))); goto zm8pQ; C1Ei3: $account->appendChild($xml->createElement("\x68\x6f\163\164", $host)); goto V4fNh; T7coo: $account->appendChild($this->getNumberRewriting($xml, $user)); goto qcYK8; oAe5j: IW8KZ: goto lg3y5; qEgc9: asTWy: goto yF7Lh; zm8pQ: $fcc = new \featurecode("\x76\x6f\151\143\145\155\141\151\x6c", "\x6d\x79\x76\x6f\x69\143\145\155\x61\x69\x6c"); goto yROal; Cuean: $blfData = $this->FreePBX->Clearlysp->getBLFInformation($user["\151\144"]); goto ac7jl; aZLEO: $device["\x74\x72\x61\x6e\163\160\x6f\162\x74"] = $matches[0]; goto YLnbN; cVS0x: $account->appendChild($xml->createElement("\x65\170\x74\x50\x72\x6f\x76\125\x72\x6c", $provisioningUrl . "\x3f" . $provisioningQuery)); goto XjfYw; j6QNd: $provXML = $xml->saveXML($xml->documentElement); goto sE79Y; N2lUv: $provisioningInterval = $this->FreePBX->Clearlysp->getConfig("\x65\x78\164\120\x72\x6f\x76\111\x6e\164\x65\x72\166\x61\154"); goto KY1EU; ac7jl: if (empty($blfData)) { goto ZoKWO; } goto vxaLN; IngYy: $xml = new DOMDocument(); goto XxNCM; XDM1y: $account->appendChild($xml->createElement("\165\x73\145\162\x43\x61\x6c\x6c\x65\162\111\x64", $device["\x69\144"])); goto KH04X; MNmNb: goto P2ojC; goto MNQDj; TPVIh: $sipSecret = htmlentities($device["\163\145\x63\x72\145\164"], ENT_XML1); goto jrMaG; qtlmW: if ($this->usePostOnly) { goto Qa5wd; } goto MBcY6; borUf: $account->appendChild($xml->createElement("\160\x75\x73\150\124\157\153\145\x6e\122\145\x70\157\x72\164\145\x72\x55\x72\154", $pushTokenUrl)); goto mx0Ir; B7Wxq: $pushTokenQuery = $this->buildQuery($this->pushTokenData); goto qtlmW; Nquq6: i0Exr: goto BSi9Z; qcYK8: if (!(!empty($device["\x6d\x65\144\x69\x61\x5f\145\x6e\143\162\171\x70\x74\x69\157\156"]) && $device["\155\145\144\151\x61\x5f\x65\x6e\143\x72\171\x70\x74\151\157\x6e"] !== "\156\x6f")) { goto mWPuV; } goto WbupH; z20jM: $cellularCodecs = array("\x6f\x70\165\163", "\147\x37\x32\71", "\x67\x73\155", "\x75\154\x61\x77", "\141\x6c\141\x77", "\151\x6c\x62\143", "\147\x37\x32\x32"); goto K_xxk; HJjMo: $account->appendChild($xml->createElement("\x63\154\157\165\144\137\160\141\x73\x73\x77\157\x72\144", $password)); goto TPVIh; PPSHA: $xml->appendChild($account); goto j6QNd; BSi9Z: $matches = explode("\x2c", $device["\x74\x72\x61\x6e\x73\160\157\162\164"]); goto x7NsN; bmTBA: YcQ8k: goto oAe5j; LjeYE: $account->appendChild($xml->createElement("\x74\151\x74\x6c\145", $device["\x69\144"])); goto ZEAVA; jrMaG: $account->appendChild($xml->createElement("\165\163\x65\x72\156\x61\155\x65", $device["\x69\x64"])); goto BhmSl; D_QKA: switch ($device["\x6d\x65\x64\x69\141\137\x65\156\x63\x72\x79\x70\164\151\x6f\x6e"]) { case "\x73\x64\145\163": goto xZ0zT; sj8Oi: $account->appendChild($xml->createElement("\x73\144\145\163\x4f\x75\164\x67\x6f\151\x6e\x67", $requireEncryption)); goto wb2A5; xZ0zT: $account->appendChild($xml->createElement("\x73\x64\145\163\111\156\143\x6f\155\x69\156\147", $requireEncryption)); goto sj8Oi; wb2A5: goto IW8KZ; goto Myes3; Myes3: case "\144\x74\154\x73": goto LyTTB; LyTTB: $account->appendChild($xml->createElement("\x64\x74\154\163\111\156\143\x6f\155\x69\x6e\147", $requireEncryption)); goto xGYxf; xGYxf: $account->appendChild($xml->createElement("\144\x74\154\163\117\x75\164\x67\157\x69\156\147", $requireEncryption)); goto T9btn; T9btn: goto IW8KZ; goto IipXH; IipXH: default: goto IW8KZ; } goto bmTBA; Q1nqs: $provisioningQuery = $this->buildQuery($this->provisioningData); goto SckdM; epiV1: Qa5wd: goto borUf; E6AEW: goto qOH5Y; goto cOEpx; syolb: $requireEncryption = "\162\145\x71\165\x69\162\x65\144"; goto NWKUa; FH2vE: $account = $xml->createElement("\141\x63\x63\157\165\156\x74"); goto LjeYE; JcrUN: if (!($port === 5060 || $port === 5061 && $device["\164\162\141\156\163\x70\x6f\x72\x74"] === "\164\154\163")) { goto YIbu4; } goto GHH4O; x7NsN: $device["\164\x72\x61\156\163\160\x6f\162\x74"] = $matches[0]; goto MNmNb; VR46X: if (preg_match("\x2f\165\x64\160\x7c\164\143\x70\174\164\x6c\x73\57", $device["\164\x72\141\x6e\x73\160\157\x72\x74"], $matches)) { goto fxHRD; } goto ndg_3; EYaTu: goto z5pF8; goto epiV1; ausGX: $pushTokenDataJSON = json_encode($this->pushTokenData); goto B7Wxq; WtdKD: $wifiCodecs = explode("\x26", $device["\141\154\154\x6f\167"]); goto QCwaq; sqo1x: $password = htmlentities($credentials["\160\141\x73\163\167\157\x72\x64"], ENT_XML1); goto HJjMo; NJd6M: if ($this->usePostOnly) { goto Oy36I; } goto p5X04; iPQHE: WZs7d: goto eOBHT; e4yDu: $account->appendChild($xml->createElement("\145\x78\164\120\x72\157\166\111\156\164\145\162\166\141\154", $provisioningInterval)); goto hyMj3; BhmSl: $account->appendChild($xml->createElement("\160\141\163\x73\x77\157\162\x64", $sipSecret)); goto C1Ei3; p5X04: $account->appendChild($xml->createElement("\147\x65\x6e\x65\x72\151\143\x53\x6d\163\x46\x65\x74\x63\150\125\x72\x6c", $fetchSmsUrl . "\77" . $fetchSmsQuery)); goto Xjt6G; F2o90: $account->appendChild($xml->createElement("\147\x65\156\x65\162\x69\x63\123\x6d\163\120\157\x73\x74\x44\141\164\141", $sendSmsQuery)); goto r0kFt; yjWIo: $filterCodecs = false; goto OHWbA; Xjt6G: $account->appendChild($xml->createElement("\147\145\156\x65\x72\x69\143\x53\x6d\x73\x53\145\x6e\144\x55\162\x6c", $sendSmsUrl . "\x3f" . $sendSmsQuery)); goto E6AEW; ZYn1D: $vpnStartupUrl = VPN::getVPNStartupUrl($xml, $credentials["\141\x70\x69"]["\x75\162\154"], $credentials["\x61\160\151"]["\x74\x6f\x6b\x65\156"]); goto kiPp7; VrQU2: wwbYy: goto yPLz3; m8yQa: $fetchSmsQuery = $this->buildQuery($this->fetchSmsData); goto jgpOx; MBcY6: $account->appendChild($xml->createElement("\160\x75\x73\150\124\x6f\153\x65\156\x52\145\160\157\162\164\x65\162\125\162\154", $pushTokenUrl . "\77" . $pushTokenQuery)); goto EYaTu; hyMj3: $account->appendChild($xml->createElement("\x58\x2d\x69\156\163\x74\141\x6c\x6c\55\x69\x64", md5($device["\151\144"] . "\x40" . $credentials["\x64\157\155\141\151\x6e"]))); goto fJGPZ; cOEpx: Oy36I: goto au2uf; OHWbA: szFOf: goto FncLX; a2WGo: $port = $this->FreePBX->Sipsettings->getDriverPort($device["\x74\x65\143\150"], $transport); goto sha4Q; MNQDj: fxHRD: goto aZLEO; WbupH: $requireEncryption = "\x65\x6e\x61\x62\154\145\144"; goto egx09; yF7Lh: $provisioningUrl = $provServer . "\57\160\x72\x6f\166"; goto Q1nqs; NWKUa: A1n5l: goto D_QKA; vxaLN: $account->appendChild($this->buildBLF($xml, $blfData)); goto QQGIG; YLnbN: P2ojC: goto r_9HC; cQ1dn: YIbu4: goto FH2vE; aLG8b: $account->appendChild($xml->createElement("\145\x78\x74\120\x72\x6f\x76\125\162\154", $provisioningUrl)); goto sPdS5; UQ1Ac: $account->appendChild($xml->createElement("\123\x54\125\116", trim($mapping["\160\145\x72\x6d\x69\163\163\151\x6f\x6e\163"]["\163\x74\x75\x6e\x75\x72\x6c"]))); goto zkyY3; QQGIG: ZoKWO: goto ZYn1D; sE79Y: return $provXML; goto rcfOo; QCwaq: $cellularCodecs = $wifiCodecs; goto yjWIo; hoMP3: if (!$device["\141\x6c\154\157\167"]) { goto szFOf; } goto WtdKD; GHH4O: $host = sprintf("\x25\x73", $this->getHost()); goto cQ1dn; ZO5Jn: if (!($mapping["\160\145\162\155\151\x73\x73\151\157\x6e\163"]["\155\x65\163\163\x61\147\x69\x6e\147"] === "\145\x6e\x61\x62\154\x65\144")) { goto wwbYy; } goto Afste; egx09: if (!(!empty($device["\155\x65\144\151\141\137\145\x6e\x63\x72\171\x70\x74\151\x6f\x6e\137\x6f\x70\x74\151\x6d\151\x73\x74\151\143"]) && $device["\155\x65\144\151\x61\x5f\x65\156\143\162\171\160\164\151\157\x6e\x5f\157\x70\x74\x69\155\151\163\x74\151\143"] === "\156\157")) { goto A1n5l; } goto syolb; yROal: $voicemailCode = $fcc->getCodeActive(); goto rbcG7; K_xxk: $filterCodecs = true; goto hoMP3; zkyY3: CdMFl: goto T7coo; k7eKG: $account->appendChild($xml->createElement("\166\x6f\151\x63\145\x4d\141\151\154\116\165\x6d\x62\145\162", $voicemailCode)); goto UU5Wb; qocJW: qOH5Y: goto VrQU2; XjfYw: goto VJppa; goto Luspp; yPLz3: $wifiCodecs = array("\x6f\x70\165\163", "\165\154\141\167", "\141\154\x61\x77", "\x67\67\x32\x32", "\x67\67\x32\71", "\x69\154\x62\143", "\x67\163\x6d"); goto z20jM; upskK: if (empty($device["\164\162\141\156\163\x70\157\x72\x74"])) { goto ujBop; } goto f8HeB; rbcG7: if (empty($voicemailCode)) { goto asTWy; } goto k7eKG; L9TjZ: z5pF8: goto ZO5Jn; Afste: $fetchSmsUrl = $provServer . "\57\146\x65\164\x63\x68\x5f\155\145\x73\163\141\147\x65\x73"; goto m8yQa; fJGPZ: $pushTokenUrl = $provServer . "\x2f\x74\x6f\x6b\145\156"; goto ausGX; au2uf: $account->appendChild($xml->createElement("\x67\145\156\x65\162\151\x63\123\155\163\x46\145\x74\x63\150\x55\162\x6c", $fetchSmsUrl)); goto yA3PO; f8HeB: if (strpos($device["\164\162\x61\156\163\x70\x6f\162\164"], "\x2c")) { goto i0Exr; } goto VR46X; rcfOo: } public function getHost() { goto jYvMq; f4eiP: if (!$extip) { goto U0SE5; } goto yLoID; yLg3u: $xml = simplexml_load_string(file_get_contents("\150\x74\x74\x70\72\57\57\x6d\x69\162\162\x6f\x72\x2e\143\x6c\145\x61\162\x6c\171\151\160\x2e\143\157\155\57\x77\x68\x61\x74\x69\163\155\171\151\160\x2e\160\150\x70", false, stream_context_create(array("\163\157\143\153\145\x74" => array("\x62\151\x6e\144\164\x6f" => "\60\72\x30"))))); goto CIKKa; hmbkG: $array = json_decode($json, true); goto O5l5w; tIOM1: ypMI3: goto viWA6; GPEe8: U0SE5: goto yLg3u; sQvFF: if (!(!empty($apiConfig["\x63\x6c\x69\145\156\164\x73"]["\x64\x6f\x6d\141\x69\x6e"]) && $apiConfig["\143\x6c\x69\145\156\164\x73"]["\x64\x6f\155\141\x69\x6e"])) { goto ypMI3; } goto Zctfm; viWA6: $extip = $this->FreePBX->Sipsettings->getConfig("\145\170\164\145\162\156\x69\x70"); goto f4eiP; jYvMq: $apiConfig = \FreePBX::Clearlysp()->getTokenData(); goto sQvFF; O5l5w: return $array["\151\160\141\x64\x64\162\145\x73\x73"]; goto iD_Xz; Zctfm: return $apiConfig["\x63\x6c\151\x65\156\164\x73"]["\x64\157\155\x61\151\x6e"]; goto tIOM1; yLoID: return $extip; goto GPEe8; CIKKa: $json = json_encode($xml); goto hmbkG; iD_Xz: } private function getCodecOrder($preferredCodecList, $filterCodecs = false) { goto yZgDu; omkFG: nPT_z: goto u3W18; uXrgC: AVQEJ: goto sIYld; lYbB7: $freepbxAllowedVoiceCodecs = \FreePBX::Sipsettings()->getConfig("\166\157\x69\x63\145\x63\x6f\144\145\143\x73"); goto I1W5h; I1W5h: foreach ($preferredCodecList as $key => $codec) { goto PCo51; PCo51: if (isset($freepbxAllowedVoiceCodecs[$codec])) { goto k28fQ; } goto WPMvL; WPMvL: unset($preferredCodecList[$key]); goto ap3n_; ap3n_: k28fQ: goto qJAZi; qJAZi: KYS5e: goto MD6QZ; MD6QZ: } goto oro81; u3W18: return $str; goto i39Vs; eFig9: return $str; goto CFPiE; dtUZC: $str = substr($str, 0, strlen($str) - 1); goto omkFG; ir1Jo: if (!$filterCodecs) { goto AVQEJ; } goto lYbB7; oro81: hwYG_: goto Ob2tl; sIYld: foreach ($preferredCodecList as $codec) { goto w41eh; w41eh: if (isset($this->codec[$codec])) { goto sTWfC; } goto dVi96; ziVe6: sTWfC: goto fVE5t; dVi96: goto Ol2kK; goto ziVe6; TYLLl: Ol2kK: goto LTlgE; fVE5t: $str .= $this->codec[$codec] . "\x2c"; goto TYLLl; LTlgE: } goto HY88I; HY88I: cov3Q: goto wwoEK; wwoEK: if (!(substr($str, -1) === "\54")) { goto nPT_z; } goto dtUZC; Ob2tl: if (!empty($preferredCodecList)) { goto XcemS; } goto eFig9; yZgDu: $str = ''; goto ir1Jo; CFPiE: XcemS: goto uXrgC; i39Vs: } private function getNumberRewriting($xml, $user) { goto OVqg8; OVqg8: $rewriting = $xml->createElement("\162\x65\x77\162\151\x74\151\156\x67"); goto v0IWs; v0IWs: $emergency = $this->FreePBX->Clearlysp->getCombinbedEmergencyRewritesByUser($user); goto G9X8L; h33tC: v9uVG: goto cCjL8; G9X8L: foreach ($emergency as $eName => $eRule) { goto mEZsu; dcMWu: nCA9g: goto Kh80P; sX1zf: $rewriting->appendChild($rule); goto dcMWu; mEZsu: $rule = $this->createNumberRewritingRule($xml, $eRule); goto sX1zf; Kh80P: } goto h33tC; cCjL8: return $rewriting; goto r3zF_; r3zF_: } private function createNumberRewritingRule($xml, $data = array()) { goto m8XYs; Naw2_: vITLk: goto OSPjQ; Hh5rR: return $rule; goto mo6iX; UutfS: $conditions = $xml->createElement("\143\157\x6e\144\151\x74\151\x6f\x6e\163"); goto QVa_p; mo6iX: S3Oll: goto UutfS; O_PfW: $rule->appendChild($actions); goto lZqgQ; qbgPf: R5ahx: goto BKmqo; sXBsQ: if (!empty($data)) { goto S3Oll; } goto Hh5rR; HXr6F: $actions = $xml->createElement("\x61\143\164\151\x6f\x6e\x73"); goto dnCYT; upaat: foreach ($data["\143\x6f\x6e\144\151\164\151\x6f\156\163"] as $key => $cond) { goto SDUhn; e64Br: AkiL5: goto Ji2jW; QSDF_: $condition->setAttributeNode(new \DOMAttr("\x74\x79\160\x65", $cond["\164\x79\160\145"])); goto ab6BV; SDUhn: $condition = $xml->createElement("\x63\x6f\156\x64\151\x74\151\x6f\156"); goto QSDF_; nGZk7: $conditions->appendChild($condition); goto e64Br; ab6BV: $condition->setAttributeNode(new \DOMAttr("\160\141\162\x61\x6d", $cond["\x70\x61\162\141\x6d"])); goto nGZk7; Ji2jW: } goto qbgPf; QVa_p: if (empty($data["\143\157\x6e\x64\x69\x74\151\157\156\163"])) { goto rVXyP; } goto upaat; BKmqo: rVXyP: goto MtvcH; lZqgQ: return $rule; goto z2A3G; kuEE1: foreach ($data["\x61\143\x74\151\157\x6e\163"] as $act) { goto elx4j; elx4j: $action = $xml->createElement("\141\x63\x74\151\157\x6e"); goto A6u0R; A6u0R: $action->setAttributeNode(new \DOMAttr("\x74\x79\x70\x65", $act["\x74\171\160\145"])); goto nEq3y; jl0uZ: $actions->appendChild($action); goto BOJWf; BOJWf: YwOId: goto zXlah; nEq3y: $action->setAttributeNode(new \DOMAttr("\160\141\162\141\x6d", $act["\160\141\162\141\155"])); goto jl0uZ; zXlah: } goto Naw2_; m8XYs: $rule = $xml->createElement("\x72\165\154\145"); goto sXBsQ; MtvcH: $rule->appendChild($conditions); goto HXr6F; OSPjQ: JGc6y: goto O_PfW; dnCYT: if (empty($data["\x61\x63\x74\x69\157\156\163"])) { goto JGc6y; } goto kuEE1; z2A3G: } private function buildQuery($params) { return urldecode(http_build_query($params, '', "\x26\141\x6d\x70\x3b")); } private function buildBLF($xml, $data = array()) { goto uJLT0; INWX_: return $blf; goto oW46j; jaJ3X: zV1Z4: goto INWX_; uJLT0: $blf = $xml->createElement("\x62\154\x66"); goto G129M; G129M: foreach ($data as $user) { $blf->appendChild($xml->createElement("\165\x72\x69", $user["\x65\x78\164\145\156\163\151\x6f\x6e"])); Suws_: } goto jaJ3X; oW46j: } }<?php
/* __________________________________________________
| Built by Clearly IP Inc. |
| on 2023-01-02 21:42:57 |
|__________________________________________________|
*/
namespace FreePBX\modules\Clearlysp\CIP\Controllers\v1;
use FreePBX\modules\Clearlysp\CIP\Controllers\Base;
use DOMDocument;
class Provisioning extends Base
{
private $usePostOnly = true;
private $provisioningData = array("cloud_username" => "%account[cloud_username]%", "cloud_password" => "%account[cloud_password]%", "cloud_id" => "%fullcode%", "device_platform" => "%platform%");
private $pushTokenData = array("cloud_username" => "%account[cloud_username]%", "cloud_password" => "%account[cloud_password]%", "token_calls" => "%pushTokenIncomingCall%", "token_msgs" => "%pushTokenOther%", "selector" => "%selector%", "appid_calls" => "%pushappid_incoming_call%", "appid_msgs" => "%pushappid_other%", "cloud_id" => "%fullcode%", "install_id" => "%installid%", "device_id" => "%uniqueid%", "device_platform" => "%platform%", "device_version" => "%platformversion%", "device_description" => "%device%");
private $fetchSmsData = array("cloud_username" => "%account[cloud_username]%", "cloud_password" => "%account[cloud_password]%", "last_id" => "%last_known_sms_id%", "last_sent_id" => "%last_known_sent_sms_id%", "device" => "%installid%", "cloud_id" => "%fullcode%", "device_id" => "%uniqueid%", "device_platform" => "%platform%");
private $sendSmsData = array("cloud_username" => "%account[cloud_username]%", "cloud_password" => "%account[cloud_password]%", "sms_to" => "%sms_to%", "sms_body" => "%sms_body%", "cloud_id" => "%fullcode%", "device_id" => "%uniqueid%", "device_platform" => "%platform%");
private $globalProvisioningData = array("cloud_username" => "%account[cloud_username]%", "cloud_password" => "%account[cloud_password]%", "cloud_id" => "%fullcode%", "device_platform" => "%platform%");
private $codec = array("ulaw" => 0, "gsm" => 3, "alaw" => 8, "g722" => 9, "ilbc" => 102, "g729" => 18, "opus" => 103);
public function magicRedirect($request, $response, $args)
{
$csc = base64_decode($request->getQueryParam("csc"));
if (!(strpos($csc, "csc:") === 0)) {
// [PHPDeobfuscator] Implied return
return;
}
return $response->withRedirect($csc, 301);
}
public function provision($request, $response, $args)
{
$tokendata = $this->FreePBX->Clearlysp->getTokenData();
if ($tokendata["subscription"]) {
if ($request->isGet()) {
$cloudid = $request->getQueryParam("cloud_id");
$user = $request->getQueryParam("cloud_username");
$pass = $request->getQueryParam("cloud_password");
goto ABfNs;
}
$body = $request->getParsedBody();
$cloudid = $body["cloud_id"];
$user = $body["cloud_username"];
$pass = $body["cloud_password"];
ABfNs:
if (!(strpos($cloudid, "CLEARLYIP") !== 0)) {
$usermanUser = $this->validateUser($user, $pass);
if ($usermanUser) {
if (!(empty($usermanUser["default_extension"]) || $usermanUser["default_extension"] === "none")) {
$device = $this->FreePBX->Core->getDevice($usermanUser["default_extension"]);
$mapping = $this->FreePBX->Clearlysp->getClientMapping($usermanUser["id"]);
$permissions = $this->FreePBX->Clearlysp->isAllowed($usermanUser["id"]);
if (!($permissions["enabled"] !== "enabled")) {
$mapping["permissions"] = $permissions;
$credentials = array("username" => base64_encode($usermanUser["username"] . "|" . $tokendata["clients"]["domain"]), "password" => $pass, "domain" => $tokendata["clients"]["domain"], "api" => array("url" => $tokendata["clients"]["apiUrl"], "token" => $tokendata["token"]));
if (in_array($device["tech"], array("sip", "pjsip"))) {
$payload = $this->getConfigPayload($usermanUser, $device, $mapping, $credentials);
return self::returnAsXML($response, $payload);
}
return self::returnError($response, _("Softphone is unavailable, please check your extension configuration to ensure it is valid"), 404);
}
return self::returnError($response, _("Softphone not enabled for this user"), 404);
}
return self::returnError($response, _("Invalid User Configuration"), 404);
}
return self::returnError($response, _("Invalid credentials"), 403);
}
return self::returnError($response, _("Unable to complete your request, please contact customer care."), 400);
}
return self::returnError($response, _("Softphone subscription is not active"), 404);
}
public function getConfigPayload($user, $device, $mapping, $credentials)
{
$xml = new DOMDocument();
$provServer = self::$defaultProvisionServer . "/app";
if (empty($device["transport"])) {
goto ujBop;
}
if (strpos($device["transport"], ",")) {
$matches = explode(",", $device["transport"]);
$device["transport"] = $matches[0];
goto P2ojC;
}
if (preg_match("/udp|tcp|tls/", $device["transport"], $matches)) {
$device["transport"] = $matches[0];
goto YLnbN;
}
YLnbN:
P2ojC:
ujBop:
$transport = !empty($device["transport"]) ? $device["transport"] : "udp";
$port = $this->FreePBX->Sipsettings->getDriverPort($device["tech"], $transport);
$host = sprintf("%s:%s", $this->getHost(), $port);
if (!($port === 5060 || $port === 5061 && $device["transport"] === "tls")) {
goto YIbu4;
}
$host = sprintf("%s", $this->getHost());
YIbu4:
$account = $xml->createElement("account");
$account->appendChild($xml->createElement("title", $device["id"]));
$account->appendChild($xml->createElement("cloud_username", $credentials["username"]));
$password = htmlentities($credentials["password"], ENT_XML1);
$account->appendChild($xml->createElement("cloud_password", $password));
$sipSecret = htmlentities($device["secret"], ENT_XML1);
$account->appendChild($xml->createElement("username", $device["id"]));
$account->appendChild($xml->createElement("password", $sipSecret));
$account->appendChild($xml->createElement("host", $host));
$account->appendChild($xml->createElement("transport", $transport));
$account->appendChild($xml->createElement("userCallerId", $device["id"]));
$account->appendChild($xml->createElement("userDisplayName", htmlentities($user["displayname"], ENT_XML1)));
$fcc = new \featurecode("voicemail", "myvoicemail");
$voicemailCode = $fcc->getCodeActive();
if (empty($voicemailCode)) {
goto asTWy;
}
$account->appendChild($xml->createElement("voiceMailNumber", $voicemailCode));
$account->appendChild($xml->createElement("pushVoicemail", 1));
asTWy:
$provisioningUrl = $provServer . "/prov";
$provisioningQuery = $this->buildQuery($this->provisioningData);
if ($this->usePostOnly) {
$account->appendChild($xml->createElement("extProvUrl", $provisioningUrl));
$account->appendChild($xml->createElement("extProvPostData", $provisioningQuery));
goto KCPxZ;
}
$account->appendChild($xml->createElement("extProvUrl", $provisioningUrl . "?" . $provisioningQuery));
KCPxZ:
$provisioningInterval = $this->FreePBX->Clearlysp->getConfig("extProvInterval");
$provisioningInterval = $provisioningInterval ? $provisioningInterval : 3600;
$account->appendChild($xml->createElement("extProvInterval", $provisioningInterval));
$account->appendChild($xml->createElement("X-install-id", md5($device["id"] . "@" . $credentials["domain"])));
$pushTokenUrl = $provServer . "/token";
$pushTokenDataJSON = json_encode($this->pushTokenData);
$pushTokenQuery = $this->buildQuery($this->pushTokenData);
if ($this->usePostOnly) {
$account->appendChild($xml->createElement("pushTokenReporterUrl", $pushTokenUrl));
$account->appendChild($xml->createElement("pushTokenReporterPostData", $pushTokenDataJSON));
$account->appendChild($xml->createElement("pushTokenReporterContentType", "application/json"));
goto L9TjZ;
}
$account->appendChild($xml->createElement("pushTokenReporterUrl", $pushTokenUrl . "?" . $pushTokenQuery));
L9TjZ:
if (!($mapping["permissions"]["messaging"] === "enabled")) {
goto wwbYy;
}
$fetchSmsUrl = $provServer . "/fetch_messages";
$fetchSmsQuery = $this->buildQuery($this->fetchSmsData);
$sendSmsUrl = $provServer . "/send_message";
$sendSmsQuery = $this->buildQuery($this->sendSmsData);
if ($this->usePostOnly) {
$account->appendChild($xml->createElement("genericSmsFetchUrl", $fetchSmsUrl));
$account->appendChild($xml->createElement("genericSmsFetchPostData", $fetchSmsQuery));
$account->appendChild($xml->createElement("genericSmsSendUrl", $sendSmsUrl));
$account->appendChild($xml->createElement("genericSmsPostData", $sendSmsQuery));
$account->appendChild($xml->createElement("genericSmsSendPostData", $sendSmsQuery));
goto qocJW;
}
$account->appendChild($xml->createElement("genericSmsFetchUrl", $fetchSmsUrl . "?" . $fetchSmsQuery));
$account->appendChild($xml->createElement("genericSmsSendUrl", $sendSmsUrl . "?" . $sendSmsQuery));
qocJW:
wwbYy:
$wifiCodecs = array("opus", "ulaw", "alaw", "g722", "g729", "ilbc", "gsm");
$cellularCodecs = array("opus", "g729", "gsm", "ulaw", "alaw", "ilbc", "g722");
$filterCodecs = true;
if (!$device["allow"]) {
goto szFOf;
}
$wifiCodecs = explode("&", $device["allow"]);
$cellularCodecs = $wifiCodecs;
$filterCodecs = false;
szFOf:
$account->appendChild($xml->createElement("codecOrder", $this->getCodecOrder($wifiCodecs, $filterCodecs)));
$account->appendChild($xml->createElement("codecOrder3G", $this->getCodecOrder($cellularCodecs, $filterCodecs)));
if (!(isset($mapping["permissions"]["pageautoanswer"]) && $mapping["permissions"]["pageautoanswer"] === "enabled")) {
goto WZs7d;
}
$account->appendChild($xml->createElement("allowAutoAnswer", 1));
WZs7d:
if (!(!empty($mapping["permissions"]["stunurl"]) && $mapping["permissions"]["stunurl"] !== "inherit")) {
goto CdMFl;
}
$account->appendChild($xml->createElement("STUN", trim($mapping["permissions"]["stunurl"])));
CdMFl:
$account->appendChild($this->getNumberRewriting($xml, $user));
if (!(!empty($device["media_encryption"]) && $device["media_encryption"] !== "no")) {
goto mWPuV;
}
$requireEncryption = "enabled";
if (!(!empty($device["media_encryption_optimistic"]) && $device["media_encryption_optimistic"] === "no")) {
goto A1n5l;
}
$requireEncryption = "required";
A1n5l:
switch ($device["media_encryption"]) {
case "sdes":
$account->appendChild($xml->createElement("sdesIncoming", $requireEncryption));
$account->appendChild($xml->createElement("sdesOutgoing", $requireEncryption));
goto IW8KZ;
case "dtls":
$account->appendChild($xml->createElement("dtlsIncoming", $requireEncryption));
$account->appendChild($xml->createElement("dtlsOutgoing", $requireEncryption));
goto IW8KZ;
default:
goto IW8KZ;
}
IW8KZ:
mWPuV:
$blfData = $this->FreePBX->Clearlysp->getBLFInformation($user["id"]);
if (empty($blfData)) {
goto ZoKWO;
}
$account->appendChild($this->buildBLF($xml, $blfData));
ZoKWO:
$vpnStartupUrl = VPN::getVPNStartupUrl($xml, $credentials["api"]["url"], $credentials["api"]["token"]);
$account->appendChild($vpnStartupUrl);
$xml->appendChild($account);
$provXML = $xml->saveXML($xml->documentElement);
return $provXML;
}
public function getHost()
{
$apiConfig = \FreePBX::Clearlysp()->getTokenData();
if (!(!empty($apiConfig["clients"]["domain"]) && $apiConfig["clients"]["domain"])) {
$extip = $this->FreePBX->Sipsettings->getConfig("externip");
if (!$extip) {
$xml = simplexml_load_string(file_get_contents("http://mirror.clearlyip.com/whatismyip.php", false, stream_context_create(array("socket" => array("bindto" => "0:0")))));
$json = json_encode($xml);
$array = json_decode($json, true);
return $array["ipaddress"];
}
return $extip;
}
return $apiConfig["clients"]["domain"];
}
private function getCodecOrder($preferredCodecList, $filterCodecs = false)
{
$str = '';
if (!$filterCodecs) {
goto AVQEJ;
}
$freepbxAllowedVoiceCodecs = \FreePBX::Sipsettings()->getConfig("voicecodecs");
foreach ($preferredCodecList as $key => $codec) {
if (isset($freepbxAllowedVoiceCodecs[$codec])) {
goto k28fQ;
}
unset($preferredCodecList[$key]);
k28fQ:
}
if (!empty($preferredCodecList)) {
AVQEJ:
foreach ($preferredCodecList as $codec) {
if (isset($this->codec[$codec])) {
$str .= $this->codec[$codec] . ",";
goto TYLLl;
}
TYLLl:
}
if (!(substr($str, 1) === ",")) {
goto nPT_z;
}
$str = substr($str, 0, strlen($str) - 1);
nPT_z:
return $str;
}
return $str;
}
private function getNumberRewriting($xml, $user)
{
$rewriting = $xml->createElement("rewriting");
$emergency = $this->FreePBX->Clearlysp->getCombinbedEmergencyRewritesByUser($user);
foreach ($emergency as $eName => $eRule) {
$rule = $this->createNumberRewritingRule($xml, $eRule);
$rewriting->appendChild($rule);
}
return $rewriting;
}
private function createNumberRewritingRule($xml, $data = array())
{
$rule = $xml->createElement("rule");
if (!empty($data)) {
$conditions = $xml->createElement("conditions");
if (empty($data["conditions"])) {
goto rVXyP;
}
foreach ($data["conditions"] as $key => $cond) {
$condition = $xml->createElement("condition");
$condition->setAttributeNode(new \DOMAttr("type", $cond["type"]));
$condition->setAttributeNode(new \DOMAttr("param", $cond["param"]));
$conditions->appendChild($condition);
}
rVXyP:
$rule->appendChild($conditions);
$actions = $xml->createElement("actions");
if (empty($data["actions"])) {
goto JGc6y;
}
foreach ($data["actions"] as $act) {
$action = $xml->createElement("action");
$action->setAttributeNode(new \DOMAttr("type", $act["type"]));
$action->setAttributeNode(new \DOMAttr("param", $act["param"]));
$actions->appendChild($action);
}
JGc6y:
$rule->appendChild($actions);
return $rule;
}
return $rule;
}
private function buildQuery($params)
{
return urldecode(http_build_query($params, '', "&"));
}
private function buildBLF($xml, $data = array())
{
$blf = $xml->createElement("blf");
foreach ($data as $user) {
$blf->appendChild($xml->createElement("uri", $user["extension"]));
}
return $blf;
}
}Malware detection & removal plugin for WordPress
(C)2020 Wordpress Doctor All rights reserved.