当前位置: 首页>>代码示例>>PHP>>正文


PHP freepbx_log函数代码示例

本文整理汇总了PHP中freepbx_log函数的典型用法代码示例。如果您正苦于以下问题:PHP freepbx_log函数的具体用法?PHP freepbx_log怎么用?PHP freepbx_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了freepbx_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _module_backtrace

function _module_backtrace()
{
    $trace = debug_backtrace();
    $function = $trace[1]['function'];
    $line = $trace[1]['line'];
    $file = $trace[1]['file'];
    freepbx_log(FPBX_LOG_WARNING, 'Depreciated Function ' . $function . ' detected in ' . $file . ' on line ' . $line);
}
开发者ID:powerpbx,项目名称:framework,代码行数:8,代码来源:modulefunctions.legacy.php

示例2: framework_print_errors

function framework_print_errors($src, $dst, $errors)
{
    out("error copying files:");
    out(sprintf(_("'cp -rf' from src: '%s' to dst: '%s'...details follow"), $src, $dst));
    freepbx_log(FPBX_LOG_ERROR, sprintf(_("framework couldn't copy file to %s"), $dst));
    foreach ($errors as $error) {
        out("{$error}");
        freepbx_log(FPBX_LOG_ERROR, _("cp error output: {$error}"));
    }
}
开发者ID:ntadmin,项目名称:framework,代码行数:10,代码来源:install.php

示例3: showPage

 public function showPage()
 {
     $media = $this->FreePBX->Media();
     $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : "";
     switch ($action) {
         case "edit":
             $data = $this->getRecordingById($_REQUEST['id']);
             $fcc = new \featurecode("recordings", 'edit-recording-' . $_REQUEST['id']);
             $rec_code = $fcc->getCode();
             $data['rec_code'] = $rec_code != '' ? $rec_code : $this->fcbase . $_REQUEST['id'];
         case "add":
             $data = isset($data) ? $data : array();
             $supported = $media->getSupportedFormats();
             ksort($supported['in']);
             ksort($supported['out']);
             $langs = $this->FreePBX->Soundlang->getLanguages();
             $default = $this->FreePBX->Soundlang->getLanguage();
             $sysrecs = $this->getSystemRecordings();
             $jsonsysrecs = json_encode($sysrecs);
             $message = '';
             if (json_last_error() !== JSON_ERROR_NONE) {
                 $message = sprintf(_("There was an error reading system recordings (%s)"), json_last_error_msg());
                 freepbx_log(FPBX_LOG_WARNING, "JSON decode error: " . json_last_error_msg());
                 $jsonsysrecs = array();
                 $sysrecs = array();
             }
             $supportedHTML5 = $media->getSupportedHTML5Formats();
             $convertto = array_intersect($supported['out'], $this->convert);
             $html = load_view(__DIR__ . "/views/form.php", array("message" => $message, "jsonsysrecs" => $jsonsysrecs, "convertto" => $convertto, "supportedHTML5" => implode(",", $supportedHTML5), "data" => $data, "default" => $default, "supported" => $supported, "langs" => $langs, "sysrecs" => $sysrecs));
             break;
         case "delete":
             $this->delRecording($_REQUEST['id']);
         default:
             $html = load_view(__DIR__ . "/views/grid.php", array());
             break;
     }
     return $html;
 }
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:38,代码来源:Recordings.class.php

示例4: outn

        $confs = $db_cdr->getRow($sql, DB_FETCHMODE_ASSOC);
        outn(_("checking if recordingfile file field needed in cdr.."));
        if (DB::IsError($confs)) {
            // no error... Already done
            $sql = "ALTER TABLE cdr ADD recordingfile VARCHAR ( 255 ) NOT NULL default ''";
            $results = $db_cdr->query($sql);
            if (DB::IsError($results)) {
                out(_("failed"));
                freepbx_log(FPBX_LOG_ERROR, "failed to add recordingfile field to cdr table during migration");
            }
            out(_("added"));
        } else {
            out(_("already there"));
        }
        $sql = "SELECT did FROM cdr";
        $confs = $db_cdr->getRow($sql, DB_FETCHMODE_ASSOC);
        outn(_("checking if did file field needed in cdr.."));
        if (DB::IsError($confs)) {
            // no error... Already done
            $sql = "ALTER TABLE cdr ADD did VARCHAR ( 50 ) NOT NULL default ''";
            $results = $db_cdr->query($sql);
            if (DB::IsError($results)) {
                out(_("failed"));
                freepbx_log(FPBX_LOG_ERROR, "failed to add did field to cdr table during migration");
            }
            out(_("added"));
        } else {
            out(_("already there"));
        }
    }
}
开发者ID:lidl,项目名称:framework,代码行数:31,代码来源:migration.php

