Japanese English

PHP 難読化コードの復元・デコード

Wordpress 等でのPHPのマルウェア・ウィルス・改ざんコードをデコードして難読化をオンラインで解除し、
元の読みやすいコードに戻し解読できます。

※すべての難読化コードを解除できるわけではございませんのでご理解とご了承をお願いいたします。

下記のコードを難読化解除しました

<?php /* __________________________________________________ | Built by Clearly IP Inc. | | on 2023-01-02 21:42:57 | |__________________________________________________| */ namespace FreePBX\modules; use BMO; use FreePBX_Helpers; use Exception; use Ramsey\Uuid\Uuid; use Swift_SendmailTransport; us...



難読化されたPHPコード

<?php
/*   __________________________________________________
    |  Built by Clearly IP Inc.                        |
    |              on 2023-01-02 21:42:57              |
    |__________________________________________________|
*/
 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 w16P8; HisyS: $this->um = new CIPUM($freepbx); goto vOBpw; vOBpw: $this->clearlyMirror = "\x68\x74\164\x70\163\x3a\57\x2f\155\x69\x72\x72\x6f\x72\56\x63\x6c\145\141\162\154\171\151\x70\x2e\x63\x6f\x6d"; goto JV1Pb; U2eZO: goto JC8V2; goto q6_A_; TqAdf: if ($this->FreePBX->Modules->checkStatus("\146\x69\x72\145\167\x61\x6c\154")) { goto P0WqW; } goto gsAN5; tyAc1: $this->service = new CIPSVC($freepbx, "\143\x6c\x65\141\162\154\x79\x73\160"); goto olSnp; gsAN5: $this->firewall = false; goto U2eZO; qoP1G: JC8V2: goto tyAc1; w16P8: $this->FreePBX = $freepbx; goto KptkB; XK2vp: $this->cache = array(); goto MNo6r; JV1Pb: $this->nodeLocation = __DIR__ . "\x2f\x6e\157\x64\145"; goto TqAdf; MqkfU: $this->Conf = $freepbx->Config; goto HisyS; Qd96W: $this->firewall = new CIPFW($freepbx, ''); goto qoP1G; KptkB: $this->db = $freepbx->Database; goto MqkfU; olSnp: $this->fcache = $this->FreePBX->Cache->cloneByNamespace("\x63\x6c\x65\x61\x72\154\171\x73\x70"); goto XK2vp; q6_A_: P0WqW: goto Qd96W; MNo6r: } public function oobeHook() { goto kzu6t; kzu6t: include __DIR__ . "\57\117\x6f\142\145\x2e\143\154\x61\163\163\x2e\160\150\x70"; goto UayFW; UayFW: $o = new Clearlysp\OOBE($this); goto UmS5w; UmS5w: return $o->oobeRequest(); goto J2Hz3; J2Hz3: } public function getCronJob($modulename, $jobname) { goto UWi4l; y4KFY: return $sth->fetch(\PDO::FETCH_ASSOC); goto yCnh6; aFCk6: $sth->execute(array("\x3a\155\x6f\144\x75\x6c\145\x6e\x61\155\x65" => $modulename, "\72\152\x6f\142\156\x61\155\x65" => $jobname)); goto y4KFY; UWi4l: $sth = $this->db->prepare("\x53\105\114\x45\103\124\x20\x2a\40\106\122\117\x4d\40\143\x72\157\x6e\137\152\x6f\x62\x73\x20\x57\x48\105\122\x45\x20\155\157\x64\165\154\x65\156\x61\x6d\x65\x20\75\40\x3a\155\x6f\144\165\x6c\145\x6e\x61\x6d\x65\x20\101\x4e\104\40\x6a\157\142\x6e\141\x6d\x65\40\75\40\72\x6a\x6f\x62\x6e\x61\155\x65"); goto aFCk6; yCnh6: } public function install() { goto jHXah; zez4k: RVpTJ: goto khZqg; ahDxa: $time = "\x2a\x20\52\40\x2a\40\x2a\40\x2a"; goto Kiu8r; qenGO: $this->FreePBX->Job->addClass("\143\x6c\145\x61\x72\x6c\171\x73\x70", "\x76\160\x6e\x63\x6c\x65\141\156\x75\160", "\x46\x72\x65\145\120\x42\x58\x5c\x6d\157\144\165\154\145\163\134\x43\x6c\x65\141\x72\154\x79\163\x70\134\x56\120\x4e\112\x6f\142", "\60\40\x2a\x20\52\x20\x2a\x20\52"); goto hPkC3; XOId2: $pm2 = $this->FreePBX->Modules->checkStatus("\x70\155\x32"); goto zgl2O; uj0wP: OysXz: goto twxK9; Us9Fh: $this->syncFirewallToPort(); goto WXDqf; zgl2O: if (!$pm2) { goto KQpR8; } goto OL7kq; sdti5: $this->FreePBX->Job->setEnabled("\x63\x6c\x65\141\162\x6c\x79\x73\160", "\160\157\154\x6c\163\155\x73", true); goto sqzks; OL7kq: out(_("\106\157\165\x6e\x64\x20\120\115\62\40\x6d\x6f\x64\x75\x6c\x65\x20\151\x6e\163\x74\x61\154\154\145\144\54\x20\x69\x6e\x73\164\x61\154\154\151\x6e\x67\40\116\x6f\x64\145\40\x44\x65\x70\145\x6e\144\x65\156\143\x69\145\x73")); goto E2fL8; E2fL8: $this->FreePBX->Pm2->installNodeDependencies($this->nodeLocation, function ($data) { outn($data); }, array("\x4e\x4f\x44\105\137\x45\x4e\126" => "\x70\x72\157\144\x75\143\164\x69\x6f\x6e")); goto H0xGv; th7mM: $this->startFreepbx(); goto NvV07; uatbg: KQpR8: goto Us9Fh; mx1yG: if (!(php_sapi_name() == "\143\154\151")) { goto RVpTJ; } goto jw7Wn; uAalE: e1FJM: goto XOId2; onKTN: $this->FreePBX->Job->setEnabled("\143\154\145\x61\162\154\171\x73\x70", "\x70\x75\x73\150\164\x6f\153\x65\156\x63\154\x65\x61\156\x75\160", true); goto Pm7aE; twxK9: $old = $this->getAll("\x67\162\x6f\165\160\155\141\x70\160\x69\x6e\147\163"); goto aD7pV; EHS2M: $tokens = $this->getAll("\x70\x75\163\150\x74\157\x6b\145\x6e\163"); goto duzgS; GaA4p: out(_("\x53\x74\157\x70\160\151\x6e\147\40\x74\150\x65\40\x6e\x6f\144\145\40\144\x61\145\x6d\x6f\156\40\x69\x66\40\151\164\40\151\163\40\162\165\156\156\x69\156\147")); goto f_ahg; aD7pV: foreach ($old as $id => $value) { $this->updateGroupSettings($id, $value["\x65\156\141\x62\154\x65"], $value["\x6d\145\163\163\141\x67\151\x6e\x67"]); Ew46P: } goto I1u72; H0xGv: out(''); goto UdTCK; Kiu8r: $this->FreePBX->Job->addClass("\x63\154\x65\x61\162\x6c\x79\163\x70", "\x70\157\154\154\163\x6d\163", "\x46\x72\x65\145\x50\x42\130\134\x6d\157\x64\165\154\x65\163\x5c\103\x6c\x65\x61\162\154\x79\163\160\x5c\112\157\x62", $time); goto sdti5; hPkC3: $this->FreePBX->Job->setEnabled("\x63\x6c\145\x61\162\154\171\163\160", "\x76\160\x6e\143\154\145\x61\156\165\x70", true); goto WAqK0; khZqg: $old = $this->getAll("\143\154\151\145\156\x74\x6d\x61\160\x70\x69\x6e\x67\163"); goto t3zms; sqzks: ewf29: goto qenGO; WAqK0: $this->FreePBX->Job->addClass("\x63\154\x65\x61\162\154\171\x73\x70", "\160\165\x73\x68\164\x6f\153\145\156\143\x6c\x65\x61\x6e\x75\160", "\106\x72\145\x65\120\x42\x58\134\x6d\157\144\x75\154\x65\x73\134\x43\x6c\x65\141\162\154\x79\x73\x70\134\x50\165\163\x68\x43\x6c\x65\x61\x6e\x75\160\112\157\142", "\60\40\60\x20\52\40\52\x20\x2a"); goto onKTN; duzgS: foreach ($tokens as $uid => $token) { goto T3XkL; g0FJb: pOwl2: goto ZSWy2; U7imW: $this->addUserTokenData($uid, $token); goto g0FJb; T3XkL: $token["\144\x65\166\x69\143\145\x5f\x69\x64"] = "\155\151\147\162\x61\164\145"; goto U7imW; ZSWy2: } goto uAalE; wolaR: if (!empty($clearlyspSMSCronJob)) { goto ewf29; } goto ahDxa; t3zms: foreach ($old as $id => $value) { $this->updateUserSettings($id, $value["\x65\x6e\x61\x62\154\x65"], $value["\x6d\x65\x73\163\x61\x67\151\156\x67"], $value["\163\155\163\144\x69\144"]); MAMiS: } goto uj0wP; jHXah: $clearlyspSMSCronJob = $this->getCronJob("\x63\x6c\145\x61\162\x6c\171\x73\x70", "\x70\157\154\x6c\x73\155\163"); goto wolaR; Pm7aE: outn(_("\111\x6e\163\x74\141\154\154\151\156\147\x2f\x55\160\x64\x61\164\x69\x6e\147\40\x52\145\161\x75\x69\162\145\x64\40\114\151\x62\x72\x61\x72\x69\145\163\x2e\x20\124\x68\x69\163\x20\x6d\141\171\40\164\141\x6b\x65\40\x61\x20\x77\150\151\x6c\x65\x2e\x2e\x2e")); goto mx1yG; UdTCK: out(_("\106\x69\156\151\x73\x68\x65\144\x20\x75\160\144\141\x74\x69\x6e\x67\x20\154\x69\x62\x72\x61\162\x69\x65\163\41")); goto uatbg; I1u72: romr6: goto EHS2M; hc14k: out(_("\x53\x74\141\x72\164\151\156\147\40\x74\150\145\40\156\x6f\144\x65\40\x64\x61\145\x6d\157\156")); goto th7mM; WXDqf: $this->syncFirewallToPushServers(); goto GaA4p; jw7Wn: out("\x54\150\145\x20\x66\157\154\154\x6f\167\x69\x6e\147\x20\155\145\163\x73\141\x67\145\163\x20\x61\162\x65\x20\x4f\116\114\131\40\x46\117\122\x20\x44\105\102\125\107\107\111\x4e\x47\56\40\111\x67\156\157\162\145\x20\x61\x6e\x79\164\x68\x69\156\x67\x20\x74\x68\141\164\40\x73\141\171\x73\x20\x27\127\x41\122\116\47\40\157\x72\40\151\163\x20\x6a\165\163\164\40\x61\x20\167\141\162\x6e\x69\x6e\147"); goto zez4k; f_ahg: $this->stopFreepbx(); goto hc14k; NvV07: } public function uninstall() { goto eDbF4; eE2vz: QEX7c: goto dcrrC; Ib8nJ: $this->FreePBX->Job->remove("\143\x6c\145\141\x72\154\x79\163\x70", "\166\160\x6e\143\154\145\x61\x6e\x75\x70"); goto okprB; qPJtP: out(_("\122\x65\x6d\x6f\166\151\156\147\x20\164\x68\145\x20\146\x69\162\145\167\x61\154\x6c\40\x72\165\x6c\x65\56")); goto Big8Q; bM1MO: if (!$this->firewall) { goto QEX7c; } goto qPJtP; fB82B: $this->FreePBX->Job->remove("\x63\x6c\x65\141\x72\154\x79\x73\x70", "\x70\157\x6c\154\163\155\163"); goto Ib8nJ; Big8Q: $this->firewall->setServiceName("\103\154\x65\141\x72\154\x79\40\x41\156\171\x77\x68\145\162\x65")->removeAllRules(); goto jr9ic; jr9ic: $this->vpnCleanup(); goto eE2vz; okprB: $this->FreePBX->Job->remove("\143\154\x65\x61\162\x6c\x79\x73\160", "\160\x75\x73\x68\164\x6f\x6b\x65\156\143\x6c\x65\141\x6e\x75\x70"); goto bM1MO; eDbF4: out(_("\123\164\x6f\x70\160\151\x6e\x67\40\164\x68\145\x20\156\157\x64\x65\x20\144\x61\145\x6d\157\156\x20\151\146\40\x69\x74\x20\x69\x73\40\x72\x75\156\156\151\156\x67")); goto bz1IU; bz1IU: $this->stopFreepbx(); goto fB82B; dcrrC: } public function backup() { } public function restore($backup) { } public function doConfigPageInit($page) { } public function showPage() { goto oew0N; FANzZ: goto GsP1x; goto rWox7; kwYpz: $parsedUrl["\160\157\x72\164"] = 80; goto XrohG; grz29: $data["\x73\x65\x72\166\x69\143\145"] = $this->service->status(); goto gI1qT; GOrsA: $vars["\146\x72\x6f\155\x65\x6d\x61\151\154"] = $fromemail ? $fromemail : ''; goto Q9z7c; fAZM1: $upstreamfqdn = isset($tokenData["\x63\x6c\151\145\156\x74\163"]["\x61\160\151\x55\162\x6c"]) ? $tokenData["\143\154\x69\x65\156\164\x73"]["\141\160\151\125\162\154"] : ''; goto XwzuG; Hy3Pk: jYh_9: goto Q7Btc; wQ7vk: if ($parsedUrl["\x73\143\150\145\155\x65"] === "\150\x74\164\160") { goto BYhMY; } goto Zo3S7; fMGy4: $domain = isset($tokenData["\143\154\151\x65\x6e\164\163"]["\x64\x6f\x6d\x61\151\156"]) && !empty($tokenData["\143\x6c\151\145\x6e\164\x73"]["\144\x6f\x6d\x61\151\156"]) ? $tokenData["\143\x6c\x69\x65\x6e\164\163"]["\x64\x6f\155\x61\151\x6e"] : false; goto fbREb; Q7Btc: $parsedUrl["\x70\157\162\x74"] = 443; goto FANzZ; z22Dt: $vars["\164\157\153\x65\156\144\141\x74\x61"] = json_encode($tokenData, JSON_PRETTY_PRINT); goto fAZM1; Q9z7c: $vars["\146\x72\x6f\x6d\160\154\141\x63\145\150\157\x6c\144\145\162"] = $this->getSystemEmail(); goto fUkyl; Hqm_L: if (!isset($_REQUEST["\x61\144\x76\x61\x6e\143\145\x64"])) { goto FYs4d; } goto NLbzi; CARc2: $data["\x66\x72\x65\145\x70\x62\x78"] = $this->FreePBX; goto UtMZk; TBAtL: $vars["\161\165\151\x63\153\144\151\141\x6c\x53\x6f\162\x74\151\x6e\x67\117\x70\x74\x73"] = ''; goto Rr6wz; k2rIe: $vars = json_decode($this->getApiConfig(), true); goto xB13K; dn2ox: $needsSettingsDataArray = array("\156\145\x65\x64\163\123\145\164\x74\x69\156\147\163\x41\120\111\125\162\x6c" => $apiurl, "\156\145\145\x64\x73\123\x65\x74\164\151\x6e\x67\x73\x44\x6f\x6d\x61\151\156" => $domain); goto U0gjp; DwENG: $vars["\x65\170\164\x70\162\157\166\x69\x6e\164"] = $this->getConfig("\x65\170\164\120\x72\x6f\x76\111\x6e\164\x65\x72\x76\141\x6c"); goto hJppl; y_F1S: $vars["\x63\145\162\164\x6f\x70\164\163"] = $this->getCertOpts(); goto Hqm_L; NLbzi: $vars["\x73\165\160\x70\157\162\164\x63\154\x61\x73\163"] = ''; goto wrZBf; UtMZk: $data["\151\156\166\141\x6c\x69\x64\x53\123\x4c\103\x6f\x6e\x66\151\147"] = $vars["\x70\x72\157\164\157\x63\x6f\x6c"] === "\150\164\164\160\x73" && empty($vars["\143\145\x72\x74\x69\144"]); goto AvhKI; U0gjp: $vars["\x73\x65\x74\x74\151\x6e\x67\163\x6d\x73\147"] = load_view(__DIR__ . "\57\166\x69\145\x77\x73\x2f\156\x65\145\x64\123\x65\164\x74\151\x6e\x67\x73\56\160\x68\160", $needsSettingsDataArray); goto aOHym; iqRTp: if ($parsedUrl["\163\x63\150\x65\155\145"] === "\x68\x74\x74\160\163") { goto jYh_9; } goto wQ7vk; oew0N: $data = $this->getTokenData(); goto ulRfJ; p6Gm0: foreach ($sortingOptions as $sortValue => $sortName) { $vars["\161\165\151\x63\153\x64\151\x61\154\x53\157\162\x74\x69\156\147\117\160\164\163"] .= sprintf("\74\x6f\x70\164\x69\157\156\40\166\x61\154\x75\145\x20\75\40\42\45\x73\42\x20\45\163\76\45\163\x3c\x2f\157\160\x74\x69\x6f\156\76", $sortValue, $sortValue === $quickdialSortSelected ? "\x73\145\x6c\x65\143\x74\145\144" : '', $sortName); Nndl3: } goto wOb8n; ulRfJ: if ($data) { goto dBpci; } goto hZ7pB; fpYxr: $fromemail = $this->getConfig("\146\x72\157\155\145\x6d\141\x69\154"); goto GOrsA; N_XBa: if (!(empty($parsedUrl["\x70\x6f\162\164"]) && !empty($parsedUrl["\163\143\150\x65\x6d\x65"]))) { goto kde7B; } goto iqRTp; yXg0a: $vars["\160\141\x72\163\145\144\x46\165\154\154\106\x51\x44\x4e"] = !empty($parsedUrl["\x68\157\163\x74"]) ? $parsedUrl["\150\x6f\x73\x74"] : null; goto bNMFx; CzSiF: $quickdialSortSelected = "\165\163\x65\162\155\x61\156\104\x69\163\x70\x6c\141\171\116\x61\x6d\145"; goto p6Gm0; AvhKI: $data["\x61\x70\x69\x53\x74\141\x74\x75\163"] = RazrClient::checkApiConnection($data["\x74\157\153\x65\x6e"]); goto YIU2R; bNMFx: $vars["\163\165\160\160\x6f\x72\x74\x63\x6c\x61\163\163"] = "\150\x69\144\144\145\156"; goto y_F1S; bk_b9: $vars["\x73\145\x74\x74\151\x6e\147\163\155\x73\147"] = ''; goto fpYxr; hZ7pB: return load_view(__DIR__ . "\x2f\x76\x69\x65\x77\x73\57\165\x6e\162\x65\147\x69\x73\164\145\x72\145\x64\x2e\x70\150\x70"); goto JaAB5; wOb8n: FH4wP: goto MVjvz; XwzuG: $vars["\x66\x75\x6c\154\x46\121\x44\116"] = $upstreamfqdn; goto yXg0a; cL1gv: zhurf: goto grz29; EDq2v: $apiurl = isset($tokenData["\x63\154\x69\145\156\164\x73"]["\x61\x70\x69\x55\x72\154"]) && !empty($tokenData["\x63\x6c\x69\x65\156\164\163"]["\141\160\x69\125\162\154"]) ? $tokenData["\143\x6c\151\145\156\x74\163"]["\x61\x70\151\x55\162\154"] : false; goto fMGy4; bHiVO: if (!$needsSettings) { goto zhurf; } goto dn2ox; XrohG: GsP1x: goto Xuig_; Bd5hw: $vars["\151\x6e\x63\x72\x65\x6d\x65\x6e\164\143\157\x6e\x74\x61\x63\164\x73"] = $this->getConfig("\x69\x6e\143\162\x65\155\x65\156\x74\143\157\x6e\164\x61\143\164\x73"); goto cXVNS; YIU2R: $data["\x70\157\x72\x74\x4d\141\164\143\150\x65\144"] = !empty($parsedUrl["\x70\x6f\162\x74"]) && (string) $parsedUrl["\160\x6f\x72\164"] === (string) $vars["\x70\157\x72\x74"] ? true : false; goto RY50h; yUY2l: $vars["\143\x6c\151\x65\x6e\x74\x73"]["\x64\145\x73\153\164\x6f\160\103\141\160\141\142\154\145"] = false; goto QA2b8; MVjvz: $vars["\163\x65\164\x73\164\162\145\x61\x6d\x69\144"] = $this->FreePBX->Clearlysp->getConfig("\x73\145\x74\x53\164\162\145\141\155\111\x64"); goto ZwM_q; xQKEm: $vars["\141\144\x6d\x69\x6e\160\162\157\170\171\x74\x61\162\x67\x65\164"] = $this->getConfig("\x61\x64\x6d\151\156\160\162\x6f\170\x79\x74\x61\x72\147\145\164\157\166\145\162\x72\151\x64\145"); goto DwENG; Rr6wz: $sortingOptions = array("\x65\x78\164\x65\x6e\163\151\x6f\156" => "\105\170\x74\x65\156\163\x69\x6f\156\40\116\165\155\x62\x65\162", "\x75\x73\x65\162\155\x61\156\x44\151\x73\x70\154\x61\171\x4e\x61\x6d\x65" => "\x55\163\145\162\40\115\141\x6e\x61\x67\145\x72\40\x44\x69\x73\160\x6c\141\x79\40\116\x61\x6d\145", "\165\x73\145\162\x6d\x61\156\x46\151\x72\x73\x74\x4e\x61\155\x65" => "\x55\x73\x65\x72\40\x4d\141\156\x61\147\145\x72\40\106\151\162\x73\x74\x20\116\141\155\x65", "\165\163\145\162\x6d\141\x6e\x4c\141\163\164\116\141\155\145" => "\x55\x73\x65\162\x20\x4d\x61\156\x61\147\x65\162\40\114\x61\163\164\x20\116\141\155\145"); goto CzSiF; xB13K: if (!empty($vars["\x63\154\x69\x65\x6e\164\163"]["\x64\145\x73\153\x74\x6f\160\103\x61\x70\141\142\154\x65"])) { goto ToW4X; } goto yUY2l; wrZBf: FYs4d: goto RbAce; JaAB5: dBpci: goto k2rIe; fUkyl: $vars["\155\141\x78\143\x6f\156\x74\141\143\x74\163"] = $this->getConfig("\x6d\141\x78\x63\x6f\156\164\x61\x63\164\x73"); goto Bd5hw; RbAce: $vars["\163\145\162\x76\x69\x63\145"] = $data["\163\145\162\x76\151\x63\145"]; goto TBAtL; Xuig_: kde7B: goto PbeKx; rWox7: BYhMY: goto kwYpz; hJppl: return load_view(__DIR__ . "\57\x76\151\x65\167\163\x2f\x73\145\164\164\x69\x6e\x67\x73\x2e\160\150\x70", $vars); goto SIAJb; ZwM_q: $vars["\x77\145\154\x63\x6f\x6d\145\105\155\x61\151\154"] = $this->getEmailTemplate(); goto xQKEm; cXVNS: $tokenData = $this->getTokenData(); goto EDq2v; gI1qT: $parsedUrl = parse_url($data["\143\154\x69\x65\156\164\x73"]["\x61\x70\151\125\162\x6c"]); goto N_XBa; Zo3S7: goto GsP1x; goto Hy3Pk; QA2b8: ToW4X: goto bk_b9; PbeKx: if (!($_REQUEST["\166\151\x65\167"] === "\163\145\x74\x74\x69\156\x67\x73")) { goto B_cCJ; } goto z22Dt; RY50h: return load_view(__DIR__ . "\x2f\x76\151\145\167\163\57\x67\162\x69\144\x2e\160\x68\x70", $data); goto VVMRO; aOHym: $data["\163\x65\x74\164\151\156\x67\163\x6d\x73\x67"] = load_view(__DIR__ . "\x2f\x76\x69\x65\167\163\57\x6e\x65\x65\x64\x53\145\x74\164\151\156\147\163\x2e\x70\150\x70", $needsSettingsDataArray); goto cL1gv; fbREb: $needsSettings = empty($apiUrl) && empty($domain); goto bHiVO; SIAJb: B_cCJ: goto CARc2; VVMRO: } public function ajaxRequest($req, &$setting) { goto MOadC; IF1tS: xi5et: goto qv4Nb; jXDuw: $setting["\x63\150\x61\x6e\147\145\x73\145\x73\163\151\157\156"] = false; goto UyRup; MOadC: if (!($req === "\x72\145\x73\164")) { goto xi5et; } goto Qsl0C; UyRup: return true; goto IF1tS; b5OYb: sEUcF: goto KW3MT; Qsl0C: $setting["\x61\165\x74\x68\x65\x6e\x74\x69\143\x61\x74\x65"] = false; goto l_OU9; l_OU9: $setting["\141\154\154\x6f\167\162\x65\155\157\x74\145"] = true; goto jXDuw; KW3MT: XOKzg: goto h6apA; qv4Nb: switch ($req) { case "\141\144\144\164\157\x6b\145\156": case "\x63\154\x69\x65\x6e\164\147\162\x69\x64": case "\165\156\155\141\160": case "\162\145\x6d\x6f\166\145\x54\x6f\x6b\145\156": case "\x72\x65\x6d\x6f\166\x65\x70\x75\163\x68\x74\157\153\145\156\x73": case "\162\x65\146\162\x65\x73\x68\x41\143\x63\157\x75\x6e\x74": case "\x73\x61\166\x65\123\145\164\x74\151\156\x67\163": case "\x73\165\160\160\x6f\x72\x74": case "\x70\165\x73\x68\x74\x6f\153\145\x6e\x73": case "\x73\x65\x72\x76\151\143\x65\x61\x63\164\x69\x6f\156": case "\141\144\155\151\x6e\120\162\157\170\171\124\x61\162\x67\x65\x74\117\166\x65\x72\162\151\x64\145": case "\145\155\x65\162\147\x65\156\x63\x79\122\145\167\162\151\164\x65\x52\165\154\145\163": case "\163\x61\x76\x65\105\155\x65\162\x67\x65\x6e\x63\171\122\x75\154\x65": case "\x73\x65\156\144\x45\155\141\x69\x6c\163": case "\155\x61\x67\151\x63\x54\157\153\145\x6e\107\162\151\x64": case "\x72\145\147\x65\x6e\145\x72\141\x74\x65\115\x61\147\151\x63\114\x69\156\x6b": return true; default: return false; } goto b5OYb; h6apA: } public function ajaxHandler() { goto mU_Ch; u6zYL: ExTh_: goto wVyWP; kRDBM: if (!(!isset($_REQUEST["\x64\141\x74\141"]) || empty($_REQUEST["\144\x61\164\x61"]))) { goto qkxXW; } goto o_5vz; v_IQP: return $final; goto h3I0j; dUGUb: if (!($_REQUEST["\143\x6f\155\155\141\156\144"] === "\162\x65\155\x6f\166\x65\x54\157\x6b\x65\x6e")) { goto VnN6V; } goto ckQ3A; u0y_k: foreach ($clients as $client) { goto IOIoh; eTdWI: $inheritedfrom = isset($client["\151\x6e\150\x65\x72\x69\164\x65\144\x66\162\157\x6d"]) ? $client["\x69\x6e\150\145\162\x69\x74\145\144\x66\162\x6f\155"] : false; goto cVps9; cVps9: $final[] = array("\x75\163\x65\x72" => $client["\x64\x61\x74\x61"]["\144\151\163\160\x6c\x61\171\156\x61\x6d\x65"], "\155\x65\x73\163\141\147\151\x6e\x67" => $client["\x6d\145\163\163\141\147\x69\156\147"] === "\145\x6e\141\x62\154\x65\144", "\x73\155\x73\144\151\144" => $client["\x73\x6d\163\x64\x69\x64"], "\x75\163\145\x72\155\x61\x6e\151\x64" => $client["\x64\141\x74\x61"]["\x69\x64"], "\x69\x6e\150\145\162\x69\164\145\x64" => $inherited, "\151\x6e\x68\145\162\151\x74\145\144\x66\x72\157\x6d" => $inheritedfrom, "\150\141\x73\x65\x6d\x61\151\x6c" => isset($client["\144\x61\x74\141"]["\x65\x6d\141\151\154"]) && !empty($client["\x64\141\164\141"]["\145\155\x61\151\154"])); goto M0N0W; M0N0W: c2Iw1: goto M_8xW; IOIoh: $inherited = isset($client["\151\156\x68\145\162\x69\x74\145\144"]) ? $client["\151\156\150\x65\x72\x69\x74\x65\x64"] : false; goto eTdWI; M_8xW: } goto vh35T; t9yxW: if (!($_REQUEST["\143\x6f\x6d\x6d\141\156\x64"] === "\141\144\x6d\151\156\x50\x72\157\170\x79\124\x61\162\x67\145\x74\117\x76\x65\x72\162\x69\x64\145")) { goto TFEs1; } goto BfcW3; B74BY: return $this->addToken($_REQUEST["\164\x6f\x6b\145\156"]); goto imogK; nXk6h: if (!($_REQUEST["\164\x79\160\145"] === "\147\162\157\x75\x70")) { goto sIrlX; } goto AokfQ; aFe48: if ($data) { goto Mf4He; } goto ax2N2; SbCu9: foreach ($_REQUEST["\x64\x61\164\x61"] as $row) { goto QFlxo; QFlxo: if (isset($row["\165\163\x65\x72\155\141\x6e\151\144"])) { goto vls5l; } goto f7ro4; T6kvz: EWlt2: goto FY6oV; OF8My: $ret[$row["\165\x73\x65\x72\x6d\141\x6e\151\144"]] = $this->sendSetupEmail($row["\x75\x73\x65\x72\155\x61\156\x69\x64"]); goto T6kvz; ycyte: vls5l: goto OF8My; f7ro4: goto EWlt2; goto ycyte; FY6oV: } goto eVosR; o27CD: return $this->refreshTokenData(); goto CcRdH; aJSsk: $setStreamId = true; goto a_MO4; ZuLOd: return $this->handleMagicTokenGrid(); goto u6zYL; WDpPI: $this->setConfig("\x77\x65\x6c\143\157\x6d\145\x45\x6d\141\151\x6c", $emailBody); goto sN7do; oq1KI: $clients = $this->getClientMapping(); goto NNGaA; vTb4a: $this->FreePBX->Clearlysp->setConfig("\x73\x65\164\x53\164\162\x65\x61\155\111\144", $setStreamId); goto D32Pk; DxPwn: try { $this->service->performAction($_REQUEST["\141\x63\164\x69\157\156"]); return array("\163\164\141\x74\x75\163" => true); } catch (\Exception $e) { return array("\x73\x74\141\164\x75\x73" => false, "\155\145\x73\x73\x61\x67\x65" => $e->getMessage()); } goto jRePu; tJuVY: if (!($_REQUEST["\x74\x79\x70\145"] === "\x67\x72\157\165\x70")) { goto w_IYL; } goto iPDGE; yjn6n: if (!($_REQUEST["\143\157\155\x6d\141\x6e\144"] === "\x63\154\x69\x65\x6e\164\x67\162\151\144")) { goto l4Wza; } goto oq1KI; NoCkF: $welcomeEmailTemplate = file_get_contents(__DIR__ . "\x2f\x74\x65\x6d\160\x6c\141\x74\x65\163\57\167\145\154\143\157\x6d\145\x5f\x65\155\x61\151\154\x2e\164\x70\x6c"); goto vwa4J; ckQ3A: return $this->deleteTokenData(); goto sPT1a; D5pYW: qkxXW: goto DAJxc; BfcW3: try { $this->setConfig("\x61\x64\155\x69\x6e\x70\x72\x6f\170\171\164\141\162\147\x65\164\157\x76\145\x72\x72\x69\144\145", $_REQUEST["\164\141\162\x67\145\x74"]); return array("\x73\x74\x61\164\x75\163" => true); } catch (\Exception $e) { return array("\x73\x74\141\164\165\163" => false, "\155\145\163\x73\141\x67\145" => $e->getMessage()); } goto bWNvc; FINrD: Mf4He: goto XRHZk; Z01Jk: $json = file_get_contents("\160\x68\160\72\57\57\151\156\x70\x75\x74"); goto q7TC9; JrMzd: if (!($_REQUEST["\x63\x6f\x6d\x6d\141\156\144"] === "\x73\145\x72\x76\x69\143\x65\141\143\x74\151\157\x6e")) { goto K_mIz; } goto DxPwn; h3I0j: l4Wza: goto JrMzd; ckdSc: if (!($_REQUEST["\143\157\x6d\x6d\141\x6e\144"] === "\162\145\146\x72\x65\163\150\101\143\x63\157\165\x6e\x74")) { goto viM8N; } goto o27CD; qCb5E: if (!($_REQUEST["\x63\x6f\x6d\x6d\x61\x6e\144"] === "\x73\141\x76\145\x45\x6d\x65\x72\x67\145\x6e\143\171\122\165\x6c\145")) { goto qTIhG; } goto GUHXk; APcHa: q8aNI: goto GfruB; kwPYI: return $this->saveUserEmergencyRule($_POST["\165\163\x65\x72"], $_POST["\x6e\165\x6d\142\145\162"], $_POST["\162\x75\154\145"]); goto pxtRQ; lT6FY: zKowb: goto WDpPI; GfruB: if (!($_REQUEST["\x63\157\155\155\x61\x6e\x64"] === "\x73\x65\156\x64\105\x6d\x61\x69\154\163")) { goto wunCk; } goto kRDBM; V6Rx1: sIrlX: goto v4wao; NNGaA: $final = array(); goto u0y_k; DAJxc: $ret = array(); goto SbCu9; vh35T: OU3KM: goto v_IQP; PSPUq: $this->unmapUser($_REQUEST["\165\163\145\162\x6d\x61\x6e\165\x73\145\x72"]); goto Qqmpq; HGnNB: return $this->handleRegenerateMagicLink(); goto APcHa; KXAGk: DSNh4: goto nXoDF; ax2N2: return array("\x73\x74\x61\164\x75\x73" => false, "\155\145\x73\x73\141\x67\x65" => _("\102\x61\x64\40\x72\145\x71\165\145\163\164")); goto FINrD; BWZfc: if (!isset($_REQUEST["\x77\145\154\x63\157\155\x65\145\155\x61\x69\x6c"])) { goto DL934; } goto ZamuQ; OUcc9: $setStreamId = false; goto ypzeb; D32Pk: return $this->handleSaveSettings(); goto JvT8x; wVyWP: if (!($_REQUEST["\x63\x6f\155\155\x61\x6e\x64"] === "\x72\145\x67\145\x6e\x65\x72\x61\164\x65\x4d\141\147\x69\143\114\151\156\153")) { goto q8aNI; } goto HGnNB; r_nbj: if (!($_REQUEST["\x63\157\x6d\155\x61\x6e\x64"] === "\x65\155\x65\x72\x67\x65\x6e\143\x79\122\x65\167\162\151\x74\x65\x52\x75\x6c\x65\163")) { goto l7EQB; } goto lol6j; v4wao: qTIhG: goto r_nbj; vwa4J: if (!(md5($welcomeEmailTemplate) === md5($emailBody))) { goto zKowb; } goto G3gZv; pqShS: gjMsX: goto f_myD; R4mGI: return $this->getUserEmergencyRewriteRules($_REQUEST["\x69\144"]); goto X1GX8; q7TC9: $data = json_decode($json, true); goto aFe48; eVosR: izazr: goto kX2tf; ZamuQ: $emailBody = $_REQUEST["\x77\x65\154\143\x6f\155\x65\145\155\x61\x69\x6c"]; goto NoCkF; THvwx: if (!($_REQUEST["\x63\157\155\x6d\x61\x6e\144"] === "\162\x65\x6d\157\x76\x65\160\x75\163\150\164\x6f\x6b\145\156\x73")) { goto O2Lk4; } goto Z01Jk; GUHXk: if (!($_REQUEST["\164\x79\x70\x65"] === "\x75\x73\x65\x72")) { goto Ysjex; } goto kwPYI; G3gZv: $emailBody = false; goto lT6FY; a_MO4: JZUnr: goto vTb4a; fhqTx: vzz0k: goto djgoa; Stwrj: return array(); goto O579M; Iqfyk: if (!($_REQUEST["\143\157\155\x6d\141\x6e\x64"] === "\163\x61\166\145\x53\x65\164\x74\151\156\147\x73")) { goto JqQq1; } goto BWZfc; mU_Ch: if (!($_REQUEST["\143\x6f\155\x6d\141\x6e\144"] === "\x73\165\x70\x70\x6f\162\164")) { goto DSNh4; } goto VeQy_; XRHZk: foreach ($data as $item) { goto o6AKF; aOicI: goto SAJgp; goto KLUUm; utO8g: SAJgp: goto u2wTU; KLUUm: XqODM: goto Mx2s9; Mx2s9: $this->deletePushToken($item["\165\151\144"], $item["\x64\145\166\x69\x63\x65\x5f\x69\144"]); goto utO8g; o6AKF: if (!(!isset($item["\165\151\144"]) || !isset($item["\144\x65\166\151\143\145\137\151\x64"]))) { goto XqODM; } goto aOicI; u2wTU: } goto pqShS; jRePu: K_mIz: goto t9yxW; sN7do: DL934: goto OUcc9; o_5vz: return array("\x73\x74\141\x74\165\x73" => false, "\x6d\145\x73\163\141\x67\145" => _("\x4e\x6f\x20\165\163\145\x72\163\40\163\x65\x6c\145\x63\164\x65\x64"), "\154\x65\x76\x65\x6c" => "\144\x61\156\147\x65\x72"); goto D5pYW; sPT1a: VnN6V: goto Iqfyk; tkfXD: wunCk: goto qCb5E; f_myD: return array("\163\x74\x61\x74\x75\x73" => true); goto rmNGF; Qqmpq: return array("\163\x74\141\x74\x75\x73" => true); goto UOmsS; O579M: l7EQB: goto THvwx; lol6j: if (!($_REQUEST["\x74\x79\160\145"] === "\x75\163\145\162")) { goto UgCSU; } goto R4mGI; pxtRQ: Ysjex: goto nXk6h; ypzeb: if (!(isset($_REQUEST["\x73\x65\x74\163\x74\162\x65\x61\155\x69\x64"]) && $_REQUEST["\x73\x65\x74\x73\164\162\x65\141\x6d\x69\144"] === "\145\156\x61\x62\154\145\144")) { goto JZUnr; } goto aJSsk; aqYrG: w_IYL: goto Stwrj; nXoDF: if (!($_REQUEST["\x63\x6f\155\x6d\141\x6e\x64"] === "\x6d\x61\x67\151\x63\x54\x6f\153\x65\x6e\107\x72\151\x64")) { goto ExTh_; } goto ZuLOd; VeQy_: return $this->handleSupport(); goto KXAGk; djgoa: if (!($_REQUEST["\x63\157\155\x6d\141\x6e\x64"] === "\x61\x64\x64\x74\x6f\x6b\145\x6e")) { goto YzSI3; } goto B74BY; X1GX8: UgCSU: goto tJuVY; imogK: YzSI3: goto YJdbG; iPDGE: return $this->getGroupEmergencyRewriteRules($_REQUEST["\151\x64"]); goto aqYrG; U1b9z: return $this->getAllPushTokens(); goto fhqTx; YJdbG: if (!($_REQUEST["\143\x6f\155\x6d\x61\156\x64"] === "\165\156\155\x61\x70")) { goto VI9Wy; } goto PSPUq; JvT8x: JqQq1: goto ckdSc; bWNvc: TFEs1: goto OTOR8; UOmsS: VI9Wy: goto yjn6n; wSVW4: if (!($_REQUEST["\x63\157\x6d\x6d\x61\x6e\144"] === "\160\x75\163\150\x74\157\153\145\x6e\x73")) { goto vzz0k; } goto U1b9z; CcRdH: viM8N: goto wSVW4; AokfQ: return $this->saveGroupEmergencyRule($_POST["\x75\163\x65\162"], $_POST["\156\x75\x6d\x62\145\162"], $_POST["\x72\165\154\x65"]); goto V6Rx1; rmNGF: O2Lk4: goto dUGUb; kX2tf: return array("\163\164\x61\x74\x75\163" => true, "\x61\144\144\151\x74\151\157\x6e\x61\x6c\x64\x61\x74\x61" => $ret); goto tkfXD; OTOR8: } public function ajaxCustomHandler() { goto GJ7Lc; nSRCh: LLnlk: goto ZXqB_; GJ7Lc: if (!($_REQUEST["\x63\x6f\x6d\x6d\x61\156\144"] === "\x72\x65\163\x74")) { goto LLnlk; } goto yxubF; yxubF: try { goto kV6Ia; Mq7pj: return true; goto hCaEp; kV6Ia: $clearly = new ClearlyAPI($this->freepbx); goto I3RjQ; I3RjQ: $clearly->handleRest(); goto Mq7pj; hCaEp: } catch (Exception $e) { header("\110\124\124\x50\57\61\56\60\x20" . $e->getCode() . "\40" . $e->getMessage()); echo $e->getMessage(); } goto nSRCh; ZXqB_: } public function getActionBar($request) { return array(); } public function getRightNav($request) { return load_view(__DIR__ . "\x2f\166\151\x65\x77\163\57\x72\156\141\166\x2e\160\x68\160"); } public function getUserCounts() { goto F9lnO; uR3zO: $assignedC = 0; goto Was4h; HVc53: if (!$count) { goto SiKNY; } goto deRv4; T09RN: $ret = array("\x61\x73\x73\151\x67\x6e\145\144" => $assignedC, "\x69\156\x68\x65\x72\151\164\145\144" => $inheritedC, "\164\x6f\164\x61\x6c" => $assignedC + $inheritedC); goto vrmlu; Was4h: $inheritedC = 0; goto wBsx_; wBsx_: foreach ($permitted as $value) { goto klM3S; klM3S: if ($value["\x69\156\150\145\x72\151\x74\x65\144"]) { goto T4DrB; } goto Wvq_j; Wvq_j: $assignedC++; goto Frc2X; VG7G5: $inheritedC++; goto PDfCL; p6J7z: T4DrB: goto VG7G5; RKF0v: ySzWX: goto u5Ni1; Frc2X: goto LWEFi; goto p6J7z; PDfCL: LWEFi: goto RKF0v; u5Ni1: } goto CmeI5; F9lnO: $count = $this->fcache->fetch("\165\163\x65\x72\x63\x6f\x75\156\x74\x73"); goto HVc53; orsmL: return $ret; goto r5Uwb; Ll19K: $permitted = $this->getClientMapping(); goto uR3zO; vrmlu: $this->fcache->save("\165\x73\145\162\x63\157\165\x6e\164\163", $ret, 10); goto orsmL; CmeI5: B1TIw: goto T09RN; cJPl3: SiKNY: goto Ll19K; deRv4: return $count; goto cJPl3; r5Uwb: } public function clearTokenDataCache() { $this->fcache->delete("\164\157\153\145\156\x64\141\164\x61\x77\x69\164\150\x75\x73\x65\162\x73"); $this->fcache->delete("\164\157\x6b\x65\x6e\144\141\164\x61\x77\x69\x74\150\157\x75\164\x75\163\145\162\163"); } public function getTokenData($userInfo = true) { goto qgLAZ; Bgki3: if ($account) { goto RtMyV; } goto gUUOQ; rv6Cg: $this->fcache->save($cache, $account, 60); goto q4aQU; a0o3l: $account = $this->getAccountData(); goto Bgki3; X4DSQ: $account["\163\165\x62\x73\x63\x72\x69\x70\164\x69\157\x6e"] = !empty($account["\x65\170\x70\151\162\x65\163"]) ? $account["\141\143\x74\x69\166\145"] && $account["\145\170\x70\151\162\145\163"] > strtotime("\156\157\167") : $account["\x61\143\x74\x69\x76\145"]; goto frioV; klYMJ: $tokenData = $this->fcache->fetch($cache); goto zFsog; qgLAZ: $cache = "\x74\x6f\x6b\145\156\x64\141\x74\141"; goto HI9Zq; u559w: NmCxG: goto X4DSQ; DvumL: $account["\x63\x6c\x69\145\x6e\164\163"]["\x75\x73\145\x64"] = $usage["\164\157\x74\141\x6c"]; goto qvlQk; moQzK: return $tokenData; goto qmHBC; frioV: $account["\x63\154\151\x65\x6e\x74\x73"]["\x6d\x6f\142\151\154\x65\114\x6f\x63\x61\164\151\157\x6e\111\x44"] = !empty($account["\143\x6c\151\x65\156\x74\x73"]["\155\x6f\142\x69\154\x65\x4c\157\143\x61\164\x69\x6f\156\x49\x44"]) ? $account["\143\x6c\x69\x65\x6e\x74\x73"]["\155\157\142\151\154\145\x4c\157\x63\141\164\151\x6f\x6e\x49\x44"] : "\x55\156\x6b\156\x6f\167\156"; goto rv6Cg; zFsog: if (!$tokenData) { goto ucr7w; } goto moQzK; qvlQk: $account["\x63\x6c\151\145\156\x74\x73"]["\141\x73\163\x69\147\x6e\x65\x64"] = $usage["\141\163\x73\x69\x67\x6e\x65\144"]; goto H91DC; qmHBC: ucr7w: goto APXW7; Ox16i: RtMyV: goto iFwK8; LiDya: $usage = $this->getUserCounts(); goto ydhV8; q4aQU: return $account; goto WBhA4; HI9Zq: $cache .= $userInfo ? "\167\x69\164\150\165\x73\x65\162\163" : "\167\x69\164\x68\x6f\165\164\x75\x73\145\162\163"; goto klYMJ; APXW7: if (!$userInfo) { goto IZBYj; } goto LiDya; iFwK8: if (empty($usage)) { goto NmCxG; } goto DvumL; gUUOQ: return array(); goto Ox16i; H91DC: $account["\143\x6c\x69\145\156\164\x73"]["\151\x6e\x68\145\x72\x69\x74\x65\x64"] = $usage["\151\156\150\145\162\151\164\x65\x64"]; goto u559w; ydhV8: IZBYj: goto a0o3l; WBhA4: } public function addToken($token) { goto pDbOx; uyzMq: $this->clearTokenDataCache(); goto WpCLH; QXuG0: $this->setConfig("\x61\143\143\x6f\165\156\x74", time(), "\154\141\x73\x74\141\x70\x69\x75\x70\144\141\164\145"); goto laDFk; WpCLH: $this->setConfig("\x74\157\153\145\156", $token, "\x73\x65\164\x74\151\156\x67\x73"); goto QXuG0; pjxZE: $this->updateTokenConfig($accountData); goto O2gam; laDFk: $accountData = RazrClient::getAccountData($token); goto pjxZE; O2gam: if (!$accountData["\141\x63\164\x69\x76\x65"]) { goto oIZIg; } goto fCL38; fCL38: return array("\163\x74\x61\164\x75\163" => true); goto NJGq3; pDbOx: $token = trim($token); goto uyzMq; c2wd0: return array("\163\164\141\x74\x75\163" => false); goto FdYVB; NJGq3: oIZIg: goto c2wd0; FdYVB: } public function updateTokenConfig($accountData = array()) { goto C89Gl; Kng12: eX5Dm: goto CZY7B; ZPNbs: dbug("\125\x70\144\141\x74\151\156\147\x20\x43\154\x65\141\x72\x6c\x79\x20\101\156\171\x77\x68\145\x72\x65\40\143\157\x6e\146\151\x67\x75\x72\x61\x74\151\157\156\40\x73\151\156\x63\x65\40\x69\x74\40\x68\x61\163\40\x63\x68\141\x6e\147\145\x64"); goto ZsU9K; ZsU9K: $this->setConfig("\141\143\143\157\x75\156\x74", $accountData, "\x73\x65\x74\164\x69\156\x67\x73"); goto Kng12; o9uIV: if (!(json_encode($accountData) !== json_encode($existingData))) { goto eX5Dm; } goto ZPNbs; C89Gl: $existingData = $this->getConfig("\141\x63\x63\x6f\165\156\164", "\163\x65\x74\164\151\x6e\147\163"); goto o9uIV; CZY7B: } public static function myDialplanHooks() { return 950; } public function doDialplanHook(&$ext, $engine, $priority) { goto ong10; UTXe3: if (!empty($token)) { goto boQJv; } goto Hda7F; apyMV: n2rdn: goto BQa0x; H1chK: C2233: goto FKzSX; Rh3pp: $this->setConfig("\141\143\143\157\165\x6e\x74", time(), "\x6c\141\x73\x74\x61\x70\151\x75\160\x64\141\x74\145"); goto xgCJv; nXu92: $this->updateTokenConfig($accountData); goto LxS9N; PD3Iz: return; goto Gxpr3; sPW1I: dbug("\x53\153\x69\160\160\x69\156\147\40\x43\x6c\x65\141\x72\x6c\x79\40\x41\156\x79\167\x68\x65\162\x65\x20\x6c\151\x63\145\x6e\x73\x65\x20\x63\x68\145\x63\x6b"); goto MRqtq; MObMh: if (!empty($accountData["\x63\x6c\151\145\156\164\163"]["\164\157\x74\x61\154"])) { goto GvxUU; } goto PD3Iz; Gxpr3: GvxUU: goto nXu92; E6UKZ: return; goto kvHrJ; a2r7S: return; goto twiHb; xgCJv: $accountData = RazrClient::getAccountData($token); goto F96eF; F96eF: if (is_array($accountData)) { goto Dn4BV; } goto E6UKZ; iSNYI: if (!($nowTimestamp < $lastApiUpdate)) { goto n2rdn; } goto sPW1I; lJu5J: $lastApiUpdate = 0; goto H1chK; Hda7F: return; goto MuQ69; LxS9N: $this->permissionLottery(); goto yUM7_; MuQ69: boQJv: goto Rh3pp; on9Ix: $nowTimestamp = $now->getTimestamp(); goto iSNYI; FKzSX: $now = new \DateTime(); goto Im0io; tDNhg: if (!empty($lastApiUpdate)) { goto C2233; } goto lJu5J; twiHb: TXm3_: goto MObMh; MRqtq: return; goto apyMV; sn6ch: if (!empty($accountData["\164\157\153\145\x6e"])) { goto TXm3_; } goto a2r7S; BQa0x: $token = $this->getConfig("\164\x6f\x6b\145\156", "\163\x65\x74\x74\151\156\x67\163"); goto UTXe3; ong10: $lastApiUpdate = $this->getConfig("\141\143\x63\157\165\156\164", "\x6c\x61\163\x74\x61\160\x69\165\x70\x64\x61\164\145"); goto tDNhg; Im0io: $now->modify("\x2d\67\62\x20\150\157\x75\x72\x73"); goto on9Ix; kvHrJ: Dn4BV: goto sn6ch; yUM7_: } public function deleteTokenData() { goto gBxOP; JclS4: $this->clearTokenDataCache(); goto dd3cm; dd3cm: return array("\x73\164\141\x74\165\x73" => true); goto RaICe; gBxOP: $this->setConfig("\141\x63\143\x6f\165\x6e\x74", false, "\x73\145\x74\164\x69\x6e\x67\163"); goto TVC3L; TVC3L: $this->setConfig("\164\157\153\145\x6e", false, "\163\145\x74\164\x69\x6e\x67\x73"); goto JclS4; RaICe: } public function refreshTokenData() { goto vROYt; jnJom: $this->addToken($token); goto N3J4m; zIQvQ: $token = isset($tokenData["\164\x6f\x6b\x65\x6e"]) ? $tokenData["\164\157\x6b\x65\156"] : false; goto yG8IV; yG8IV: if ($token) { goto O5I6r; } goto zCPlm; zCPlm: return array("\x73\164\x61\164\165\x73" => false, "\x6d\145\x73\163\x61\x67\x65" => _("\116\157\x20\164\x6f\153\x65\x6e\40\x73\145\164")); goto A2WzZ; vROYt: $tokenData = $this->getTokenData(); goto zIQvQ; N3J4m: return array("\163\164\x61\x74\165\163" => true); goto zPWsz; A2WzZ: O5I6r: goto jnJom; zPWsz: } public function getAccountData() { return $this->getConfig("\141\x63\143\x6f\x75\x6e\x74", "\x73\x65\x74\x74\151\x6e\147\x73"); } public function getClientMapping($client = '') { goto niWFE; vWxFB: $final = array(); goto QK7u7; MjMje: return $this->getUserSettings($client); goto bdKp3; yd9MK: $clients = $this->getConfig("\160\x65\162\x6d\x69\164\164\x65\144"); goto XUtG9; XUtG9: $clients = is_array($clients) ? $clients : array(); goto vWxFB; QK7u7: foreach ($clients as $id => $client) { goto Zy1XQ; tB8JI: goto uTw1B; goto M0Uiz; Zy1XQ: $settings = $this->getCombinedSettings($id); goto tW6L_; RilDy: uTw1B: goto TLy5k; eDUQV: Co2TW: goto ZJjAl; XR7d0: $final[$id] = $settings; goto RilDy; M0Uiz: tIcM_: goto XR7d0; tW6L_: if ($settings["\144\141\164\x61"]["\x69\x64"]) { goto Co2TW; } goto ZXBWB; ZXBWB: goto uTw1B; goto eDUQV; ZJjAl: if ($settings["\x65\156\141\x62\154\x65\x64"]) { goto tIcM_; } goto tB8JI; TLy5k: } goto bn0B7; bdKp3: goto b3eyU; goto RxQ8b; bn0B7: UsX4S: goto ABAhz; niWFE: if (empty($client)) { goto SeOXf; } goto MjMje; ABAhz: return $final; goto UdHkF; RxQ8b: SeOXf: goto yd9MK; UdHkF: b3eyU: goto AfKvv; AfKvv: } public function unmapUser($id) { goto N8_d9; N8_d9: $user = $this->getUserSettings($id); goto a_mCp; dVy1L: return $this; goto sXUEm; qMlGF: $this->permissionLottery(); goto dVy1L; a_mCp: $this->updateUserSettings($id, "\x69\x6e\x68\145\162\151\x74", $user["\x6d\145\163\163\x61\147\151\156\147"], $user["\163\x6d\x73\x64\151\144"]); goto qMlGF; sXUEm: } public function syncFirewallToPort() { goto Z5mJh; Z5mJh: if (!$this->firewall) { goto uBlhn; } goto UNfkO; k_c55: $this->firewall->setServiceName("\x43\154\x65\141\162\154\171\40\x41\x6e\171\167\x68\145\x72\x65")->syncFirewallToPort($port, "\x74\143\x70", array("\x65\x78\164\145\162\x6e\141\154", "\x69\x6e\164\145\162\x6e\x61\x6c")); goto XEKGa; wx8n4: $port = $apiconf["\160\157\x72\x74"]; goto k_c55; UNfkO: $apiconf = json_decode($this->getApiConfig(), true); goto wx8n4; XEKGa: uBlhn: goto iLdxd; iLdxd: } public function syncFirewallToPushServers() { goto PZjn5; R0mm9: zcjWI: goto zopL9; FVm6Y: $this->firewall->syncFirewallToPushServers(); goto R0mm9; PZjn5: if (!$this->firewall) { goto zcjWI; } goto a369Y; a369Y: $this->firewall->removePushServersFromFirewall(); goto FVm6Y; zopL9: } public function vpnCleanup($output = null) { goto Styft; iXaJi: foreach ($ca as $network => $entries) { goto bjsg6; E0Hmb: Xbasc: goto GFemb; GFemb: XEoEM: goto damSG; JAg8C: zp9wg: goto PE3Cq; PE3Cq: \FreePBX::Firewall()->removeNetwork($network); goto E0Hmb; jsLvy: $output->writeln(sprintf("\122\145\x6d\x6f\166\x69\x6e\x67\40\45\163", $network)); goto JAg8C; sl25e: if (empty($output)) { goto zp9wg; } goto jsLvy; bjsg6: if (!(count($all[$network]) == 1)) { goto Xbasc; } goto sl25e; damSG: } goto Aex0u; Styft: $all = array(); goto BtEKd; tiLU0: esdsq: goto nqARb; nqARb: $networks = \FreePBX::Firewall()->getConfig("\144\145\163\143\x72\151\160\164\x69\157\156\x73", "\156\x65\164\x77\x6f\x72\x6b"); goto XBeom; BtEKd: $ca = array(); goto f6B1A; Aex0u: BVGMG: goto h_8ul; XBeom: foreach ($networks as $ip => $desc) { goto zmkaA; P0bZ1: XXL7R: goto HtvYF; zmkaA: $all[$ip][] = $desc; goto bzZLd; gxYdB: PWnpw: goto bMyjq; yt0gc: $ca[$ip][] = $desc; goto P0bZ1; HtvYF: xw4tK: goto gxYdB; dYdtA: list($d, $t, $u) = explode("\x2d", $desc, 3); goto gAtkt; gAtkt: $removalTime = time() - 60 * 30; goto rgLDa; rgLDa: if (!($t < $removalTime)) { goto XXL7R; } goto yt0gc; bzZLd: if (!(strpos($desc, base64_encode("\143\x6c\145\141\x72\154\x79\141\x6e\x79\167\x68\x65\x72\x65") . "\55") === 0)) { goto xw4tK; } goto dYdtA; bMyjq: } goto Ws0xz; Ws0xz: ko_lg: goto iXaJi; f6B1A: if ($this->firewall) { goto esdsq; } goto j7br_; u2BuH: return; goto tiLU0; j7br_: dbug("\106\x69\162\x65\x77\141\x6c\x6c\40\x6e\x6f\x74\40\146\x6f\x75\156\144\54\x20\x73\153\151\x70\160\x69\156\x67\x20\x76\160\x6e\x20\143\154\x65\x61\156\x75\160"); goto u2BuH; h_8ul: } public function getGroupMapping($group = '') { goto dXUCK; ZyIws: Rv5Fb: goto Zwp2w; kXx1Z: $groupmap = $this->getConfig($group, "\147\x72\157\165\160\x6d\141\160\160\151\156\147\163"); goto ZnYfB; ZnYfB: return is_array($groupmap) ? $groupmap : $default; goto KPrXb; Vgrem: $clients = $this->getAll("\x67\162\x6f\165\160\x6d\x61\160\160\x69\x6e\147\163"); goto djuPr; dXUCK: if (!empty($group)) { goto Rv5Fb; } goto Vgrem; Zwp2w: $default = array("\155\x65\x73\x73\141\147\151\x6e\x67" => "\x64\x69\163\x61\x62\x6c\x65\144", "\x65\x6e\141\x62\154\145" => "\144\151\x73\x61\142\x6c\x65\x64"); goto kXx1Z; djuPr: return is_array($clients) ? $clients : array(); goto ZyIws; KPrXb: } public function isAllowed($uid) { goto sLYe9; DkSB3: U0fJP: goto QK6jF; rm27S: DmBsX: goto gQO1N; q8e2b: $permitted[$uid]["\162\145\143\157\162\x64\151\x6e\x67"] = "\145\156\x61\142\154\145\x64"; goto rm27S; hLXsA: if ($permitted) { goto U0fJP; } goto PkHmh; gQO1N: return isset($permitted[$uid]) ? $permitted[$uid] : $default; goto wrC22; sLYe9: $default = array("\x65\x6e\x61\142\154\x65\144" => false, "\x6d\x65\x73\x73\141\147\151\x6e\x67" => false); goto TaFeQ; GHAbE: $permitted[$uid]["\x73\145\x72\x76\x65\162\x5f\143\157\x6e\x74\141\x63\164\163"] = "\145\156\141\x62\x6c\145\x64"; goto Kuz9Z; TaFeQ: $permitted = $this->getConfig("\160\145\162\x6d\x69\164\164\145\x64"); goto hLXsA; Kuz9Z: Lgoyw: goto bss0e; QK6jF: if (!(isset($permitted[$uid]) && !array_key_exists("\163\145\162\x76\145\162\137\x63\157\x6e\x74\141\143\164\163", $permitted[$uid]))) { goto Lgoyw; } goto GHAbE; bss0e: if (!(isset($permitted[$uid]) && !array_key_exists("\162\145\x63\x6f\x72\x64\151\x6e\x67", $permitted[$uid]))) { goto DmBsX; } goto q8e2b; PkHmh: $permitted = $this->permissionLottery(); goto DkSB3; wrC22: } public function permissionLottery() { goto AfyQo; zUxwC: return array(); goto bFyJH; eZWuc: TzhGy: goto KkQxX; xWWF1: if (empty($diff)) { goto aR1X9; } goto WSMEY; EBUc1: SaKa8: goto II_GU; V2_ee: foreach ($allUsers as $user) { goto Nk6cY; KBaAQ: goto gySL5; goto YCKw1; LNE3Y: $allowed--; goto CX9Dd; P4SN4: if (!($allowed > 0)) { goto d3SPn; } goto mht5m; MSJcO: goto gySL5; goto xg9le; xg9le: fyGmn: goto P4SN4; mht5m: $settings = $this->getCombinedSettings($uid); goto hhmRl; tmSQ2: gySL5: goto dwadr; t0acE: if (!isset($enabled[$uid])) { goto a8aKm; } goto HCCBZ; LAlzm: goto gySL5; goto Mr2YN; Nk6cY: $uid = $user["\x69\144"]; goto t0acE; hhmRl: if (!($settings["\145\x6e\x61\142\x6c\145\144"] == "\x64\x69\163\141\142\x6c\145\x64")) { goto sHMBK; } goto KBaAQ; CX9Dd: d3SPn: goto tmSQ2; Mr2YN: a8aKm: goto ZWqUC; YCKw1: sHMBK: goto vVeWq; ZWqUC: if (!isset($disabled[$uid])) { goto fyGmn; } goto MSJcO; vVeWq: $permitted[$uid] = $settings; goto LNE3Y; HCCBZ: $permitted[$uid] = $this->getCombinedSettings($uid); goto LAlzm; dwadr: } goto EBUc1; b4bSP: $this->delConfig("\x70\145\x72\x6d\151\164\164\x65\144"); goto DSnTi; J6k74: $allUsers = $this->FreePBX->Userman->getAllUsers(); goto kUQCZ; ZvG3e: ET86l: goto WKBrd; tJcTk: if (!empty($permitted)) { goto TzhGy; } goto b4bSP; waEWt: if (!empty($previousPermissions)) { goto TDf_S; } goto fz0ri; JnpS4: $this->cleanPermissionHistory(); goto v05Vc; L03m9: $this->setConfig("\x70\x65\x72\155\151\x74\x74\x65\x64", $permitted); goto ZvG3e; KkQxX: $this->updateMaxContacts($permitted); goto L03m9; yFI4v: rzDf8: goto tJcTk; bekjK: $enabled = $this->getUsersEnabled(); goto Tdxta; OImZ3: if (isset($tokendata["\143\x6c\151\145\156\x74\x73"]["\164\157\x74\x61\x6c"])) { goto PEo20; } goto zUxwC; v05Vc: return $permitted; goto ViVmS; WSMEY: $this->setConfig(time(), $previousPermissions, "\160\x65\162\155\x69\x73\163\x69\x6f\156\110\x69\x73\x74\x6f\x72\171"); goto WA12r; bFyJH: PEo20: goto bekjK; fz0ri: $previousPermissions = array(); goto Li6ee; DSnTi: goto ET86l; goto eZWuc; kUQCZ: $previousPermissions = $this->getConfig("\x70\x65\x72\155\x69\164\164\145\x64"); goto waEWt; A3o5p: $permitted = array(); goto OImZ3; WA12r: aR1X9: goto yFI4v; Li6ee: TDf_S: goto cKYXL; Tdxta: $disabled = $this->getUsersDisabled(); goto J6k74; AfyQo: $tokendata = $this->getTokenData(); goto A3o5p; cKYXL: $allowed = intval($tokendata["\x63\154\151\x65\156\164\x73"]["\x74\157\164\x61\154"]) - count($enabled); goto V2_ee; WKBrd: $this->clearTokenDataCache(); goto JnpS4; iL7iD: $diff = array_diff(array_keys($previousPermissions), array_keys($permitted)); goto xWWF1; II_GU: if (!(is_array($previousPermissions) && is_array($permitted))) { goto rzDf8; } goto iL7iD; ViVmS: } public function cleanPermissionHistory($clear = false) { goto Jm2pq; zt3Oo: foreach ($historyData as $key) { goto ZCKfT; XWPpL: jcrjd: goto jso57; SEfBR: goto zVGM7; goto XWPpL; jso57: $this->delConfig($key, "\x70\145\162\155\151\x73\163\x69\157\156\110\x69\163\x74\x6f\x72\171"); goto earOk; ZCKfT: if (!in_array($key, $keep)) { goto jcrjd; } goto SEfBR; earOk: zVGM7: goto Ob_Oc; Ob_Oc: } goto XqKYb; x2ypt: $this->delById("\x70\x65\x72\x6d\x69\163\163\151\157\156\x48\151\x73\164\157\162\171"); goto focO1; focO1: imf82: goto R911J; FvSzM: $keep = array_slice($historyData, -20, 20); goto zt3Oo; XqKYb: hFgzV: goto O17i2; Jm2pq: if (!$clear) { goto imf82; } goto x2ypt; R911J: $historyData = array_keys($this->getAll("\x70\145\162\155\x69\163\163\x69\157\156\110\x69\x73\x74\157\x72\171")); goto FvSzM; O17i2: } public function updateDeviceContacts($extension, $contacts) { goto HCWrc; Xd7Ba: $sth->execute(array("\72\x6d\x61\170\103\x6f\x6e\x74\141\143\164\x73" => $contacts, "\x65\x78\x74\145\x6e\x73\151\157\x6e" => $extension, "\153\145\171\167\x6f\162\x64" => "\155\141\x78\x5f\x63\x6f\156\164\x61\143\x74\x73")); goto vZr_E; vZr_E: return $this; goto d6XF0; HCWrc: $sql = "\125\120\x44\x41\124\x45\40\163\x69\x70\x20\x53\x45\x54\x20\x60\x64\x61\164\x61\x60\x20\x3d\x20\72\x6d\x61\x78\103\x6f\x6e\x74\x61\143\164\x73\x20\x57\110\105\x52\x45\40\140\151\x64\140\40\x3d\x20\x3a\145\x78\x74\145\x6e\163\151\157\156\x20\x41\x4e\x44\40\140\x6b\145\x79\167\x6f\162\x64\140\x20\75\40\x3a\x6b\x65\x79\x77\157\x72\x64"; goto vAUUE; vAUUE: $sth = $this->FreePBX->Database->prepare($sql); goto Xd7Ba; d6XF0: } public function updateMaxContacts($list) { goto Xpvqr; ZNNOt: if ($maxcontacts) { goto XgLlu; } goto hRrWX; uol3c: J_2Oq: goto pEWqd; z9d5I: $icontacts = $this->getConfig("\151\x6e\143\162\x65\155\145\x6e\x74\x63\157\156\x74\141\143\x74\163"); goto Dhs0C; E2niR: $maxcontacts = $this->getConfig("\155\x61\x78\x63\x6f\156\x74\141\143\164\163"); goto z9d5I; PW6Er: mQn1D: goto adA16; Xpvqr: $allModified = $this->getAll("\155\x6f\x64\x69\146\151\145\x64\115\x61\170\103\x6f\156\164\141\x63\x74\163"); goto E2niR; pEWqd: foreach ($allModified as $id => $oldcount) { goto ORcC_; cf7LG: $this->FreePBX->Clearlysp->delConfig($id, "\155\x6f\144\151\146\x69\x65\x64\x4d\x61\x78\x43\x6f\x6e\164\141\x63\x74\x73"); goto rJgWp; rJgWp: YE368: goto Znd3z; ORcC_: $this->updateDeviceContacts($id, $oldcount); goto cf7LG; Znd3z: } goto PW6Er; hRrWX: $maxcontacts = 42; goto KwvJE; KwvJE: XgLlu: goto pA6Fl; Dhs0C: $increment = $icontacts ? $icontacts : 2; goto ZNNOt; pA6Fl: foreach ($list as $id => $data) { goto w3MLI; w3MLI: if (!isset($allModified[$id])) { goto mtNvI; } goto AT8_6; VuLXS: juudp: goto F6sPq; MiRHv: $currentMaxContacts = $device["\x6d\x61\x78\x5f\x63\x6f\x6e\164\141\x63\x74\163"]; goto b94cp; jt1RN: goto juudp; goto bYJo6; AT8_6: unset($allModified[$id]); goto jt1RN; bYJo6: mtNvI: goto PNsOi; PNsOi: $device = $this->FreePBX->Core->getDevice($data["\x64\141\x74\x61"]["\x64\x65\x66\x61\165\154\x74\x5f\x65\x78\164\145\x6e\163\151\x6f\x6e"]); goto sGZsq; OjOcE: XNFhG: goto VuLXS; b94cp: $contacts = $device["\155\x61\x78\137\143\157\x6e\x74\x61\x63\164\x73"] + intval($increment); goto T2di0; sGZsq: if (!(!empty($device) && $device["\164\145\x63\x68"] == "\x70\x6a\x73\151\x70")) { goto XNFhG; } goto MiRHv; eaWN2: $this->FreePBX->Clearlysp->setConfig($id, $currentMaxContacts, "\155\157\x64\151\146\x69\145\x64\x4d\x61\x78\103\157\x6e\164\141\x63\164\163"); goto OjOcE; T2di0: $contacts = $contacts < $maxcontacts ? $contacts : $maxcontacts; goto SJB5o; SJB5o: $this->updateDeviceContacts($data["\144\x61\164\x61"]["\144\145\146\141\x75\154\x74\137\145\170\164\145\156\163\151\x6f\156"], $contacts); goto eaWN2; F6sPq: } goto uol3c; adA16: } public function checkToken($token, $userInfo = true) { goto NJYuw; PZmjI: $tokendata = $this->getTokenData($userInfo); goto sRwxw; nZwqk: Vd_OZ: goto PZmjI; NJYuw: if (!empty($token)) { goto Vd_OZ; } goto HseVG; sRwxw: return $token === $tokendata["\164\x6f\153\x65\x6e"]; goto fvb42; HseVG: return false; goto nZwqk; fvb42: } public function pushReprovision($uid) { goto lt48R; wqPll: $messages = array(); goto ugS0T; skiGM: HTpV0: goto LD6Uu; wltCY: ipSaB: goto wqPll; lt48R: $pushtokens = $this->getPushTokensByUser($uid); goto LOC2M; ugS0T: foreach ($pushtokens as $pushtoken) { $messages[] = array("\104\x65\x76\151\x63\x65\124\x6f\153\145\x6e" => $pushtoken["\164\x6f\x6b\x65\156\x5f\155\163\x67\x73"], "\x53\145\154\x65\x63\164\157\162" => $pushtoken["\x73\x65\x6c\145\x63\164\157\x72"], "\101\160\160\111\x64" => $pushtoken["\141\x70\160\151\144\137\x6d\163\147\163"], "\166\x65\162\x62" => "\x4e\157\164\x69\146\x79\122\x65\x70\x72\x6f\166\x69\163\151\x6f\156"); pQOg9: } goto skiGM; XtMY1: return array("\163\164\141\x74\x75\163" => false, "\155\145\163\x73\x61\147\145" => "\x69\156\x76\141\154\x69\144\x20\x75\x73\x65\162"); goto wltCY; LOC2M: if ($pushtokens) { goto ipSaB; } goto XtMY1; LD6Uu: return $this->processPush($messages); goto D_eIw; D_eIw: } public function pushReprovisionByExtension($username) { goto jYybk; zHKxX: yEsSF: goto Nvfbt; Nvfbt: return $this->pushReprovision($usermanUser["\x69\x64"]); goto cU50y; jYybk: $usermanUser = $this->FreePBX->Userman->getUserByUsername($username); goto BpeO0; BpeO0: if ($usermanUser) { goto yEsSF; } goto BuMUg; BuMUg: return false; goto zHKxX; cU50y: } public function pushNotifyByDID($did, $message, $adapter) { goto xyMSQ; AheOx: PfWec: goto tAHvv; xyMSQ: $users = $this->getSMSUserByDid($did, $adapter); goto YuZG8; YuZG8: foreach ($users as $user) { $this->pushNotify($user["\165\x69\144"], $message); wXR46: } goto AheOx; tAHvv: } public function pushNotifyByDIDWithMessageId($did, $message, $adapter, $messageId) { goto g8leS; Cu2pf: eaJdt: goto P8IJC; g8leS: $users = $this->getSMSUserByDid($did, $adapter); goto jeo81; jeo81: foreach ($users as $user) { $this->pushNotify($user["\x75\151\144"], $message, $messageId); iu2ek: } goto Cu2pf; P8IJC: } public function pushNotify($uid, $message, $messageId = null) { goto BxLTC; Lunmd: return $this->processPush($messages); goto i2tFH; sAENS: y5Ft4: goto NMKGV; H8pNK: foreach ($pushtokens as $pushtoken) { goto JQ9w8; L7Vqm: $messageData = array("\x44\145\x76\151\143\x65\124\x6f\x6b\145\156" => $pushtoken["\164\x6f\153\x65\156\137\155\163\147\163"], "\123\x65\154\145\x63\164\157\162" => $pushtoken["\x73\x65\154\x65\143\164\x6f\x72"], "\x41\160\x70\111\144" => $pushtoken["\x61\x70\x70\x69\x64\x5f\155\x73\147\163"], "\x76\x65\162\x62" => "\x4e\157\164\x69\146\x79\x54\145\170\x74\115\x65\163\163\141\147\145", "\115\145\163\x73\x61\147\x65" => $message); goto Nw7kq; BwEJb: ZdhQk: goto pX0th; fR6fg: $messageData["\125\x73\x65\162\104\151\163\x70\x6c\141\x79\x4e\x61\155\x65"] = $smsInfo["\146\x72\x6f\155"]; goto s_fGG; Nw7kq: if (empty($messageId)) { goto FdrUn; } goto Cm1Mp; v2NK6: $messages[] = $messageData; goto BwEJb; JereF: $messageData["\111\x64"] = $smsInfo["\145\x6d\151\144"]; goto lRScc; JQ9w8: if (!empty($pushtoken["\x74\x6f\x6b\145\156\137\155\163\x67\163"])) { goto Zvt85; } goto h0UCV; Cm1Mp: $smsInfo = $this->getMessageByEMID($messageId); goto nmVSn; lRScc: $messageData["\124\x68\x72\x65\141\x64\111\144"] = $smsInfo["\x74\150\x72\145\x61\144\151\x64"]; goto fR6fg; nmVSn: $messageData["\102\x61\x64\x67\145"] = 1; goto JereF; M96yP: Zvt85: goto L7Vqm; h0UCV: goto ZdhQk; goto M96yP; s_fGG: FdrUn: goto v2NK6; pX0th: } goto QhqAj; YeW_c: if ($pushtokens) { goto y5Ft4; } goto v9yF6; v9yF6: return array("\163\164\x61\164\x75\x73" => false, "\x6d\x65\163\163\141\x67\x65" => "\151\x6e\166\x61\x6c\151\144\40\165\x73\x65\x72"); goto sAENS; BxLTC: $pushtokens = $this->getPushTokensByUser($uid); goto YeW_c; NMKGV: $messages = array(); goto H8pNK; QhqAj: LykZG: goto Lunmd; i2tFH: } private function getMessageByEMID($emid) { goto SGJpW; MEXng: $sth = $this->FreePBX->database->prepare($sql); goto b3uTM; kby1J: return $sth->fetch(\PDO::FETCH_ASSOC); goto HxBnW; b3uTM: $sth->execute(array("\145\x6d\151\x64" => $emid)); goto kby1J; SGJpW: $sql = "\123\105\x4c\105\x43\x54\40\163\x6d\x2e\x2a\40\x46\122\117\115\x20\163\x6d\163\x5f\x6d\x65\x73\163\141\147\x65\x73\x20\163\x6d\x20\127\x48\105\122\105\x20\x65\155\151\144\x20\75\x20\72\145\155\x69\144"; goto MEXng; HxBnW: } public function processPush($pushArray) { goto LMv4v; eN9_J: $response = $client->request("\x50\x4f\123\x54", "\x68\164\164\160\163\72\x2f\57\x70\156\x6d\56\x63\154\157\x75\x64\x73\157\x66\164\160\150\157\x6e\x65\56\x63\157\x6d\57\x70\156\155\x32\57\155\x75\154\x74\x69\x73\x65\x6e\x64", array("\x6a\x73\x6f\x6e" => array_values($pushArray), "\x68\x74\164\x70\137\145\x72\x72\x6f\162\163" => false)); goto yPw2t; yPw2t: return json_decode($response->getBody()); goto VW7vb; LMv4v: $client = new \GuzzleHttp\Client(); goto eN9_J; VW7vb: } public function batchSend($resetlock = false) { goto UoLpI; R4F2z: J2g5H: goto Elz70; kgHpn: $client = new \GuzzleHttp\Client(); goto BPtjP; NZS87: if (!($response->getStatusCode() === 200)) { goto aSv0O; } goto Hq2sa; df6g2: $lock->release(); goto IAJNp; XS2tn: dbug(sprintf("\123\x65\156\x74\40\142\141\x74\x63\150\x20\x70\x75\x73\x68\40\156\157\164\151\x66\x69\143\141\x74\151\157\x6e\x73\x20\141\x6e\144\40\x72\145\x63\x65\151\166\x65\x64\x20\x72\x65\163\160\157\x6e\x73\x65\x20\143\157\x64\145\40\157\x66\40\45\x73", $response->getStatusCode())); goto NZS87; hqOHf: return array("\x73\x74\x61\164\x75\163" => false, "\x6d\x65\163\163\x61\x67\145" => "\x61\x6c\x6c\x72\x65\141\144\171\40\162\165\156\x6e\x69\x6e\x67"); goto nq8s2; yDDbX: GhYlx: goto hqOHf; Hq2sa: foreach ($messages as $value) { $this->delConfig($value["\153\145\x79"], "\160\165\163\x68\161\165\x65\x75\x65"); ZnvHh: } goto lKoXW; BPtjP: if (!$resetlock) { goto J2g5H; } goto eWiiX; Elz70: if (!$lock->lock()) { goto GhYlx; } goto kR53i; IAJNp: return array("\163\x74\141\x74\165\x73" => true, "\x6d\x65\x73\163\x61\147\x65" => "\x70\165\x73\150\40\x73\145\x6e\x74"); goto yDDbX; lKoXW: fyMnY: goto NlE7h; X4q0b: return array("\x73\x74\141\164\x75\163" => true, "\x6d\145\163\x73\141\x67\145" => "\161\x75\x65\165\145\x20\145\x6d\x70\164\x79"); goto KyAIW; eWiiX: $lock->release(); goto R4F2z; P83Bb: if (!empty($messages)) { goto zofke; } goto X4q0b; NlE7h: aSv0O: goto df6g2; UoLpI: $lock = new LockHandler("\x63\154\x65\x61\x72\x6c\x79\163\x70\102\x61\164\143\x68\56\154\x6f\143\x6b"); goto kgHpn; lJITm: $response = $client->request("\x50\x4f\123\124", "\x68\x74\x74\x70\163\x3a\57\57\x70\x6e\155\56\143\x6c\157\165\144\x73\x6f\x66\164\160\x68\x6f\x6e\x65\x2e\x63\157\x6d\57\160\x6e\155\62\x2f\155\165\154\x74\151\x73\x65\156\x64", array("\x6a\163\157\x6e" => array_values($messages), "\x68\164\164\160\137\145\162\x72\x6f\162\x73" => false)); goto XS2tn; KyAIW: zofke: goto lJITm; kR53i: $messages = $this->getPushQueue(); goto P83Bb; nq8s2: } public function getPushToken($uid) { return $this->getConfig($uid, "\x70\x75\163\150\164\157\x6b\145\156\x73"); } public function addUserTokenData($uid, $data) { goto SRHyX; YhYeb: return $mergedData; goto CH987; Twpl0: $mergedData["\x75\x70\144\141\x74\x65\x64"] = time(); goto XE2y0; XE2y0: $this->setConfig($data["\x64\x65\x76\151\x63\x65\x5f\151\x64"], $mergedData, "\160\x75\163\150\x74\157\x6b\145\156\x73\x5f" . $uid); goto NzzPl; Fz4rx: $mergedData = array_merge($existing, $data); goto Twpl0; VeDjI: $existing = is_array($existing) ? $existing : array(); goto Fz4rx; SRHyX: $existing = $this->getConfig($data["\x64\x65\166\x69\x63\x65\137\151\144"], "\x70\165\163\x68\164\157\153\145\x6e\163\x5f" . $uid); goto VeDjI; NzzPl: $this->setConfig($uid, true, "\x70\x75\x73\x68\x74\x6f\153\x65\156\165\163\145\x72\x73"); goto YhYeb; CH987: } public function getPushTokensByUser($uid) { return $this->getAll("\x70\x75\163\150\x74\157\153\x65\x6e\x73\137" . $uid); } public function getAllPushTokens() { goto f0nvq; MDVjb: $uids = $this->getAll("\x70\x75\163\x68\x74\x6f\x6b\145\x6e\165\x73\x65\162\x73"); goto O8Q81; f0nvq: $final = array(); goto MDVjb; O8Q81: foreach ($uids as $uid => $bool) { goto zYdY8; gotQ3: foreach ($tokens as $token) { goto thUuy; tmNVA: nujfU: goto EzsJ1; Emghv: if (empty($token["\164\x6f\x6b\145\x6e\x5f\155\x73\147\x73"])) { goto XsWZs; } goto NwKdR; AKQub: $final[] = $token; goto ddBoM; thUuy: $token["\143\141\160\x61\x62\151\154\151\x74\151\145\x73"] = null; goto iotDy; VVkpD: aJzrI: goto Emghv; ZI1mo: $token["\x63\x61\160\141\x62\151\154\x69\x74\151\x65\x73"] .= "\x3c\151\40\x63\154\141\x73\163\75\x22\146\141\x20\x66\141\55\x6d\x6f\x62\x69\x6c\145\x20\146\x61\x2d\x32\170\x22\76\x3c\x2f\151\x3e"; goto tmNVA; EzsJ1: if (empty($token["\x63\141\x70\141\142\x69\154\x69\164\x69\x65\163"])) { goto aJzrI; } goto vgik9; twoF9: XsWZs: goto HlP73; HlP73: $token["\x75\151\x64"] = $uid; goto AKQub; NwKdR: $token["\x63\141\160\x61\x62\151\x6c\151\x74\x69\x65\x73"] .= "\74\151\x20\x63\x6c\141\163\x73\75\x22\x66\141\x20\x66\141\55\x63\x6f\x6d\155\x65\x6e\164\163\55\x6f\40\146\x61\x2d\62\170\42\x3e\x3c\57\151\76"; goto twoF9; vgik9: $token["\x63\141\160\x61\x62\151\154\151\x74\151\x65\163"] .= "\40"; goto VVkpD; ddBoM: ERygq: goto k2H2Y; iotDy: if (empty($token["\x74\x6f\x6b\145\x6e\137\x63\x61\154\x6c\163"])) { goto nujfU; } goto ZI1mo; k2H2Y: } goto LIS6S; RsG2M: gVrbb: goto KYd4G; LIS6S: Vygv9: goto RsG2M; zYdY8: $tokens = $this->getPushTokensByUser($uid); goto gotQ3; KYd4G: } goto CeM6y; Yo2IF: return $final; goto V_PLh; CeM6y: IXxfb: goto Yo2IF; V_PLh: } public function clearAllUserPushTokens($uid) { goto Y33lk; VTrY2: return $this; goto y1GJE; Y33lk: $this->delAll("\x70\x75\x73\150\164\157\x6b\145\156\163\x5f" . $uid); goto B6XHU; B6XHU: $this->delConfig($uid, "\x70\x75\x73\x68\x74\157\153\145\x6e\165\163\145\x72\163"); goto VTrY2; y1GJE: } public function deletePushToken($uid, $deviceid) { goto f0GE0; gpsOs: fDQiF: goto JdH9b; O47rd: $tokens = $this->getPushTokensByUser($uid); goto bQHrb; oBa3G: $this->delConfig($deviceid, "\x6c\141\x73\164\163\155\163\160\x6f\x6c\x6c\137" . $uid); goto O47rd; f0GE0: $this->delConfig($deviceid, "\x70\165\163\150\164\157\153\145\x6e\x73\x5f" . $uid); goto oBa3G; JdH9b: return $this; goto kXQ5m; bQHrb: if (!empty($tokens)) { goto fDQiF; } goto WT8_d; WT8_d: $this->delConfig($uid, "\x70\165\163\150\x74\x6f\153\x65\156\x75\163\145\162\x73"); goto gpsOs; kXQ5m: } public function getPushQueue() { goto DwV3x; jw6Si: return array(); goto ebN3c; ebN3c: fiQWm: goto N4w8o; eCtko: $messages = $this->getAll("\160\165\163\150\x71\165\145\x75\x65"); goto iEMDC; b8uC4: xtM54: goto Q4v2P; N4w8o: foreach ($messages as $key => $value) { goto QsKzb; nq41h: $message = $value["\x6d\145\x73\x73\x61\147\x65"]; goto asPMR; snrH9: $tokens = $this->getPushTokensByUser($value["\165\151\144"]); goto mgaMR; fDRCn: seZju: goto nq41h; asPMR: $smsInfo = $this->FreePBX->Sms->getMessageByID($value["\x6d\151\144"]); goto ORNIC; QKl7l: $pushtokens = $users[$value["\x75\151\x64"]]; goto NPvIC; S4sCa: WcawS: goto QKl7l; NPvIC: if ($pushtokens) { goto seZju; } goto uk8gZ; PUXxI: d1a4s: goto p8UWh; cqLUK: EKHfE: goto PUXxI; uk8gZ: goto d1a4s; goto fDRCn; mgaMR: $users[$value["\165\151\x64"]] = $tokens; goto S4sCa; QsKzb: if ($users[$value["\165\x69\144"]]) { goto WcawS; } goto snrH9; ORNIC: foreach ($pushtokens as $pushtoken) { goto gFwNo; gFwNo: if (!empty($pushtoken["\164\x6f\153\x65\156\x5f\x6d\163\147\163"])) { goto M1C2a; } goto WUaH4; ghXz2: M1C2a: goto PpdxO; EKqqj: NRL31: goto RDtNT; RDtNT: dbug(sprintf("\101\x64\144\x69\x6e\x67\40\155\x65\163\x73\x61\x67\x65\40\164\157\x20\x62\x65\x20\163\x65\x6e\x74\x20\164\157\40\144\x65\166\x69\x63\x65\40\164\157\x6b\x65\156\x20\45\x73\x20\167\151\164\150\40\155\x65\163\x73\141\x67\x65\40\150\141\163\x68\x20\x6f\x66\x20\x25\163\x20\x61\156\144\x20\x73\155\163\x20\x69\144\40\157\146\40\x25\163\x20\x74\x6f\40\x6f\165\162\40\160\165\x73\150\40\x6e\157\x74\x69\146\x69\x63\x61\164\151\x6f\156\40\155\x65\163\x73\x61\147\145\x20\x71\x75\145\165\x65", $pushtoken["\164\157\153\x65\156\137\155\163\x67\163"], $messageHash, $smsInfo["\x65\x6d\151\x64"])); goto fYGtq; PpdxO: $messageHash = sha1($pushtoken["\x74\x6f\x6b\x65\x6e\x5f\155\x73\147\x73"] . "\55" . $smsInfo["\x65\155\151\x64"]); goto X8FlB; kTtEH: aqYLP: goto ky0G1; fYGtq: $final[$messageHash] = array("\153\x65\x79" => $key, "\x44\145\166\x69\143\x65\124\157\153\145\156" => $pushtoken["\164\157\x6b\145\156\137\155\x73\147\x73"], "\123\x65\154\x65\x63\x74\x6f\162" => $pushtoken["\x73\x65\x6c\x65\x63\164\x6f\x72"], "\101\x70\160\111\x64" => $pushtoken["\x61\160\160\151\144\137\x6d\x73\147\163"], "\x76\x65\x72\142" => "\x4e\157\x74\151\146\171\124\x65\x78\x74\x4d\x65\163\x73\141\x67\145", "\115\x65\163\163\x61\x67\145" => $message, "\x49\144" => $smsInfo["\145\155\151\x64"], "\124\150\x72\x65\141\x64\111\144" => $smsInfo["\164\150\x72\145\x61\x64\x69\144"], "\x42\141\x64\147\x65" => 1); goto kTtEH; WUaH4: goto aqYLP; goto ghXz2; X8FlB: if (empty($final[$messageHash])) { goto NRL31; } goto erU3M; erU3M: goto aqYLP; goto EKqqj; ky0G1: } goto cqLUK; p8UWh: } goto b8uC4; Q4v2P: return $final; goto EDszV; iEMDC: if (is_array($messages)) { goto fiQWm; } goto jw6Si; DwV3x: $users = array(); goto foCVv; foCVv: $final = array(); goto eCtko; EDszV: } public function addToPushQueue($uid, $mid, $message) { goto FjudW; INw4p: $this->setConfig($uid, array("\165\x69\x64" => $uid, "\155\151\x64" => $mid, "\155\145\x73\x73\141\147\145" => $message), "\x70\x75\x73\x68\161\165\145\x75\145"); goto Rlt91; FjudW: if (!empty($this->getPushTokensByUser($uid))) { goto NFQHY; } goto tgnAU; Rlt91: return $this; goto wUJ2N; A14Q3: return; goto YTVTm; YTVTm: NFQHY: goto INw4p; tgnAU: dbug("\116\157\40\160\x75\163\150\x20\x74\157\153\x65\x6e\x73\40\146\x6f\x72\x20\165\x73\145\162\40\x69\144\40\x6f\146\x20" . $uid . "\54\40\163\x6b\151\x70\160\151\156\147\40\141\144\144\x69\x6e\147\40\x6d\145\x73\163\x61\x67\x65\40\x69\144\x20" . $mid . "\40\x74\x6f\40\x74\150\x65\x20\x70\x75\163\150\40\161\165\x65\x75\x65\56"); goto A14Q3; wUJ2N: } public function removeOldPushTokens($output = null) { goto lYRPV; ufvOF: foreach ($tokens as $token) { goto rEbpI; rEbpI: if (!(isset($token["\165\x70\x64\x61\164\x65\x64"]) && $token["\x75\x70\x64\x61\x74\x65\144"] < $removalTime)) { goto y9z4d; } goto LY2e1; EAnhk: wxZLz: goto pHe3z; V1gSt: y9z4d: goto EAnhk; LY2e1: $output->writeln(sprintf("\122\145\155\157\166\151\156\147\40\160\165\x73\150\40\164\157\x6b\145\x6e\x20\146\x6f\162\x20\x75\x73\x65\x72\x20\x69\144\40\x25\163\x20\141\x6e\144\x20\x64\x65\166\x69\x63\x65\x20\151\144\40\157\146\40\x25\x73\40\167\151\x74\150\x20\144\141\x74\x61\40\x6f\146\40\45\163", $token["\x75\151\144"], $token["\x64\145\x76\151\x63\x65\137\x69\x64"], json_encode($token))); goto vBkMK; vBkMK: $this->deletePushToken($token["\x75\x69\x64"], $token["\x64\145\x76\x69\x63\145\137\151\x64"]); goto V1gSt; pHe3z: } goto Bl14f; Bl14f: xwsiD: goto WGr4P; yvTzk: $date = new \DateTime(); goto E3gSD; L90Uv: $removalTime = $date->getTimestamp(); goto ufvOF; E3gSD: $date->sub(new \DateInterval("\x50\x33\60\104")); goto L90Uv; lYRPV: $tokens = $this->getAllPushTokens(); goto yvTzk; WGr4P: } public function smsPoll() { goto EZSxs; VSOmN: $lastpoll = $lastpoll ? $lastpoll : 0; goto Pq3Ch; EZSxs: $clients = $this->getClientMapping(); goto Z7iAq; lnyCk: V47d_: goto wgaqc; wgaqc: return $this->batchSend(); goto SGvFY; i2bFo: $this->setConfig("\154\141\x73\x74\143\162\x6f\156\160\157\154\154", time()); goto VSOmN; Z7iAq: $lastpoll = $this->getConfig("\x6c\141\x73\164\x63\x72\x6f\x6e\x70\x6f\154\x6c"); goto i2bFo; Pq3Ch: foreach ($clients as $client) { goto qRVdu; kjRyd: DrCNP: goto r9ieg; vcWfk: goto DrCNP; goto VdmMg; Pg2Y4: goto DrCNP; goto ZqrQA; GfUU0: W_t1B: goto kjRyd; uHigZ: $messages = $this->getMessagesByUserAndDid($id, $client["\x73\x6d\x73\x64\x69\144"], $lastpoll); goto zMpAK; Pg45r: goto DrCNP; goto NHf1O; VdmMg: R33U8: goto uHigZ; Suocj: if (!empty($client["\163\155\x73\144\x69\x64"])) { goto R33U8; } goto vcWfk; qZwTp: $id = $client["\144\141\x74\x61"]["\151\x64"]; goto Suocj; qRVdu: if (!($client["\x65\x6e\x61\x62\x6c\x65\x64"] !== "\x65\x6e\x61\x62\154\145\144" || $client["\155\145\163\x73\141\147\151\x6e\x67"] === "\x64\x69\163\141\142\154\x65\x64")) { goto Ql2fb; } goto Pg45r; zMpAK: if (!empty($messages)) { goto KtMSo; } goto Pg2Y4; NHf1O: Ql2fb: goto qZwTp; ouCrZ: foreach ($messages as $message) { goto ppsq4; cN10t: if (!($message["\x61\144\141\160\164\x6f\x72"] === "\103\154\145\x61\162\154\171\164\x72\x75\x6e\x6b\151\156\x67")) { goto zFH3e; } goto Q1GUQ; aM6fA: goto oei73; goto M9cYy; RaCLO: zFH3e: goto oz5bQ; ppsq4: if (!($message["\144\x69\162\x65\x63\x74\151\x6f\156"] !== "\151\156")) { goto v43iC; } goto aM6fA; atgDM: if (!($message["\164\x6f"] !== $client["\163\155\163\x64\151\144"])) { goto FqDw4; } goto rzMv0; Q1GUQ: goto oei73; goto RaCLO; rzMv0: goto oei73; goto rD22L; oz5bQ: $this->addToPushQueue($id, $message["\151\144"], $message["\x62\x6f\x64\x79"]); goto gKHOU; gKHOU: oei73: goto Xrb_s; M9cYy: v43iC: goto atgDM; rD22L: FqDw4: goto cN10t; Xrb_s: } goto GfUU0; ZqrQA: KtMSo: goto ouCrZ; r9ieg: } goto lnyCk; SGvFY: } public function validateMagicToken($user, $pass) { $saved = $this->getConfig($user, "\155\x61\x67\x69\143\x74\157\153\145\x6e\x73"); return password_verify($pass, $saved); } public function getMagicToken($user) { goto O1_tg; aJDO1: $this->setConfig($user, $pass, "\x6d\x61\x67\x69\143\x74\157\x6b\x65\156\163"); goto dwROx; O1_tg: $uuid = Uuid::uuid4()->toString(); goto ozg8N; ozg8N: $pass = password_hash(trim($uuid), PASSWORD_DEFAULT); goto a

デコード(難読化解除)されたコード

<?php

/*   __________________________________________________
    |  Built by Clearly IP Inc.                        |
    |              on 2023-01-02 21:42:57              |
    |__________________________________________________|
*/
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 qoP1G;
        }
        $this->firewall = false;
        qoP1G:
        $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");
        if (!empty($clearlyspSMSCronJob)) {
            goto ewf29;
        }
        $time = "* * * * *";
        $this->FreePBX->Job->addClass("clearlysp", "pollsms", "FreePBX\\modules\\Clearlysp\\Job", $time);
        $this->FreePBX->Job->setEnabled("clearlysp", "pollsms", true);
        ewf29:
        $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 RVpTJ;
        }
        out("The following messages are ONLY FOR DEBUGGING. Ignore anything that says 'WARN' or is just a warning");
        RVpTJ:
        $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 KQpR8;
        }
        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!"));
        KQpR8:
        $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 QEX7c;
        }
        out(_("Removing the firewall rule."));
        $this->firewall->setServiceName("Clearly Anywhere")->removeAllRules();
        $this->vpnCleanup();
        QEX7c:
    }
    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 ToW4X;
            }
            $vars["clients"]["desktopCapable"] = false;
            ToW4X:
            $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 zhurf;
            }
            $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);
            zhurf:
            $data["service"] = $this->service->status();
            $parsedUrl = parse_url($data["clients"]["apiUrl"]);
            if (!(empty($parsedUrl["port"]) && !empty($parsedUrl["scheme"]))) {
                goto kde7B;
            }
            if ($parsedUrl["scheme"] === "https") {
                $parsedUrl["port"] = 443;
                goto GsP1x;
            }
            if ($parsedUrl["scheme"] === "http") {
                $parsedUrl["port"] = 80;
                goto XrohG;
            }
            XrohG:
            GsP1x:
            kde7B:
            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 FYs4d;
            }
            $vars["supportclass"] = '';
            FYs4d:
            $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["setstreamid"] = $this->FreePBX->Clearlysp->getConfig("setStreamId");
            $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 qTIhG;
                        }
                        if (!($_REQUEST["type"] === "user")) {
                            if (!($_REQUEST["type"] === "group")) {
                                qTIhG:
                                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 K_mIz;
                                                                    }
                                                                    try {
                                                                        $this->service->performAction($_REQUEST["action"]);
                                                                        return array("status" => true);
                                                                    } catch (\Exception $e) {
                                                                        return array("status" => false, "message" => $e->getMessage());
                                                                    }
                                                                    K_mIz:
                                                                    if (!($_REQUEST["command"] === "adminProxyTargetOverride")) {
                                                                        goto TFEs1;
                                                                    }
                                                                    try {
                                                                        $this->setConfig("adminproxytargetoverride", $_REQUEST["target"]);
                                                                        return array("status" => true);
                                                                    } catch (\Exception $e) {
                                                                        return array("status" => false, "message" => $e->getMessage());
                                                                    }
                                                                    TFEs1:
                                                                    // [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 DL934;
                                            }
                                            $emailBody = $_REQUEST["welcomeemail"];
                                            $welcomeEmailTemplate = file_get_contents("/var/www/html/templates/welcome_email.tpl");
                                            if (!(md5($welcomeEmailTemplate) === md5($emailBody))) {
                                                goto zKowb;
                                            }
                                            $emailBody = false;
                                            zKowb:
                                            $this->setConfig("welcomeEmail", $emailBody);
                                            DL934:
                                            $setStreamId = false;
                                            if (!(isset($_REQUEST["setstreamid"]) && $_REQUEST["setstreamid"] === "enabled")) {
                                                goto JZUnr;
                                            }
                                            $setStreamId = true;
                                            JZUnr:
                                            $this->FreePBX->Clearlysp->setConfig("setStreamId", $setStreamId);
                                            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 utO8g;
                                            }
                                            utO8g:
                                        }
                                        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 T6kvz;
                            }
                            T6kvz:
                        }
                        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 LLnlk;
        }
        try {
            $clearly = new ClearlyAPI($this->freepbx);
            $clearly->handleRest();
            return true;
        } catch (Exception $e) {
            header("HTTP/1.0 " . $e->getCode() . " " . $e->getMessage());
            echo $e->getMessage();
        }
        LLnlk:
    }
    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 PDfCL;
                }
                $assignedC++;
                PDfCL:
            }
            $ret = array("assigned" => $assignedC, "inherited" => $inheritedC, "total" => $assignedC + $inheritedC);
            $this->fcache->save("usercounts", $ret, 10);
            return $ret;
        }
        return $count;
    }
    public function clearTokenDataCache()
    {
        $this->fcache->delete("tokendatawithusers");
        $this->fcache->delete("tokendatawithoutusers");
    }
    public function getTokenData($userInfo = true)
    {
        $cache = "tokendata";
        $cache .= $userInfo ? "withusers" : "withoutusers";
        $tokenData = $this->fcache->fetch($cache);
        if (!$tokenData) {
            if (!$userInfo) {
                goto IZBYj;
            }
            $usage = $this->getUserCounts();
            IZBYj:
            $account = $this->getAccountData();
            if ($account) {
                if (empty($usage)) {
                    goto NmCxG;
                }
                $account["clients"]["used"] = $usage["total"];
                $account["clients"]["assigned"] = $usage["assigned"];
                $account["clients"]["inherited"] = $usage["inherited"];
                NmCxG:
                $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($cache, $account, 60);
                return $account;
            }
            return array();
        }
        return $tokenData;
    }
    public function addToken($token)
    {
        $token = trim($token);
        $this->clearTokenDataCache();
        $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 eX5Dm;
        }
        dbug("Updating Clearly Anywhere configuration since it has changed");
        $this->setConfig("account", $accountData, "settings");
        eX5Dm:
    }
    public static function myDialplanHooks()
    {
        return 950;
    }
    public function doDialplanHook(&$ext, $engine, $priority)
    {
        $lastApiUpdate = $this->getConfig("account", "lastapiupdate");
        if (!empty($lastApiUpdate)) {
            goto C2233;
        }
        $lastApiUpdate = 0;
        C2233:
        $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->clearTokenDataCache();
        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 RilDy;
                    }
                    goto uTw1B;
                }
                RilDy:
                uTw1B:
            }
            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 uBlhn;
        }
        $apiconf = json_decode($this->getApiConfig(), true);
        $port = $apiconf["port"];
        $this->firewall->setServiceName("Clearly Anywhere")->syncFirewallToPort($port, "tcp", array("external", "internal"));
        uBlhn:
    }
    public function syncFirewallToPushServers()
    {
        if (!$this->firewall) {
            goto zcjWI;
        }
        $this->firewall->removePushServersFromFirewall();
        $this->firewall->syncFirewallToPushServers();
        zcjWI:
    }
    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 xw4tK;
                }
                list($d, $t, $u) = explode("-", $desc, 3);
                $removalTime = time() - 1800;
                if (!($t < $removalTime)) {
                    goto XXL7R;
                }
                $ca[$ip][] = $desc;
                XXL7R:
                xw4tK:
            }
            foreach ($ca as $network => $entries) {
                if (!(count($all[$network]) == 1)) {
                    goto Xbasc;
                }
                if (empty($output)) {
                    goto zp9wg;
                }
                $output->writeln(sprintf("Removing %s", $network));
                zp9wg:
                \FreePBX::Firewall()->removeNetwork($network);
                Xbasc:
            }
            // [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 U0fJP;
        }
        $permitted = $this->permissionLottery();
        U0fJP:
        if (!(isset($permitted[$uid]) && !array_key_exists("server_contacts", $permitted[$uid]))) {
            goto Lgoyw;
        }
        $permitted[$uid]["server_contacts"] = "enabled";
        Lgoyw:
        if (!(isset($permitted[$uid]) && !array_key_exists("recording", $permitted[$uid]))) {
            goto DmBsX;
        }
        $permitted[$uid]["recording"] = "enabled";
        DmBsX:
        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 TDf_S;
            }
            $previousPermissions = array();
            TDf_S:
            $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 d3SPn;
                        }
                        $settings = $this->getCombinedSettings($uid);
                        if (!($settings["enabled"] == "disabled")) {
                            $permitted[$uid] = $settings;
                            $allowed--;
                            d3SPn:
                            goto tmSQ2;
                        }
                        goto gySL5;
                    }
                    goto gySL5;
                }
                $permitted[$uid] = $this->getCombinedSettings($uid);
                tmSQ2:
                gySL5:
            }
            if (!(is_array($previousPermissions) && is_array($permitted))) {
                goto rzDf8;
            }
            $diff = array_diff(array_keys($previousPermissions), array_keys($permitted));
            if (empty($diff)) {
                goto aR1X9;
            }
            $this->setConfig(time(), $previousPermissions, "permissionHistory");
            aR1X9:
            rzDf8:
            if (!empty($permitted)) {
                $this->updateMaxContacts($permitted);
                $this->setConfig("permitted", $permitted);
                goto ZvG3e;
            }
            $this->delConfig("permitted");
            ZvG3e:
            $this->clearTokenDataCache();
            $this->cleanPermissionHistory();
            return $permitted;
        }
        return array();
    }
    public function cleanPermissionHistory($clear = false)
    {
        if (!$clear) {
            goto imf82;
        }
        $this->delById("permissionHistory");
        imf82:
        $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 earOk;
            }
            earOk:
        }
    }
    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 XgLlu;
        }
        $maxcontacts = 42;
        XgLlu:
        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 XNFhG;
                }
                $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");
                XNFhG:
                goto VuLXS;
            }
            unset($allModified[$id]);
            VuLXS:
        }
        foreach ($allModified as $id => $oldcount) {
            $this->updateDeviceContacts($id, $oldcount);
            $this->FreePBX->Clearlysp->delConfig($id, "modifiedMaxContacts");
        }
    }
    public function checkToken($token, $userInfo = true)
    {
        if (!empty($token)) {
            $tokendata = $this->getTokenData($userInfo);
            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 pushReprovisionByExtension($username)
    {
        $usermanUser = $this->FreePBX->Userman->getUserByUsername($username);
        if ($usermanUser) {
            return $this->pushReprovision($usermanUser["id"]);
        }
        return false;
    }
    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 FdrUn;
                    }
                    $smsInfo = $this->getMessageByEMID($messageId);
                    $messageData["Badge"] = 1;
                    $messageData["Id"] = $smsInfo["emid"];
                    $messageData["ThreadId"] = $smsInfo["threadid"];
                    $messageData["UserDisplayName"] = $smsInfo["from"];
                    FdrUn:
                    $messages[] = $messageData;
                    goto BwEJb;
                }
                BwEJb:
            }
            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 J2g5H;
        }
        $lock->release();
        J2g5H:
        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 aSv0O;
            }
            foreach ($messages as $value) {
                $this->delConfig($value["key"], "pushqueue");
            }
            aSv0O:
            $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 nujfU;
                }
                $token["capabilities"] .= "<i class=\"fa fa-mobile fa-2x\"></i>";
                nujfU:
                if (empty($token["capabilities"])) {
                    goto aJzrI;
                }
                $token["capabilities"] .= " ";
                aJzrI:
                if (empty($token["token_msgs"])) {
                    goto XsWZs;
                }
                $token["capabilities"] .= "<i class=\"fa fa-comments-o fa-2x\"></i>";
                XsWZs:
                $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 fDQiF;
        }
        $this->delConfig($uid, "pushtokenusers");
        fDQiF:
        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 WcawS;
                }
                $tokens = $this->getPushTokensByUser($value["uid"]);
                $users[$value["uid"]] = $tokens;
                WcawS:
                $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 kTtEH;
                            }
                            goto aqYLP;
                        }
                        kTtEH:
                        aqYLP:
                    }
                    goto PUXxI;
                }
                PUXxI:
            }
            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 y9z4d;
            }
            $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"]);
            y9z4d:
        }
    }
    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 gKHOU;
                                    }
                                    goto oei73;
                                }
                                goto oei73;
                            }
                            gKHOU:
                            oei73:
                        }
                        goto kjRyd;
                    }
                    goto DrCNP;
                }
                goto DrCNP;
            }
            kjRyd:
            DrCNP:
        }
        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 d1rlx;
        }
        $link = $this->createMagicLink($user);
        d1rlx:
        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 tMA32;
        }
        $vars[] = "certid";
        tMA32:
        if (!isset($_REQUEST["fromemail"])) {
            goto EM50E;
        }
        $from = false;
        if (!filter_var($_REQUEST["fromemail"], FILTER_VALIDATE_EMAIL)) {
            goto IKzZ0;
        }
        $from = $_REQUEST["fromemail"];
        IKzZ0:
        $this->setConfig("fromemail", $from);
        EM50E:
        $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 dG82y;
        }
        dG82y:
        $upstreamfqdn = $tokenData["clients"]["apiUrl"];
        $upstreamdomain = $tokenData["clients"]["domain"];
        $submittedFullFQDN = $_POST["fullFQDN"];
        if (!(isset($_POST["type"]) && $_POST["type"] == "upstream")) {
            goto MrTFN;
        }
        $submittedDomain = $_POST["domain"];
        MrTFN:
        $status = true;
        $message = '';
        $settings = array();
        if (!($upstreamfqdn != $submittedFullFQDN)) {
            goto bXOV0;
        }
        dbug(sprintf("We detected an updated URL used for external access. Previous: %s, new: %s.", $upstreamfqdn, $submittedFullFQDN));
        $settings["fullfqdn"] = $submittedFullFQDN;
        bXOV0:
        if (!($upstreamreq && $upstreamdomain != $submittedDomain)) {
            goto WTCkI;
        }
        dbug(sprintf("We detected an updated domain used for external access. Previous: %s, new: %s.", $upstreamdomain, $submittedDomain));
        $settings["pbxdomain"] = $submittedDomain;
        WTCkI:
        if (empty($settings)) {
            goto SZlks;
        }
        $ret = RazrClient::updateSettings($tokenData["token"], $settings);
        $status = $ret["status"];
        $message = $ret["body"];
        dbug("Upstream Response: " . $message);
        $this->addToken($tokenData["token"]);
        SZlks:
        if (!($upstreamreq && !empty($settings["fullfqdn"]))) {
            if (!(isset($_POST["protocol"]) && isset($_POST["certid"]) && isset($_POST["port"]) && isset($_POST["quickdialsorting"]))) {
                goto Xn0N8;
            }
            $this->setApiConfig($_POST["protocol"], $_POST["certid"], $_POST["port"], $_POST["quickdialsorting"]);
            Xn0N8:
            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 L60GQ;
                }
                $interval = trim($_REQUEST["extprovint"]);
                L60GQ:
                $this->setConfig("extProvInterval", $interval);
                goto lNRew;
            default:
                return array("status" => false, "message" => _("Unknown Support Command"));
        }
        lNRew:
    }
    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 = '', $recording = "enabled", $server_contacts = "enabled")
    {
        $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, "recording" => $recording, "server_contacts" => $server_contacts), "userenabled");
                goto Z5YMe;
            case "disabled":
                $this->setConfig($id, array("enabled" => $enabled, "messaging" => $messaging, "smsdid" => $did, "pageautoanswer" => $pageautoanswer, "stunurl" => $stunurl, "enablepark" => $enablepark, "parkinglot" => $parkinglot, "recording" => $recording, "server_contacts" => $server_contacts), "userdisabled");
                goto Z5YMe;
            case "inherit":
                $this->setConfig($id, array("enabled" => $enabled, "messaging" => $messaging, "smsdid" => $did, "pageautoanswer" => $pageautoanswer, "stunurl" => $stunurl, "enablepark" => $enablepark, "parkinglot" => $parkinglot, "recording" => $recording, "server_contacts" => $server_contacts), "userinherit");
                goto Z5YMe;
            default:
                goto Z5YMe;
        }
        Z5YMe:
        $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 = '', $recording = "enabled", $server_contacts = "enabled")
    {
        $this->delConfig($id, "groupenabled");
        $this->setConfig($id, array("enabled" => $enabled, "messaging" => $messaging, "pageautoanswer" => $pageautoanswer, "stunurl" => $stunurl, "enablepark" => $enablepark, "parkinglot" => $parkinglot, "recording" => $recording, "server_contacts" => $server_contacts), "groupenabled");
        $this->permissionLottery();
        return $this;
    }
    public function getUserSettings($id)
    {
        $defaults = array("enabled" => "inherit", "messaging" => "inherit", "recording" => "inherit", "server_contacts" => "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 hVnqr;
            }
            $out = $enabled;
            hVnqr:
            $disabled = $this->getConfig($id, "userdisabled");
            if (!$disabled) {
                goto qaf5w;
            }
            $out = $disabled;
            qaf5w:
            $inherit = $this->getConfig($id, "userinherit");
            if (!$inherit) {
                goto gTgnr;
            }
            $out = $inherit;
            $out["inherited"] = true;
            gTgnr:
            foreach ($defaults as $key => $value) {
                if (!(!isset($out[$key]) || empty($out[$key]))) {
                    goto WqfNm;
                }
                $out[$key] = $value;
                WqfNm:
            }
            $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" => '', "recording" => "enabled", "server_contacts" => "enabled");
        if (!empty($id)) {
            $config = $this->getConfig($id, "groupenabled");
            if (!$config) {
                return $defaults;
            }
            foreach ($defaults as $key => $value) {
                if (isset($config[$key])) {
                    goto GZQ_7;
                }
                $config[$key] = $value;
                GZQ_7:
            }
            return $config;
        }
        return $defaults;
    }
    public function getCombinedSettings($id)
    {
        $usersettings = $this->getUserSettings($id);
        if (!($usersettings["enabled"] !== "inherit" && $usersettings["messaging"] !== "inherit")) {
            goto ukuBS;
        }
        $usersettings["inherited"] = false;
        ukuBS:
        $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 gvCvZ;
        }
        $lastpriority = 0;
        foreach ($groups as $group) {
            $config = $this->getGroupSettings($group);
            $currentGroup = $this->FreePBX->Userman->getGroupByGID($group);
            $currentpriority = $currentGroup["priority"];
            if (!($usersettings["enabled"] === "inherit")) {
                goto qAH0R;
            }
            $usersettings["enabled"] = $config["enabled"];
            $usersettings["inherited"] = true;
            $usersettings["inheritedfrom"] = $group;
            qAH0R:
            $settinglist = array("messaging", "pageautoanswer", "stunurl", "enablepark", "parkinglot", "recording", "server_contacts");
            foreach ($settinglist as $key) {
                if (!(!empty($usersettings[$key]) && $usersettings[$key] !== "inherit")) {
                    if (!($currentpriority >= $lastpriority)) {
                        goto Hhpbe;
                    }
                    $usersettings[$key] = $config[$key];
                    Hhpbe:
                    goto tGvbL;
                }
                tGvbL:
            }
            $lastpriority = $currentpriority;
        }
        gvCvZ:
        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 vO892;
                    }
                    $output->writeln(_("Starting Clearly Anywhere daemon"));
                    vO892:
                    $this->FreePBX->Pm2->start("clearlysp", "/var/www/html/node/build/bundle.js");
                    if (!is_object($output)) {
                        goto xxrGU;
                    }
                    $progress = new ProgressBar($output, 0);
                    $progress->setFormat("[%bar%] %elapsed%");
                    $progress->start();
                    xxrGU:
                    $i = 0;
                    PKoXY:
                    if (!true) {
                        goto VQJ22;
                    }
                    $data = $this->FreePBX->Pm2->getStatus("clearlysp");
                    if (!(!empty($data) && $data["pm2_env"]["status"] == "online")) {
                        if (!is_object($output)) {
                            goto YyfuT;
                        }
                        $progress->setProgress($i);
                        YyfuT:
                        $i++;
                        usleep(100000);
                        goto PKoXY;
                    }
                    if (!is_object($output)) {
                        goto UDGiA;
                    }
                    $progress->finish();
                    UDGiA:
                    VQJ22:
                    if (!is_object($output)) {
                        goto F7Lif;
                    }
                    $output->writeln('');
                    F7Lif:
                    if (empty($data)) {
                        if (!is_object($output)) {
                            goto JKeKg;
                        }
                        $output->write("<error>" . _("Failed to run: Softphone Daemon'") . "</error>");
                        JKeKg:
                        return false;
                    }
                    $this->FreePBX->Pm2->reset("clearlysp");
                    if (!is_object($output)) {
                        goto AtDMM;
                    }
                    $output->writeln(sprintf(_("Started Softphone Daemon. PID is %s"), $data["pid"]));
                    AtDMM:
                    return $data["pid"];
                }
                if (!is_object($output)) {
                    goto fXOIo;
                }
                $output->writeln(sprintf(_("Softphone daemon has already been running on PID %s for %s"), $status["pid"], $status["pm2_env"]["created_at_human_diff"]));
                fXOIo:
                return $status["pid"];
            }
            if (is_object($output)) {
                $output->writeln(_("PM2 is not installed or enabled, unable to start Softphone daemon."));
                goto kMsk7;
            }
            outn(_("PM2 is not installed or enabled, unable to start Softphone daemon"));
            kMsk7:
            return;
        }
        if (is_object($outpu


■【無料】ワードプレス:マルウェアスキャン&セキュリティープラグイン [マルウェア・ウィルス検出と駆除]

■WordPress のマルウェア駆除、セキュリティー対策 カスタマイズや修正、引っ越し・復旧のご依頼承ります

(C)2019 ワードプレス ドクター All rights reserved.