Japanese English

PHP deobfuscation, decryption, reconstruction tool

De-obfuscate PHP malware/viruses and tampering code on Wordpress to original readable code.

*Please note that not all obfuscation codes can be decoded.

Decoded the code below.

<?php /* __________________________________________________ | Built by Clearly IP Inc. | | on 2022-04-29 15:09:29 | |__________________________________________________| */ namespace FreePBX\modules; use BMO; use FreePBX_Helpers; use Exception; use Ramsey\Uuid\Uuid; use Swift_SendmailTransport; us...



Obfuscated php code

<?php
/*   __________________________________________________
    |  Built by Clearly IP Inc.                        |
    |              on 2022-04-29 15:09:29              |
    |__________________________________________________|
*/
 namespace FreePBX\modules; use BMO; use FreePBX_Helpers; use Exception; use Ramsey\Uuid\Uuid; use Swift_SendmailTransport; use Swift_Mailer; use Swift_Message; use FreePBX\modules\Clearlysp\CIP\ClearlyAPI; use FreePBX\modules\Clearlysp\CIP\Clients\RazrClient; use FreePBX\modules\Clearlysp\BMOHooks\Usermanager as CIPUM; use Symfony\Component\Filesystem\LockHandler; use Symfony\Component\Console\Helper\ProgressBar; use FreePBX\modules\Clearlysp\CIP\Functions\Firewall as CIPFW; use FreePBX\modules\Clearlysp\CIP\Functions\Service as CIPSVC; class Clearlysp extends FreePBX_Helpers implements BMO { private $freepbx; public function __construct($freepbx = null) { goto NiRBr; Raw3k: $this->nodeLocation = __DIR__ . "\x2f\156\x6f\x64\x65"; goto zVmrw; NiRBr: $this->FreePBX = $freepbx; goto gH4mQ; UrYXp: $this->um = new CIPUM($freepbx); goto cVm9N; SZodE: $this->firewall = false; goto BRsRm; akd7O: $this->service = new CIPSVC($freepbx, "\143\154\145\141\162\x6c\171\x73\x70"); goto m5Uqx; sClF5: NwRHH: goto akd7O; m5Uqx: $this->fcache = $this->FreePBX->Cache->cloneByNamespace("\x63\x6c\145\x61\162\154\171\163\x70"); goto yA30I; zVmrw: if ($this->FreePBX->Modules->checkStatus("\x66\x69\162\x65\167\x61\154\154")) { goto yy3xY; } goto SZodE; cVm9N: $this->clearlyMirror = "\x68\164\x74\160\x73\72\57\57\155\151\x72\162\x6f\162\x2e\143\154\x65\x61\x72\x6c\x79\x69\x70\x2e\143\157\x6d"; goto Raw3k; v3d_T: yy3xY: goto iLUdM; iLUdM: $this->firewall = new CIPFW($freepbx, ''); goto sClF5; yQJUJ: $this->Conf = $freepbx->Config; goto UrYXp; BRsRm: goto NwRHH; goto v3d_T; yA30I: $this->cache = array(); goto ysRCG; gH4mQ: $this->db = $freepbx->Database; goto yQJUJ; ysRCG: } public function oobeHook() { goto kqyW_; ilRYY: $o = new Clearlysp\OOBE($this); goto WR7QP; kqyW_: include __DIR__ . "\57\117\157\142\x65\56\143\x6c\141\x73\x73\56\160\150\x70"; goto ilRYY; WR7QP: return $o->oobeRequest(); goto lrDFg; lrDFg: } public function getCronJob($modulename, $jobname) { goto xiFcP; viRxI: return $sth->fetch(\PDO::FETCH_ASSOC); goto oJ8b5; xiFcP: $sth = $this->db->prepare("\123\x45\x4c\105\103\124\x20\x2a\x20\x46\x52\x4f\115\x20\x63\162\x6f\x6e\137\152\x6f\142\163\40\x57\x48\x45\x52\x45\40\x6d\x6f\144\165\154\145\x6e\x61\x6d\145\x20\x3d\x20\x3a\155\157\144\165\154\145\x6e\x61\x6d\x65\x20\101\116\x44\x20\152\x6f\x62\x6e\x61\x6d\145\40\75\x20\x3a\152\x6f\142\156\x61\155\145"); goto Q8uYB; Q8uYB: $sth->execute(array("\x3a\155\157\x64\x75\x6c\145\x6e\x61\155\x65" => $modulename, "\72\x6a\x6f\142\156\x61\x6d\x65" => $jobname)); goto viRxI; oJ8b5: } public function install() { goto pyKMw; ro1aQ: if (!$pm2) { goto cVCEk; } goto BIooF; HkwNI: cVCEk: goto XsOvR; fg793: $this->syncFirewallToPushServers(); goto rvAw7; wiRhv: out("\124\150\x65\40\146\157\154\154\x6f\167\151\x6e\x67\x20\x6d\145\x73\163\x61\147\x65\163\40\141\x72\145\x20\117\x4e\x4c\131\x20\x46\117\122\x20\104\105\x42\125\107\x47\111\x4e\107\x2e\x20\111\x67\x6e\x6f\x72\145\40\x61\156\x79\164\150\x69\156\x67\x20\164\150\x61\164\40\x73\x61\171\x73\x20\47\x57\101\122\x4e\47\x20\x6f\x72\x20\x69\163\40\x6a\x75\163\164\x20\x61\x20\x77\x61\162\x6e\151\x6e\147"); goto WdXUn; EfiwI: out(_("\106\151\x6e\151\x73\150\x65\x64\40\x75\x70\x64\x61\x74\151\x6e\x67\40\154\151\x62\162\x61\x72\151\145\x73\x21")); goto HkwNI; slbbG: $this->stopFreepbx(); goto AVjaq; PQU9O: Bscgf: goto JpCSU; XsOvR: $this->syncFirewallToPort(); goto fg793; gv38n: if (!(php_sapi_name() == "\143\x6c\x69")) { goto YBwHr; } goto wiRhv; AVjaq: out(_("\123\x74\x61\x72\x74\151\156\147\x20\x74\150\x65\x20\156\157\x64\145\40\144\141\x65\155\157\x6e")); goto NlWKf; v2SHk: SESHn: goto X8bvg; rvAw7: out(_("\x53\164\157\160\160\151\156\x67\x20\164\150\145\x20\156\157\144\145\x20\x64\x61\x65\155\157\156\40\x69\146\40\x69\x74\40\x69\163\x20\162\165\156\x6e\x69\156\x67")); goto slbbG; JAEaH: foreach ($tokens as $uid => $token) { goto HlAEe; Khi4Q: $this->addUserTokenData($uid, $token); goto RKkZl; HlAEe: $token["\x64\145\x76\151\x63\x65\137\x69\144"] = "\x6d\x69\147\162\x61\x74\x65"; goto Khi4Q; RKkZl: KfWgW: goto WlAIV; WlAIV: } goto v2SHk; RP3ps: $this->FreePBX->Job->setEnabled("\x63\154\x65\141\x72\154\171\163\160", "\160\x6f\x6c\154\163\x6d\x73", true); goto MDnlR; MDnlR: AjdLL: goto dqpol; yNebD: $this->FreePBX->Job->setEnabled("\x63\154\x65\141\162\154\x79\x73\160", "\166\x70\x6e\143\x6c\145\x61\156\x75\x70", true); goto LsbPF; SM4Rp: foreach ($old as $id => $value) { $this->updateUserSettings($id, $value["\x65\x6e\x61\142\x6c\x65"], $value["\155\x65\x73\163\141\x67\151\156\147"], $value["\x73\155\163\x64\x69\x64"]); a_8Kl: } goto PQU9O; Ostbb: $tokens = $this->getAll("\160\165\x73\150\x74\x6f\153\x65\156\x73"); goto JAEaH; eAF2D: $this->FreePBX->Pm2->installNodeDependencies($this->nodeLocation, function ($data) { outn($data); }, array("\116\117\104\x45\137\105\116\x56" => "\160\162\x6f\144\165\x63\164\x69\157\156")); goto dE6LN; LsbPF: $this->FreePBX->Job->addClass("\143\154\145\141\x72\154\171\163\x70", "\x70\165\163\150\x74\x6f\153\x65\x6e\x63\x6c\x65\141\156\165\160", "\x46\162\x65\x65\120\x42\x58\134\155\x6f\x64\x75\x6c\145\x73\x5c\x43\154\145\x61\x72\x6c\x79\x73\x70\x5c\x50\165\163\150\103\154\145\x61\x6e\165\160\112\x6f\x62", "\x30\40\60\40\52\x20\52\40\52"); goto tkjIq; pyKMw: $clearlyspSMSCronJob = $this->getCronJob("\143\154\x65\x61\162\x6c\x79\163\160", "\x70\157\154\x6c\163\x6d\x73"); goto PV7zT; tkjIq: $this->FreePBX->Job->setEnabled("\x63\154\x65\141\x72\x6c\171\x73\x70", "\160\x75\x73\x68\x74\x6f\153\145\x6e\143\x6c\x65\x61\x6e\x75\160", true); goto ZDi8Z; BIooF: out(_("\x46\157\165\x6e\x64\40\120\x4d\62\40\155\x6f\144\165\x6c\145\x20\x69\x6e\163\x74\141\154\x6c\x65\144\x2c\40\151\156\x73\164\141\x6c\154\x69\x6e\147\40\116\x6f\144\145\x20\104\x65\x70\x65\x6e\144\x65\x6e\x63\x69\145\163")); goto eAF2D; JpCSU: $old = $this->getAll("\x67\162\x6f\x75\x70\x6d\141\160\160\x69\x6e\147\x73"); goto pVJIN; ZDi8Z: outn(_("\x49\x6e\x73\164\x61\154\154\x69\x6e\147\57\125\160\x64\141\164\x69\x6e\147\x20\x52\x65\161\x75\151\x72\145\144\x20\114\x69\142\162\x61\162\151\145\x73\56\40\124\x68\151\163\x20\x6d\x61\171\40\x74\x61\x6b\145\x20\141\40\167\150\x69\x6c\145\x2e\x2e\x2e")); goto gv38n; fTZfR: $old = $this->getAll("\x63\x6c\x69\145\156\x74\x6d\141\x70\160\151\x6e\147\x73"); goto SM4Rp; dE6LN: out(''); goto EfiwI; WdXUn: YBwHr: goto fTZfR; pVJIN: foreach ($old as $id => $value) { $this->updateGroupSettings($id, $value["\145\x6e\141\x62\154\145"], $value["\155\x65\163\163\x61\147\x69\x6e\x67"]); kWOVV: } goto ZieDR; Wnme1: if (!empty($clearlyspSMSCronJob)) { goto AjdLL; } goto RP3ps; PV7zT: $time = "\x2a\x20\52\x20\52\x20\52\40\52"; goto m7dXG; dqpol: $this->FreePBX->Job->addClass("\143\x6c\145\141\162\x6c\x79\163\160", "\x76\160\x6e\x63\154\145\x61\156\165\x70", "\106\162\145\145\120\102\130\134\x6d\x6f\x64\165\x6c\x65\163\134\x43\154\145\x61\x72\x6c\171\163\x70\134\126\x50\x4e\112\x6f\x62", "\x30\x20\x2a\x20\52\40\x2a\x20\x2a"); goto yNebD; NlWKf: $this->startFreepbx(); goto abk58; X8bvg: $pm2 = $this->FreePBX->Modules->checkStatus("\160\155\x32"); goto ro1aQ; m7dXG: $this->FreePBX->Job->addClass("\x63\x6c\x65\x61\x72\x6c\171\163\x70", "\160\x6f\154\x6c\x73\x6d\x73", "\106\162\145\x65\120\x42\x58\x5c\155\157\144\165\x6c\145\163\x5c\x43\154\145\141\x72\x6c\x79\163\x70\x5c\112\157\x62", $time); goto Wnme1; ZieDR: Bv2kS: goto Ostbb; abk58: } public function uninstall() { goto SJNHS; Dczaj: ccNcp: goto o0udT; xN6_M: $this->FreePBX->Job->remove("\143\x6c\x65\x61\162\154\171\163\160", "\x76\x70\156\x63\154\145\141\x6e\x75\x70"); goto oh6LL; SJNHS: out(_("\x53\x74\157\x70\160\151\x6e\x67\40\x74\x68\145\x20\156\157\144\145\x20\x64\x61\x65\155\157\156\40\x69\x66\x20\151\164\x20\151\x73\40\x72\x75\x6e\156\x69\156\147")); goto lOsMb; EIiy_: if (!$this->firewall) { goto ccNcp; } goto ReN0u; TTSBM: $this->vpnCleanup(); goto Dczaj; lOsMb: $this->stopFreepbx(); goto HPJ5T; lTvUI: $this->firewall->setServiceName("\103\x6c\145\x61\x72\154\x79\40\x41\x6e\171\x77\x68\145\x72\145")->removeAllRules(); goto TTSBM; ReN0u: out(_("\122\145\155\x6f\166\x69\156\147\40\164\150\145\x20\146\x69\162\145\167\x61\x6c\154\x20\162\x75\x6c\x65\x2e")); goto lTvUI; oh6LL: $this->FreePBX->Job->remove("\143\x6c\145\x61\162\154\x79\163\160", "\160\x75\163\x68\164\x6f\153\x65\x6e\x63\154\145\141\156\165\160"); goto EIiy_; HPJ5T: $this->FreePBX->Job->remove("\143\x6c\x65\141\x72\x6c\171\163\x70", "\x70\157\x6c\x6c\x73\155\x73"); goto xN6_M; o0udT: } public function backup() { } public function restore($backup) { } public function doConfigPageInit($page) { } public function showPage() { goto XcGh8; SXBFe: $parsedUrl["\160\x6f\x72\x74"] = 80; goto PZzhy; ZTuMB: if (!($_REQUEST["\x76\x69\x65\x77"] === "\x73\x65\x74\164\x69\x6e\147\163")) { goto yem8i; } goto ORs9h; ORs9h: $vars["\164\157\153\145\156\x64\x61\164\x61"] = json_encode($tokenData, JSON_PRETTY_PRINT); goto lxLZb; J22Dw: $vars = json_decode($this->getApiConfig(), true); goto p5vfy; HQudV: $vars["\145\170\x74\160\x72\157\x76\x69\x6e\x74"] = $this->getConfig("\x65\170\164\x50\162\x6f\166\x49\x6e\164\x65\162\x76\141\x6c"); goto ZyUIm; pir1Z: foreach ($sortingOptions as $sortValue => $sortName) { $vars["\161\x75\x69\x63\x6b\144\151\x61\x6c\123\x6f\x72\164\x69\x6e\147\x4f\x70\x74\163"] .= sprintf("\x3c\157\160\x74\151\x6f\x6e\x20\x76\141\x6c\165\x65\x20\x3d\x20\x22\x25\x73\x22\x20\45\163\x3e\x25\163\x3c\x2f\x6f\160\164\151\157\x6e\76", $sortValue, $sortValue === $quickdialSortSelected ? "\163\145\x6c\145\x63\164\145\144" : '', $sortName); V8wHJ: } goto vmK1u; sYMFa: $needsSettings = empty($apiUrl) && empty($domain); goto Nsp5P; Nsp5P: if (!$needsSettings) { goto H9QIT; } goto hgktD; fFTpH: $data["\160\157\x72\164\x4d\141\164\143\150\x65\x64"] = !empty($parsedUrl["\160\x6f\x72\x74"]) && (string) $parsedUrl["\160\157\162\164"] === (string) $vars["\x70\157\162\x74"] ? true : false; goto sgL3L; p5vfy: if (!empty($vars["\x63\154\x69\145\x6e\x74\x73"]["\144\145\x73\153\164\x6f\x70\x43\x61\160\x61\142\154\145"])) { goto owv34; } goto ODkUS; DVboI: $vars["\143\x65\162\164\x6f\160\164\x73"] = $this->getCertOpts(); goto VKem2; VKem2: if (!isset($_REQUEST["\x61\144\166\141\156\143\x65\x64"])) { goto XG9VW; } goto EQdnG; dc_fC: $parsedUrl = parse_url($data["\143\x6c\x69\x65\x6e\164\x73"]["\141\160\151\125\x72\x6c"]); goto bTnud; Ry6R2: owv34: goto yMnuW; Y7sDo: if ($parsedUrl["\163\143\150\x65\155\x65"] === "\150\164\164\x70\x73") { goto loGi4; } goto LxWHj; bIAgB: Z2xw6: goto J22Dw; pmFr5: $vars["\146\165\154\x6c\x46\121\x44\116"] = $upstreamfqdn; goto mjRLb; av6kw: goto DV820; goto UXndw; vmK1u: E21yE: goto kyaMa; bUH70: return load_view(__DIR__ . "\x2f\166\x69\x65\167\x73\57\x75\156\162\145\147\151\163\x74\x65\x72\145\x64\x2e\160\150\x70"); goto bIAgB; lvaf6: goto DV820; goto JseFh; AfPKj: $data["\x69\x6e\166\141\x6c\151\144\123\123\114\103\157\156\x66\151\147"] = $vars["\160\162\157\164\x6f\x63\157\154"] === "\x68\164\164\160\x73" && empty($vars["\x63\x65\x72\x74\151\x64"]); goto XqBs4; kyaMa: $vars["\x77\x65\154\143\157\155\x65\x45\x6d\x61\151\154"] = $this->getEmailTemplate(); goto MkzIp; JseFh: loGi4: goto PyK6w; PZzhy: DV820: goto V7lfe; dQhbf: $vars["\x66\x72\x6f\x6d\160\x6c\141\143\x65\x68\x6f\154\x64\145\162"] = $this->getSystemEmail(); goto f6c9P; byXwZ: $vars["\x66\x72\157\155\x65\155\141\151\154"] = $fromemail ? $fromemail : ''; goto dQhbf; hgktD: $needsSettingsDataArray = array("\156\x65\x65\144\163\x53\145\164\x74\x69\156\147\x73\x41\x50\111\x55\162\154" => $apiurl, "\x6e\x65\x65\144\163\123\x65\x74\164\151\156\147\163\104\157\155\141\x69\x6e" => $domain); goto T05Xk; T05Xk: $vars["\163\x65\x74\x74\x69\156\147\163\155\163\x67"] = load_view(__DIR__ . "\57\x76\151\145\167\x73\x2f\156\145\145\144\123\x65\164\164\x69\156\147\163\56\x70\150\160", $needsSettingsDataArray); goto zyI4Q; BBvD7: H9QIT: goto KDb2u; XP2sD: $sortingOptions = array("\x65\170\x74\x65\156\163\x69\157\x6e" => "\105\170\x74\x65\x6e\163\151\157\x6e\40\x4e\165\155\x62\145\x72", "\165\x73\x65\162\x6d\141\156\x44\151\163\x70\x6c\141\171\x4e\x61\155\x65" => "\x55\163\x65\162\x20\x4d\x61\x6e\x61\x67\x65\x72\40\x44\x69\x73\x70\x6c\x61\x79\40\116\x61\x6d\145", "\165\x73\x65\162\x6d\x61\x6e\x46\151\162\x73\x74\116\x61\155\145" => "\125\x73\145\162\40\x4d\141\x6e\x61\147\x65\x72\40\x46\x69\162\x73\x74\x20\116\x61\x6d\x65", "\165\x73\145\x72\155\x61\156\114\x61\x73\164\116\141\155\145" => "\125\163\145\162\40\115\x61\x6e\141\147\x65\x72\x20\114\x61\163\164\x20\116\x61\155\x65"); goto X8HQt; yMnuW: $vars["\163\145\164\x74\151\156\147\163\155\163\x67"] = ''; goto yfoHE; ODkUS: $vars["\143\154\151\x65\x6e\164\163"]["\144\145\x73\x6b\164\x6f\160\103\141\160\141\142\154\x65"] = false; goto Ry6R2; MkzIp: $vars["\141\x64\x6d\x69\156\160\162\x6f\x78\171\164\141\162\x67\x65\x74"] = $this->getConfig("\x61\x64\x6d\x69\x6e\x70\x72\x6f\x78\171\164\x61\x72\147\145\164\x6f\166\145\x72\162\x69\144\x65"); goto HQudV; L8Xjb: $tokenData = $this->getTokenData(); goto XG28D; LN00h: yem8i: goto nilcm; XcGh8: $data = $this->getTokenData(); goto FizY3; rkd1B: $vars["\151\156\x63\162\x65\x6d\x65\x6e\x74\143\x6f\x6e\x74\141\x63\164\x73"] = $this->getConfig("\151\156\x63\162\x65\x6d\x65\x6e\x74\x63\x6f\x6e\x74\141\x63\164\163"); goto L8Xjb; nilcm: $data["\x66\x72\145\145\160\142\170"] = $this->FreePBX; goto AfPKj; e4XRZ: $domain = isset($tokenData["\x63\x6c\151\x65\x6e\164\163"]["\144\x6f\155\141\151\156"]) && !empty($tokenData["\143\x6c\151\x65\156\164\x73"]["\144\157\155\141\151\156"]) ? $tokenData["\143\x6c\x69\145\156\x74\x73"]["\x64\x6f\x6d\x61\x69\x6e"] : false; goto sYMFa; EQdnG: $vars["\x73\x75\160\x70\x6f\162\164\143\x6c\141\163\163"] = ''; goto X4c2W; yfoHE: $fromemail = $this->getConfig("\146\162\157\155\145\155\x61\x69\154"); goto byXwZ; zyI4Q: $data["\163\145\164\x74\151\x6e\x67\163\155\x73\x67"] = load_view(__DIR__ . "\57\166\x69\x65\167\x73\57\x6e\x65\x65\144\x53\145\x74\164\x69\x6e\x67\x73\x2e\x70\x68\x70", $needsSettingsDataArray); goto BBvD7; FizY3: if ($data) { goto Z2xw6; } goto bUH70; LxWHj: if ($parsedUrl["\x73\143\150\x65\155\145"] === "\x68\164\x74\160") { goto LmJwW; } goto lvaf6; V7lfe: rzyAb: goto ZTuMB; KDb2u: $data["\163\145\x72\x76\x69\143\145"] = $this->service->status(); goto dc_fC; UXndw: LmJwW: goto SXBFe; PyK6w: $parsedUrl["\x70\157\x72\164"] = 443; goto av6kw; rUoK0: $vars["\x73\165\160\160\157\x72\x74\x63\154\x61\x73\x73"] = "\x68\151\x64\144\x65\156"; goto DVboI; XqBs4: $data["\x61\x70\x69\123\164\x61\x74\165\x73"] = RazrClient::checkApiConnection($data["\164\157\153\x65\156"]); goto fFTpH; p2K8j: $vars["\163\145\x72\166\x69\x63\145"] = $data["\x73\x65\162\166\151\x63\145"]; goto v7Kes; lxLZb: $upstreamfqdn = isset($tokenData["\143\x6c\x69\145\156\164\x73"]["\x61\x70\x69\x55\x72\154"]) ? $tokenData["\x63\154\151\x65\x6e\x74\163"]["\x61\x70\151\125\162\154"] : ''; goto pmFr5; mjRLb: $vars["\160\x61\x72\163\x65\144\x46\165\154\x6c\x46\121\x44\116"] = !empty($parsedUrl["\150\x6f\163\x74"]) ? $parsedUrl["\150\157\x73\x74"] : null; goto rUoK0; bTnud: if (!(empty($parsedUrl["\160\157\162\x74"]) && !empty($parsedUrl["\x73\143\x68\x65\x6d\145"]))) { goto rzyAb; } goto Y7sDo; X4c2W: XG9VW: goto p2K8j; XG28D: $apiurl = isset($tokenData["\143\x6c\x69\145\156\x74\163"]["\141\160\151\125\162\x6c"]) && !empty($tokenData["\x63\154\151\x65\156\164\x73"]["\x61\x70\x69\x55\x72\154"]) ? $tokenData["\x63\x6c\x69\145\x6e\164\x73"]["\x61\x70\151\x55\x72\x6c"] : false; goto e4XRZ; sgL3L: return load_view(__DIR__ . "\x2f\166\x69\145\167\x73\57\x67\x72\151\144\56\160\150\160", $data); goto dw0YP; v7Kes: $vars["\161\x75\x69\x63\153\x64\x69\x61\154\x53\x6f\x72\164\151\156\147\117\160\164\163"] = ''; goto XP2sD; f6c9P: $vars["\x6d\141\170\143\157\156\x74\141\143\x74\163"] = $this->getConfig("\155\x61\x78\x63\157\156\164\141\x63\x74\x73"); goto rkd1B; ZyUIm: return load_view(__DIR__ . "\57\x76\151\x65\167\163\57\x73\x65\x74\x74\x69\156\x67\x73\x2e\160\150\160", $vars); goto LN00h; X8HQt: $quickdialSortSelected = "\165\163\x65\x72\155\141\x6e\x44\x69\163\x70\154\x61\171\116\x61\x6d\x65"; goto pir1Z; dw0YP: } public function ajaxRequest($req, &$setting) { goto cO9FE; fzGay: $setting["\x61\x6c\154\157\167\x72\145\x6d\157\164\x65"] = true; goto UwqZM; UwqZM: $setting["\143\x68\141\x6e\147\x65\x73\x65\163\x73\151\x6f\156"] = false; goto Nvu_2; XiA_F: switch ($req) { case "\141\x64\144\x74\157\153\145\x6e": case "\x63\154\151\x65\156\x74\x67\x72\151\x64": case "\x75\156\x6d\141\160": case "\x72\145\x6d\x6f\x76\145\124\x6f\153\145\x6e": case "\x72\145\155\157\166\145\160\x75\x73\x68\x74\x6f\153\145\156\x73": case "\162\x65\x66\x72\145\x73\x68\101\143\x63\157\165\156\164": case "\163\x61\x76\145\x53\x65\x74\x74\151\x6e\147\x73": case "\163\165\x70\x70\157\162\164": case "\x70\x75\163\x68\x74\x6f\x6b\145\156\x73": case "\163\145\x72\166\151\143\145\141\x63\164\x69\157\156": case "\141\144\x6d\151\x6e\x50\x72\157\170\171\124\141\x72\147\x65\164\x4f\166\x65\x72\x72\151\x64\145": case "\x65\x6d\145\162\x67\x65\x6e\143\x79\x52\x65\167\x72\x69\164\x65\x52\165\154\x65\163": case "\163\x61\166\145\x45\155\x65\162\147\145\156\143\x79\122\x75\154\x65": case "\x73\x65\x6e\x64\x45\x6d\141\x69\x6c\x73": case "\x6d\141\147\x69\x63\124\x6f\x6b\145\156\x47\162\151\x64": case "\162\x65\147\145\x6e\x65\162\141\x74\145\x4d\x61\x67\x69\143\x4c\x69\x6e\x6b": return true; default: return false; } goto kuirv; pSi11: qs9DZ: goto XiA_F; Nvu_2: return true; goto pSi11; v5y68: $setting["\141\x75\164\x68\x65\156\164\x69\x63\x61\x74\x65"] = false; goto fzGay; FY4Vc: TNbF0: goto hYpGn; cO9FE: if (!($req === "\162\145\163\164")) { goto qs9DZ; } goto v5y68; kuirv: htrQO: goto FY4Vc; hYpGn: } public function ajaxHandler() { goto N76YW; dP8_o: EayWV: goto IadbV; xumar: $this->unmapUser($_REQUEST["\165\x73\x65\x72\x6d\x61\x6e\x75\163\145\x72"]); goto Pebb5; U8JV6: kOQ0G: goto G8hff; y2xCB: return array(); goto LOvGG; MNmoX: L0pjB: goto DhU43; f3t7k: if (!($_REQUEST["\x63\x6f\155\x6d\x61\156\144"] === "\x63\x6c\151\145\x6e\164\x67\x72\x69\144")) { goto a0viV; } goto SvwC2; N76YW: if (!($_REQUEST["\143\157\155\x6d\x61\156\144"] === "\163\165\160\x70\x6f\162\x74")) { goto rtsWr; } goto YpKCt; DYFQs: tobQx: goto V9kf0; DhU43: return array("\163\164\141\x74\165\163" => true); goto c3Yf7; A4wAX: $emailBody = false; goto WNC_8; x4UIa: if (!($_REQUEST["\x63\157\x6d\x6d\x61\156\144"] === "\163\141\x76\145\123\x65\x74\164\x69\x6e\x67\163")) { goto b0XWA; } goto EReEY; maEdU: w39mf: goto hRSUy; LxLjE: V1pfi: goto g4YQM; LOvGG: bRcIK: goto BdsWL; d2Y5G: VHWwI: goto rn2L6; uZYOl: return array("\163\x74\x61\164\165\x73" => false, "\x6d\145\x73\163\x61\147\x65" => _("\x42\x61\144\40\x72\x65\x71\165\145\163\x74")); goto LzvYB; YwC6P: I_M7m: goto bG2kf; LzvYB: zNkED: goto R_lOM; YpKCt: return $this->handleSupport(); goto KsLGR; e6wrq: $this->setConfig("\167\145\x6c\x63\x6f\155\145\105\155\141\151\x6c", $emailBody); goto kJrQ1; TnbQw: return $this->handleRegenerateMagicLink(); goto DYFQs; uErB4: if (!($_REQUEST["\143\x6f\155\x6d\x61\x6e\x64"] === "\x72\145\x67\x65\156\145\162\141\164\x65\115\141\147\151\x63\x4c\151\x6e\153")) { goto tobQx; } goto TnbQw; ALJq3: if (!($_REQUEST["\143\157\155\155\141\x6e\144"] === "\x70\x75\163\150\164\157\153\x65\x6e\x73")) { goto kOQ0G; } goto xwPAF; ag5NP: ZkTjC: goto ALJq3; gDbnY: try { $this->setConfig("\x61\x64\155\x69\x6e\x70\162\157\170\171\164\x61\162\147\145\164\x6f\x76\x65\x72\162\151\144\145", $_REQUEST["\164\141\162\x67\x65\x74"]); return array("\x73\164\x61\x74\x75\x73" => true); } catch (\Exception $e) { return array("\163\164\141\164\165\x73" => false, "\155\145\x73\163\141\147\145" => $e->getMessage()); } goto otVgM; anV_x: $json = file_get_contents("\160\150\160\72\57\57\151\x6e\x70\165\164"); goto xkjaL; uG10P: ZZGv7: goto y2xCB; X81Eq: foreach ($_REQUEST["\x64\x61\x74\141"] as $row) { goto GJRtq; IHqdn: $ret[$row["\165\x73\145\162\155\x61\156\151\144"]] = $this->sendSetupEmail($row["\165\163\145\162\x6d\x61\x6e\x69\x64"]); goto U7vhW; TFqxX: goto VxmgO; goto eyTPh; U7vhW: VxmgO: goto ioEvn; GJRtq: if (isset($row["\x75\x73\x65\x72\x6d\x61\156\x69\x64"])) { goto DbkWi; } goto TFqxX; eyTPh: DbkWi: goto IHqdn; ioEvn: } goto ZNlve; BbDBs: return $this->getUserEmergencyRewriteRules($_REQUEST["\x69\144"]); goto LxLjE; WNC_8: e7oWu: goto e6wrq; c4EfY: hxV0g: goto YwC6P; hzL8B: if (!($_REQUEST["\x63\x6f\x6d\155\x61\156\x64"] === "\x73\x61\166\145\x45\x6d\145\162\x67\145\156\143\171\122\165\154\x65")) { goto I_M7m; } goto bGgkQ; FDSvL: return $this->deleteTokenData(); goto SM0dy; Er0Al: $emailBody = $_REQUEST["\x77\145\x6c\143\x6f\x6d\x65\145\x6d\x61\x69\x6c"]; goto vHFRm; o33s1: return $this->handleMagicTokenGrid(); goto WqUqP; kfjQM: if ($data) { goto zNkED; } goto uZYOl; Z1Muj: KD84F: goto f3t7k; nrPL0: return $this->addToken($_REQUEST["\164\x6f\x6b\145\156"]); goto maEdU; Pebb5: return array("\x73\x74\141\164\x75\x73" => true); goto Z1Muj; uG5yY: return $this->getGroupEmergencyRewriteRules($_REQUEST["\151\144"]); goto uG10P; NVSgE: return $final; goto Ctvk2; WqUqP: Y6aXb: goto uErB4; BdsWL: if (!($_REQUEST["\x63\x6f\155\x6d\141\156\144"] === "\x72\x65\x6d\x6f\x76\145\x70\165\163\150\164\157\x6b\145\156\163")) { goto UK1WM; } goto anV_x; xwPAF: return $this->getAllPushTokens(); goto U8JV6; c3Yf7: UK1WM: goto h3ktQ; otVgM: J2yJ8: goto sWtCL; xkjaL: $data = json_decode($json, true); goto kfjQM; bG2kf: if (!($_REQUEST["\x63\x6f\155\155\x61\x6e\144"] === "\145\x6d\145\x72\x67\x65\x6e\x63\171\x52\145\x77\162\151\164\x65\122\165\x6c\145\x73")) { goto bRcIK; } goto JZM6O; ri0go: b0XWA: goto Gs5uR; brHxE: stNgO: goto S_WR8; Gs5uR: if (!($_REQUEST["\143\157\x6d\x6d\141\x6e\x64"] === "\162\145\146\x72\x65\163\150\x41\x63\x63\157\165\156\164")) { goto ZkTjC; } goto K4JXu; s7542: if (!($_REQUEST["\x63\157\x6d\x6d\x61\156\144"] === "\x73\145\162\166\151\x63\145\x61\x63\x74\x69\x6f\x6e")) { goto EayWV; } goto Zf8Wq; bGgkQ: if (!($_REQUEST["\x74\171\160\x65"] === "\x75\x73\145\x72")) { goto VHWwI; } goto xGXph; upYdh: R1lJZ: goto NVSgE; xGXph: return $this->saveUserEmergencyRule($_POST["\x75\x73\145\x72"], $_POST["\156\x75\x6d\x62\x65\x72"], $_POST["\162\165\154\145"]); goto d2Y5G; KS2LZ: $final = array(); goto SVYfx; vHFRm: $welcomeEmailTemplate = file_get_contents(__DIR__ . "\57\164\x65\155\x70\154\141\x74\x65\163\57\167\145\x6c\143\x6f\x6d\145\x5f\145\x6d\x61\x69\154\56\x74\160\x6c"); goto HJ4ky; v7ytx: if (!(!isset($_REQUEST["\x64\x61\164\x61"]) || empty($_REQUEST["\x64\x61\x74\x61"]))) { goto stNgO; } goto f1E9o; g4YQM: if (!($_REQUEST["\164\171\160\x65"] === "\x67\x72\x6f\165\160")) { goto ZZGv7; } goto uG5yY; R_lOM: foreach ($data as $item) { goto gMsiS; wqHZ9: Fft3_: goto DVE1u; DVE1u: $this->deletePushToken($item["\x75\x69\x64"], $item["\144\x65\166\151\143\x65\137\x69\x64"]); goto kH_oc; kH_oc: yuwnX: goto XktFo; zJ8sN: goto yuwnX; goto wqHZ9; gMsiS: if (!(!isset($item["\165\151\x64"]) || !isset($item["\144\145\x76\151\x63\x65\x5f\x69\x64"]))) { goto Fft3_; } goto zJ8sN; XktFo: } goto MNmoX; V9kf0: if (!($_REQUEST["\x63\157\155\155\x61\156\144"] === "\163\x65\x6e\x64\105\155\x61\151\154\163")) { goto pyccy; } goto v7ytx; IadbV: if (!($_REQUEST["\143\157\x6d\x6d\x61\x6e\x64"] === "\x61\144\x6d\151\156\120\162\x6f\x78\171\124\141\x72\147\x65\x74\117\x76\145\162\x72\x69\144\x65")) { goto J2yJ8; } goto gDbnY; kJrQ1: K5x7z: goto GOlcv; S_WR8: $ret = array(); goto X81Eq; hRSUy: if (!($_REQUEST["\x63\x6f\155\155\x61\x6e\144"] === "\x75\156\155\x61\x70")) { goto KD84F; } goto xumar; ZNlve: UTv0l: goto zpNfa; SvwC2: $clients = $this->getClientMapping(); goto KS2LZ; K4JXu: return $this->refreshTokenData(); goto ag5NP; Zf8Wq: try { $this->service->performAction($_REQUEST["\141\143\164\151\157\x6e"]); return array("\163\164\141\x74\165\x73" => true); } catch (\Exception $e) { return array("\163\164\x61\164\x75\x73" => false, "\x6d\145\x73\x73\x61\147\145" => $e->getMessage()); } goto dP8_o; GOlcv: return $this->handleSaveSettings(); goto ri0go; SVYfx: foreach ($clients as $client) { goto bagCY; ib6wo: $inheritedfrom = isset($client["\151\156\x68\x65\x72\x69\x74\x65\144\146\x72\x6f\x6d"]) ? $client["\x69\156\150\145\x72\x69\x74\x65\144\146\x72\x6f\x6d"] : false; goto EA24s; bagCY: $inherited = isset($client["\x69\x6e\x68\145\162\151\x74\145\x64"]) ? $client["\x69\156\x68\x65\162\151\164\145\x64"] : false; goto ib6wo; JCXje: adSii: goto YUg62; EA24s: $final[] = array("\165\163\x65\x72" => $client["\x64\x61\x74\x61"]["\x64\151\x73\x70\154\141\171\x6e\141\x6d\x65"], "\x6d\145\163\163\x61\147\x69\x6e\147" => $client["\x6d\x65\163\163\x61\147\x69\156\x67"] === "\x65\x6e\141\142\154\145\144", "\x73\x6d\x73\144\x69\x64" => $client["\163\x6d\x73\144\151\x64"], "\x75\x73\x65\x72\155\141\156\151\144" => $client["\144\141\x74\x61"]["\x69\144"], "\151\156\x68\145\162\x69\164\145\x64" => $inherited, "\151\156\x68\x65\x72\151\x74\145\144\146\162\157\155" => $inheritedfrom, "\150\141\163\145\x6d\x61\151\154" => isset($client["\x64\x61\164\x61"]["\145\x6d\x61\151\x6c"]) && !empty($client["\x64\x61\164\141"]["\x65\x6d\x61\x69\154"])); goto JCXje; YUg62: } goto upYdh; SM0dy: DU8PR: goto x4UIa; JZM6O: if (!($_REQUEST["\x74\x79\x70\x65"] === "\x75\x73\x65\162")) { goto V1pfi; } goto BbDBs; Ctvk2: a0viV: goto s7542; L0_wV: return $this->saveGroupEmergencyRule($_POST["\x75\x73\145\x72"], $_POST["\156\165\155\x62\x65\162"], $_POST["\162\x75\154\145"]); goto c4EfY; zpNfa: return array("\x73\x74\x61\164\165\x73" => true, "\x61\x64\x64\151\x74\x69\157\156\x61\154\x64\141\164\x61" => $ret); goto dY5Hj; h3ktQ: if (!($_REQUEST["\x63\157\155\x6d\141\x6e\144"] === "\162\145\155\x6f\x76\145\x54\x6f\x6b\x65\x6e")) { goto DU8PR; } goto FDSvL; rn2L6: if (!($_REQUEST["\x74\x79\160\x65"] === "\x67\162\157\x75\160")) { goto hxV0g; } goto L0_wV; EReEY: if (!isset($_REQUEST["\x77\x65\x6c\143\x6f\x6d\x65\145\x6d\141\x69\154"])) { goto K5x7z; } goto Er0Al; G8hff: if (!($_REQUEST["\143\157\x6d\x6d\x61\156\144"] === "\141\x64\144\x74\x6f\153\x65\156")) { goto w39mf; } goto nrPL0; KsLGR: rtsWr: goto aNBxC; f1E9o: return array("\x73\164\x61\164\x75\x73" => false, "\155\x65\x73\x73\x61\x67\x65" => _("\116\157\40\x75\x73\145\162\x73\40\163\145\154\145\143\164\145\x64"), "\154\145\166\x65\x6c" => "\x64\x61\156\x67\x65\x72"); goto brHxE; HJ4ky: if (!(md5($welcomeEmailTemplate) === md5($emailBody))) { goto e7oWu; } goto A4wAX; aNBxC: if (!($_REQUEST["\x63\x6f\155\155\x61\x6e\x64"] === "\155\141\147\x69\x63\x54\157\x6b\x65\156\x47\162\x69\144")) { goto Y6aXb; } goto o33s1; dY5Hj: pyccy: goto hzL8B; sWtCL: } public function ajaxCustomHandler() { goto CPNcE; W_L_T: zP2bu: goto avYf3; mqgaO: try { goto IoZu5; EBAfy: $clearly->handleRest(); goto jx_7w; IoZu5: $clearly = new ClearlyAPI($this->freepbx); goto EBAfy; jx_7w: return true; goto y8b3I; y8b3I: } catch (Exception $e) { header("\x48\x54\124\120\57\61\x2e\60\40" . $e->getCode() . "\x20" . $e->getMessage()); echo $e->getMessage(); } goto W_L_T; CPNcE: if (!($_REQUEST["\x63\157\155\x6d\x61\156\x64"] === "\x72\145\163\164")) { goto zP2bu; } goto mqgaO; avYf3: } public function getActionBar($request) { return array(); } public function getRightNav($request) { return load_view(__DIR__ . "\x2f\166\x69\145\167\x73\57\162\156\x61\x76\56\160\x68\x70"); } public function getUserCounts() { goto oELrE; xG9OH: $ret = array("\141\163\x73\151\147\x6e\145\144" => $assignedC, "\151\x6e\x68\145\162\151\x74\x65\144" => $inheritedC, "\x74\157\x74\141\x6c" => $assignedC + $inheritedC); goto yMFKI; E9FVd: $inheritedC = 0; goto l29W0; C2p7R: $permitted = $this->getClientMapping(); goto T5iLL; oELrE: $count = $this->fcache->fetch("\165\163\145\162\x63\x6f\165\x6e\x74\163"); goto hZ_Dd; yMFKI: $this->fcache->save("\x75\x73\145\x72\143\x6f\165\x6e\x74\x73", $ret, 10); goto VJMD2; hZ_Dd: if (!$count) { goto phNJr; } goto Z7IIs; c3ijY: XgLwl: goto xG9OH; dkRXg: phNJr: goto C2p7R; T5iLL: $assignedC = 0; goto E9FVd; Z7IIs: return $count; goto dkRXg; l29W0: foreach ($permitted as $value) { goto sxvL7; sxvL7: if ($value["\151\x6e\150\145\x72\x69\164\145\x64"]) { goto PnG1T; } goto Qwjlb; y_z55: $inheritedC++; goto MiHKu; Qwjlb: $assignedC++; goto h86jG; MiHKu: E4CuS: goto P5CHM; Jd2_m: PnG1T: goto y_z55; P5CHM: IuWGP: goto X74Ls; h86jG: goto E4CuS; goto Jd2_m; X74Ls: } goto c3ijY; VJMD2: return $ret; goto vlQ0o; vlQ0o: } public function getTokenData() { goto jKGix; U5E7o: $this->fcache->save("\164\157\x6b\x65\156\x64\141\164\x61", $account, 60); goto i11TO; zpUxi: return $tokenData; goto aIK1H; xAtYq: $account["\143\154\x69\145\x6e\164\x73"]["\141\163\x73\151\x67\x6e\x65\144"] = $usage["\x61\x73\163\x69\147\156\x65\x64"]; goto fVli8; gD4my: $account = $this->getAccountData(); goto ylUkJ; Ahd3H: $account["\143\154\x69\145\156\164\163"]["\165\163\145\x64"] = $usage["\x74\x6f\x74\141\x6c"]; goto xAtYq; Pjav2: return array(); goto HunMO; fVli8: $account["\143\154\x69\145\x6e\x74\x73"]["\151\156\150\x65\x72\151\164\145\144"] = $usage["\x69\x6e\x68\x65\162\x69\164\x65\x64"]; goto ycR8C; ylUkJ: if ($account) { goto VcQF_; } goto Pjav2; f8kav: if (!$tokenData) { goto ILLDk; } goto zpUxi; i11TO: return $account; goto sfK2m; b1K_5: $account["\143\x6c\151\145\x6e\x74\x73"]["\x6d\x6f\142\x69\154\145\114\157\x63\x61\x74\151\x6f\156\111\104"] = !empty($account["\x63\x6c\151\145\x6e\164\x73"]["\x6d\x6f\142\151\x6c\x65\114\x6f\x63\141\x74\x69\157\x6e\111\x44"]) ? $account["\x63\154\151\145\x6e\x74\x73"]["\155\157\x62\x69\x6c\x65\x4c\x6f\143\141\x74\151\x6f\156\111\x44"] : "\125\156\x6b\156\157\167\156"; goto U5E7o; jKGix: $tokenData = $this->fcache->fetch("\x74\x6f\153\145\156\144\x61\164\141"); goto f8kav; aIK1H: ILLDk: goto Z29Tq; HunMO: VcQF_: goto Ahd3H; ycR8C: $account["\163\165\142\163\x63\162\151\x70\164\x69\x6f\156"] = !empty($account["\x65\x78\x70\151\162\145\163"]) ? $account["\x61\x63\x74\151\x76\145"] && $account["\x65\170\x70\151\x72\x65\x73"] > strtotime("\x6e\157\x77") : $account["\141\x63\x74\x69\166\145"]; goto b1K_5; Z29Tq: $usage = $this->getUserCounts(); goto gD4my; sfK2m: } public function addToken($token) { goto f5jVu; VU2iR: return array("\163\x74\141\x74\165\x73" => false); goto lY2Wp; jqb2K: $this->setConfig("\x61\x63\143\157\x75\x6e\x74", time(), "\154\x61\x73\164\x61\160\151\x75\x70\144\141\164\145"); goto WMxLY; k4V7J: if (!$accountData["\141\x63\164\151\166\x65"]) { goto vm0my; } goto iT58N; iT58N: return array("\x73\164\x61\x74\x75\x73" => true); goto YrhPk; WMxLY: $accountData = RazrClient::getAccountData($token); goto S_W00; YrhPk: vm0my: goto VU2iR; f5jVu: $token = trim($token); goto j1rfH; j1rfH: $this->fcache->delete("\x74\157\x6b\x65\156\x64\x61\164\x61"); goto I1Vns; S_W00: $this->updateTokenConfig($accountData); goto k4V7J; I1Vns: $this->setConfig("\164\x6f\x6b\x65\x6e", $token, "\x73\x65\x74\x74\x69\x6e\147\x73"); goto jqb2K; lY2Wp: } public function updateTokenConfig($accountData = array()) { goto lp2Yy; lp2Yy: $existingData = $this->getConfig("\141\143\x63\157\x75\156\x74", "\163\145\164\164\151\156\x67\x73"); goto q87Gz; q87Gz: if (!(json_encode($accountData) !== json_encode($existingData))) { goto dyhwT; } goto fC9w0; fC9w0: dbug("\x55\160\144\x61\164\x69\156\147\40\103\154\x65\141\x72\154\x79\40\x41\156\171\x77\x68\145\x72\x65\x20\x63\157\x6e\146\x69\147\165\162\141\x74\151\157\x6e\x20\163\151\x6e\x63\x65\x20\x69\164\x20\x68\x61\163\x20\143\150\141\156\147\145\144"); goto RJ9Te; RJ9Te: $this->setConfig("\x61\143\x63\157\x75\x6e\x74", $accountData, "\x73\145\x74\164\151\156\147\x73"); goto kgM1u; kgM1u: dyhwT: goto Lh5ST; Lh5ST: } public static function myDialplanHooks() { return 950; } public function doDialplanHook(&$ext, $engine, $priority) { goto bDmhV; NAyq5: $token = $this->getConfig("\x74\157\x6b\145\x6e", "\163\x65\x74\x74\151\x6e\147\163"); goto bcRtw; zK2t4: $this->setConfig("\141\x63\x63\x6f\x75\156\x74", time(), "\154\x61\163\x74\x61\160\x69\x75\160\144\141\x74\145"); goto PTW22; nd9E7: z8yFX: goto zK2t4; Xj8h5: $this->permissionLottery(); goto UBoYn; qNEPR: kGqri: goto NAyq5; yKIXB: if (!($nowTimestamp < $lastApiUpdate)) { goto kGqri; } goto ZSGui; ZSGui: dbug("\123\x6b\x69\x70\160\151\156\147\40\103\x6c\145\141\162\154\171\40\101\156\x79\x77\x68\145\162\145\40\154\151\x63\145\156\x73\145\x20\x63\x68\x65\143\153"); goto PmM9w; bDmhV: $lastApiUpdate = $this->getConfig("\x61\x63\143\x6f\x75\x6e\x74", "\154\x61\x73\x74\141\160\151\165\x70\144\141\164\145"); goto YCE9X; C7SVq: return; goto GbLyA; fnAso: return; goto nd9E7; tzNQ1: if (is_array($accountData)) { goto nUrgd; } goto C7SVq; Q7ATf: if (!empty($accountData["\x63\154\x69\x65\156\x74\x73"]["\x74\157\164\x61\154"])) { goto qlQ6q; } goto dbyz8; PTW22: $accountData = RazrClient::getAccountData($token); goto tzNQ1; ecoLq: $lastApiUpdate = 0; goto F1gyC; aK8pQ: qlQ6q: goto VH8EC; wUv37: $now->modify("\x2d\x37\x32\40\150\x6f\x75\x72\163"); goto PBeJQ; VH8EC: $this->updateTokenConfig($accountData); goto Xj8h5; eE4jT: $now = new \DateTime(); goto wUv37; Hv9Rs: PrEqJ: goto Q7ATf; GbLyA: nUrgd: goto Gv6Ni; Gv6Ni: if (!empty($accountData["\x74\x6f\x6b\145\156"])) { goto PrEqJ; } goto GlHxT; F1gyC: o0yeT: goto eE4jT; PBeJQ: $nowTimestamp = $now->getTimestamp(); goto yKIXB; YCE9X: if (!empty($lastApiUpdate)) { goto o0yeT; } goto ecoLq; bcRtw: if (!empty($token)) { goto z8yFX; } goto fnAso; GlHxT: return; goto Hv9Rs; PmM9w: return; goto qNEPR; dbyz8: return; goto aK8pQ; UBoYn: } public function deleteTokenData() { goto NyAqv; xmMru: return array("\x73\x74\x61\164\165\163" => true); goto o20R2; NyAqv: $this->setConfig("\x61\143\x63\157\x75\x6e\x74", false, "\163\145\x74\x74\151\156\x67\x73"); goto FJO1P; FJO1P: $this->setConfig("\164\x6f\x6b\x65\x6e", false, "\x73\145\164\164\x69\156\x67\163"); goto GmB4S; GmB4S: $this->fcache->delete("\x74\157\153\145\x6e\x64\141\164\x61"); goto xmMru; o20R2: } public function refreshTokenData() { goto pNr4F; LgCZK: return array("\163\164\141\x74\165\163" => false, "\x6d\x65\x73\x73\141\147\x65" => _("\116\157\x20\164\x6f\x6b\x65\x6e\40\x73\x65\164")); goto zVBtT; pNr4F: $tokenData = $this->getTokenData(); goto GbB8W; ZbRgl: return array("\163\164\x61\x74\165\163" => true); goto HVCO4; GbB8W: $token = isset($tokenData["\164\157\x6b\145\x6e"]) ? $tokenData["\164\x6f\153\145\156"] : false; goto xsaSN; xsaSN: if ($token) { goto qEGuJ; } goto LgCZK; ULOtJ: $this->addToken($token); goto ZbRgl; zVBtT: qEGuJ: goto ULOtJ; HVCO4: } public function getAccountData() { return $this->getConfig("\141\x63\143\157\165\156\x74", "\163\145\164\164\151\156\x67\163"); } public function getClientMapping($client = '') { goto aV557; UUxsw: $clients = $this->getConfig("\x70\x65\162\x6d\x69\x74\164\x65\144"); goto TCFru; aV557: if (empty($client)) { goto YJxra; } goto PV8Wi; I7FsI: $final = array(); goto dYvPr; TCFru: $clients = is_array($clients) ? $clients : array(); goto I7FsI; Q3ldt: YJxra: goto UUxsw; dYvPr: foreach ($clients as $id => $client) { goto ZtC0R; j_Bnp: cOQVy: goto ZYUOI; ZYUOI: $final[$id] = $settings; goto xXvIm; xXvIm: FI2uz: goto FoZeD; KnINT: if ($settings["\x64\x61\x74\141"]["\151\x64"]) { goto e3IO0; } goto MkLoG; ONSuU: e3IO0: goto METHA; MkLoG: goto FI2uz; goto ONSuU; ZtC0R: $settings = $this->getCombinedSettings($id); goto KnINT; ZVeq7: goto FI2uz; goto j_Bnp; METHA: if ($settings["\x65\x6e\141\142\154\x65\144"]) { goto cOQVy; } goto ZVeq7; FoZeD: } goto Wmh8V; lZ6v2: WgBnO: goto d_3s_; Ub7MC: goto WgBnO; goto Q3ldt; PV8Wi: return $this->getUserSettings($client); goto Ub7MC; Wmh8V: da0uu: goto r40GM; r40GM: return $final; goto lZ6v2; d_3s_: } public function unmapUser($id) { goto Gd8Jn; UNrbT: $this->permissionLottery(); goto baiFf; T6jsA: $this->updateUserSettings($id, "\x69\x6e\150\x65\x72\151\x74", $user["\x6d\145\163\163\x61\x67\151\x6e\x67"], $user["\x73\x6d\163\x64\151\x64"]); goto UNrbT; baiFf: return $this; goto gwN9x; Gd8Jn: $user = $this->getUserSettings($id); goto T6jsA; gwN9x: } public function syncFirewallToPort() { goto m2Nzy; m2Nzy: if (!$this->firewall) { goto cXyir; } goto W1nIO; ncyiv: $port = $apiconf["\x70\157\162\x74"]; goto T_YRy; W1nIO: $apiconf = json_decode($this->getApiConfig(), true); goto ncyiv; T_YRy: $this->firewall->setServiceName("\x43\x6c\145\141\162\x6c\x79\40\x41\156\171\167\150\x65\x72\145")->syncFirewallToPort($port, "\164\x63\x70", array("\145\170\x74\x65\162\156\141\x6c", "\151\x6e\164\x65\162\x6e\141\154")); goto Ys0ln; Ys0ln: cXyir: goto OhB49; OhB49: } public function syncFirewallToPushServers() { goto N4Xfi; GXqlI: MhndR: goto XLAoA; ylXoM: $this->firewall->removePushServersFromFirewall(); goto cUx2M; N4Xfi: if (!$this->firewall) { goto MhndR; } goto ylXoM; cUx2M: $this->firewall->syncFirewallToPushServers(); goto GXqlI; XLAoA: } public function vpnCleanup($output = null) { goto g7V2k; PBKnt: $networks = \FreePBX::Firewall()->getConfig("\144\145\x73\143\162\151\x70\164\151\x6f\x6e\x73", "\x6e\x65\164\167\157\162\x6b"); goto hkf8Q; wuYM4: foreach ($ca as $network => $entries) { goto CU3Vk; S45tn: if (empty($output)) { goto ZBuWz; } goto D4ENg; D4ENg: $output->writeln(sprintf("\122\145\155\x6f\x76\151\x6e\147\40\45\163", $network)); goto b4Bc6; fEZBB: PFBAB: goto h1wRK; CU3Vk: if (!(count($all[$network]) == 1)) { goto PFBAB; } goto S45tn; h1wRK: LF0QU: goto HJ4rz; eivEx: \FreePBX::Firewall()->removeNetwork($network); goto fEZBB; b4Bc6: ZBuWz: goto eivEx; HJ4rz: } goto Y3BnW; wQpHa: ofzQl: goto wuYM4; E0Kzq: return; goto I8IJR; hkf8Q: foreach ($networks as $ip => $desc) { goto No8oW; tptJK: $ca[$ip][] = $desc; goto xj5ev; hWTsN: if (!(strpos($desc, base64_encode("\143\154\x65\x61\162\154\x79\141\x6e\x79\167\150\x65\x72\x65") . "\x2d") === 0)) { goto Om_8U; } goto tRo8H; mA4t0: if (!($t < $removalTime)) { goto ZVlMk; } goto tptJK; No8oW: $all[$ip][] = $desc; goto hWTsN; u2AdQ: K8siX: goto LMBIC; xj5ev: ZVlMk: goto rRohn; rRohn: Om_8U: goto u2AdQ; tRo8H: list($d, $t, $u) = explode("\x2d", $desc, 3); goto w3f2a; w3f2a: $removalTime = time() - 60 * 30; goto mA4t0; LMBIC: } goto wQpHa; I8IJR: LplSs: goto PBKnt; LcFUb: if ($this->firewall) { goto LplSs; } goto CH312; Y3BnW: ODhRi: goto Ej4JR; CH312: dbug("\106\x69\x72\145\167\x61\154\154\40\156\157\x74\40\146\x6f\x75\x6e\x64\54\x20\163\153\x69\160\x70\151\x6e\147\x20\166\x70\156\40\143\154\145\141\x6e\165\x70"); goto E0Kzq; GorUj: $ca = array(); goto LcFUb; g7V2k: $all = array(); goto GorUj; Ej4JR: } public function getGroupMapping($group = '') { goto jDCiZ; YVroD: $groupmap = $this->getConfig($group, "\147\162\x6f\x75\x70\155\141\x70\x70\151\156\x67\x73"); goto IWWd8; Duxae: $clients = $this->getAll("\147\162\157\165\160\x6d\x61\x70\160\151\x6e\x67\x73"); goto vrN9X; IWWd8: return is_array($groupmap) ? $groupmap : $default; goto PzZfp; vrN9X: return is_array($clients) ? $clients : array(); goto kUj7d; kUj7d: FqEBr: goto KO6pJ; KO6pJ: $default = array("\x6d\145\x73\x73\141\x67\x69\156\x67" => "\144\x69\x73\x61\x62\154\145\144", "\145\156\141\x62\x6c\145" => "\144\x69\x73\141\x62\x6c\145\x64"); goto YVroD; jDCiZ: if (!empty($group)) { goto FqEBr; } goto Duxae; PzZfp: } public function isAllowed($uid) { goto XLdA0; fDP9Z: if ($permitted) { goto rVtIP; } goto tbCj1; VqZH4: rVtIP: goto G6PBD; G6PBD: return isset($permitted[$uid]) ? $permitted[$uid] : $default; goto xSXx3; kv2il: $permitted = $this->getConfig("\x70\145\x72\x6d\x69\164\x74\x65\x64"); goto fDP9Z; tbCj1: $permitted = $this->permissionLottery(); goto VqZH4; XLdA0: $default = array("\145\156\141\142\154\x65\144" => false, "\155\x65\x73\163\141\x67\151\x6e\x67" => false); goto kv2il; xSXx3: } public function permissionLottery() { goto pQptJ; GJ4KD: $this->delConfig("\160\145\162\x6d\x69\164\164\145\144"); goto Zv3KG; lFjrB: $this->setConfig(time(), $previousPermissions, "\x70\x65\x72\x6d\x69\x73\163\x69\157\156\110\x69\x73\x74\157\x72\x79"); goto scso2; MfISB: PFP0O: goto Md1yt; o7E7A: $previousPermissions = array(); goto QGyUo; Md1yt: if (!(is_array($previousPermissions) && is_array($permitted))) { goto ZMh_A; } goto odfLD; cv1X_: fkIrN: goto rEHJ0; KxXWH: if (!empty($permitted)) { goto fkIrN; } goto GJ4KD; u8_oC: return array(); goto MMGb2; QGyUo: G6NDR: goto rVjca; Eodfn: if (empty($diff)) { goto ZghBg; } goto lFjrB; rVjca: $allowed = intval($tokendata["\143\154\151\145\156\164\163"]["\x74\x6f\x74\x61\x6c"]) - count($enabled); goto A9fyw; Zv3KG: goto cxLEw; goto cv1X_; A9fyw: foreach ($allUsers as $user) { goto EciNZ; AqrYg: if (!($settings["\145\156\141\x62\154\x65\x64"] == "\144\x69\x73\x61\142\154\145\x64")) { goto UT3n7; } goto iDCsg; MFXLc: $settings = $this->getCombinedSettings($uid); goto AqrYg; V4J3R: $permitted[$uid] = $this->getCombinedSettings($uid); goto yF1oi; zdAlA: mbWP9: goto lrODH; ku5OM: yIKy0: goto AYsA8; C5yhR: if (!isset($disabled[$uid])) { goto yIKy0; } goto FZSd5; JyeE2: $allowed--; goto jW5NH; ncphb: YGkrU: goto C5yhR; mp2Lj: $permitted[$uid] = $settings; goto JyeE2; AYsA8: if (!($allowed > 0)) { goto wpxJq; } goto MFXLc; ZZLOc: if (!isset($enabled[$uid])) { goto YGkrU; } goto V4J3R; iDCsg: goto mbWP9; goto WlbyB; jW5NH: wpxJq: goto zdAlA; FZSd5: goto mbWP9; goto ku5OM; WlbyB: UT3n7: goto mp2Lj; yF1oi: goto mbWP9; goto ncphb; EciNZ: $uid = $user["\x69\x64"]; goto ZZLOc; lrODH: } goto MfISB; iuAM8: cxLEw: goto rBay_; Q1nFC: $disabled = $this->getUsersDisabled(); goto mpU5R; cg0o4: ZMh_A: goto KxXWH; scso2: ZghBg: goto cg0o4; MMGb2: M4BJU: goto LKP6e; KBs9W: $this->cleanPermissionHistory(); goto KdTtQ; jegX0: $this->setConfig("\x70\x65\x72\155\151\x74\164\x65\x64", $permitted); goto iuAM8; KdTtQ: return $permitted; goto JyRxl; pQptJ: $tokendata = $this->getTokenData(); goto qF6JH; hrZZf: if (isset($tokendata["\143\154\x69\145\156\x74\163"]["\x74\x6f\164\x61\x6c"])) { goto M4BJU; } goto u8_oC; rBay_: $this->fcache->delete("\164\157\153\145\x6e\144\141\164\x61"); goto KBs9W; nFz18: $previousPermissions = $this->getConfig("\160\145\x72\155\151\164\164\x65\144"); goto cuOAs; rEHJ0: $this->updateMaxContacts($permitted); goto jegX0; LKP6e: $enabled = $this->getUsersEnabled(); goto Q1nFC; odfLD: $diff = array_diff(array_keys($previousPermissions), array_keys($permitted)); goto Eodfn; qF6JH: $permitted = array(); goto hrZZf; cuOAs: if (!empty($previousPermissions)) { goto G6NDR; } goto o7E7A; mpU5R: $allUsers = $this->FreePBX->Userman->getAllUsers(); goto nFz18; JyRxl: } public function cleanPermissionHistory($clear = false) { goto d3JUh; oS2YC: Euk6l: goto ZhszA; d3JUh: if (!$clear) { goto Euk6l; } goto wLAI0; ZhszA: $historyData = array_keys($this->getAll("\x70\x65\162\155\x69\163\x73\x69\157\x6e\110\151\163\x74\157\x72\171")); goto IAklI; IAklI: $keep = array_slice($historyData, -20, 20); goto vr2Ks; wLAI0: $this->delById("\x70\x65\162\x6d\151\x73\163\151\157\156\x48\151\x73\x74\x6f\162\171"); goto oS2YC; vr2Ks: foreach ($historyData as $key) { goto IiCVW; IiCVW: if (!in_array($key, $keep)) { goto wkEEH; } goto d_2yI; JatHs: $this->delConfig($key, "\160\145\162\155\x69\x73\163\x69\x6f\x6e\110\151\163\164\x6f\x72\171"); goto eNgxL; yBp0K: wkEEH: goto JatHs; eNgxL: ImrKh: goto jwc19; d_2yI: goto ImrKh; goto yBp0K; jwc19: } goto TL1k5; TL1k5: RQrp8: goto aw8Dl; aw8Dl: } public function updateDeviceContacts($extension, $contacts) { goto lCUMY; N_rZ5: $sth = $this->FreePBX->Database->prepare($sql); goto dj9dV; pvcE9: return $this; goto ZKxlc; lCUMY: $sql = "\125\120\x44\101\124\105\x20\x73\151\x70\x20\x53\105\x54\x20\x60\144\141\x74\141\x60\x20\75\40\72\155\141\170\x43\157\x6e\x74\141\x63\x74\163\x20\x57\110\105\122\105\40\x60\151\144\140\x20\x3d\40\x3a\x65\x78\164\145\156\x73\x69\157\156\x20\x41\x4e\104\x20\140\x6b\x65\171\x77\157\162\x64\x60\40\75\40\72\153\145\x79\167\x6f\162\144"; goto N_rZ5; dj9dV: $sth->execute(array("\x3a\x6d\141\170\x43\157\x6e\x74\x61\x63\164\x73" => $contacts, "\145\x78\x74\x65\156\163\151\157\x6e" => $extension, "\x6b\145\171\x77\x6f\162\144" => "\155\141\x78\137\x63\157\156\164\141\x63\x74\x73")); goto pvcE9; ZKxlc: } public function updateMaxContacts($list) { goto KyrrO; gTL8A: if ($maxcontacts) { goto TgdVn; } goto t4FOt; SWO80: A_2Js: goto LFl8T; t4FOt: $maxcontacts = 42; goto xD2Em; KyrrO: $allModified = $this->getAll("\155\157\x64\x69\x66\x69\145\x64\115\x61\x78\103\157\x6e\x74\x61\x63\x74\163"); goto mLGzd; MPuIT: MfLVq: goto uXr9E; LFl8T: foreach ($allModified as $id => $oldcount) { goto AzzfK; zgAQB: Jd71I: goto O5sC_; AzzfK: $this->updateDeviceContacts($id, $oldcount); goto qNpNc; qNpNc: $this->FreePBX->Clearlysp->delConfig($id, "\x6d\157\144\x69\146\151\x65\144\x4d\141\x78\103\x6f\x6e\x74\141\143\164\163"); goto zgAQB; O5sC_: } goto MPuIT; UgzOr: $icontacts = $this->getConfig("\x69\156\143\x72\145\x6d\145\156\164\143\157\x6e\164\141\143\x74\x73"); goto eDktx; eDktx: $increment = $icontacts ? $icontacts : 2; goto gTL8A; xD2Em: TgdVn: goto dK5hi; mLGzd: $maxcontacts = $this->getConfig("\x6d\141\170\143\157\156\x74\x61\143\164\163"); goto UgzOr; dK5hi: foreach ($list as $id => $data) { goto D1Jux; FjQPT: Bf_yW: goto oCh6E; GSsQl: $contacts = $contacts < $maxcontacts ? $contacts : $maxcontacts; goto WWRmk; sH7kA: if (!(!empty($device) && $device["\x74\x65\x63\x68"] == "\x70\152\163\151\x70")) { goto Bf_yW; } goto Ol0tk; oCh6E: FbLBL: goto mMtUu; IyGv4: goto FbLBL; goto n7tgt; LnCu7: $contacts = $device["\155\x61\x78\137\143\x6f\156\164\x61\x63\164\x73"] + intval($increment); goto GSsQl; D1Jux: if (!isset($allModified[$id])) { goto hMQ_y; } goto GF96n; fb2pw: $this->FreePBX->Clearlysp->setConfig($id, $currentMaxContacts, "\155\x6f\x64\x69\x66\x69\145\x64\115\x61\170\x43\157\x6e\x74\x61\143\x74\x73"); goto FjQPT; n7tgt: hMQ_y: goto vgA74; WWRmk: $this->updateDeviceContacts($data["\x64\x61\164\141"]["\x64\x65\146\141\165\154\x74\x5f\x65\x78\x74\x65\x6e\163\x69\x6f\156"], $contacts); goto fb2pw; vgA74: $device = $this->FreePBX->Core->getDevice($data["\144\x61\164\x61"]["\144\145\146\141\165\x6c\x74\x5f\x65\x78\164\x65\x6e\163\x69\157\156"]); goto sH7kA; Ol0tk: $currentMaxContacts = $device["\155\141\x78\x5f\143\157\156\x74\141\x63\x74\x73"]; goto LnCu7; GF96n: unset($allModified[$id]); goto IyGv4; mMtUu: } goto SWO80; uXr9E: } public function checkToken($token) { goto eeWa8; VVe1P: return false; goto Tyojw; Tyojw: yzMUf: goto I0UHE; eeWa8: if (!empty($token)) { goto yzMUf; } goto VVe1P; I0UHE: $tokendata = $this->getTokenData(); goto G1KHd; G1KHd: return $token === $tokendata["\x74\x6f\153\x65\156"]; goto U5K7T; U5K7T: } public function pushReprovision($uid) { goto Jd75F; jPE6X: return array("\x73\164\x61\164\165\163" => false, "\155\x65\x73\163\141\x67\x65" => "\x69\x6e\x76\141\x6c\x69\144\40\x75\163\x65\x72"); goto p3RaT; rc1cm: if ($pushtokens) { goto lWO7J; } goto jPE6X; sd0nb: $messages = array(); goto PAvu0; nN2LV: return $this->processPush($messages); goto dSqTg; Jd75F: $pushtokens = $this->getPushTokensByUser($uid); goto rc1cm; p3RaT: lWO7J: goto sd0nb; PAvu0: foreach ($pushtokens as $pushtoken) { $messages[] = array("\x44\x65\166\151\x63\x65\x54\x6f\153\145\156" => $pushtoken["\x74\157\x6b\x65\x6e\x5f\x6d\163\x67\163"], "\x53\145\x6c\x65\143\x74\157\162" => $pushtoken["\163\x65\154\x65\x63\x74\157\162"], "\x41\160\160\x49\x64" => $pushtoken["\141\160\160\151\144\x5f\155\x73\x67\x73"], "\166\x65\162\142" => "\116\x6f\164\x69\x66\171\x52\145\x70\x72\157\x76\151\x73\151\x6f\x6e"); dPiNx: } goto Vz2j2; Vz2j2: ON5X7: goto nN2LV; dSqTg: } public function pushNotifyByDID($did, $message, $adapter) { goto OJ0SF; DvkLl: p1DQ6: goto qIM3a; OJ0SF: $users = $this->getSMSUserByDid($did, $adapter); goto nc53j; nc53j: foreach ($users as $user) { $this->pushNotify($user["\x75\x69\144"], $message); PHocp: } goto DvkLl; qIM3a: } public function pushNotifyByDIDWithMessageId($did, $message, $adapter, $messageId) { goto KQleO; KCsW6: foreach ($users as $user) { $this->pushNotify($user["\x75\x69\x64"], $message, $messageId); QOsha: } goto g51Ed; KQleO: $users = $this->getSMSUserByDid($did, $adapter); goto KCsW6; g51Ed: inrsx: goto p4wbP; p4wbP: } public function pushNotify($uid, $message, $messageId = null) { goto xxeUt; pkuXm: return array("\x73\x74\x61\x74\x75\163" => false, "\155\145\x73\x73\141\x67\145" => "\x69\156\166\x61\154\151\144\x20\x75\163\x65\x72"); goto GexNL; JOQ2W: $messages = array(); goto ditO_; ditO_: foreach ($pushtokens as $pushtoken) { goto B2rUr; RopbX: $smsInfo = $this->getMessageByEMID($messageId); goto V64yq; Z5aCc: $messageData["\125\x73\145\x72\104\151\163\x70\x6c\141\171\x4e\x61\x6d\145"] = $smsInfo["\146\162\x6f\155"]; goto AIIV_; B2rUr: if (!empty($pushtoken["\164\x6f\x6b\x65\156\x5f\155\163\147\163"])) { goto ohbu5; } goto hp7y6; HK2T7: $messageData["\x54\x68\162\x65\141\144\x49\144"] = $smsInfo["\x74\150\162\145\141\144\x69\144"]; goto Z5aCc; k84EA: $messageData = array("\x44\x65\x76\151\143\145\124\x6f\x6b\x65\x6e" => $pushtoken["\164\157\153\145\156\x5f\155\x73\147\163"], "\x53\x65\x6c\145\143\x74\x6f\162" => $pushtoken["\163\x65\x6c\145\143\164\x6f\162"], "\x41\x70\x70\x49\144" => $pushtoken["\141\160\x70\x69\x64\x5f\x6d\163\147\x73"], "\166\145\162\x62" => "\116\157\164\x69\x66\171\x54\145\170\164\115\145\163\x73\x61\x67\x65", "\x4d\x65\163\163\141\x67\x65" => $message); goto fZ_CZ; AIIV_: ltbMa: goto Wn07f; Wn07f: $messages[] = $messageData; goto mzk54; hp7y6: goto KF1vI; goto EMqTe; fZ_CZ: if (empty($messageId)) { goto ltbMa; } goto RopbX; V64yq: $messageData["\x42\x61\144\147\145"] = 1; goto rq3iN; rq3iN: $messageData["\x49\144"] = $smsInfo["\x65\x6d\151\x64"]; goto HK2T7; mzk54: KF1vI: goto FmgIB; EMqTe: ohbu5: goto k84EA; FmgIB: } goto ban4C; ban4C: oM3Um: goto aRq3A; GexNL: pf7Dt: goto JOQ2W; aRq3A: return $this->processPush($messages); goto RuwV5; xxeUt: $pushtokens = $this->getPushTokensByUser($uid); goto o9fQp; o9fQp: if ($pushtokens) { goto pf7Dt; } goto pkuXm; RuwV5: } private function getMessageByEMID($emid) { goto mOc1S; kp9n5: return $sth->fetch(\PDO::FETCH_ASSOC); goto ItbFs; WR4qv: $sth->execute(array("\145\155\x69\144" => $emid)); goto kp9n5; J8Fs0: $sth = $this->FreePBX->database->prepare($sql); goto WR4qv; mOc1S: $sql = "\x53\105\x4c\x45\x43\124\x20\163\155\x2e\x2a\40\x46\122\117\115\x20\x73\155\x73\x5f\155\145\163\x73\x61\147\145\163\x20\163\x6d\x20\x57\110\105\122\105\40\145\155\151\144\x20\x3d\40\72\145\155\151\x64"; goto J8Fs0; ItbFs: } public function processPush($pushArray) { goto deVE5; deVE5: $client = new \GuzzleHttp\Client(); goto kuFXh; iNN4k: return json_decode($response->getBody()); goto Eln41; kuFXh: $response = $client->request("\120\x4f\123\x54", "\x68\x74\164\x70\163\72\57\x2f\160\x6e\x6d\x2e\x63\154\157\165\144\x73\x6f\x66\x74\x70\150\157\156\x65\56\x63\157\155\x2f\160\x6e\x6d\x32\57\155\165\x6c\x74\x69\x73\x65\x6e\144", array("\152\x73\x6f\x6e" => array_values($pushArray), "\150\x74\x74\160\137\145\x72\x72\x6f\x72\x73" => false)); goto iNN4k; Eln41: } public function batchSend($resetlock = false) { goto BYCek; iNHmU: $response = $client->request("\x50\117\x53\124", "\150\164\x74\160\x73\x3a\x2f\57\x70\156\155\x2e\x63\154\x6f\x75\144\x73\157\x66\164\x70\x68\x6f\156\145\56\x63\x6f\155\x2f\160\156\155\x32\57\x6d\165\154\164\x69\163\x65\156\144", array("\152\x73\x6f\156" => array_values($messages), "\x68\164\164\160\137\145\162\x72\157\x72\163" => false)); goto Wojul; WRu_I: if (!$resetlock) { goto DZ8_l; } goto wYQ5T; eLQuH: ETtMI: goto JtTmH; VzjQy: return array("\x73\164\x61\164\165\163" => true, "\x6d\x65\x73\163\x61\147\x65" => "\161\x75\x65\x75\145\x20\x65\155\x70\164\171"); goto SB_nh; nolIf: $lock->release(); goto aYZD2; JtTmH: return array("\x73\x74\x61\164\x75\x73" => false, "\x6d\145\x73\163\x61\x67\x65" => "\141\x6c\x6c\x72\145\141\x64\171\40\162\x75\156\x6e\151\156\x67"); goto bF2Br; ha5nL: if (!empty($messages)) { goto g3vF_; } goto VzjQy; uQ5J3: WWcSV: goto ZfZ8R; ZfZ8R: EkUiC: goto nolIf; bxvLi: $client = new \GuzzleHttp\Client(); goto WRu_I; xlQej: if (!($response->getStatusCode() === 200)) { goto EkUiC; } goto edaKl; KqF4O: DZ8_l: goto qnCsk; BYCek: $lock = new LockHandler("\143\x6c\x65\141\162\154\x79\163\x70\102\x61\164\143\150\56\x6c\x6f\x63\153"); goto bxvLi; aYZD2: return array("\163\164\141\164\165\x73" => true, "\x6d\145\163\163\141\147\x65" => "\x70\x75\163\x68\40\163\145\x6e\164"); goto eLQuH; SB_nh: g3vF_: goto iNHmU; wYQ5T: $lock->release(); goto KqF4O; Wojul: dbug(sprintf("\123\145\156\164\40\x62\141\164\x63\150\40\x70\x75\163\150\40\x6e\x6f\x74\151\x66\151\x63\x61\164\151\x6f\156\163\x20\x61\156\144\40\162\145\143\x65\151\166\145\x64\40\162\x65\x73\x70\x6f\156\x73\145\x20\x63\157\x64\145\40\157\146\40\x25\163", $response->getStatusCode())); goto xlQej; edaKl: foreach ($messages as $value) { $this->delConfig($value["\153\x65\x79"], "\160\165\163\x68\161\165\145\x75\x65"); ks0pz: } goto uQ5J3; r9y9O: $messages = $this->getPushQueue(); goto ha5nL; qnCsk: if (!$lock->lock()) { goto ETtMI; } goto r9y9O; bF2Br: } public function getPushToken($uid) { return $this->getConfig($uid, "\x70\x75\163\x68\x74\x6f\153\x65\x6e\x73"); } public function addUserTokenData($uid, $data) { goto xA1CJ; gKQL4: $mergedData["\x75\x70\x64\x61\x74\x65\x64"] = time(); goto pM9_a; pM9_a: $this->setConfig($data["\x64\x65\x76\151\143\145\x5f\151\144"], $mergedData, "\160\165\163\150\164\157\153\x65\x6e\163\137" . $uid); goto SBSpy; nPbKp: $existing = is_array($existing) ? $existing : array(); goto h_dgx; SBSpy: $this->setConfig($uid, true, "\160\x75\x73\150\164\x6f\x6b\x65\156\x75\x73\145\x72\163"); goto UeVor; h_dgx: $mergedData = array_merge($existing, $data); goto gKQL4; xA1CJ: $existing = $this->getConfig($data["\x64\145\x76\x69\x63\x65\x5f\x69\x64"], "\x70\165\163\x68\x74\157\153\x65\x6e\x73\137" . $uid); goto nPbKp; UeVor: return $mergedData; goto iEir3; iEir3: } public function getPushTokensByUser($uid) { return $this->getAll("\160\165\163\150\164\x6f\153\145\x6e\163\137" . $uid); } public function getAllPushTokens() { goto UzKE0; QzRCy: $uids = $this->getAll("\x70\x75\x73\x68\x74\x6f\x6b\x65\156\165\x73\x65\162\163"); goto yqC3l; rEt63: return $final; goto ZRssC; yqC3l: foreach ($uids as $uid => $bool) { goto JIdIQ; IE2VF: piCNR: goto Yoskg; lUJN7: z0KS0: goto IE2VF; dMgsX: foreach ($tokens as $token) { goto hoxGI; xtnsP: $token["\x63\141\160\x61\x62\151\154\151\164\151\x65\163"] .= "\40"; goto N36lS; d2z_Q: kqua5: goto Ov90p; N36lS: LiQqm: goto SlTAZ; EaFnz: UiQGo: goto fSh_l; fSh_l: if (empty($token["\x63\141\160\x61\142\x69\x6c\151\x74\x69\x65\163"])) { goto LiQqm; } goto xtnsP; AaWSH: $final[] = $token; goto d2z_Q; ztLkW: $token["\165\151\x64"] = $uid; goto AaWSH; e374N: $token["\143\x61\160\x61\x62\151\x6c\151\x74\151\x65\x73"] .= "\x3c\151\x20\x63\154\x61\x73\163\75\42\x66\141\40\x66\x61\55\143\157\155\x6d\145\156\x74\x73\55\x6f\40\x66\141\x2d\x32\170\42\x3e\74\x2f\151\x3e"; goto obBYu; hoxGI: $token["\x63\x61\160\141\142\x69\154\x69\164\x69\x65\x73"] = null; goto Ra2Pi; obBYu: J00eh: goto ztLkW; Ra2Pi: if (empty($token["\x74\157\x6b\145\156\x5f\143\141\154\x6c\163"])) { goto UiQGo; } goto fbigP; fbigP: $token["\143\x61\160\141\142\x69\x6c\151\x74\151\x65\x73"] .= "\74\x69\x20\x63\154\141\x73\163\x3d\x22\x66\141\x20\x66\x61\x2d\155\157\x62\151\x6c\x65\x20\x66\x61\55\62\x78\42\76\x3c\57\151\76"; goto EaFnz; SlTAZ: if (empty($token["\164\x6f\153\x65\156\137\155\163\147\163"])) { goto J00eh; } goto e374N; Ov90p: } goto lUJN7; JIdIQ: $tokens = $this->getPushTokensByUser($uid); goto dMgsX; Yoskg: } goto NBz14; UzKE0: $final = array(); goto QzRCy; NBz14: dbjPI: goto rEt63; ZRssC: } public function clearAllUserPushTokens($uid) { goto VKToP; V0sqZ: return $this; goto bWevR; YqX_F: $this->delConfig($uid, "\160\165\163\x68\164\157\x6b\x65\156\165\x73\145\162\x73"); goto V0sqZ; VKToP: $this->delAll("\160\165\163\x68\x74\x6f\x6b\x65\x6e\163\x5f" . $uid); goto YqX_F; bWevR: } public function deletePushToken($uid, $deviceid) { goto ctv3u; QqX_A: $this->delConfig($deviceid, "\x6c\141\x73\x74\x73\155\x73\160\x6f\154\x6c\x5f" . $uid); goto sDUBs; ctv3u: $this->delConfig($deviceid, "\160\165\x73\150\x74\x6f\153\145\x6e\163\x5f" . $uid); goto QqX_A; E61mp: return $this; goto iBSgA; sDUBs: $tokens = $this->getPushTokensByUser($uid); goto J324p; J324p: if (!empty($tokens)) { goto XmfxE; } goto T1u3e; T1u3e: $this->delConfig($uid, "\160\165\x73\150\x74\157\x6b\x65\156\165\163\145\x72\163"); goto dzPCo; dzPCo: XmfxE: goto E61mp; iBSgA: } public function getPushQueue() { goto lDLR3; FhLdy: foreach ($messages as $key => $value) { goto w3kwg; xN0YE: Hg8Vu: goto sux3K; LN0u0: foreach ($pushtokens as $pushtoken) { goto FiVhK; GCHms: dbug(sprintf("\101\144\x64\151\x6e\147\40\x6d\x65\x73\x73\x61\147\145\x20\164\x6f\x20\x62\x65\40\163\145\x6e\x74\x20\x74\157\x20\x64\145\166\151\x63\145\x20\x74\x6f\153\x65\156\x20\x25\163\40\167\151\164\x68\x20\x6d\x65\x73\x73\x61\147\x65\40\x68\x61\163\x68\x20\157\x66\40\45\x73\x20\x61\x6e\x64\40\x73\155\163\40\x69\144\40\157\x66\40\x25\163\40\x74\x6f\40\x6f\165\x72\40\160\165\163\150\x20\x6e\157\164\x69\146\151\x63\x61\164\x69\157\x6e\40\x6d\x65\x73\x73\141\x67\x65\x20\x71\165\145\x75\145", $pushtoken["\x74\x6f\153\x65\x6e\x5f\x6d\163\147\163"], $messageHash, $smsInfo["\x65\x6d\x69\144"])); goto sd4wA; m_GW_: PCOLC: goto GCHms; smAxq: goto RC1Xg; goto m_GW_; FiVhK: if (!empty($pushtoken["\164\157\153\145\x6e\137\x6d\x73\x67\x73"])) { goto F9RJf; } goto S1LGS; tOzi3: if (empty($final[$messageHash])) { goto PCOLC; } goto smAxq; sd4wA: $final[$messageHash] = array("\153\x65\171" => $key, "\x44\x65\166\x69\143\x65\x54\x6f\x6b\x65\x6e" => $pushtoken["\164\x6f\x6b\145\156\x5f\155\163\147\163"], "\123\x65\x6c\x65\x63\x74\157\162" => $pushtoken["\163\x65\x6c\x65\x63\x74\x6f\x72"], "\x41\x70\160\111\x64" => $pushtoken["\141\160\x70\151\144\137\155\x73\147\163"], "\x76\x65\x72\x62" => "\116\157\x74\151\146\171\124\145\170\164\115\x65\x73\x73\x61\x67\145", "\x4d\x65\x73\163\141\147\145" => $message, "\111\x64" => $smsInfo["\145\x6d\151\144"], "\x54\x68\x72\145\141\144\111\144" => $smsInfo["\164\150\x72\x65\x61\144\x69\x64"], "\x42\141\144\x67\x65" => 1); goto v1sSa; S1LGS: goto RC1Xg; goto G3hwh; na50g: $messageHash = sha1($pushtoken["\x74\x6f\x6b\x65\156\x5f\155\163\147\x73"] . "\x2d" . $smsInfo["\145\155\x69\144"]); goto tOzi3; G3hwh: F9RJf: goto na50g; v1sSa: RC1Xg: goto OSedq; OSedq: } goto QOXmc; LQkef: $tokens = $this->getPushTokensByUser($value["\165\x69\x64"]); goto aRZbG; nZYxq: $pushtokens = $users[$value["\x75\151\x64"]]; goto i6jB6; JLtLc: $message = $value["\x6d\145\x73\x73\x61\147\x65"]; goto ZfT1B; ZfT1B: $smsInfo = $this->FreePBX->Sms->getMessageByID($value["\155\151\x64"]); goto LN0u0; hpgmW: goto Hg8Vu; goto WL06r; i6jB6: if ($pushtokens) { goto VCml0; } goto hpgmW; WL06r: VCml0: goto JLtLc; w3kwg: if ($users[$value["\165\151\144"]]) { goto XqGWw; } goto LQkef; mT2OP: XqGWw: goto nZYxq; QOXmc: Rmkia: goto xN0YE; aRZbG: $users[$value["\165\x69\x64"]] = $tokens; goto mT2OP; sux3K: } goto rMRH4; kLPby: $messages = $this->getAll("\x70\165\163\x68\161\165\x65\x75\x65"); goto Bq27Z; Bq27Z: if (is_array($messages)) { goto WZFE6; } goto Nj2Yx; TsII_: $final = array(); goto kLPby; ZSPf5: WZFE6: goto FhLdy; Nj2Yx: return array(); goto ZSPf5; rMRH4: Ut0S3: goto toR7l; toR7l: return $final; goto Fgynk; lDLR3: $users = array(); goto TsII_; Fgynk: } public function addToPushQueue($uid, $mid, $message) { goto Xh7Pr; Xh7Pr: if (!empty($this->getPushTokensByUser($uid))) { goto g5WAL; } goto g3z6E; g3z6E: dbug("\x4e\x6f\x20\x70\165\x73\x68\40\164\157\x6b\145\x6e\x73\40\146\x6f\x72\40\165\163\145\162\40\x69\144\40\157\x66\x20" . $uid . "\54\x20\163\x6b\x69\160\x70\x69\156\147\40\141\x64\144\151\x6e\147\40\x6d\x65\x73\163\x61\x67\145\x20\151\144\40" . $mid . "\x20\164\x6f\x20\164\150\x65\40\x70\x75\x73\150\40\x71\165\x65\165\x65\x2e"); goto mi5FJ; h712H: $this->setConfig($uid, array("\x75\151\144" => $uid, "\155\x69\x64" => $mid, "\155\145\163\x73\x61\147\x65" => $message), "\160\x75\x73\x68\161\x75\145\x75\145"); goto Pj5kS; I_bBB: g5WAL: goto h712H; mi5FJ: return; goto I_bBB; Pj5kS: return $this; goto LADmR; LADmR: } public function removeOldPushTokens($output = null) { goto qpvUY; nUYtR: qIcGC: goto A3k07; TQDXD: $removalTime = $date->getTimestamp(); goto cvCTu; cvCTu: foreach ($tokens as $token) { goto cxKAo; hAT57: eIn3F: goto xooKt; U3qCq: $this->deletePushToken($token["\165\151\144"], $token["\144\145\166\x69\x63\x65\x5f\x69\144"]); goto TpyM1; OjEuJ: $output->writeln(sprintf("\x52\145\x6d\157\166\151\156\147\x20\160\x75\x73\x68\40\x74\x6f\x6b\145\x6e\40\x66\157\162\x20\165\x73\x65\162\40\151\x64\40\x25\163\x20\x61\156\x64\40\x64\x65\166\151\x63\145\x20\151\x64\x20\x6f\x66\40\x25\x73\40\167\x69\x74\x68\x20\x64\x61\164\141\40\x6f\x66\x20\x25\163", $token["\x75\151\x64"], $token["\x64\145\x76\x69\x63\x65\137\151\x64"], json_encode($token))); goto U3qCq; cxKAo: if (!(isset($token["\165\160\144\141\164\145\x64"]) && $token["\x75\x70\144\x61\164\145\x64"] < $removalTime)) { goto hcBeu; } goto OjEuJ; TpyM1: hcBeu: goto hAT57; xooKt: } goto nUYtR; qpvUY: $tokens = $this->getAllPushTokens(); goto LaFQa; Zw7xA: $date->sub(new \DateInterval("\x50\x33\60\x44")); goto TQDXD; LaFQa: $date = new \DateTime(); goto Zw7xA; A3k07: } public function smsPoll() { goto QvIdv; fhIpN: foreach ($clients as $client) { goto LcUQp; MhF1b: goto XRnuN; goto t4T_F; LcUQp: if (!($client["\145\x6e\141\142\154\x65\x64"] !== "\145\x6e\x61\x62\154\x65\x64" || $client["\155\x65\x73\x73\141\147\x69\156\147"] === "\x64\151\163\141\x62\154\x65\144")) { goto fSp5x; } goto nyiXC; Ir7am: foreach ($messages as $message) { goto brc9q; uMxFx: ujdXm: goto equgy; MC3_a: goto KMSMF; goto QLcHq; qTyNg: goto KMSMF; goto uMxFx; brc9q: if (!($message["\x64\x69\x72\145\x63\x74\151\157\x6e"] !== "\x69\x6e")) { goto ujdXm; } goto qTyNg; equgy: if (!($message["\164\157"] !== $client["\163\155\163\144\151\144"])) { goto AR43j; } goto MC3_a; SRTN5: goto KMSMF; goto u674t; u674t: G8TmU: goto JkRZt; JkRZt: $this->addToPushQueue($id, $message["\151\x64"], $message["\142\x6f\x64\x79"]); goto qbikv; yvVty: if (!($message["\141\144\x61\160\164\x6f\x72"] === "\103\x6c\x65\x61\162\x6c\171\x74\x72\x75\156\x6b\151\156\x67")) { goto G8TmU; } goto SRTN5; QLcHq: AR43j: goto yvVty; qbikv: KMSMF: goto Km20E; Km20E: } goto Y6Kap; fTOsI: $id = $client["\144\x61\x74\x61"]["\151\x64"]; goto QNId3; v8zXF: goto XRnuN; goto c05fe; isKYU: XRnuN: goto WEUu6; t4T_F: Izx0o: goto Ir7am; Ga9Jj: fSp5x: goto fTOsI; c05fe: iEUCT: goto IICnp; Y6Kap: yMmco: goto isKYU; ec7gu: if (!empty($messages)) { goto Izx0o; } goto MhF1b; QNId3: if (!empty($client["\x73\155\x73\x64\x69\x64"])) { goto iEUCT; } goto v8zXF; IICnp: $messages = $this->getMessagesByUserAndDid($id, $client["\163\x6d\x73\144\x69\x64"], $lastpoll); goto ec7gu; nyiXC: goto XRnuN; goto Ga9Jj; WEUu6: } goto JUHBh; ZbLC3: $lastpoll = $this->getConfig("\x6c\141\x73\164\x63\x72\x6f\x6e\160\x6f\x6c\154"); goto uQIV2; UArCG: return $this->batchSend(); goto MsSVO; JUHBh: Np9Ni: goto UArCG; QvIdv: $clients = $this->getClientMapping(); goto ZbLC3; al1WL: $lastpoll = $lastpoll ? $lastpoll : 0; goto fhIpN; uQIV2: $this->setConfig("\x6c\x61\163\x74\x63\x72\157\x6e\x70\x6f\x6c\154", time()); goto al1WL; MsSVO: } public function validateMagicToken($user, $pass) { $saved = $this->getConfig($user, "\x6d\141\x67\x69\x63\164\157\x6b\x65\x6e\x73"); return password_verify($pass, $saved); } public function getMagicToken($user) { goto P2yZL; F8gw7: $pass = password_hash(trim($uuid), PASSWORD_DEFAULT); goto Z3zYF; P2yZL: $uuid = Uuid::uuid4()->toString(); goto F8gw7; Z3zYF: $this->setConfig($user, $pass, "\155\x61\147\x69\143\x74\x6f\x6b\x65\156\163"); goto ghWG1; ghWG1: return $uuid; goto bWsfH; bWsfH: } public function deleteMagicToken($user) { $this->deleteMagicLink($user); return $this->delConfig($user, "\x6d\141\147\151\143\x74\x6f\x6b\145\156\x73"); } public function validUUID($uuid) { goto oYYTd; oYYTd: if (!(!is_string($uuid) || preg_match("\57\x5e\133\x30\55\x39\141\55\x66\x5d\173\70\175\55\133\x30\x2d\x39\x61\55\x66\135\x7b\64\x7d\55\64\133\x30\55\71\141\x2d\x66\x5d\x7b\x33\x7d\55\133\x38\x39\x61\x62\135\x5b\x30\55\71\141\x2d\146\x5d\173\x33\175\x2d\133\60\x2d\x39\x61\55\146\135\173\61\x32\x7d\x24\57", $uuid) !== 1)) { goto N0ES5; } goto Df1LV; Df1LV: return false; goto gdW0Y; gdW0Y: N0ES5: goto QLXzg; QLXzg: return true; goto qqqhC; qqqhC: } public function getMagicLink($user) { goto kZKS0; LvyvR: return $link; goto GjmXo; VnHsQ: if ($link) { goto nZf10; } goto CkGHN; CkGHN: $link = $this->createMagicLink($user); goto Zd1jI; Zd1jI: nZf10: goto LvyvR; kZKS0: $link = $this->getConfig($user, "\155\x61\147\x69\143\114\151\x6e\153\x73"); goto VnHsQ; GjmXo: } public function createMagicLink($user) { goto gp3jr; EGix3: $exten = base64_encode($umuser["\165\163\x65\162\x6e\141\155\145"] . "\174" . $domain); goto pVngF; BhsvP: return $string; goto lX0zS; gp3jr: $tokendata = $this->FreePBX->Clearlysp->getTokenData(); goto KCbgq; hgcwT: $token = $this->getMagicToken($user); goto dUGHG; KCbgq: $domain = $tokendata["\143\x6c\x69\x65\156\x74\x73"]["\x64\157\x6d\x61\x69\156"]; goto hgcwT; pVngF: $string = sprintf("\x63\163\x63\x3a\x25\x73\72\45\x73\x40\103\x4c\x45\101\x52\114\x59\111\120", $exten, $token); goto jphOc; jphOc: $this->setConfig($user, $string, "\x6d\141\x67\151\143\114\151\156\x6b\x73"); goto BhsvP; dUGHG: $umuser = $this->FreePBX->Userman->getUserById($user); goto EGix3; lX0zS: } public function clearPushQueue() { $this->delById("\160\165\163\150\x71\x75\x65\x75\145"); return $this; } public function clearMessageCache() { $this->delById("\x6d\145\163\163\141\x67\145\143\141\143\150\145"); return $this; } public function handleRegenerateMag

Decoded(de-Obfuscated) php code

<?php

/*   __________________________________________________
    |  Built by Clearly IP Inc.                        |
    |              on 2022-04-29 15:09:29              |
    |__________________________________________________|
*/
namespace FreePBX\modules;

use BMO;
use FreePBX_Helpers;
use Exception;
use Ramsey\Uuid\Uuid;
use Swift_SendmailTransport;
use Swift_Mailer;
use Swift_Message;
use FreePBX\modules\Clearlysp\CIP\ClearlyAPI;
use FreePBX\modules\Clearlysp\CIP\Clients\RazrClient;
use FreePBX\modules\Clearlysp\BMOHooks\Usermanager as CIPUM;
use Symfony\Component\Filesystem\LockHandler;
use Symfony\Component\Console\Helper\ProgressBar;
use FreePBX\modules\Clearlysp\CIP\Functions\Firewall as CIPFW;
use FreePBX\modules\Clearlysp\CIP\Functions\Service as CIPSVC;
class Clearlysp extends FreePBX_Helpers implements BMO
{
    private $freepbx;
    public function __construct($freepbx = null)
    {
        $this->FreePBX = $freepbx;
        $this->db = $freepbx->Database;
        $this->Conf = $freepbx->Config;
        $this->um = new CIPUM($freepbx);
        $this->clearlyMirror = "https://mirror.clearlyip.com";
        $this->nodeLocation = "/var/www/html/node";
        if ($this->FreePBX->Modules->checkStatus("firewall")) {
            $this->firewall = new CIPFW($freepbx, '');
            goto sClF5;
        }
        $this->firewall = false;
        sClF5:
        $this->service = new CIPSVC($freepbx, "clearlysp");
        $this->fcache = $this->FreePBX->Cache->cloneByNamespace("clearlysp");
        $this->cache = array();
    }
    public function oobeHook()
    {
        include "/var/www/html/Oobe.class.php";
        $o = new Clearlysp\OOBE($this);
        return $o->oobeRequest();
    }
    public function getCronJob($modulename, $jobname)
    {
        $sth = $this->db->prepare("SELECT * FROM cron_jobs WHERE modulename = :modulename AND jobname = :jobname");
        $sth->execute(array(":modulename" => $modulename, ":jobname" => $jobname));
        return $sth->fetch(\PDO::FETCH_ASSOC);
    }
    public function install()
    {
        $clearlyspSMSCronJob = $this->getCronJob("clearlysp", "pollsms");
        $time = "* * * * *";
        $this->FreePBX->Job->addClass("clearlysp", "pollsms", "FreePBX\\modules\\Clearlysp\\Job", $time);
        if (!empty($clearlyspSMSCronJob)) {
            goto AjdLL;
        }
        $this->FreePBX->Job->setEnabled("clearlysp", "pollsms", true);
        AjdLL:
        $this->FreePBX->Job->addClass("clearlysp", "vpncleanup", "FreePBX\\modules\\Clearlysp\\VPNJob", "0 * * * *");
        $this->FreePBX->Job->setEnabled("clearlysp", "vpncleanup", true);
        $this->FreePBX->Job->addClass("clearlysp", "pushtokencleanup", "FreePBX\\modules\\Clearlysp\\PushCleanupJob", "0 0 * * *");
        $this->FreePBX->Job->setEnabled("clearlysp", "pushtokencleanup", true);
        outn(_("Installing/Updating Required Libraries. This may take a while..."));
        if (!(php_sapi_name() == "cli")) {
            goto YBwHr;
        }
        out("The following messages are ONLY FOR DEBUGGING. Ignore anything that says 'WARN' or is just a warning");
        YBwHr:
        $old = $this->getAll("clientmappings");
        foreach ($old as $id => $value) {
            $this->updateUserSettings($id, $value["enable"], $value["messaging"], $value["smsdid"]);
        }
        $old = $this->getAll("groupmappings");
        foreach ($old as $id => $value) {
            $this->updateGroupSettings($id, $value["enable"], $value["messaging"]);
        }
        $tokens = $this->getAll("pushtokens");
        foreach ($tokens as $uid => $token) {
            $token["device_id"] = "migrate";
            $this->addUserTokenData($uid, $token);
        }
        $pm2 = $this->FreePBX->Modules->checkStatus("pm2");
        if (!$pm2) {
            goto cVCEk;
        }
        out(_("Found PM2 module installed, installing Node Dependencies"));
        $this->FreePBX->Pm2->installNodeDependencies($this->nodeLocation, function ($data) {
            outn($data);
        }, array("NODE_ENV" => "production"));
        out('');
        out(_("Finished updating libraries!"));
        cVCEk:
        $this->syncFirewallToPort();
        $this->syncFirewallToPushServers();
        out(_("Stopping the node daemon if it is running"));
        $this->stopFreepbx();
        out(_("Starting the node daemon"));
        $this->startFreepbx();
    }
    public function uninstall()
    {
        out(_("Stopping the node daemon if it is running"));
        $this->stopFreepbx();
        $this->FreePBX->Job->remove("clearlysp", "pollsms");
        $this->FreePBX->Job->remove("clearlysp", "vpncleanup");
        $this->FreePBX->Job->remove("clearlysp", "pushtokencleanup");
        if (!$this->firewall) {
            goto ccNcp;
        }
        out(_("Removing the firewall rule."));
        $this->firewall->setServiceName("Clearly Anywhere")->removeAllRules();
        $this->vpnCleanup();
        ccNcp:
    }
    public function backup()
    {
    }
    public function restore($backup)
    {
    }
    public function doConfigPageInit($page)
    {
    }
    public function showPage()
    {
        $data = $this->getTokenData();
        if ($data) {
            $vars = json_decode($this->getApiConfig(), true);
            if (!empty($vars["clients"]["desktopCapable"])) {
                goto owv34;
            }
            $vars["clients"]["desktopCapable"] = false;
            owv34:
            $vars["settingsmsg"] = '';
            $fromemail = $this->getConfig("fromemail");
            $vars["fromemail"] = $fromemail ? $fromemail : '';
            $vars["fromplaceholder"] = $this->getSystemEmail();
            $vars["maxcontacts"] = $this->getConfig("maxcontacts");
            $vars["incrementcontacts"] = $this->getConfig("incrementcontacts");
            $tokenData = $this->getTokenData();
            $apiurl = isset($tokenData["clients"]["apiUrl"]) && !empty($tokenData["clients"]["apiUrl"]) ? $tokenData["clients"]["apiUrl"] : false;
            $domain = isset($tokenData["clients"]["domain"]) && !empty($tokenData["clients"]["domain"]) ? $tokenData["clients"]["domain"] : false;
            $needsSettings = empty($apiUrl) && empty($domain);
            if (!$needsSettings) {
                goto H9QIT;
            }
            $needsSettingsDataArray = array("needsSettingsAPIUrl" => $apiurl, "needsSettingsDomain" => $domain);
            $vars["settingsmsg"] = load_view("/var/www/html/views/needSettings.php", $needsSettingsDataArray);
            $data["settingsmsg"] = load_view("/var/www/html/views/needSettings.php", $needsSettingsDataArray);
            H9QIT:
            $data["service"] = $this->service->status();
            $parsedUrl = parse_url($data["clients"]["apiUrl"]);
            if (!(empty($parsedUrl["port"]) && !empty($parsedUrl["scheme"]))) {
                goto rzyAb;
            }
            if ($parsedUrl["scheme"] === "https") {
                $parsedUrl["port"] = 443;
                goto DV820;
            }
            if ($parsedUrl["scheme"] === "http") {
                $parsedUrl["port"] = 80;
                goto PZzhy;
            }
            PZzhy:
            DV820:
            rzyAb:
            if (!($_REQUEST["view"] === "settings")) {
                $data["freepbx"] = $this->FreePBX;
                $data["invalidSSLConfig"] = $vars["protocol"] === "https" && empty($vars["certid"]);
                $data["apiStatus"] = RazrClient::checkApiConnection($data["token"]);
                $data["portMatched"] = !empty($parsedUrl["port"]) && (string) $parsedUrl["port"] === (string) $vars["port"] ? true : false;
                return load_view("/var/www/html/views/grid.php", $data);
            }
            $vars["tokendata"] = json_encode($tokenData, JSON_PRETTY_PRINT);
            $upstreamfqdn = isset($tokenData["clients"]["apiUrl"]) ? $tokenData["clients"]["apiUrl"] : '';
            $vars["fullFQDN"] = $upstreamfqdn;
            $vars["parsedFullFQDN"] = !empty($parsedUrl["host"]) ? $parsedUrl["host"] : null;
            $vars["supportclass"] = "hidden";
            $vars["certopts"] = $this->getCertOpts();
            if (!isset($_REQUEST["advanced"])) {
                goto XG9VW;
            }
            $vars["supportclass"] = '';
            XG9VW:
            $vars["service"] = $data["service"];
            $vars["quickdialSortingOpts"] = '';
            $sortingOptions = array("extension" => "Extension Number", "usermanDisplayName" => "User Manager Display Name", "usermanFirstName" => "User Manager First Name", "usermanLastName" => "User Manager Last Name");
            $quickdialSortSelected = "usermanDisplayName";
            foreach ($sortingOptions as $sortValue => $sortName) {
                $vars["quickdialSortingOpts"] .= sprintf("<option value = \"%s\" %s>%s</option>", $sortValue, $sortValue === $quickdialSortSelected ? "selected" : '', $sortName);
            }
            $vars["welcomeEmail"] = $this->getEmailTemplate();
            $vars["adminproxytarget"] = $this->getConfig("adminproxytargetoverride");
            $vars["extprovint"] = $this->getConfig("extProvInterval");
            return load_view("/var/www/html/views/settings.php", $vars);
        }
        return load_view("/var/www/html/views/unregistered.php");
    }
    public function ajaxRequest($req, &$setting)
    {
        if (!($req === "rest")) {
            switch ($req) {
                case "addtoken":
                case "clientgrid":
                case "unmap":
                case "removeToken":
                case "removepushtokens":
                case "refreshAccount":
                case "saveSettings":
                case "support":
                case "pushtokens":
                case "serviceaction":
                case "adminProxyTargetOverride":
                case "emergencyRewriteRules":
                case "saveEmergencyRule":
                case "sendEmails":
                case "magicTokenGrid":
                case "regenerateMagicLink":
                    return true;
                default:
                    return false;
            }
            // [PHPDeobfuscator] Implied return
            return;
        }
        $setting["authenticate"] = false;
        $setting["allowremote"] = true;
        $setting["changesession"] = false;
        return true;
    }
    public function ajaxHandler()
    {
        if (!($_REQUEST["command"] === "support")) {
            if (!($_REQUEST["command"] === "magicTokenGrid")) {
                if (!($_REQUEST["command"] === "regenerateMagicLink")) {
                    if (!($_REQUEST["command"] === "sendEmails")) {
                        if (!($_REQUEST["command"] === "saveEmergencyRule")) {
                            goto I_M7m;
                        }
                        if (!($_REQUEST["type"] === "user")) {
                            if (!($_REQUEST["type"] === "group")) {
                                I_M7m:
                                if (!($_REQUEST["command"] === "emergencyRewriteRules")) {
                                    if (!($_REQUEST["command"] === "removepushtokens")) {
                                        if (!($_REQUEST["command"] === "removeToken")) {
                                            if (!($_REQUEST["command"] === "saveSettings")) {
                                                if (!($_REQUEST["command"] === "refreshAccount")) {
                                                    if (!($_REQUEST["command"] === "pushtokens")) {
                                                        if (!($_REQUEST["command"] === "addtoken")) {
                                                            if (!($_REQUEST["command"] === "unmap")) {
                                                                if (!($_REQUEST["command"] === "clientgrid")) {
                                                                    if (!($_REQUEST["command"] === "serviceaction")) {
                                                                        goto EayWV;
                                                                    }
                                                                    try {
                                                                        $this->service->performAction($_REQUEST["action"]);
                                                                        return array("status" => true);
                                                                    } catch (\Exception $e) {
                                                                        return array("status" => false, "message" => $e->getMessage());
                                                                    }
                                                                    EayWV:
                                                                    if (!($_REQUEST["command"] === "adminProxyTargetOverride")) {
                                                                        goto J2yJ8;
                                                                    }
                                                                    try {
                                                                        $this->setConfig("adminproxytargetoverride", $_REQUEST["target"]);
                                                                        return array("status" => true);
                                                                    } catch (\Exception $e) {
                                                                        return array("status" => false, "message" => $e->getMessage());
                                                                    }
                                                                    J2yJ8:
                                                                    // [PHPDeobfuscator] Implied return
                                                                    return;
                                                                }
                                                                $clients = $this->getClientMapping();
                                                                $final = array();
                                                                foreach ($clients as $client) {
                                                                    $inherited = isset($client["inherited"]) ? $client["inherited"] : false;
                                                                    $inheritedfrom = isset($client["inheritedfrom"]) ? $client["inheritedfrom"] : false;
                                                                    $final[] = array("user" => $client["data"]["displayname"], "messaging" => $client["messaging"] === "enabled", "smsdid" => $client["smsdid"], "usermanid" => $client["data"]["id"], "inherited" => $inherited, "inheritedfrom" => $inheritedfrom, "hasemail" => isset($client["data"]["email"]) && !empty($client["data"]["email"]));
                                                                }
                                                                return $final;
                                                            }
                                                            $this->unmapUser($_REQUEST["usermanuser"]);
                                                            return array("status" => true);
                                                        }
                                                        return $this->addToken($_REQUEST["token"]);
                                                    }
                                                    return $this->getAllPushTokens();
                                                }
                                                return $this->refreshTokenData();
                                            }
                                            if (!isset($_REQUEST["welcomeemail"])) {
                                                goto K5x7z;
                                            }
                                            $emailBody = $_REQUEST["welcomeemail"];
                                            $welcomeEmailTemplate = file_get_contents("/var/www/html/templates/welcome_email.tpl");
                                            if (!(md5($welcomeEmailTemplate) === md5($emailBody))) {
                                                goto e7oWu;
                                            }
                                            $emailBody = false;
                                            e7oWu:
                                            $this->setConfig("welcomeEmail", $emailBody);
                                            K5x7z:
                                            return $this->handleSaveSettings();
                                        }
                                        return $this->deleteTokenData();
                                    }
                                    $json = file_get_contents("php://input");
                                    $data = json_decode($json, true);
                                    if ($data) {
                                        foreach ($data as $item) {
                                            if (!(!isset($item["uid"]) || !isset($item["device_id"]))) {
                                                $this->deletePushToken($item["uid"], $item["device_id"]);
                                                goto kH_oc;
                                            }
                                            kH_oc:
                                        }
                                        return array("status" => true);
                                    }
                                    return array("status" => false, "message" => _("Bad request"));
                                }
                                if (!($_REQUEST["type"] === "user")) {
                                    if (!($_REQUEST["type"] === "group")) {
                                        return array();
                                    }
                                    return $this->getGroupEmergencyRewriteRules($_REQUEST["id"]);
                                }
                                return $this->getUserEmergencyRewriteRules($_REQUEST["id"]);
                            }
                            return $this->saveGroupEmergencyRule($_POST["user"], $_POST["number"], $_POST["rule"]);
                        }
                        return $this->saveUserEmergencyRule($_POST["user"], $_POST["number"], $_POST["rule"]);
                    }
                    if (!(!isset($_REQUEST["data"]) || empty($_REQUEST["data"]))) {
                        $ret = array();
                        foreach ($_REQUEST["data"] as $row) {
                            if (isset($row["usermanid"])) {
                                $ret[$row["usermanid"]] = $this->sendSetupEmail($row["usermanid"]);
                                goto U7vhW;
                            }
                            U7vhW:
                        }
                        return array("status" => true, "additionaldata" => $ret);
                    }
                    return array("status" => false, "message" => _("No users selected"), "level" => "danger");
                }
                return $this->handleRegenerateMagicLink();
            }
            return $this->handleMagicTokenGrid();
        }
        return $this->handleSupport();
    }
    public function ajaxCustomHandler()
    {
        if (!($_REQUEST["command"] === "rest")) {
            goto zP2bu;
        }
        try {
            $clearly = new ClearlyAPI($this->freepbx);
            $clearly->handleRest();
            return true;
        } catch (Exception $e) {
            header("HTTP/1.0 " . $e->getCode() . " " . $e->getMessage());
            echo $e->getMessage();
        }
        zP2bu:
    }
    public function getActionBar($request)
    {
        return array();
    }
    public function getRightNav($request)
    {
        return load_view("/var/www/html/views/rnav.php");
    }
    public function getUserCounts()
    {
        $count = $this->fcache->fetch("usercounts");
        if (!$count) {
            $permitted = $this->getClientMapping();
            $assignedC = 0;
            $inheritedC = 0;
            foreach ($permitted as $value) {
                if ($value["inherited"]) {
                    $inheritedC++;
                    goto MiHKu;
                }
                $assignedC++;
                MiHKu:
            }
            $ret = array("assigned" => $assignedC, "inherited" => $inheritedC, "total" => $assignedC + $inheritedC);
            $this->fcache->save("usercounts", $ret, 10);
            return $ret;
        }
        return $count;
    }
    public function getTokenData()
    {
        $tokenData = $this->fcache->fetch("tokendata");
        if (!$tokenData) {
            $usage = $this->getUserCounts();
            $account = $this->getAccountData();
            if ($account) {
                $account["clients"]["used"] = $usage["total"];
                $account["clients"]["assigned"] = $usage["assigned"];
                $account["clients"]["inherited"] = $usage["inherited"];
                $account["subscription"] = !empty($account["expires"]) ? $account["active"] && $account["expires"] > strtotime("now") : $account["active"];
                $account["clients"]["mobileLocationID"] = !empty($account["clients"]["mobileLocationID"]) ? $account["clients"]["mobileLocationID"] : "Unknown";
                $this->fcache->save("tokendata", $account, 60);
                return $account;
            }
            return array();
        }
        return $tokenData;
    }
    public function addToken($token)
    {
        $token = trim($token);
        $this->fcache->delete("tokendata");
        $this->setConfig("token", $token, "settings");
        $this->setConfig("account", time(), "lastapiupdate");
        $accountData = RazrClient::getAccountData($token);
        $this->updateTokenConfig($accountData);
        if (!$accountData["active"]) {
            return array("status" => false);
        }
        return array("status" => true);
    }
    public function updateTokenConfig($accountData = array())
    {
        $existingData = $this->getConfig("account", "settings");
        if (!(json_encode($accountData) !== json_encode($existingData))) {
            goto dyhwT;
        }
        dbug("Updating Clearly Anywhere configuration since it has changed");
        $this->setConfig("account", $accountData, "settings");
        dyhwT:
    }
    public static function myDialplanHooks()
    {
        return 950;
    }
    public function doDialplanHook(&$ext, $engine, $priority)
    {
        $lastApiUpdate = $this->getConfig("account", "lastapiupdate");
        if (!empty($lastApiUpdate)) {
            goto o0yeT;
        }
        $lastApiUpdate = 0;
        o0yeT:
        $now = new \DateTime();
        $now->modify("-72 hours");
        $nowTimestamp = $now->getTimestamp();
        if (!($nowTimestamp < $lastApiUpdate)) {
            $token = $this->getConfig("token", "settings");
            if (!empty($token)) {
                $this->setConfig("account", time(), "lastapiupdate");
                $accountData = RazrClient::getAccountData($token);
                if (is_array($accountData)) {
                    if (!empty($accountData["token"])) {
                        if (!empty($accountData["clients"]["total"])) {
                            $this->updateTokenConfig($accountData);
                            $this->permissionLottery();
                            // [PHPDeobfuscator] Implied return
                            return;
                        }
                        return;
                    }
                    return;
                }
                return;
            }
            return;
        }
        dbug("Skipping Clearly Anywhere license check");
        return;
    }
    public function deleteTokenData()
    {
        $this->setConfig("account", false, "settings");
        $this->setConfig("token", false, "settings");
        $this->fcache->delete("tokendata");
        return array("status" => true);
    }
    public function refreshTokenData()
    {
        $tokenData = $this->getTokenData();
        $token = isset($tokenData["token"]) ? $tokenData["token"] : false;
        if ($token) {
            $this->addToken($token);
            return array("status" => true);
        }
        return array("status" => false, "message" => _("No token set"));
    }
    public function getAccountData()
    {
        return $this->getConfig("account", "settings");
    }
    public function getClientMapping($client = '')
    {
        if (empty($client)) {
            $clients = $this->getConfig("permitted");
            $clients = is_array($clients) ? $clients : array();
            $final = array();
            foreach ($clients as $id => $client) {
                $settings = $this->getCombinedSettings($id);
                if ($settings["data"]["id"]) {
                    if ($settings["enabled"]) {
                        $final[$id] = $settings;
                        goto xXvIm;
                    }
                    goto FI2uz;
                }
                xXvIm:
                FI2uz:
            }
            return $final;
        }
        return $this->getUserSettings($client);
    }
    public function unmapUser($id)
    {
        $user = $this->getUserSettings($id);
        $this->updateUserSettings($id, "inherit", $user["messaging"], $user["smsdid"]);
        $this->permissionLottery();
        return $this;
    }
    public function syncFirewallToPort()
    {
        if (!$this->firewall) {
            goto cXyir;
        }
        $apiconf = json_decode($this->getApiConfig(), true);
        $port = $apiconf["port"];
        $this->firewall->setServiceName("Clearly Anywhere")->syncFirewallToPort($port, "tcp", array("external", "internal"));
        cXyir:
    }
    public function syncFirewallToPushServers()
    {
        if (!$this->firewall) {
            goto MhndR;
        }
        $this->firewall->removePushServersFromFirewall();
        $this->firewall->syncFirewallToPushServers();
        MhndR:
    }
    public function vpnCleanup($output = null)
    {
        $all = array();
        $ca = array();
        if ($this->firewall) {
            $networks = \FreePBX::Firewall()->getConfig("descriptions", "network");
            foreach ($networks as $ip => $desc) {
                $all[$ip][] = $desc;
                if (!(strpos($desc, base64_encode("clearlyanywhere") . "-") === 0)) {
                    goto Om_8U;
                }
                list($d, $t, $u) = explode("-", $desc, 3);
                $removalTime = time() - 1800;
                if (!($t < $removalTime)) {
                    goto ZVlMk;
                }
                $ca[$ip][] = $desc;
                ZVlMk:
                Om_8U:
            }
            foreach ($ca as $network => $entries) {
                if (!(count($all[$network]) == 1)) {
                    goto PFBAB;
                }
                if (empty($output)) {
                    goto ZBuWz;
                }
                $output->writeln(sprintf("Removing %s", $network));
                ZBuWz:
                \FreePBX::Firewall()->removeNetwork($network);
                PFBAB:
            }
            // [PHPDeobfuscator] Implied return
            return;
        }
        dbug("Firewall not found, skipping vpn cleanup");
        return;
    }
    public function getGroupMapping($group = '')
    {
        if (!empty($group)) {
            $default = array("messaging" => "disabled", "enable" => "disabled");
            $groupmap = $this->getConfig($group, "groupmappings");
            return is_array($groupmap) ? $groupmap : $default;
        }
        $clients = $this->getAll("groupmappings");
        return is_array($clients) ? $clients : array();
    }
    public function isAllowed($uid)
    {
        $default = array("enabled" => false, "messaging" => false);
        $permitted = $this->getConfig("permitted");
        if ($permitted) {
            goto rVtIP;
        }
        $permitted = $this->permissionLottery();
        rVtIP:
        return isset($permitted[$uid]) ? $permitted[$uid] : $default;
    }
    public function permissionLottery()
    {
        $tokendata = $this->getTokenData();
        $permitted = array();
        if (isset($tokendata["clients"]["total"])) {
            $enabled = $this->getUsersEnabled();
            $disabled = $this->getUsersDisabled();
            $allUsers = $this->FreePBX->Userman->getAllUsers();
            $previousPermissions = $this->getConfig("permitted");
            if (!empty($previousPermissions)) {
                goto G6NDR;
            }
            $previousPermissions = array();
            G6NDR:
            $allowed = intval($tokendata["clients"]["total"]) - count($enabled);
            foreach ($allUsers as $user) {
                $uid = $user["id"];
                if (!isset($enabled[$uid])) {
                    if (!isset($disabled[$uid])) {
                        if (!($allowed > 0)) {
                            goto wpxJq;
                        }
                        $settings = $this->getCombinedSettings($uid);
                        if (!($settings["enabled"] == "disabled")) {
                            $permitted[$uid] = $settings;
                            $allowed--;
                            wpxJq:
                            goto zdAlA;
                        }
                        goto mbWP9;
                    }
                    goto mbWP9;
                }
                $permitted[$uid] = $this->getCombinedSettings($uid);
                zdAlA:
                mbWP9:
            }
            if (!(is_array($previousPermissions) && is_array($permitted))) {
                goto ZMh_A;
            }
            $diff = array_diff(array_keys($previousPermissions), array_keys($permitted));
            if (empty($diff)) {
                goto ZghBg;
            }
            $this->setConfig(time(), $previousPermissions, "permissionHistory");
            ZghBg:
            ZMh_A:
            if (!empty($permitted)) {
                $this->updateMaxContacts($permitted);
                $this->setConfig("permitted", $permitted);
                goto iuAM8;
            }
            $this->delConfig("permitted");
            iuAM8:
            $this->fcache->delete("tokendata");
            $this->cleanPermissionHistory();
            return $permitted;
        }
        return array();
    }
    public function cleanPermissionHistory($clear = false)
    {
        if (!$clear) {
            goto Euk6l;
        }
        $this->delById("permissionHistory");
        Euk6l:
        $historyData = array_keys($this->getAll("permissionHistory"));
        $keep = array_slice($historyData, 20, 20);
        foreach ($historyData as $key) {
            if (!in_array($key, $keep)) {
                $this->delConfig($key, "permissionHistory");
                goto eNgxL;
            }
            eNgxL:
        }
    }
    public function updateDeviceContacts($extension, $contacts)
    {
        $sql = "UPDATE sip SET `data` = :maxContacts WHERE `id` = :extension AND `keyword` = :keyword";
        $sth = $this->FreePBX->Database->prepare($sql);
        $sth->execute(array(":maxContacts" => $contacts, "extension" => $extension, "keyword" => "max_contacts"));
        return $this;
    }
    public function updateMaxContacts($list)
    {
        $allModified = $this->getAll("modifiedMaxContacts");
        $maxcontacts = $this->getConfig("maxcontacts");
        $icontacts = $this->getConfig("incrementcontacts");
        $increment = $icontacts ? $icontacts : 2;
        if ($maxcontacts) {
            goto TgdVn;
        }
        $maxcontacts = 42;
        TgdVn:
        foreach ($list as $id => $data) {
            if (!isset($allModified[$id])) {
                $device = $this->FreePBX->Core->getDevice($data["data"]["default_extension"]);
                if (!(!empty($device) && $device["tech"] == "pjsip")) {
                    goto Bf_yW;
                }
                $currentMaxContacts = $device["max_contacts"];
                $contacts = $device["max_contacts"] + intval($increment);
                $contacts = $contacts < $maxcontacts ? $contacts : $maxcontacts;
                $this->updateDeviceContacts($data["data"]["default_extension"], $contacts);
                $this->FreePBX->Clearlysp->setConfig($id, $currentMaxContacts, "modifiedMaxContacts");
                Bf_yW:
                goto oCh6E;
            }
            unset($allModified[$id]);
            oCh6E:
        }
        foreach ($allModified as $id => $oldcount) {
            $this->updateDeviceContacts($id, $oldcount);
            $this->FreePBX->Clearlysp->delConfig($id, "modifiedMaxContacts");
        }
    }
    public function checkToken($token)
    {
        if (!empty($token)) {
            $tokendata = $this->getTokenData();
            return $token === $tokendata["token"];
        }
        return false;
    }
    public function pushReprovision($uid)
    {
        $pushtokens = $this->getPushTokensByUser($uid);
        if ($pushtokens) {
            $messages = array();
            foreach ($pushtokens as $pushtoken) {
                $messages[] = array("DeviceToken" => $pushtoken["token_msgs"], "Selector" => $pushtoken["selector"], "AppId" => $pushtoken["appid_msgs"], "verb" => "NotifyReprovision");
            }
            return $this->processPush($messages);
        }
        return array("status" => false, "message" => "invalid user");
    }
    public function pushNotifyByDID($did, $message, $adapter)
    {
        $users = $this->getSMSUserByDid($did, $adapter);
        foreach ($users as $user) {
            $this->pushNotify($user["uid"], $message);
        }
    }
    public function pushNotifyByDIDWithMessageId($did, $message, $adapter, $messageId)
    {
        $users = $this->getSMSUserByDid($did, $adapter);
        foreach ($users as $user) {
            $this->pushNotify($user["uid"], $message, $messageId);
        }
    }
    public function pushNotify($uid, $message, $messageId = null)
    {
        $pushtokens = $this->getPushTokensByUser($uid);
        if ($pushtokens) {
            $messages = array();
            foreach ($pushtokens as $pushtoken) {
                if (!empty($pushtoken["token_msgs"])) {
                    $messageData = array("DeviceToken" => $pushtoken["token_msgs"], "Selector" => $pushtoken["selector"], "AppId" => $pushtoken["appid_msgs"], "verb" => "NotifyTextMessage", "Message" => $message);
                    if (empty($messageId)) {
                        goto ltbMa;
                    }
                    $smsInfo = $this->getMessageByEMID($messageId);
                    $messageData["Badge"] = 1;
                    $messageData["Id"] = $smsInfo["emid"];
                    $messageData["ThreadId"] = $smsInfo["threadid"];
                    $messageData["UserDisplayName"] = $smsInfo["from"];
                    ltbMa:
                    $messages[] = $messageData;
                    goto mzk54;
                }
                mzk54:
            }
            return $this->processPush($messages);
        }
        return array("status" => false, "message" => "invalid user");
    }
    private function getMessageByEMID($emid)
    {
        $sql = "SELECT sm.* FROM sms_messages sm WHERE emid = :emid";
        $sth = $this->FreePBX->database->prepare($sql);
        $sth->execute(array("emid" => $emid));
        return $sth->fetch(\PDO::FETCH_ASSOC);
    }
    public function processPush($pushArray)
    {
        $client = new \GuzzleHttp\Client();
        $response = $client->request("POST", "https://pnm.cloudsoftphone.com/pnm2/multisend", array("json" => array_values($pushArray), "http_errors" => false));
        return json_decode($response->getBody());
    }
    public function batchSend($resetlock = false)
    {
        $lock = new LockHandler("clearlyspBatch.lock");
        $client = new \GuzzleHttp\Client();
        if (!$resetlock) {
            goto DZ8_l;
        }
        $lock->release();
        DZ8_l:
        if (!$lock->lock()) {
            return array("status" => false, "message" => "allready running");
        }
        $messages = $this->getPushQueue();
        if (!empty($messages)) {
            $response = $client->request("POST", "https://pnm.cloudsoftphone.com/pnm2/multisend", array("json" => array_values($messages), "http_errors" => false));
            dbug(sprintf("Sent batch push notifications and received response code of %s", $response->getStatusCode()));
            if (!($response->getStatusCode() === 200)) {
                goto EkUiC;
            }
            foreach ($messages as $value) {
                $this->delConfig($value["key"], "pushqueue");
            }
            EkUiC:
            $lock->release();
            return array("status" => true, "message" => "push sent");
        }
        return array("status" => true, "message" => "queue empty");
    }
    public function getPushToken($uid)
    {
        return $this->getConfig($uid, "pushtokens");
    }
    public function addUserTokenData($uid, $data)
    {
        $existing = $this->getConfig($data["device_id"], "pushtokens_" . $uid);
        $existing = is_array($existing) ? $existing : array();
        $mergedData = array_merge($existing, $data);
        $mergedData["updated"] = time();
        $this->setConfig($data["device_id"], $mergedData, "pushtokens_" . $uid);
        $this->setConfig($uid, true, "pushtokenusers");
        return $mergedData;
    }
    public function getPushTokensByUser($uid)
    {
        return $this->getAll("pushtokens_" . $uid);
    }
    public function getAllPushTokens()
    {
        $final = array();
        $uids = $this->getAll("pushtokenusers");
        foreach ($uids as $uid => $bool) {
            $tokens = $this->getPushTokensByUser($uid);
            foreach ($tokens as $token) {
                $token["capabilities"] = null;
                if (empty($token["token_calls"])) {
                    goto UiQGo;
                }
                $token["capabilities"] .= "<i class=\"fa fa-mobile fa-2x\"></i>";
                UiQGo:
                if (empty($token["capabilities"])) {
                    goto LiQqm;
                }
                $token["capabilities"] .= " ";
                LiQqm:
                if (empty($token["token_msgs"])) {
                    goto J00eh;
                }
                $token["capabilities"] .= "<i class=\"fa fa-comments-o fa-2x\"></i>";
                J00eh:
                $token["uid"] = $uid;
                $final[] = $token;
            }
        }
        return $final;
    }
    public function clearAllUserPushTokens($uid)
    {
        $this->delAll("pushtokens_" . $uid);
        $this->delConfig($uid, "pushtokenusers");
        return $this;
    }
    public function deletePushToken($uid, $deviceid)
    {
        $this->delConfig($deviceid, "pushtokens_" . $uid);
        $this->delConfig($deviceid, "lastsmspoll_" . $uid);
        $tokens = $this->getPushTokensByUser($uid);
        if (!empty($tokens)) {
            goto XmfxE;
        }
        $this->delConfig($uid, "pushtokenusers");
        XmfxE:
        return $this;
    }
    public function getPushQueue()
    {
        $users = array();
        $final = array();
        $messages = $this->getAll("pushqueue");
        if (is_array($messages)) {
            foreach ($messages as $key => $value) {
                if ($users[$value["uid"]]) {
                    goto XqGWw;
                }
                $tokens = $this->getPushTokensByUser($value["uid"]);
                $users[$value["uid"]] = $tokens;
                XqGWw:
                $pushtokens = $users[$value["uid"]];
                if ($pushtokens) {
                    $message = $value["message"];
                    $smsInfo = $this->FreePBX->Sms->getMessageByID($value["mid"]);
                    foreach ($pushtokens as $pushtoken) {
                        if (!empty($pushtoken["token_msgs"])) {
                            $messageHash = sha1($pushtoken["token_msgs"] . "-" . $smsInfo["emid"]);
                            if (empty($final[$messageHash])) {
                                dbug(sprintf("Adding message to be sent to device token %s with message hash of %s and sms id of %s to our push notification message queue", $pushtoken["token_msgs"], $messageHash, $smsInfo["emid"]));
                                $final[$messageHash] = array("key" => $key, "DeviceToken" => $pushtoken["token_msgs"], "Selector" => $pushtoken["selector"], "AppId" => $pushtoken["appid_msgs"], "verb" => "NotifyTextMessage", "Message" => $message, "Id" => $smsInfo["emid"], "ThreadId" => $smsInfo["threadid"], "Badge" => 1);
                                goto v1sSa;
                            }
                            goto RC1Xg;
                        }
                        v1sSa:
                        RC1Xg:
                    }
                    goto xN0YE;
                }
                xN0YE:
            }
            return $final;
        }
        return array();
    }
    public function addToPushQueue($uid, $mid, $message)
    {
        if (!empty($this->getPushTokensByUser($uid))) {
            $this->setConfig($uid, array("uid" => $uid, "mid" => $mid, "message" => $message), "pushqueue");
            return $this;
        }
        dbug("No push tokens for user id of " . $uid . ", skipping adding message id " . $mid . " to the push queue.");
        return;
    }
    public function removeOldPushTokens($output = null)
    {
        $tokens = $this->getAllPushTokens();
        $date = new \DateTime();
        $date->sub(new \DateInterval("P30D"));
        $removalTime = $date->getTimestamp();
        foreach ($tokens as $token) {
            if (!(isset($token["updated"]) && $token["updated"] < $removalTime)) {
                goto hcBeu;
            }
            $output->writeln(sprintf("Removing push token for user id %s and device id of %s with data of %s", $token["uid"], $token["device_id"], json_encode($token)));
            $this->deletePushToken($token["uid"], $token["device_id"]);
            hcBeu:
        }
    }
    public function smsPoll()
    {
        $clients = $this->getClientMapping();
        $lastpoll = $this->getConfig("lastcronpoll");
        $this->setConfig("lastcronpoll", time());
        $lastpoll = $lastpoll ? $lastpoll : 0;
        foreach ($clients as $client) {
            if (!($client["enabled"] !== "enabled" || $client["messaging"] === "disabled")) {
                $id = $client["data"]["id"];
                if (!empty($client["smsdid"])) {
                    $messages = $this->getMessagesByUserAndDid($id, $client["smsdid"], $lastpoll);
                    if (!empty($messages)) {
                        foreach ($messages as $message) {
                            if (!($message["direction"] !== "in")) {
                                if (!($message["to"] !== $client["smsdid"])) {
                                    if (!($message["adaptor"] === "Clearlytrunking")) {
                                        $this->addToPushQueue($id, $message["id"], $message["body"]);
                                        goto qbikv;
                                    }
                                    goto KMSMF;
                                }
                                goto KMSMF;
                            }
                            qbikv:
                            KMSMF:
                        }
                        goto isKYU;
                    }
                    goto XRnuN;
                }
                goto XRnuN;
            }
            isKYU:
            XRnuN:
        }
        return $this->batchSend();
    }
    public function validateMagicToken($user, $pass)
    {
        $saved = $this->getConfig($user, "magictokens");
        return password_verify($pass, $saved);
    }
    public function getMagicToken($user)
    {
        $uuid = Uuid::uuid4()->toString();
        $pass = password_hash(trim($uuid), PASSWORD_DEFAULT);
        $this->setConfig($user, $pass, "magictokens");
        return $uuid;
    }
    public function deleteMagicToken($user)
    {
        $this->deleteMagicLink($user);
        return $this->delConfig($user, "magictokens");
    }
    public function validUUID($uuid)
    {
        if (!(!is_string($uuid) || preg_match("/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\$/", $uuid) !== 1)) {
            return true;
        }
        return false;
    }
    public function getMagicLink($user)
    {
        $link = $this->getConfig($user, "magicLinks");
        if ($link) {
            goto nZf10;
        }
        $link = $this->createMagicLink($user);
        nZf10:
        return $link;
    }
    public function createMagicLink($user)
    {
        $tokendata = $this->FreePBX->Clearlysp->getTokenData();
        $domain = $tokendata["clients"]["domain"];
        $token = $this->getMagicToken($user);
        $umuser = $this->FreePBX->Userman->getUserById($user);
        $exten = base64_encode($umuser["username"] . "|" . $domain);
        $string = sprintf("csc:%s:%s@CLEARLYIP", $exten, $token);
        $this->setConfig($user, $string, "magicLinks");
        return $string;
    }
    public function clearPushQueue()
    {
        $this->delById("pushqueue");
        return $this;
    }
    public function clearMessageCache()
    {
        $this->delById("messagecache");
        return $this;
    }
    public function handleRegenerateMagicLink()
    {
        $id = $_REQUEST["uid"];
        $this->deleteMagicToken($id);
        $this->deleteMagicLink($id);
        return array("status" => true, "token" => $this->getMagicLink($id));
    }
    public function handleMagicTokenGrid()
    {
        $clients = $this->getClientMapping();
        $clients = $clients ? $clients : array();
        $final = array();
        foreach ($clients as $client) {
            $final[] = array("uid" => $client["data"]["id"], "username" => $client["data"]["username"], "displayname" => $client["data"]["displayname"], "extension" => $client["data"]["default_extension"], "token" => $this->getMagicLink($client["data"]["id"]));
        }
        return $final;
    }
    public function handleSaveSettings()
    {
        $vars = array("port", "protocol", "quickdialsorting");
        $upstreamreq = isset($_POST["type"]) && $_POST["type"] == "upstream";
        $tokenData = $this->getTokenData();
        if (!(isset($_POST["protocol"]) && $_POST["protocol"] === "https")) {
            goto T19mY;
        }
        $vars[] = "certid";
        T19mY:
        if (!isset($_REQUEST["fromemail"])) {
            goto gPCWM;
        }
        $from = false;
        if (!filter_var($_REQUEST["fromemail"], FILTER_VALIDATE_EMAIL)) {
            goto xYHVo;
        }
        $from = $_REQUEST["fromemail"];
        xYHVo:
        $this->setConfig("fromemail", $from);
        gPCWM:
        $maxcontacts = isset($_REQUEST["maxcontacts"]) && !empty($_REQUEST["maxcontacts"]) ? $_REQUEST["maxcontacts"] : false;
        $this->setConfig("maxcontacts", $maxcontacts);
        $this->setConfig("maxcontacts", $maxcontacts);
        foreach ($vars as $var) {
            if (!$upstreamreq) {
                if (!(!isset($_POST[$var]) || empty($_POST[$var]))) {
                }
                return array("status" => false, "message" => sprintf(_("%s not set"), $var));
            }
            goto AlwG4;
        }
        AlwG4:
        $upstreamfqdn = $tokenData["clients"]["apiUrl"];
        $upstreamdomain = $tokenData["clients"]["domain"];
        $submittedFullFQDN = $_POST["fullFQDN"];
        if (!(isset($_POST["type"]) && $_POST["type"] == "upstream")) {
            goto fIDKo;
        }
        $submittedDomain = $_POST["domain"];
        fIDKo:
        $status = true;
        $message = '';
        $settings = array();
        if (!($upstreamfqdn != $submittedFullFQDN)) {
            goto jzBE7;
        }
        dbug(sprintf("We detected an updated URL used for external access. Previous: %s, new: %s.", $upstreamfqdn, $submittedFullFQDN));
        $settings["fullfqdn"] = $submittedFullFQDN;
        jzBE7:
        if (!($upstreamreq && $upstreamdomain != $submittedDomain)) {
            goto l8jZV;
        }
        dbug(sprintf("We detected an updated domain used for external access. Previous: %s, new: %s.", $upstreamdomain, $submittedDomain));
        $settings["pbxdomain"] = $submittedDomain;
        l8jZV:
        if (empty($settings)) {
            goto V4Cku;
        }
        $ret = RazrClient::updateSettings($tokenData["token"], $settings);
        $status = $ret["status"];
        $message = $ret["body"];
        dbug("Upstream Response: " . $message);
        $this->addToken($tokenData["token"]);
        V4Cku:
        if (!($upstreamreq && !empty($settings["fullfqdn"]))) {
            if (!(isset($_POST["protocol"]) && isset($_POST["certid"]) && isset($_POST["port"]) && isset($_POST["quickdialsorting"]))) {
                goto Ou6wL;
            }
            $this->setApiConfig($_POST["protocol"], $_POST["certid"], $_POST["port"], $_POST["quickdialsorting"]);
            Ou6wL:
            return array("status" => $status, "message" => $message);
        }
        $upstreamreqParsedFQDN = parse_url($settings["fullfqdn"]);
        $upstreamreqParsedPort = isset($upstreamreqParsedFQDN["port"]) ? $upstreamreqParsedFQDN["port"] : "2267";
        $upstreamreqParsedScheme = $upstreamreqParsedFQDN["scheme"] === "https" ? "https" : "http";
        $this->setApiConfig($upstreamreqParsedScheme, '', $upstreamreqParsedPort, "usermanDisplayName");
        return array("status" => $status, "message" => $message);
    }
    public function handleSupport()
    {
        $command = $_REQUEST["supportCommand"];
        switch ($command) {
            case "clearpushqueue":
                $this->clearPushQueue();
                return array("status" => true);
            case "clearmessagecache":
                $this->clearMessageCache();
                return array("status" => true);
            case "runlottery":
                $this->permissionLottery();
                return array("status" => true);
            case "saveProxyTarget":
                $this->setConfig("proxyTarget", $_REQUEST["proxyTarget"], "proxySettings");
                $this->stopFreepbx();
                $this->startFreepbx();
                return array("status" => true);
            case "saveExtProv":
                $interval = 3600;
                if (!(isset($_REQUEST["extprovint"]) && !empty(trim($_REQUEST["extprovint"])))) {
                    goto c0jhK;
                }
                $interval = trim($_REQUEST["extprovint"]);
                c0jhK:
                $this->setConfig("extProvInterval", $interval);
                goto ZZPca;
            default:
                return array("status" => false, "message" => _("Unknown Support Command"));
        }
        ZZPca:
    }
    public function deleteMagicLink($user)
    {
        return $this->delConfig($user, "magicLinks");
    }
    public function setPort($type, $port)
    {
        if (!(!is_numeric($port) || intval($port) > 65536 || intval($port) < 1)) {
            $this->setConfig($type, $port, "ports");
            return true;
        }
        return false;
    }
    public function updateUserSettings($id, $enabled, $messaging, $did, $pageautoanswer = "disabled", $stunurl = '', $enablepark = "disabled", $parkinglot = '')
    {
        $this->delConfig($id, "userenabled");
        $this->delConfig($id, "userdisabled");
        $this->delConfig($id, "userinherit");
        switch ($enabled) {
            case "enabled":
                $this->setConfig($id, array("enabled" => $enabled, "messaging" => $messaging, "smsdid" => $did, "pageautoanswer" => $pageautoanswer, "stunurl" => $stunurl, "enablepark" => $enablepark, "parkinglot" => $parkinglot), "userenabled");
                goto EnamH;
            case "disabled":
                $this->setConfig($id, array("enabled" => $enabled, "messaging" => $messaging, "smsdid" => $did, "pageautoanswer" => $pageautoanswer, "stunurl" => $stunurl, "enablepark" => $enablepark, "parkinglot" => $parkinglot), "userdisabled");
                goto EnamH;
            case "inherit":
                $this->setConfig($id, array("enabled" => $enabled, "messaging" => $messaging, "smsdid" => $did, "pageautoanswer" => $pageautoanswer, "stunurl" => $stunurl, "enablepark" => $enablepark, "parkinglot" => $parkinglot), "userinherit");
                goto EnamH;
            default:
                goto EnamH;
        }
        EnamH:
        $this->permissionLottery();
        return $this;
    }
    public function getUsersEnabled()
    {
        return $this->getAll("userenabled");
    }
    public function getUsersDisabled()
    {
        return $this->getAll("userdisabled");
    }
    public function updateGroupSettings($id, $enabled, $messaging, $pageautoanswer = "disabled", $stunurl = '', $enablepark = "disabled", $parkinglot = '')
    {
        $this->delConfig($id, "groupenabled");
        if (!($enabled === "enabled")) {
            goto sfrba;
        }
        $this->setConfig($id, array("enabled" => $enabled, "messaging" => $messaging, "pageautoanswer" => $pageautoanswer, "stunurl" => $stunurl, "enablepark" => $enablepark, "parkinglot" => $parkinglot), "groupenabled");
        sfrba:
        $this->permissionLottery();
        return $this;
    }
    public function getUserSettings($id)
    {
        $defaults = array("enabled" => "inherit", "messaging" => "inherit", "smsdid" => '', "inherited" => false, "quickdial" => array(), "emergency_rewrite" => "inherit", "emergency_rewrite_rules" => array(), "pageautoanswer" => "inherit", "stunurl" => "inherit");
        if (!empty($id)) {
            $user = $this->FreePBX->Userman->getUserByID($id);
            $enabled = $this->getConfig($id, "userenabled");
            if (!$enabled) {
                goto Bn8WM;
            }
            $out = $enabled;
            Bn8WM:
            $disabled = $this->getConfig($id, "userdisabled");
            if (!$disabled) {
                goto yhTcT;
            }
            $out = $disabled;
            yhTcT:
            $inherit = $this->getConfig($id, "userinherit");
            if (!$inherit) {
                goto J0Jlc;
            }
            $out = $inherit;
            $out["inherited"] = true;
            J0Jlc:
            foreach ($defaults as $key => $value) {
                if (!(!isset($out[$key]) || empty($out[$key]))) {
                    goto oDwx2;
                }
                $out[$key] = $value;
                oDwx2:
            }
            $out["inherited"] = isset($out["inherited"]) ? $out["inherited"] : false;
            $out["data"] = array();
            $umfields = array("id", "username", "displayname", "fname", "lname", "default_extension", "email");
            foreach ($umfields as $field) {
                $out["data"][$field] = isset($user[$field]) ? $user[$field] : '';
            }
            $out["quickdial"] = $this->getConfig($id, "quickdial");
            $emergency_rewrite = $this->getConfig($id, "emergency_rewrite");
            $emergency_rewrite_rules = $this->getConfig($id, "emergency_rewrite_rules");
            $out["emergency_rewrite_rules"] = $emergency_rewrite_rules ? $emergency_rewrite_rules : array();
            $out["emergency_rewrite"] = $emergency_rewrite ? $emergency_rewrite : "inherit";
            return $out;
        }
        return $defaults;
    }
    public function getGroupSettings($id = null)
    {
        $defaults = array("enabled" => "disabled", "messaging" => "disabled", "pageautoanswer" => "disabled", "stunurl" => '', "enablepark" => "disabled", "parkinglot" => '');
        if (!empty($id)) {
            $config = $this->getConfig($id, "groupenabled");
            if (!$config) {
                return $defaults;
            }
            foreach ($defaults as $key => $value) {
                if (isset($config[$key])) {
                    goto CDDyN;
                }
                $config[$key] = $value;
                CDDyN:
            }
            return $config;
        }
        return $defaults;
    }
    public function getCombinedSettings($id)
    {
        $usersettings = $this->getUserSettings($id);
        if (!($usersettings["enabled"] !== "inherit" && $usersettings["messaging"] !== "inherit")) {
            goto jv4r7;
        }
        $usersettings["inherited"] = false;
        jv4r7:
        $groups = $this->FreePBX->Userman->getGroupsByID($id);
        if (empty($groups) && $usersettings["enabled"] === "inherit") {
            $usersettings["enabled"] = "disabled";
            $usersettings["messaging"] = "disabled";
            $usersettings["inherited"] = false;
            $usersettings["pageautoanswer"] = "inherit";
            $usersettings["stunurl"] = "inherit";
            $usersettings["enablepark"] = "inherit";
            $usersettings["parkinglot"] = "inherit";
            goto Ynbb4;
        }
        $lastpriority = 0;
        foreach ($groups as $group) {
            $config = $this->getGroupSettings($group);
            $currentGroup = $this->FreePBX->Userman->getGroupByGID($group);
            $currentpriority = $currentGroup["priority"];
            if (!($usersettings["enabled"] === "inherit")) {
                goto gj3Ai;
            }
            $usersettings["enabled"] = $config["enabled"];
            $usersettings["inherited"] = true;
            $usersettings["inheritedfrom"] = $group;
            gj3Ai:
            $settinglist = array("messaging", "pageautoanswer", "stunurl", "enablepark", "parkinglot");
            foreach ($settinglist as $key) {
                if (!(!empty($usersettings[$key]) && $usersettings[$key] !== "inherit")) {
                    if (!($currentpriority >= $lastpriority)) {
                        goto wYSOi;
                    }
                    $usersettings[$key] = $config[$key];
                    wYSOi:
                    goto bohec;
                }
                bohec:
            }
            $lastpriority = $currentpriority;
        }
        Ynbb4:
        return $usersettings;
    }
    public function usermanDelGroup($id, $display, $data)
    {
        return $this->um->delGroup($id, $display, $data);
    }
    public function usermanAddGroup($id, $display, $data)
    {
        return $this->um->addGroup($id, $display, $data);
    }
    public function usermanUpdateGroup($id, $display, $data)
    {
        return $this->um->updateGroup($id, $display, $data);
    }
    public function usermanDelUser($id, $display, $data)
    {
        return $this->um->delUser($id, $display, $data);
    }
    public function usermanAddUser($id, $display, $data)
    {
        return $this->um->addUser($id, $display, $data);
    }
    public function usermanUpdateUser($id, $display, $data)
    {
        return $this->um->updateUser($id, $display, $data);
    }
    public function usermanShowPage()
    {
        return $this->um->showPage();
    }
    public function usermanUserDetails($user)
    {
        return $this->um->userDetails($user);
    }
    public function usermanAddContactInfo($user)
    {
        return $this->um->addContactInfo($user);
    }
    public function startFreepbx($output = null)
    {
        exec("node -v > /dev/null 2>&1", $out, $ret);
        if (!($ret !== 0)) {
            if ($this->FreePBX->Modules->checkStatus("pm2")) {
                $status = $this->FreePBX->Pm2->getStatus("clearlysp");
                if (!($status["pm2_env"]["status"] == "online")) {
                    if (!is_object($output)) {
                        goto T1oAl;
                    }
                    $output->writeln(_("Starting Clearly Anywhere daemon"));
                    T1oAl:
                    $this->FreePBX->Pm2->start("clearlysp", "/var/www/html/node/build/bundle.js");
                    if (!is_object($output)) {
                        goto HsT1P;
                    }
                    $progress = new ProgressBar($output, 0);
                    $progress->setFormat("[%bar%] %elapsed%");
                    $progress->start();
                    HsT1P:
                    $i = 0;
                    al9zg:
                    if (!true) {
                        goto x2Jak;
                    }
                    $data = $this->FreePBX->Pm2->getStatus("clearlysp");
                    if (!(!empty($data) && $data["pm2_env"]["status"] == "online")) {
                        if (!is_object($output)) {
                            goto RfvFH;
                        }
                        $progress->setProgress($i);
                        RfvFH:
                        $i++;
                        usleep(100000);
                        goto al9zg;
                    }
                    if (!is_object($output)) {
                        goto bAKhj;
                    }
                    $progress->finish();
                    bAKhj:
                    x2Jak:
                    if (!is_object($output)) {
                        goto uXdHw;
                    }
                    $output->writeln('');
                    uXdHw:
                    if (empty($data)) {
                        if (!is_object($output)) {
                            goto AjFZp;
                        }
                        $output->write("<error>" . _("Failed to run: Softphone Daemon'") . "</error>");
                        AjFZp:
                        return false;
                    }
                    $this->FreePBX->Pm2->reset("clearlysp");
                    if (!is_object($output)) {
                        goto a9PGp;
                    }
                    $output->writeln(sprintf(_("Started Softphone Daemon. PID is %s"), $data["pid"]));
                    a9PGp:
                    return $data["pid"];
                }
                if (!is_object($output)) {
                    goto SZf3P;
                }
                $output->writeln(sprintf(_("Softphone daemon has already been running on PID %s for %s"), $status["pid"], $status["pm2_env"]["created_at_human_diff"]));
                SZf3P:
                return $status["pid"];
            }
            if (is_object($output)) {
                $output->writeln(_("PM2 is not installed or enabled, unable to start Softphone daemon."));
                goto CdZkN;
            }
            outn(_("PM2 is not installed or enabled, unable to start Softphone daemon"));
            CdZkN:
            return;
        }
        if (is_object($output)) {
            $output->writeln(_("Node.js is not installed."));
            goto gL3f4;
        }
        outn(_("Node.js is not enabled."));
        gL3f4:
        return;
    }
    public function stopFreepbx($output = null)
    {
        if ($this->FreePBX->Modules->checkStatus("pm2")) {
            $data = $this->FreePBX->Pm2->getStatus("clearlysp");
            if (!(empty($data) || $data["pm2_env"]["status"] != "online")) {
                if (!is_object($output)) {
                    goto CcdCE;
                }
                $output->writeln(_("Stopping Softphone Daemon"));
                CcdCE:
                $this->FreePBX->Pm2->stop("clearlysp");
                if (!is_object($output)) {
                    goto OetBU;
                }
                $progress = new ProgressBar($output, 0);
                $progress->setFormat("[%bar%] %elapsed%");
                $progress->start();
                OetBU:
                $i = 0;
                AHBfh:
                if (!true) {
                    goto gC4vk;
                }
                $data = $this->FreePBX->Pm2->getStatus("clearlysp");
                if (!(!empty($data) && $data["pm2_env"]["status"] != "online")) {
                    if (!is_object($output)) {
                        goto IiK2m;
                    }
                    $progress->setProgress($i);
                    IiK2m:
                    $i++;
                    usleep(100000);
                    goto AHBfh;
                }
                if (!is_object($output)) {
                    goto SYdyA;
                }
                $progress->finish();
                SYdyA:
                gC4vk:
                if (!is_object($output)) {
                    goto in0T_;
                }
                $output->writeln('');
                in0T_:
                $data = $this->FreePBX->Pm2->getStatus("clearlysp");
                if (empty($data) || $data["pm2_env"]["status"] != "online") {
                    if (!is_object($output)) {
                        goto rJjhY;
                    }
                    $output->writeln(sprintf(_("Stopped %s Daemon"), $this->getBrandName()


Malware detection & removal plugin for WordPress

(C)2020 Wordpress Doctor All rights reserved.