示例5: array

//connect to cdrdb if requestes
if ($bootstrap_settings['cdrdb']) {
    $dsn = array('phptype' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : $amp_conf['AMPDBENGINE'], 'hostspec' => $amp_conf['CDRDBHOST'] ? $amp_conf['CDRDBHOST'] : $amp_conf['AMPDBHOST'], 'username' => $amp_conf['CDRDBUSER'] ? $amp_conf['CDRDBUSER'] : $amp_conf['AMPDBUSER'], 'password' => $amp_conf['CDRDBPASS'] ? $amp_conf['CDRDBPASS'] : $amp_conf['AMPDBPASS'], 'port' => $amp_conf['CDRDBPORT'] ? $amp_conf['CDRDBPORT'] : '3306', 'database' => $amp_conf['CDRDBNAME'] ? $amp_conf['CDRDBNAME'] : 'asteriskcdrdb');
    $cdrdb = DB::connect($dsn);
}
$bootstrap_settings['astman_connected'] = false;
if (!$bootstrap_settings['skip_astman']) {
    require_once $dirname . '/libraries/php-asmanager.php';
    $astman = new AGI_AsteriskManager($bootstrap_settings['astman_config'], $bootstrap_settings['astman_options']);
    // attempt to connect to asterisk manager proxy
    if (!$amp_conf["ASTMANAGERPROXYPORT"] || !($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) {
        // attempt to connect directly to asterisk, if no proxy or if proxy failed
        if (!($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) {
            // couldn't connect at all
            unset($astman);
            freepbx_log(FPBX_LOG_CRITICAL, "Connection attmempt to AMI failed");
        } else {
            $bootstrap_settings['astman_connected'] = true;
        }
    }
} else {
    $bootstrap_settings['astman_connected'] = true;
}
//Because BMO was moved upward we have to inject this lower
if (isset($astman)) {
    FreePBX::create()->astman = $astman;
}
//include gui functions + auth if nesesarry
// If set to freepbx_auth but we are in a cli mode, then don't bother authenticating either way.
// TODO: is it ever possible through an apache or httplite configuration to run a web launched php script
//       as 'cli' ? Also, from a security perspective, should we just require this always be set to false
开发者ID:ntadmin,项目名称:framework,代码行数:31,代码来源:bootstrap.php

示例6: output

 function output()
 {
     global $version;
     if (version_compare($version, "12.5", "<")) {
         global $chan_dahdi;
         if ($chan_dahdi) {
             $command = 'DAHDIBarge';
         } else {
             $command = 'ZapBarge';
         }
         return "{$command}(" . $this->data . ")";
     } else {
         $trace = debug_backtrace();
         $function = $trace[1]['function'];
         $line = $trace[1]['line'];
         $file = $trace[1]['file'];
         freepbx_log(FPBX_LOG_WARNING, 'Depreciated Asterisk Function ' . $function . ' detected in ' . $file . ' on line ' . $line);
         $n = new ext_noop('Using zapbarge or DAHDibarge has been removed');
         $n->data = 'Using zapbarge or DAHDibarge has been removed';
         return $n->output();
     }
 }
开发者ID:nriendeau,项目名称:framework,代码行数:22,代码来源:extensions.class.php

示例7: _prepare_conf_value


//.........这里部分代码省略.........
                 $this->_last_update_status['msg'] = _("Invalid value supplied to select");
                 $this->_last_update_status['saved_value'] = $ret;
                 $this->_last_update_status['saved'] = false;
                 //
                 // NOTE: returning from function early!
                 return $ret;
             }
             break;
         case CONF_TYPE_FSELECT:
             if (!is_array($options)) {
                 $options = unserialize($options);
             }
             if (array_key_exists($value, $options)) {
                 $ret = $value;
                 $this->_last_update_status['validated'] = true;
             } else {
                 $ret = null;
                 $this->_last_update_status['validated'] = false;
                 $this->_last_update_status['msg'] = _("Invalid value supplied to select");
                 $this->_last_update_status['saved_value'] = $ret;
                 $this->_last_update_status['saved'] = false;
                 //
                 // NOTE: returning from function early!
                 return $ret;
             }
             break;
         case CONF_TYPE_DIR:
             // we don't consider trailing '/' in a directory an error for validation purposes
             $value = rtrim($value, '/');
             // NOTE: fallthrough to CONF_TYPE_TEXT, NO break on purpose!
             //       |
             //       |
             //       V
         // NOTE: fallthrough to CONF_TYPE_TEXT, NO break on purpose!
         //       |
         //       |
         //       V
         case CONF_TYPE_TEXT:
         case CONF_TYPE_TEXTAREA:
             if ($value == '' && !$emptyok) {
                 $this->_last_update_status['validated'] = false;
                 $this->_last_update_status['msg'] = _("Empty value not allowed for this field");
             } else {
                 if ($options != '' && $value != '') {
                     if (preg_match($options, $value)) {
                         $ret = $value;
                         $this->_last_update_status['validated'] = true;
                     } else {
                         $ret = null;
                         $this->_last_update_status['validated'] = false;
                         $this->_last_update_status['msg'] = sprintf(_("Invalid value supplied violates the validation regex: %s"), $options);
                         $this->_last_update_status['saved_value'] = $ret;
                         $this->_last_update_status['saved'] = false;
                         //
                         // NOTE: returning from function early!
                         return $ret;
                     }
                 } else {
                     $ret = $value;
                     $this->_last_update_status['validated'] = true;
                 }
             }
             //if cli then dont echo out newlines its confusing
             if (php_sapi_name() === 'cli' && $type === CONF_TYPE_TEXTAREA) {
                 //$ret = str_replace(array("\r", "\n", "\r\n"), ",", $ret);
             }
             break;
         case CONF_TYPE_INT:
             $ret = !is_numeric($value) && $value != '' ? '' : $value;
             $ret = $emptyok && (string) trim($ret) === '' ? '' : (int) $ret;
             if ($options != '' && (string) $ret !== '') {
                 $range = is_array($options) ? $options : explode(',', $options);
                 switch (true) {
                     case $ret < $range[0]:
                         $ret = $range[0];
                         $this->_last_update_status['validated'] = false;
                         $this->_last_update_status['msg'] = sprintf(_("Value [%s] out of range, changed to [%s]"), $value, $ret);
                         break;
                     case $ret > $range[1]:
                         $ret = $range[1];
                         $this->_last_update_status['validated'] = false;
                         $this->_last_update_status['msg'] = sprintf(_("Value [%s] out of range, changed to [%s]"), $value, $ret);
                         break;
                     default:
                         $this->_last_update_status['validated'] = (string) $ret === (string) $value;
                         break;
                 }
             } else {
                 $this->_last_update_status['validated'] = (string) $ret === (string) $value;
             }
             break;
         default:
             $this->_last_update_status['validated'] = false;
             freepbx_log(FPBX_LOG_ERROR, sprintf(_("unknown type: [%s]"), $type));
             break;
     }
     $this->_last_update_status['saved_value'] = $ret;
     $this->_last_update_status['saved'] = true;
     return $ret;
 }
