本文整理汇总了PHP中registry_search函数的典型用法代码示例。如果您正苦于以下问题:PHP registry_search函数的具体用法?PHP registry_search怎么用?PHP registry_search使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了registry_search函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: site_config_get
/**
* Get site configuration
*
* @param integer $uid
* User ID
* @return array Site configuration
*/
function site_config_get($uid = 0)
{
global $user_config, $plugin_config;
$c_uid = (int) $uid ? (int) $uid : $user_config['uid'];
$reg = registry_search($c_uid, 'core', 'site_config');
$plugin_config['site']['site_config'] = $reg['core']['site_config'];
return $plugin_config['site']['site_config'];
}
示例2: incoming_pre_rules_get
/**
* Get pre rules
*
* @return array Pre rules
* Available pre rules keys:
* - match_username
* - match_groupcode
*/
function incoming_pre_rules_get()
{
// scan message for @username
$data = registry_search(1, 'feature', 'incoming', 'incoming_match_username');
$pre_rules['match_username'] = (int) $data['feature']['incoming']['incoming_match_username'];
// scan message for #groupcode
$data = registry_search(1, 'feature', 'incoming', 'incoming_match_groupcode');
$pre_rules['match_groupcode'] = (int) $data['feature']['incoming']['incoming_match_groupcode'];
return $pre_rules;
}
示例3: firewall_hook_blacklist_checkip
/**
* Check if IP address deserved to get listed in blacklist, if deserved then blacklist_addip()
*
* @param string $label
* single label, can be $username or $uid, its up to the implementator
* @param string $ip
* single IP address
* @return boolean TRUE on checked (not necessarily added)
*/
function firewall_hook_blacklist_checkip($label, $ip)
{
global $plugin_config;
$ret = FALSE;
$hash = md5($label . $ip);
$data = registry_search(0, 'feature', 'firewall');
$login_attempt = $data['feature']['firewall'][$hash];
if ($login_attempt > $plugin_config['firewall']['login_attempt_limit']) {
blacklist_addip($label, $ip);
}
$items[$hash] = $login_attempt ? $login_attempt + 1 : 1;
if (registry_update(0, 'feature', 'firewall', $items)) {
$ret = TRUE;
}
return $ret;
}
示例4: auth_validate_login
/**
* Validate username and password
*
* @param string $username
* Username
* @param string $password
* Password
* @return boolean TRUE when validated or boolean FALSE when validation failed
*/
function auth_validate_login($username, $password)
{
$uid = user_username2uid($username);
_log('login attempt u:' . $username . ' uid:' . $uid . ' p:' . md5($password) . ' ip:' . $_SERVER['REMOTE_ADDR'], 3, 'auth_validate_login');
// check blacklist
if (blacklist_ifipexists($username, $_SERVER['REMOTE_ADDR'])) {
_log('IP blacklisted u:' . $username . ' uid:' . $uid . ' ip:' . $_SERVER['REMOTE_ADDR'], 2, 'auth_validate_login');
return FALSE;
}
if (user_banned_get($uid)) {
_log('user banned u:' . $username . ' uid:' . $uid . ' ip:' . $_SERVER['REMOTE_ADDR'], 2, 'auth_validate_login');
return FALSE;
}
$db_query = "SELECT password FROM " . _DB_PREF_ . "_tblUser WHERE flag_deleted='0' AND username='{$username}'";
$db_result = dba_query($db_query);
$db_row = dba_fetch_array($db_result);
$res_password = trim($db_row['password']);
$password = md5($password);
if ($password && $res_password && $password == $res_password) {
_log('valid login u:' . $username . ' uid:' . $uid . ' ip:' . $_SERVER['REMOTE_ADDR'], 2, 'auth_validate_login');
// remove IP on successful login
blacklist_clearip($username, $_SERVER['REMOTE_ADDR']);
return true;
} else {
$ret = registry_search(1, 'auth', 'tmp_password', $username);
$tmp_password = $ret['auth']['tmp_password'][$username];
if ($password && $tmp_password && $password == $tmp_password) {
_log('valid login u:' . $username . ' uid:' . $uid . ' ip:' . $_SERVER['REMOTE_ADDR'] . ' using temporary password', 2, 'auth_validate_login');
if (!registry_remove(1, 'auth', 'tmp_password', $username)) {
_log('WARNING: unable to remove temporary password after successful login', 3, 'login');
}
// remove IP on successful login
blacklist_clearip($username, $_SERVER['REMOTE_ADDR']);
return true;
}
}
// check blacklist
blacklist_checkip($username, $_SERVER['REMOTE_ADDR']);
_log('invalid login u:' . $username . ' uid:' . $uid . ' ip:' . $_SERVER['REMOTE_ADDR'], 2, 'auth_validate_login');
return false;
}
示例5: user_getdatabyusername
$json['status'] = 'ERR';
$json['error'] = '100';
}
} else {
$json['status'] = 'ERR';
$json['error'] = '100';
}
$log_this = TRUE;
break;
case "WS_LOGIN":
$user = user_getdatabyusername($u);
if ($c_uid = $user['uid']) {
// supplied login key
$login_key = trim($_REQUEST['login_key']);
// saved login key
$reg = registry_search($c_uid, 'core', 'webservices', 'login_key');
$c_login_key = trim($reg['core']['webservices']['login_key']);
// immediately remove saved login key, only proceed upon successful removal
if (registry_remove($c_uid, 'core', 'webservices', 'login_key')) {
// auth by comparing login keys
if ($login_key && $c_login_key && $login_key == $c_login_key) {
// setup login session
auth_session_setup($c_uid);
_log("webservices logged in u:" . $u . " ip:" . $_SERVER['REMOTE_ADDR'] . " op:" . _OP_, 3, "webservices");
} else {
_log("webservices invalid login u:" . $u . " ip:" . $_SERVER['REMOTE_ADDR'] . " op:" . _OP_, 3, "webservices");
}
} else {
_log("webservices error unable to remove registry u:" . $u . " ip:" . $_SERVER['REMOTE_ADDR'] . " op:" . _OP_, 3, "webservices");
}
} else {
示例6: defined
<?php
defined('_SECURE_') or die('Forbidden');
$callback_url = '';
if (!$core_config['daemon_process']) {
$callback_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/plugin/gateway/generic/callback.php";
$callback_url = str_replace("//", "/", $callback_url);
$callback_url = ($core_config['ishttps'] ? "https://" : "http://") . $callback_url;
}
$data = registry_search(0, 'gateway', 'generic');
$plugin_config['generic'] = $data['gateway']['generic'];
$plugin_config['generic']['name'] = 'generic';
$plugin_config['generic']['default_url'] = 'http://example.api.url/handler.php?user={GENERIC_API_USERNAME}&pwd={GENERIC_API_PASSWORD}&sender={GENERIC_SENDER}&msisdn={GENERIC_TO}&message={GENERIC_MESSAGE}';
$plugin_config['generic']['default_callback_url'] = $callback_url;
if (!trim($plugin_config['generic']['url'])) {
$plugin_config['generic']['url'] = $plugin_config['generic']['default_url'];
}
if (!trim($plugin_config['generic']['callback_url'])) {
$plugin_config['generic']['callback_url'] = $plugin_config['generic']['default_callback_url'];
}
if (!trim($plugin_config['generic']['callback_url_authcode'])) {
$plugin_config['generic']['callback_url_authcode'] = sha1(_PID_);
}
// smsc configuration
$plugin_config['generic']['_smsc_config_'] = array('url' => _('Generic send SMS URL'), 'api_username' => _('API username'), 'api_password' => _('API password'), 'module_sender' => _('Module sender ID'), 'datetime_timezone' => _('Module timezone'));
示例7: defined
<?php
defined('_SECURE_') or die('Forbidden');
$callback_url = '';
if (!$core_config['daemon_process']) {
$callback_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/plugin/gateway/jasmin/callback.php";
$callback_url = str_replace("//", "/", $callback_url);
$callback_url = ($core_config['ishttps'] ? "https://" : "http://") . $callback_url;
}
$data = registry_search(0, 'gateway', 'jasmin');
$plugin_config['jasmin'] = $data['gateway']['jasmin'];
$plugin_config['jasmin']['name'] = 'jasmin';
$plugin_config['jasmin']['default_url'] = 'https://127.0.0.1:1401/send';
$plugin_config['jasmin']['default_callback_url'] = $callback_url;
if (!trim($plugin_config['jasmin']['url'])) {
$plugin_config['jasmin']['url'] = $plugin_config['jasmin']['default_url'];
}
if (!trim($plugin_config['jasmin']['callback_url'])) {
$plugin_config['jasmin']['callback_url'] = $plugin_config['jasmin']['default_callback_url'];
}
// smsc configuration
$plugin_config['jasmin']['_smsc_config_'] = array('url' => _('Jasmin send SMS URL'), 'callback_url' => _('Callback URL'), 'api_username' => _('API username'), 'api_password' => _('API password'), 'module_sender' => _('Module sender ID'), 'datetime_timezone' => _('Module timezone'));
示例8: error_reporting
*
* You should have received a copy of the GNU General Public License
* along with playSMS. If not, see <http://www.gnu.org/licenses/>.
*/
error_reporting(0);
if (!$called_from_hook_call) {
chdir("../../../");
// ignore CSRF
$core_config['init']['ignore_csrf'] = TRUE;
include "init.php";
include $core_config['apps_path']['libs'] . "/function.php";
chdir("plugin/feature/sms_sync/");
}
$r = $_REQUEST;
$c_uid = $r['uid'];
$list = registry_search($c_uid, 'feature', 'sms_sync');
$sms_sync_secret = $list['feature']['sms_sync']['secret'];
$sms_sync_enable = $list['feature']['sms_sync']['enable'];
$message_id = $r['message_id'];
$sms_datetime = core_display_datetime(core_get_datetime());
$sms_sender = $r['from'];
$message = $r['message'];
$sms_receiver = $r['sent_to'];
$ok = FALSE;
if ($sms_sync_enable && $c_uid && $r['secret'] == $sms_sync_secret && $message_id && $sms_sender && $message) {
$db_table = _DB_PREF_ . '_featureSmssysnc';
$conditions = array('uid' => $c_uid, 'message_id' => $message_id);
if (dba_isavail($db_table, $conditions, 'AND')) {
_log("saving uid:" . $c_uid . " dt:" . $sms_datetime . " ts:" . $r['sent_timestamp'] . " message_id:" . $message_id . " s:" . $sms_sender . " m:" . $message . " r:" . $sms_receiver, 3, "sms_sync sync");
// if keyword does not exists (checkavailablekeyword == TRUE)
// then prefix the message with an @username so that it will be routed to $c_uid's inbox
示例9: core_get_version
/**
* Get playSMS version
*
* @return string
*/
function core_get_version()
{
$version = registry_search(1, 'core', 'config', 'playsms_version');
if ($version = $version['core']['config']['playsms_version']) {
return $version;
} else {
return '';
}
}
示例10: user_getdatabyusername
if (auth_isvalid()) {
// load user's data from user's DB table
$user_config = user_getdatabyusername($_SESSION['username']);
$user_config['opt']['sms_footer_length'] = strlen($footer) > 0 ? strlen($footer) + 1 : 0;
$user_config['opt']['per_sms_length'] = $core_config['main']['per_sms_length'] - $user_config['opt']['sms_footer_length'];
$user_config['opt']['per_sms_length_unicode'] = $core_config['main']['per_sms_length_unicode'] - $user_config['opt']['sms_footer_length'];
$user_config['opt']['max_sms_length'] = $core_config['main']['max_sms_length'] - $user_config['opt']['sms_footer_length'];
$user_config['opt']['max_sms_length_unicode'] = $core_config['main']['max_sms_length_unicode'] - $user_config['opt']['sms_footer_length'];
$user_config['opt']['gravatar'] = 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($user_config['email'])));
if (!$core_config['daemon_process']) {
// save login session information
user_session_set();
}
// special setting to credit unicode SMS the same as normal SMS length
// for example: 2 unicode SMS (140 chars length) will be deducted as 1 credit just like a normal SMS (160 chars length)
$result = registry_search($user_config['uid'], 'core', 'user_config', 'enable_credit_unicode');
$user_config['opt']['enable_credit_unicode'] = (int) $result['core']['user_config']['enable_credit_unicode'];
if (!$user_config['opt']['enable_credit_unicode']) {
// global config overriden by user config
$user_config['opt']['enable_credit_unicode'] = (int) $core_config['main']['enable_credit_unicode'];
}
}
// override main config with site config for branding purposes distinguished by domain name
$site_config = array();
if (!$core_config['daemon_process'] && $_SERVER['HTTP_HOST']) {
$s = site_config_getbydomain($_SERVER['HTTP_HOST']);
if ((int) $s[0]['uid']) {
$c_site_config = site_config_get((int) $s[0]['uid']);
if (strtolower($c_site_config['domain']) == strtoloweR($_SERVER['HTTP_HOST'])) {
$site_config = array_merge($c_site_config, $s[0]);
}
示例11: defined
* playSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with playSMS. If not, see <http://www.gnu.org/licenses/>.
*/
defined('_SECURE_') or die('Forbidden');
if (!auth_isadmin()) {
auth_block();
}
switch (_OP_) {
case "main_config":
// get original main_config
$data = registry_search(1, 'core', 'main_config');
$main_config = $data['core']['main_config'];
// enable register yes-no option
$option_enable_register = _options(array(_('yes') => 1, _('no') => 0), $main_config['enable_register']);
// enable forgot yes-no option
$option_enable_forgot = _options(array(_('yes') => 1, _('no') => 0), $main_config['enable_forgot']);
// disable login as subuser yes-no option
$option_disable_login_as = _options(array(_('yes') => 1, _('no') => 0), $main_config['disable_login_as']);
// enhance privacy for subusers
$option_enhance_privacy_subuser = _options(array(_('yes') => 1, _('no') => 0), $main_config['enhance_privacy_subuser']);
// enable logo yes-no option
$option_enable_logo = _options(array(_('yes') => 1, _('no') => 0), $main_config['enable_logo']);
// enable logo to replace main website title yes-no option
$option_logo_replace_title = _options(array(_('yes') => 1, _('no') => 0), $main_config['logo_replace_title']);
// option default account status on user registration
$option_default_user_status = _options(array(_('User') => 3, _('Subuser') => 4), $main_config['default_user_status']);
示例12: email2sms_hook_playsmsd_once
function email2sms_hook_playsmsd_once($param)
{
$c_param = explode('_', $param);
if ($c_param[0] == 'email2sms') {
if ($c_param[1] == 'uid') {
$uid = (int) $c_param[2];
}
}
// get username
$username = user_uid2username($uid);
// _log('fetch uid:' . $uid . ' username:' . $username, 3, 'email2sms_hook_playsmsd_once');
if ($uid && $username) {
$items = registry_search($uid, 'features', 'email2sms');
$enable = $items['features']['email2sms']['enable'];
if (!$enable) {
return;
}
$ssl = $items['features']['email2sms']['ssl'] == 1 ? "/ssl" : "";
$novalidate_cert = $items['features']['email2sms']['novalidate_cert'] == 1 ? "/novalidate-cert" : "";
$email_hostname = '{' . $items['features']['email2sms']['server'] . ':' . $items['features']['email2sms']['port'] . '/' . $items['features']['email2sms']['protocol'] . $ssl . $novalidate_cert . '}INBOX';
$email_username = $items['features']['email2sms']['username'];
$email_password = $items['features']['email2sms']['password'];
// _log('fetch ' . $email_username . ' at ' . $email_hostname, 3, 'email2sms_hook_playsmsd_once');
// open mailbox
$inbox = imap_open($email_hostname, $email_username, $email_password);
if (!$inbox) {
$errors = imap_errors();
foreach ($errors as $error) {
// _log('error:' . $error, 3, 'email2sms_hook_playsmsd_once');
}
return;
}
$emails = imap_search($inbox, 'UNSEEN');
if (count($emails)) {
rsort($emails);
foreach ($emails as $email_number) {
$overview = imap_fetch_overview($inbox, $email_number, 0);
$email_subject = trim($overview[0]->subject);
$email_sender = trim($overview[0]->from);
$email_body = trim(imap_fetchbody($inbox, $email_number, 1));
_log('email from:[' . $email_sender . '] subject:[' . $email_subject . '] body:[' . $email_body . ']', 3, 'email2sms_hook_playsmsd');
// destination numbers is in array and retrieved from email body
// remove email footer/signiture
$sms_to = preg_replace('/--[\\r\\n]+.*/s', '', $email_body);
$sms_to = explode(',', $sms_to);
// Check "from" email before checking PIN if option "Check email sender" is TRUE
if ($items['features']['email2sms']['check_sender']) {
preg_match('#\\<(.*?)\\>#', $email_sender, $match);
if (user_email2uid($match[1]) == "") {
continue;
}
}
// message is from email subject
// $message = trim($email_subject);
$message = trim(preg_replace('/' . $items['features']['email2sms']['pin'] . '/', '', $email_subject, -1, $count));
if ($count <= 0) {
_log('PIN does not match. Subject: ' . $email_subject, 2, 'email2sms_hook_playsmsd');
}
// sendsms
if ($username && count($sms_to) && $message && $count > 0) {
_log('email2sms username:' . $username, 3, 'email2sms_hook_playsmsd_once');
list($ok, $to, $smslog_id, $queue, $counts, $sms_count, $sms_failed) = sendsms_helper($username, $sms_to, $message, '', '', '', '', '', '', $reference_id);
}
}
}
// close mailbox
imap_close($inbox);
}
}
示例13: simplerate_hook_rate_deduct
function simplerate_hook_rate_deduct($smslog_id)
{
global $core_config;
logger_print("enter smslog_id:" . $smslog_id, 2, "simplerate deduct");
$db_query = "SELECT p_dst,p_footer,p_msg,uid,unicode FROM " . _DB_PREF_ . "_tblSMSOutgoing WHERE smslog_id='{$smslog_id}'";
$db_result = dba_query($db_query);
if ($db_row = dba_fetch_array($db_result)) {
$p_dst = $db_row['p_dst'];
$p_msg = $db_row['p_msg'];
$p_footer = $db_row['p_footer'];
$uid = $db_row['uid'];
$unicode = $db_row['unicode'];
if ($p_dst && $p_msg && $uid) {
// get charge
$p_msg_len = strlen($p_msg) + strlen($p_footer);
list($count, $rate, $charge) = rate_getcharges($uid, $p_msg_len, $unicode, $p_dst);
// sender's
$username = user_uid2username($uid);
$credit = rate_getusercredit($username);
$balance = $credit - $charge;
// parent's when sender is a subuser
$parent_uid = user_getparentbyuid($uid);
if ($parent_uid) {
$username_parent = user_uid2username($parent_uid);
$credit_parent = rate_getusercredit($username_parent);
$balance_parent = $credit_parent - $charge;
}
// if sender have parent then deduct parent first
if ($parent_uid) {
if (!rate_setusercredit($parent_uid, $balance_parent)) {
return FALSE;
}
logger_print("parent uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id . " msglen:" . $p_msg_len . " count:" . $count . " rate:" . $rate . " charge:" . $charge . " credit_parent:" . $credit_parent . " balance_parent:" . $balance_parent, 2, "simplerate deduct");
}
if (rate_setusercredit($uid, $balance)) {
logger_print("user uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id . " msglen:" . $p_msg_len . " count:" . $count . " rate:" . $rate . " charge:" . $charge . " credit:" . $credit . " balance:" . $balance, 2, "simplerate deduct");
if (billing_post($smslog_id, $rate, $credit, $count, $charge)) {
logger_print("deduct successful uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
// if balance under credit lowest limit and never been notified then notify admins, parent_uid and uid
$credit_lowest_limit = (double) $core_config['main']['credit_lowest_limit'];
_log('credit_lowest_limit:' . $credit_lowest_limit . ' balance:' . $balance . ' charge:' . $charge, 3, 'simplerate deduct');
$reg = registry_search($uid, 'feature', 'credit', 'lowest_limit_notif');
$notified = $reg['feature']['credit']['lowest_limit_notif'] ? TRUE : FALSE;
if ($charge && $balance && $credit_lowest_limit && $balance <= $credit_lowest_limit && !$notified) {
// set notified
registry_update($uid, 'feature', 'credit', array('lowest_limit_notif' => TRUE));
// notif admins
$admins = user_getallwithstatus(2);
foreach ($admins as $admin) {
$credit_message_to_admins = sprintf(_('Username %s with account ID %d has reached lowest credit limit of %s'), $username, $uid, $credit_lowest_limit);
recvsms_inbox_add(core_get_datetime(), _SYSTEM_SENDER_ID_, $admin['username'], $credit_message_to_admins);
}
// notif parent_uid if exists
if ($parent_uid && $username_parent) {
$credit_message_to_parent = sprintf(_('Your subuser with username %s and account ID %d has reached lowest credit limit of %s'), $username, $uid, $credit_lowest_limit);
recvsms_inbox_add(core_get_datetime(), _SYSTEM_SENDER_ID_, $username_parent, $credit_message_to_parent);
}
// notif uid
$sender_username = $username_parent ? $username_parent : _SYSTEM_SENDER_ID_;
$credit_message_to_self = sprintf(_('You have reached lowest credit limit of %s'), $credit_lowest_limit);
recvsms_inbox_add(core_get_datetime(), $sender_username, $username, $credit_message_to_self);
_log('sent notification credit_lowest_limit:' . $credit_lowest_limit, 3, 'simplerate deduct');
}
return TRUE;
} else {
logger_print("deduct failed uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
return FALSE;
}
} else {
logger_print("rate deduct failed due to unable to save to db uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
}
} else {
logger_print("rate deduct failed due to empty data uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
}
} else {
logger_print("rate deduct failed due to missing data uid:" . $uid . " parent_uid:" . $parent_uid . " smslog_id:" . $smslog_id, 3, "simplerate deduct");
}
return FALSE;
}
示例14: user_banned_list
/**
* List all banned users
*
* @return array banned users
*/
function user_banned_list()
{
$ret = array();
$list = registry_search(1, 'auth', 'banned_users');
foreach ($list['auth']['banned_users'] as $key => $val) {
$uid = (int) $key;
$username = user_uid2username($uid);
$bantime = $val;
if ($uid && $username && $bantime) {
$ret[] = array('uid' => $uid, 'username' => $username, 'bantime' => $bantime);
}
}
return $ret;
}
示例15: defined
<?php
defined('_SECURE_') or die('Forbidden');
// get gammu config from registry
$data = registry_search(0, 'gateway', 'gammu');
$plugin_config['gammu']['name'] = 'gammu';
$plugin_config['gammu']['path'] = trim(core_sanitize_path($data['gateway']['gammu']['path']));
if (!$plugin_config['gammu']['path']) {
$plugin_config['gammu']['path'] = '/var/spool/gammu';
}
$plugin_config['gammu']['dlr'] = TRUE;
// smsc configuration
$plugin_config['gammu']['_smsc_config_'] = array('path' => _('Spool folder'));
// insert to left menu array
//if (isadmin()) {
// $menutab_gateway = $core_config['menutab']['gateway'];
// $menu_config[$menutab_gateway][] = array("index.php?app=main&inc=gateway_gammu&op=manage", _('Manage gammu'));
//}