本文整理汇总了PHP中Phpfox_Error::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Phpfox_Error::reset方法的具体用法?PHP Phpfox_Error::reset怎么用?PHP Phpfox_Error::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phpfox_Error
的用法示例。
在下文中一共展示了Phpfox_Error::reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
$aUser['month'] = (int) (empty($aUser['month']) ? date('m') : $aUser['month']);
$aUser['year'] = (int) (empty($aUser['year']) ? date('Y') : $aUser['year']);
if ($aUser['day'] === 0 || $aUser['day'] > 31) {
$aUser['day'] = 1;
}
if ($aUser['month'] === 0 || $aUser['month'] > 12) {
$aUser['month'] = 1;
}
if ($aUser['year'] < 1900) {
$aUser['year'] = 1982;
}
$aUser['user_name'] = $aUser['user'];
$aUser['user_name'] = str_replace(' ', '_', $aUser['user_name']);
Phpfox::getService('user.validate')->user($aUser['user_name']);
if (!Phpfox_Error::isPassed()) {
Phpfox_Error::reset();
$aUser['user_name'] = $aUser['user_name'] . '_' . uniqid();
}
$aInsert = array('user_group_id' => $aUser['type'] == '0' ? '1' : '2', 'user_name' => $oParseInput->clean($aUser['user_name'], 255), 'full_name' => $oParseInput->clean($aUser['user'], 255), 'status' => $oParseInput->clean($aUser['headline'], 255), 'password' => md5($aUser['password'] . md5($sSalt)), 'password_salt' => $sSalt, 'email' => $aUser['email'], 'joined' => $aUser['signup'], 'gender' => isset($aCacheGender[$aUser['gender']]) ? $aCacheGender[$aUser['gender']] : 0, 'birthday' => Phpfox::getService('user')->buildAge($aUser['day'], $aUser['month'], $aUser['year']), 'birthday_search' => Phpfox::getLib('date')->mktime(0, 0, 0, $aUser['month'], $aUser['day'], $aUser['year']), 'country_iso' => isset($aCacheCountry[$aUser['location']]) ? $aCacheCountry[$aUser['location']] : null, 'language_id' => 'en', 'time_zone' => null, 'last_login' => $aUser['login'], 'upgrade_user_id' => $aUser['id'], 'user_image' => '{file/pic/user/' . $aUser['user'] . '%s.jpg}');
$iId = $this->_db()->insert(Phpfox::getT('user'), $aInsert);
// check if user profile was private
if ($aUser['friends_only'] == 1) {
$aPrivacy = array('user_id' => $iId, 'user_privacy' => 'profile.view_profile', 'user_value' => 2);
$this->_db()->insert(Phpfox::getT('user_privacy'), $aPrivacy);
}
// check if only friends could add comments
if ($aUser['friends_comment'] == 1) {
$aPrivacy = array('user_id' => $iId, 'user_privacy' => 'comment.add_comment', 'user_value' => 2);
$this->_db()->insert(Phpfox::getT('user_privacy'), $aPrivacy);
}
// Notifications
示例2: login
public function login($sLogin, $sPassword, $bRemember = false, $sType = 'email', $bNoPasswordCheck = false)
{
$sSelect = 'user_id, email, user_name, password, password_salt, status_id';
/* Used to control the return in case we detect a brute force attack */
$bReturn = false;
$sLogin = $this->database()->escape($sLogin);
if ($sPlugin = Phpfox_Plugin::get('user.service_auth_login__start')) {
eval($sPlugin);
if (isset($mReturn)) {
return $mReturn;
}
}
$aRow = $this->database()->select($sSelect)->from($this->_sTable)->where($sType == 'both' ? "email = '" . $sLogin . "' OR user_name = '" . $sLogin . "'" : ($sType == 'email' ? "email" : "user_name") . " = '" . $sLogin . "'")->execute('getRow');
if ($sPlugin = Phpfox_Plugin::get('user.service_auth_login_skip_email_verification')) {
eval($sPlugin);
}
if (!defined('PHPFOX_INSTALLER') && isset($aRow['status_id']) && $aRow['status_id'] == 1 && !isset($bEmailVerification)) {
Phpfox::getLib('session')->set('cache_user_id', $aRow['user_id']);
if (defined('PHPFOX_MUST_PAY_FIRST')) {
Phpfox::getLib('url')->send('subscribe.register', array('id' => PHPFOX_MUST_PAY_FIRST, 'login' => '1'));
}
Phpfox::getLib('url')->send('user.verify', null, Phpfox::getPhrase('user.you_need_to_verify_your_email_address_before_logging_in', array('email' => $aRow['email'])));
}
if (!isset($aRow['user_name'])) {
switch (Phpfox::getParam('user.login_type')) {
case 'user_name':
$sMessage = Phpfox::getPhrase('user.invalid_user_name');
break;
case 'email':
$sMessage = Phpfox::getPhrase('user.invalid_email');
break;
default:
$sMessage = Phpfox::getPhrase('user.invalid_login_id');
}
Phpfox_Error::set($sMessage);
if ($sPlugin = Phpfox_Plugin::get('user.service_auth_login__no_user_name')) {
eval($sPlugin);
}
//return array(false, $aRow);
$bReturn = true;
} else {
$bDoPhpfoxLoginCheck = true;
if ($sPlugin = Phpfox_Plugin::get('user.service_auth_login__password')) {
eval($sPlugin);
}
if (!$bNoPasswordCheck && $bDoPhpfoxLoginCheck && Phpfox::getLib('hash')->setHash($sPassword, $aRow['password_salt']) != $aRow['password']) {
Phpfox_Error::set(Phpfox::getPhrase('user.invalid_password'));
//return array(false, $aRow);
$bReturn = true;
}
}
/* Add the check for the brute force here */
if (!empty($aRow) && !defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.brute_force_time_check') > 0) {
/* Check if the account is already locked */
$iLocked = $this->database()->select('brute_force_locked_at')->from(Phpfox::getT('user_field'))->where('user_id = ' . $aRow['user_id'])->execute('getSlaveField');
$iUnlockTimeOut = $iLocked + Phpfox::getParam('user.brute_force_cool_down') * 60;
$iRemaining = $iUnlockTimeOut - PHPFOX_TIME;
$iTimeFrom = PHPFOX_TIME - 60 * Phpfox::getParam('user.brute_force_time_check');
$iAttempts = $this->database()->select('COUNT(*)')->from(Phpfox::getT('user_ip'))->where('user_id = ' . $aRow['user_id'] . ' AND type_id = "login_failed" AND time_stamp > ' . $iTimeFrom)->execute('getSlaveField');
$aReplace = array('iCoolDown' => Phpfox::getParam('user.brute_force_cool_down'), 'sForgotLink' => Phpfox::getLib('url')->makeUrl('user.password.request'), 'iUnlockTimeOut' => ceil($iRemaining / 60));
if ($iRemaining > 0) {
Phpfox_Error::reset();
Phpfox_Error::set(Phpfox::getPhrase('user.brute_force_account_locked', $aReplace));
return array(false, $aRow);
}
if ($iAttempts >= Phpfox::getParam('user.brute_force_attempts_count')) {
$this->database()->update(Phpfox::getT('user_field'), array('brute_force_locked_at' => PHPFOX_TIME), 'user_id = ' . $aRow['user_id']);
Phpfox_Error::reset();
/* adjust new remaining time*/
$aReplace['iUnlockTimeOut'] = Phpfox::getParam('user.brute_force_cool_down');
Phpfox_Error::set(Phpfox::getPhrase('user.brute_force_account_locked', $aReplace));
$bReturn = true;
}
}
if ($bReturn == true) {
/* Log the attempt */
$this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => isset($aRow['user_id']) ? $aRow['user_id'] : '0', 'type_id' => 'login_failed', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME));
return array(false, $aRow);
}
// ban check
$oBan = Phpfox::getService('ban');
if (!$oBan->check('email', $aRow['email'])) {
Phpfox_Error::set(Phpfox::getPhrase('ban.global_ban_message'));
}
if (!$oBan->check('ip', Phpfox::getLib('request')->getIp())) {
// this is a new phrase, text: "Your IP address is not allowed"
Phpfox_Error::set(Phpfox::getPhrase('ban.not_allowed_ip_address'));
}
$aBanned = Phpfox::getService('ban')->isUserBanned($aRow);
if ($aBanned['is_banned']) {
if (isset($aBanned['reason']) && !empty($aBanned['reason'])) {
$aBanned['reason'] = str_replace(''', "'", Phpfox::getLib('parse.output')->parse($aBanned['reason']));
$sReason = preg_replace('/\\{phrase var=\'(.*)\'\\}/ise', "'' . Phpfox::getPhrase('\\1',array(), false, null, '" . Phpfox::getUserBy('language_id') . "') . ''", $aBanned['reason']);
Phpfox_Error::set($sReason);
} else {
Phpfox_Error::set(Phpfox::getPhrase('ban.global_ban_message'));
}
}
if (Phpfox_Error::isPassed()) {
if ($sPlugin = Phpfox_Plugin::get('user.service_auth_login__cookie_start')) {
//.........这里部分代码省略.........
示例3: addUser
/**
* Adds a user.
* Required fields:
* - full_name - string(255) - Used as the site wide display name
* - email - string(255) - Users unique email
*
* Option fields:
* - user_name - string(100) - Used to create vanity URL, if not passed we will create one from the "full_name"
* - birth_year - int - Users birth year
* - birth_month - int - Users birth month
* - birth_day - int - Users birth day
* - gender - string - Users gender (Must be "male" or "female")
* - country - string - Users location (eg. United States, Sweden etc...)
* - city - string - Users city (eg. Miami, Stockholm etc...)
* - state - string - Users state/province (eg. Florida, Skane etc...)
* - joined - int - Time stamp of when the user joined (Must be a UNIX time stamp)
*
* @param array $aVals Holds an array of all the required/option fields
*/
public function addUser($aVals)
{
static $aCacheData = null;
if ($aCacheData === null) {
$aRows = $this->database()->select('country_iso, name')->from(Phpfox::getT('country'))->execute('getRows');
foreach ($aRows as $aRow) {
$aCacheData['country'][strtolower($aRow['name'])] = $aRow['country_iso'];
$aCacheData['country_iso'][$aRow['country_iso']] = $aRow['country_iso'];
}
$aRows = $this->database()->select('child_id, name')->from(Phpfox::getT('country_child'))->execute('getRows');
foreach ($aRows as $aRow) {
$aCacheData['country_child'][strtolower($aRow['name'])] = $aRow['child_id'];
}
}
if (empty($aVals['full_name']) || empty($aVals['email'])) {
return false;
}
$aUser = array('user_group_id' => '2', 'full_name' => $aVals['full_name'], 'email' => $aVals['email']);
$iEmailCheck = $this->database()->select('COUNT(*)')->from(Phpfox::getT('user'))->where('email = \'' . $this->database()->escape($aVals['email']) . '\'')->execute('getField');
if ($iEmailCheck) {
return false;
}
if (empty($aVals['password'])) {
$sSalt = '';
for ($i = 0; $i < 3; $i++) {
$sSalt .= chr(rand(33, 91));
}
}
if (!empty($aVals['birth_year'])) {
$aVals['day'] = (int) (empty($aVals['day']) ? date('d') : $aVals['birth_day']);
$aVals['month'] = (int) (empty($aVals['month']) ? date('m') : $aVals['birth_month']);
$aVals['year'] = (int) (empty($aVals['year']) ? date('Y') : $aVals['birth_year']);
if ($aVals['day'] === 0 || $aVals['day'] > 31) {
$aVals['day'] = 1;
}
if ($aVals['month'] === 0 || $aVals['month'] > 12) {
$aVals['month'] = 1;
}
if ($aVals['year'] < 1900) {
$aVals['year'] = 1982;
}
$aUser['birthday'] = Phpfox::getService('user')->buildAge($aVals['day'], $aVals['month'], $aVals['year']);
$aUser['birthday_search'] = Phpfox::getLib('date')->mktime(0, 0, 0, $aVals['month'], $aVals['day'], $aVals['year']);
}
if (!empty($aVals['gender'])) {
$aUser['gender'] = strtolower($aVals['gender']) == 'male' ? '1' : '2';
}
if (empty($aVals['user_name'])) {
$aVals['user_name'] = $aVals['full_name'];
}
$aUser['user_name'] = Phpfox::getLib('parse.input')->cleanTitle($aVals['user_name']);
Phpfox::getService('user.validate')->user($aUser['user_name']);
// $aErrors = Phpfox_Error::get();
if (!Phpfox_Error::isPassed()) {
Phpfox_Error::reset();
$aUser['user_name'] = $aUser['user_name'] . '_' . uniqid();
}
if (!empty($aVals['country']) && isset($aCacheData['country']) && isset($aCacheData['country'][strtolower($aVals['country'])])) {
$aUser['country_iso'] = $aCacheData['country'][strtolower($aVals['country'])];
}
if (!empty($aVals['country_iso']) && isset($aCacheData['country_iso']) && isset($aCacheData['country_iso'][$aVals['country_iso']])) {
$aUser['country_iso'] = $aCacheData['country_iso'][$aVals['country_iso']];
}
$sPassword = '';
if (empty($aVals['password'])) {
for ($i = 1; $i <= 10; $i++) {
$sPassword .= substr('0123456789aBcDeF/()$#!', rand(0, 21), 1);
}
$aUser['password'] = md5(md5($sPassword) . md5($sSalt));
$aUser['password_salt'] = $sSalt;
}
if (!empty($aVals['joined'])) {
$aUser['joined'] = $aVals['joined'];
}
if (!empty($aVals['last_login'])) {
$aUser['last_login'] = $aVals['last_login'];
}
if (!empty($aVals['last_activity'])) {
$aUser['last_activity'] = $aVals['last_activity'];
}
$iId = $this->database()->insert(Phpfox::getT('user'), $aUser);
//.........这里部分代码省略.........