开发者ID:powerpbx,项目名称:framework,代码行数:101,代码来源:Freepbx_conf.class.php

示例8: show_deprecated

function show_deprecated($message = "", $dismisable = true, $logit = false)
{
    if ($dismisable) {
        $html = '<div class="alert alert-warning alert-dismissable hidden depnotice" data-for="dep">';
        $html .= '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>';
    } else {
        $html = '<div class="alert alert-warning hidden">';
    }
    $html .= '<h3><i class="fa fa-warning"></i> ' . _("This Module has been deprecated") . '</h3>';
    $html .= $message;
    $html .= '</div>';
    $html .= '<script>';
    $html .= '$( document ).ready(function() {';
    $html .= 'if($.cookie(res[2]+"depdis") != "1"){$(".depnotice").each(function(){$(this).removeClass("hidden")})}';
    $html .= '$(".alert").bind("closed.bs.alert", function(){if($(this).data("for") == "dep"){$.cookie(res[2]+"depdis", "1")}});';
    $html .= '});';
    $html .= '</script>';
    if ($logit) {
        freepbx_log($message);
        dbug($message);
    }
    return $html;
}
开发者ID:lidl,项目名称:framework,代码行数:23,代码来源:view.functions.php

示例9: out

    $result = $db->query($sql);
    if (DB::IsError($result)) {
        out(_("Unable to add index to tech field in devices"));
        freepbx_log(FPBX_LOG_ERROR, "Failed to add index to tech field in the devices table");
    } else {
        out(_("Adding index to tech field in the devices"));
    }
}
$sql = "SHOW KEYS FROM users WHERE Key_name='extension'";
$check = $db->getOne($sql);
if (empty($check)) {
    $sql = "ALTER TABLE users ADD KEY `extension` (`extension`)";
    $result = $db->query($sql);
    if (DB::IsError($result)) {
        out(_("Unable to add index to extensions field in users"));
        freepbx_log(FPBX_LOG_ERROR, "Failed to add index to extensions field in the users table");
    } else {
        out(_("Adding index to extensions field in the users"));
    }
}
// The following are from General Settings that may need to be migrated.
// We will first create them all, the define_conf_settings() method will
// not change the value if already set. We will update the settings
// to the currently configured values from the globals table afer defining
// them here and then remove them from the globals table.
$globals_convert['VMX_CONTEXT'] = 'from-internal';
$globals_convert['VMX_PRI'] = '1';
$globals_convert['VMX_TIMEDEST_CONTEXT'] = '';
$globals_convert['VMX_TIMEDEST_EXT'] = 'dovm';
$globals_convert['VMX_TIMEDEST_PRI'] = '1';
$globals_convert['VMX_LOOPDEST_CONTEXT'] = '';
开发者ID:lidl,项目名称:core,代码行数:31,代码来源:install.php

