/** * Sends a password reset email * @param {int} $id The userid */ public function sendPassResetEmail($id) { global $amp_conf; $user = $this->getUserByID($id); if (empty($user) || empty($user['email'])) { return false; } $token = $this->Userman->generatePasswordResetToken($id); if (empty($token)) { return false; } $user['token'] = $token['token']; $user['brand'] = $this->brand; $user['host'] = 'http://' . $_SERVER["SERVER_NAME"]; $user['link'] = $user['host'] . "/ucp/?forgot=" . $user['token']; $user['valid'] = date("h:i:s A", $token['valid']); $ports = array(); if ($this->FreePBX->Modules->moduleHasMethod("sysadmin", "getPorts")) { $ports = \FreePBX::Sysadmin()->getPorts(); } else { if (!function_exists('sysadmin_get_portmgmt') && $this->FreePBX->Modules->checkStatus('sysadmin') && file_exists($this->FreePBX->Config()->get('AMPWEBROOT') . '/admin/modules/sysadmin/functions.inc.php')) { include $this->FreePBX->Config()->get('AMPWEBROOT') . '/admin/modules/sysadmin/functions.inc.php'; } if (function_exists('sysadmin_get_portmgmt')) { $ports = sysadmin_get_portmgmt(); } } if (!empty($ports['ucp'])) { $user['host'] = $user['host'] . ":" . $ports['ucp']; $user['link'] = $user['host'] . "/?forgot=" . $user['token']; } $template = file_get_contents(__DIR__ . '/views/emails/reset_text.tpl'); preg_match_all('/%([\\w|\\d]*)%/', $template, $matches); foreach ($matches[1] as $match) { $replacement = !empty($user[$match]) ? $user[$match] : ''; $template = str_replace('%' . $match . '%', $replacement, $template); } $this->Userman->sendEmail($user['id'], $this->brand . " password reset", $template); }
private function getSvc_restapps() { $retarr = array("name" => _("REST Apps"), "defzones" => array("internal"), "descr" => _("Text for REST Apps not done..."), "fw" => array(array("protocol" => "tcp", "port" => 85))); // TODO: This is not portable for machines that don't have sysadmin. // Ask sysadmin for the REAL port of the admin interface try { $ports = \FreePBX::Sysadmin()->getPorts(); $retarr['fw'][0]['port'] = $ports['restapps']; } catch (\Exception $e) { // ignore } return $retarr; }