示例10: _freepbx_log

 /**
  * FreePBX Logging
  *
  * @param const $level Notification Level to show (can be blank for all)
  * @param string $module Raw name of the module requesting
  * @param string $id ID of the notification
  * @param string $display_text The text that will be displayed as the subject/header of the message
  * @ignore
  */
 function _freepbx_log($level, $module, $id, $display_text, $extended_text = null)
 {
     global $amp_conf;
     if ($amp_conf['LOG_NOTIFICATIONS']) {
         if ($extended_text) {
             $display_text .= " ({$extended_text})";
         }
         freepbx_log($level, "[NOTIFICATION]-[{$module}]-[{$id}] - {$display_text}");
     }
 }
开发者ID:ntadmin,项目名称:framework,代码行数:19,代码来源:Notifications.class.php

示例11: backup_migrate_legacy

function backup_migrate_legacy($bu)
{
    global $amp_conf;
    $legacy_name = '';
    $name = pathinfo($bu, PATHINFO_BASENAME);
    if (substr($name, -7) != '.tar.gz') {
        return false;
    }
    //get legacy name based on the directory the legacy backup was origionally created in
    //were expcecting to see something like: /tmp/ampbackups.20110310.16.00.00/
    //in the tarball
    $cmd[] = fpbx_which('tar');
    $cmd[] = 'tf';
    $cmd[] = $bu;
    exec(implode(' ', $cmd), $res);
    unset($cmd);
    foreach ($res as $r) {
        if (preg_match('/\\/tmp\\/ampbackups\\.([\\d]{8}(\\.[\\d]{2}){3})\\//', $r, $legacy_name)) {
            if (isset($legacy_name[1])) {
                $legacy_name = $legacy_name[1];
                break;
            }
        }
    }
    if (!$legacy_name) {
        return false;
    }
    //create directory where tarball will be exctracted to
    $dir = $amp_conf['ASTSPOOLDIR'] . '/tmp/' . $legacy_name;
    mkdir($dir, 0755, true);
    $cmd[] = fpbx_which('tar');
    $cmd[] = '-zxf';
    $cmd[] = $bu;
    $cmd[] = ' -C ' . $dir;
    exec(implode(' ', $cmd));
    unset($cmd);
    $dir2 = $dir . '/tmp/ampbackups.' . $legacy_name;
    //exctract sub tarballs
    foreach (scandir($dir2) as $file) {
        if (substr($file, -7) == '.tar.gz') {
            $cmd[] = fpbx_which('tar');
            $cmd[] = '-zxf';
            $cmd[] = $dir2 . '/' . $file;
            $cmd[] = ' -C ' . $dir2;
            exec(implode(' ', $cmd));
            unset($cmd);
            unlink($dir2 . '/' . $file);
        }
    }
    //add files to manifest
    $ret['file_list'] = scandirr($dir2);
    $ret['file_count'] = count($ret['file_list'], COUNT_RECURSIVE);
    $ret['fpbx_db'] = '';
    $ret['fpbx_cdrdb'] = '';
    //format db's + add to manifest
    if (is_file($dir2 . '/astdb.dump')) {
        //rename file
        rename($dir2 . '/astdb.dump', $dir2 . '/astdb');
        //remove it from the file_list
        unset($ret['file_list'][array_search('astdb.dump', $ret['file_list'])]);
        //set the manifest
        $ret['astdb'] = 'astdb';
    } elseif (is_file($dir2 . '/tmp/ampbackups.' . $legacy_name . '/astdb.dump')) {
        rename($dir2 . '/tmp/ampbackups.' . $legacy_name . '/astdb.dump', $dir2 . '/astdb');
        $ret['astdb'] = 'astdb';
    }
    //serialize the astdb
    if (!empty($ret['astdb'])) {
        $astdb = array();
        foreach (file($dir2 . '/astdb') as $line) {
            $line = explode('] [', trim($line, '[]/'));
            //chuck the bad values
            if ($line[1] == '<bad value>') {
                continue;
            }
            //expldoe the key
            list($family, $key) = explode('/', $line[0], 2);
            //add to astdb array
            $astdb[$family][$key] = trim(trim($line[1]), ']');
        }
        file_put_contents($dir2 . '/astdb', serialize($astdb));
    }
    //migrate mysql files to a format that we can restore from
    $src = $dir2 . '/asterisk.sql';
    if (is_file($src)) {
        $dst = $dir2 . '/mysql-db.sql';
        unset($ret['file_list'][array_search('asterisk.sql', $ret['file_list'])]);
        //remove from manifest
        $ret['fpbx_db'] = 'mysql-db';
        $ret['mysql']['db'] = array('file' => 'mysql-db.sql');
        // remove SET and comments that later break restores when using pear
        $cmd[] = fpbx_which('grep');
        $cmd[] = "-v '^\\/\\*\\|^SET\\|^--'";
        $cmd[] = $src;
        $cmd[] = ' > ' . $dst;
        exec(implode(' ', $cmd), $file, $status);
        if ($status) {
            // The grep failed, if there is a $dst file remove it and either way rename the $src
            freepbx_log(FPBX_LOG_ERROR, _("Failed converting asterisk.sql to proper format, renaming to mysql-db.sql in current state"));
            if (is_file($dst)) {
//.........这里部分代码省略.........
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:101,代码来源:restore.php

示例12: _module_runscripts_include

/** Include additional files requested in module.xml for install and uninstall
 * @param array   The modulexml array
 * @param string  The action to perform, either 'install' or 'uninstall'
 * @return boolean   If the action was successful, currently TRUE so we don't prevent the install
 */
function _module_runscripts_include($modulexml, $type)
{
    global $amp_conf;
    foreach ($modulexml as $modulename => $items) {
        $moduledir = $amp_conf["AMPWEBROOT"] . "/admin/modules/" . $modulename;
        if (isset($items['fileinclude'][$type]) && !empty($items['fileinclude'][$type])) {
            if (!is_array($items['fileinclude'][$type])) {
                $ret = _modules_doinclude($moduledir . '/' . $items['fileinclude'][$type], $modulename);
                if (!$ret) {
                    freepbx_log(FPBX_LOG_WARNING, sprintf(_("failed to include %s during %s of the %s module."), $items['fileinclude'][$type], $type, $modulename));
                }
            } else {
                foreach ($items['fileinclude'][$type] as $key => $filename) {
                    $ret = _modules_doinclude($moduledir . '/' . $filename, $modulename);
                    if (!$ret) {
                        freepbx_log(FPBX_LOG_WARNING, sprintf(_("failed to include %s during %s of the %s module."), $filename, $type, $modulename));
                    }
                }
            }
        }
    }
    return true;
}
开发者ID:jfinstrom,项目名称:framework,代码行数:28,代码来源:module.functions.php

示例13: out

}
if (!function_exists("out")) {
    function out($text)
    {
        echo $text . "<br />";
    }
}
// Remove this section in FreePBX 14
$sql = "SHOW KEYS FROM `{$db_name}`.`{$db_table_name}` WHERE Key_name='did'";
$check = $dbcdr->getOne($sql);
if (empty($check)) {
    $sql = "ALTER TABLE `{$db_name}`.`{$db_table_name}` ADD INDEX `did` (`did` ASC)";
    $result = $dbcdr->query($sql);
    if (DB::IsError($result)) {
        out(_("Unable to add index to did field in the cdr table"));
        freepbx_log(FPBX_LOG_ERROR, "Failed to add index to did field in the cdr table");
    } else {
        out(_("Adding index to did field in the cdr table"));
    }
}
// Remove this section in FreePBX 14
$db_name = FreePBX::Config()->get('CDRDBNAME');
$db_host = FreePBX::Config()->get('CDRDBHOST');
$db_port = FreePBX::Config()->get('CDRDBPORT');
$db_user = FreePBX::Config()->get('CDRDBUSER');
$db_pass = FreePBX::Config()->get('CDRDBPASS');
$db_table = FreePBX::Config()->get('CDRDBTABLENAME');
$dbt = FreePBX::Config()->get('CDRDBTYPE');
$db_hash = array('mysql' => 'mysql', 'postgres' => 'pgsql');
$dbt = !empty($dbt) ? $dbt : 'mysql';
$db_type = $db_hash[$dbt];
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:31,代码来源:install.php

示例14: install

    public function install()
    {
        global $db;
        global $amp_conf;
        $sql[] = 'CREATE TABLE IF NOT EXISTS `restapi_general` (
		  `keyword` varchar(50),
		  `value` varchar(150) default NULL,
		  UNIQUE KEY `keyword` (`keyword`)
		);';
        $sql[] = 'CREATE TABLE IF NOT EXISTS `restapi_log_event_details` (
		  `id` int(11) default NULL AUTO_INCREMENT,
		  `e_id` int(11) default NULL,
		  `time` int(11) default NULL,
		  `event` varchar(150) default NULL,
		  `data` text,
		  `trigger` text,
		   UNIQUE KEY `id` (`id`),
		   KEY `e_id` (`e_id`)
		);';
        $sql[] = 'CREATE TABLE IF NOT EXISTS `restapi_log_events` (
		  `id` int(11) default NULL AUTO_INCREMENT,
		  `time` int(11) default NULL,
		  `token` varchar(75) default NULL,
		  `signature` varchar(150) default NULL,
		  `ip` varchar(20) default NULL,
		  `server` varchar(75) default NULL,
		   UNIQUE KEY `id` (`id`),
		   KEY `time` (`time`),
		   KEY `token` (`token`)
		);';
        $sql[] = 'CREATE TABLE IF NOT EXISTS `restapi_token_details` (
		  `token_id` int(11) default NULL,
		  `key` varchar(50) default NULL,
		  `value` text default NULL
		);';
        $sql[] = 'CREATE TABLE IF NOT EXISTS `restapi_tokens` (
		  `id` int(11) default NULL AUTO_INCREMENT,
		  `name` varchar(150) default NULL,
		  `desc` varchar(250) default NULL,
		  UNIQUE KEY `id` (`id`)
		);';
        $sql[] = 'CREATE TABLE IF NOT EXISTS `restapi_token_user_mapping` (
		  `user` varchar(25) default NULL,
		  `token_id` int(11) default NULL
		);';
        $firstinstall = false;
        $q = $db->query('SELECT * FROM restapi_general;');
        if (\DB::isError($q)) {
            $firstinstall = true;
            $sql[] = 'INSERT IGNORE INTO `restapi_general` VALUES
			  ("status", "normal"),
			  ("token", "' . restapi_tokens_generate() . '"),
			  ("tokenkey", "' . restapi_tokens_generate() . '");';
        }
        foreach ($sql as $statement) {
            $check = $db->query($statement);
            if (\DB::IsError($check)) {
                die_freepbx("Can not execute {$statement} : " . $check->getMessage() . "\n");
            }
        }
        $sql = "SHOW KEYS FROM restapi_log_event_details WHERE Key_name='e_id'";
        $check = $db->getOne($sql);
        if (empty($check)) {
            $sql = "ALTER TABLE restapi_log_event_details ADD KEY `e_id` (`e_id`)";
            $result = $db->query($sql);
            if (\DB::IsError($result)) {
                out(_("Unable to add index to e_id field in restapi_log_event_details table"));
                freepbx_log(FPBX_LOG_ERROR, "Failed to add index to e_id field in the restapi_log_event_details table");
            } else {
                out(_("Adding index to e_id field in the restapi_log_event_details table"));
            }
        }
        $sql = "SHOW KEYS FROM restapi_log_events WHERE Key_name='time'";
        $check = $db->getOne($sql);
        if (empty($check)) {
            $sql = "ALTER TABLE restapi_log_events ADD KEY `time` (`time`), ADD KEY `token` (`token`)";
            $result = $db->query($sql);
            if (\DB::IsError($result)) {
                out(_("Unable to add index to time field in restapi_log_events table"));
                freepbx_log(FPBX_LOG_ERROR, "Failed to add index to time field in the restapi_log_events table");
            } else {
                out(_("Adding index to time field in the restapi_log_events table"));
            }
        }
        $sql = "SELECT data_type FROM information_schema.columns WHERE table_name = 'restapi_token_details' AND column_name = 'value' AND data_type = 'varchar'";
        $check = $db->getOne($sql);
        if (!empty($check)) {
            $sql = "ALTER TABLE restapi_token_details MODIFY `value` TEXT";
            $result = $db->query($sql);
            if (\DB::IsError($result)) {
                out(_("Unable to modify data type of value field in restapi_token_details table"));
            } else {
                out(_("Modifying data type of value field in the restapi_token_details table"));
            }
        }
        if (!file_exists($amp_conf['AMPWEBROOT'] . '/restapi')) {
            @mkdir($amp_conf['AMPWEBROOT'] . '/restapi');
        }
        if (!file_exists($amp_conf['AMPWEBROOT'] . '/restapi/rest.php')) {
            @symlink(dirname(__FILE__) . '/rest.php', $amp_conf['AMPWEBROOT'] . '/restapi/rest.php');
//.........这里部分代码省略.........
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:101,代码来源:Restapi.class.php

示例15: sendPassResetEmail

 /**
  * 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)) {
         freepbx_log(FPBX_LOG_NOTICE, sprintf(_("A token has already been generated for %s, not sending email again"), $user['username']));
         return false;
     }
     $user['token'] = $token['token'];
     $user['brand'] = $this->brand;
     $user['host'] = (!empty($_SERVER["HTTPS"]) ? 'https://' : '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);
 }
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:44,代码来源:Ucp.class.php


注:本文中的freepbx_log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。