本文整理汇总了PHP中Phpfox::getIp方法的典型用法代码示例。如果您正苦于以下问题:PHP Phpfox::getIp方法的具体用法?PHP Phpfox::getIp怎么用?PHP Phpfox::getIp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phpfox
的用法示例。
在下文中一共展示了Phpfox::getIp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add($iBlockedUserId)
{
Phpfox::isUser(true);
Phpfox::getUserParam('user.can_block_other_members', true);
if ($iBlockedUserId == Phpfox::getUserId())
{
return Phpfox_Error::set(Phpfox::getPhrase('user.not_able_to_block_yourself'));
}
if (Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $iBlockedUserId))
{
return Phpfox_Error::set(Phpfox::getPhrase('user.you_have_already_blocked_this_user'));
}
$aUser = Phpfox::getService('user')->getUser($iBlockedUserId, 'u.user_id, u.user_group_id');
if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_be_blocked_by_others'))
{
return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_block_this_user'));
}
$this->database()->insert($this->_sTable, array(
'user_id' => Phpfox::getUserId(),
'block_user_id' => (int) $iBlockedUserId,
'time_stamp' => PHPFOX_TIME,
'ip_address' => Phpfox::getIp()
)
);
Phpfox::getService('friend.process')->deleteFromConnection(Phpfox::getUserId(), $iBlockedUserId);
Phpfox::getService('friend.process')->deleteFromConnection($iBlockedUserId, Phpfox::getUserId());
return true;
}
示例2: add
public function add($aUserInfo)
{
$aVals = array('user_group_id' => NORMAL_USER_ID, 'joined' => PHPFOX_TIME, 'last_ip_address' => Phpfox::getIp(), 'last_activity' => PHPFOX_TIME);
$aVals['full_name'] = $aUserInfo['displayName'];
if (empty($aVals['full_name'])) {
Phpfox::getLib('url')->send('janrain.account', array('type' => 'full-name'));
}
if (!empty($aUserInfo['preferredUsername'])) {
$aVals['user_name'] = $aUserInfo['preferredUsername'];
}
if (empty($aVals['user_name'])) {
$aVals['user_name'] = $aUserInfo['displayName'];
}
if (!empty($aUserInfo['email'])) {
Phpfox::getService('user.validate')->email($aUserInfo['email']);
if (Phpfox_Error::get()) {
Phpfox::getLib('url')->send('janrain.account', array('type' => 'email'));
}
}
$aVals['user_name'] = Phpfox::getLib('parse.input')->prepareTitle('user', $aVals['user_name'], 'user_name', null, Phpfox::getT('user'));
$aVals['email'] = empty($aUserInfo['email']) ? null : $aUserInfo['email'];
$aVals['gender'] = !isset($aUserInfo['gender']) ? '0' : ($aUserInfo['gender'] == 'female' ? '2' : '1');
$iUserId = $this->database()->insert(Phpfox::getT('user'), $aVals);
$aExtras = array('user_id' => $iUserId);
$this->database()->insert(Phpfox::getT('user_activity'), $aExtras);
$this->database()->insert(Phpfox::getT('user_field'), $aExtras);
$this->database()->insert(Phpfox::getT('user_space'), $aExtras);
$this->database()->insert(Phpfox::getT('user_count'), $aExtras);
$this->database()->insert($this->_sTable, array('user_id' => $iUserId, 'identifier' => md5($aUserInfo['identifier']), 'time_stamp' => PHPFOX_TIME));
if (!empty($aUserInfo['photo'])) {
$sImage = $aUserInfo['photo'];
$sNewImage = md5($iUserId . PHPFOX_TIME . uniqid()) . '%s.jpg';
Phpfox::getLib('file')->writeToCache($sNewImage, file_get_contents($sImage));
copy(PHPFOX_DIR_CACHE . $sNewImage, Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''));
unlink(PHPFOX_DIR_CACHE . $sNewImage);
foreach (Phpfox::getParam('user.user_pic_sizes') as $iSize) {
Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize), $iSize, $iSize);
Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize . '_square'), $iSize, $iSize, false);
}
Phpfox::getLib('database')->update(Phpfox::getT('user'), array('user_image' => $sNewImage, 'server_id' => 0), 'user_id = ' . (int) $iUserId);
}
// Taken from user.process->add
$iFriendId = (int) Phpfox::getParam('user.on_signup_new_friend');
if ($iFriendId > 0) {
$this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iUserId, 'friend_user_id' => $iFriendId, 'time_stamp' => PHPFOX_TIME));
$this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iFriendId, 'friend_user_id' => $iUserId, 'time_stamp' => PHPFOX_TIME));
Phpfox::getService('friend.process')->updateFriendCount($iUserId, $iFriendId);
Phpfox::getService('friend.process')->updateFriendCount($iFriendId, $iUserId);
}
return $iUserId;
}
示例3: add
/**
* This function adds a ban filter, it was not renamed after 2.1 for compatibility
* @param array $aVals
* @param <type> $aBanFilter
* @return true
*/
public function add($aVals, &$aBanFilter = null)
{
Phpfox::isAdmin(true);
$aForm = array('type_id' => array('type' => 'string:required'), 'find_value' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('ban.filter_value_is_required')), 'reason' => array('type' => 'string'), 'days_banned' => array('type' => 'int'), 'return_user_group' => array('type' => 'int'), 'bShow' => array('type' => 'string'), 'user_groups_affected' => array('type' => 'array'));
if ($aBanFilter !== null && isset($aBanFilter['replace'])) {
$aForm['replacement'] = array('type' => 'string:required', 'message' => Phpfox::getPhrase('ban.filter_replacement_is_required'));
}
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
if ($aVals['find_value'] == Phpfox::getIp()) {
return Phpfox_Error::set('You cannot ban yourself.');
}
$aVals['user_id'] = Phpfox::getUserId();
$aVals['time_stamp'] = PHPFOX_TIME;
$aVals['find_value'] = $this->preParse()->convert($aVals['find_value']);
if (isset($aVals['bShow']) && $aVals['bShow'] == '0' || !isset($aVals['bShow'])) {
unset($aVals['reason']);
unset($aVals['days_banned']);
unset($aVals['return_user_group']);
} else {
$aVals['reason'] = !Phpfox_Locale::instance()->isPhrase($aVals['reason']) ? Phpfox::getLib('parse.input')->clean($aVals['reason']) : $aVals['reason'];
$aVals['days_banned'] = (int) $aVals['days_banned'];
$aVals['return_user_group'] = (int) $aVals['return_user_group'];
if (!isset($aVals['user_groups_affected'])) {
$aVals['user_groups_affected'] = array();
}
$aVals['user_groups_affected'] = serialize($aVals['user_groups_affected']);
}
unset($aVals['bShow']);
if (isset($aVals['replacement'])) {
$aVals['replacement'] = $this->preParse()->convert($aVals['replacement']);
}
if (empty($aVals['user_groups_affected'])) {
$aVals['user_groups_affected'] = '';
}
$this->database()->insert($this->_sTable, $aVals);
$this->cache()->remove('ban', 'substr');
return true;
}
示例4: setUserSession
public function setUserSession()
{
$oSession = Phpfox::getLib('session');
$oRequest = Phpfox_Request::instance();
$sSessionHash = $oSession->get('session');
if (Phpfox::getParam('core.store_only_users_in_session')) {
$this->_aSession = Phpfox::getService('user.auth')->getUserSession();
} else {
if ($sSessionHash) {
$this->_aSession = Phpfox::getService('user.auth')->getUserSession();
if (!isset($this->_aSession['session_hash']) && !Phpfox::getParam('core.store_only_users_in_session')) {
$this->database()->where("s.session_hash = '" . $this->database()->escape($oSession->get('session')) . "' AND s.id_hash = '" . $this->database()->escape($oRequest->getIdHash()) . "'");
$this->_aSession = $this->database()->select('s.session_hash, s.id_hash, s.captcha_hash, s.user_id')->from($this->_sTable, 's')->execute('getRow');
}
}
}
$sLocation = $oRequest->get(PHPFOX_GET_METHOD);
$sLocation = substr($sLocation, 0, 244);
$sBrowser = substr(Phpfox_Request::instance()->getBrowser(), 0, 99);
$sIp = Phpfox_Request::instance()->getIp();
if (Phpfox::getParam('core.log_site_activity')) {
// Unsure why this is here. Causes http://www.phpfox.com/tracker/view/15330/
// Perhaps instead of the database delete, the log is only for logged in users?
// I cannot find a reason why the script should log guests activity.
// Besides, guest activity may increase the number of inserts into this table very largely
/*if(Phpfox::getUserId() > 0)
{
$this->database()->delete($this->_sTable, 'user_id = ' . Phpfox::getUserId());
}*/
// Like this:
if (Phpfox::getUserId() > 0) {
$this->database()->insert(Phpfox::getT('log_view'), array('user_id' => Phpfox::getUserId(), 'ip_address' => $sIp, 'protocal' => $_SERVER['REQUEST_METHOD'], 'cache_data' => serialize(array('location' => $_SERVER['REQUEST_URI'], 'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null, 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'request' => strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ? serialize($_POST) : serialize($_GET))), 'time_stamp' => PHPFOX_TIME));
}
}
/**
* @todo Needs to be added into the 'setting' db table
*/
$aDisAllow = array('captcha/image');
// Don't log a session into the DB if we disallow it
if (Phpfox_Url::instance()->isUrl($aDisAllow)) {
return;
}
$bIsForum = strstr($sLocation, Phpfox::getParam('core.module_forum')) ? true : false;
$iForumId = 0;
if ($bIsForum) {
$aForumIds = explode('-', $oRequest->get('req2'));
if (isset($aForumIds[count($aForumIds) - 1])) {
$iForumId = (int) $aForumIds[count($aForumIds) - 1];
}
}
$iIsHidden = 0;
if (Phpfox::isUser()) {
if (Phpfox::getUserBy('im_hide')) {
$iIsHidden = 1;
}
}
if (Phpfox::getParam('core.store_only_users_in_session')) {
if (Phpfox::isUser()) {
if (!isset($this->_aSession['session_hash'])) {
if (Phpfox::getUserId() > 0) {
$this->database()->delete(Phpfox::getT('session'), 'user_id = ' . Phpfox::getUserId());
}
$this->database()->insert(Phpfox::getT('session'), array('user_id' => Phpfox::getUserId(), 'last_activity' => PHPFOX_TIME));
} else {
$this->database()->update(Phpfox::getT('session'), array('last_activity' => PHPFOX_TIME), 'user_id = ' . (int) Phpfox::getUserId());
}
}
} else {
if (!isset($this->_aSession['session_hash'])) {
$sSessionHash = $oRequest->getSessionHash();
if (Phpfox::getUserId() > 0) {
$this->database()->delete($this->_sTable, 'user_id = ' . Phpfox::getUserId());
}
$this->database()->insert($this->_sTable, array('session_hash' => $sSessionHash, 'id_hash' => $oRequest->getIdHash(), 'user_id' => Phpfox::getUserId(), 'last_activity' => PHPFOX_TIME, 'location' => $sLocation, 'is_forum' => $bIsForum ? '1' : '0', 'forum_id' => $iForumId, 'im_hide' => $iIsHidden, 'ip_address' => $sIp, 'user_agent' => $sBrowser));
$oSession->set('session', $sSessionHash);
} else {
if (isset($this->_aSession['session_hash'])) {
$this->database()->update($this->_sTable, array('last_activity' => PHPFOX_TIME, 'user_id' => Phpfox::getUserId(), "location" => $sLocation, "is_forum" => $bIsForum ? "1" : "0", "forum_id" => $iForumId, 'im_hide' => $iIsHidden, "ip_address" => $sIp, "user_agent" => $sBrowser), "session_hash = '" . $this->_aSession["session_hash"] . "'");
}
}
}
if (!Phpfox::getCookie('visit')) {
Phpfox::setCookie('visit', PHPFOX_TIME);
}
if (Phpfox::isUser()) {
if (!Phpfox::getCookie('last_login')) {
Phpfox::setCookie('last_login', PHPFOX_TIME, PHPFOX_TIME + Phpfox::getParam('log.active_session') * 60);
if (Phpfox::getUserBy('last_activity') < PHPFOX_TIME + Phpfox::getParam('log.active_session') * 60) {
$this->database()->update(Phpfox::getT('user'), array('last_login' => PHPFOX_TIME), 'user_id = ' . Phpfox::getUserId());
$this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => Phpfox::getUserId(), 'type_id' => 'session_login', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME));
}
}
if (!Phpfox::getParam('user.disable_store_last_user')) {
$this->database()->update(Phpfox::getT('user'), array('last_activity' => PHPFOX_TIME, 'last_ip_address' => Phpfox::getIp()), 'user_id = ' . Phpfox::getUserId());
}
}
}
示例5: define
*
*/
define('PHPFOX_DS', DIRECTORY_SEPARATOR);
/**
* phpFox Root Directory
*
*/
define('PHPFOX_DIR', dirname(dirname(__FILE__)) . PHPFOX_DS);
if (isset($_GET['ajax_page_display'])) {
define('PHPFOX_IS_AJAX_PAGE', true);
} else {
define('PHPFOX_IS_AJAX', true);
}
// Require phpFox Init
require PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php';
if (!Phpfox::getService('ban')->check('ip', Phpfox::getIp())) {
exit;
}
if (isset($_GET['ajax_page_display'])) {
$oCache = Phpfox::getLib('cache');
$oAjax = Phpfox::getLib('ajax');
if (Phpfox::getLib('template')->getThemeFolder() == 'nebula') {
$oTpl = Phpfox::getLib('template');
$sUserProfileImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => Phpfox::getService('user')->getUserFields(true)), array('path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_50_square', 'max_width' => 50, 'max_height' => 50)));
$oTpl->assign(array('sUserProfileImage' => $sUserProfileImage, 'sUserProfileUrl' => Phpfox::getLib('url')->makeUrl('profile', Phpfox::getUserBy('user_name')), 'sCurrentUserName' => Phpfox::getLib('parse.output')->shorten(Phpfox::getLib('parse.output')->clean(Phpfox::getUserBy('full_name')), Phpfox::getParam('user.max_length_for_username'), '...')));
}
Phpfox::run();
$aHeaderFiles = Phpfox::getLib('template')->getHeader(true);
if (Phpfox::getLib('template')->sDisplayLayout) {
Phpfox::getLib('template')->getLayout(Phpfox::getLib('template')->sDisplayLayout);
}
示例6: verify
/**
* This function checks if the hash submitted is valid.
* In every case it deletes the hash from the database, if the hash expired it creates a new one and sends an email to the user.
* @param String $sHash
* @param Boolean $bStrict tells if we should check if the password has expired, added to complement the adminVerify
* @return boolean false if the hash is not found on the db or if it has expired | true if the hash matches
*/
public function verify($sHash, $bStrict = true)
{
$aVerify = $this->database()->select('uv.user_id, uv.email as newMail, u.password, uv.time_stamp')->join(Phpfox::getT('user'), 'u', 'u.user_id = uv.user_id')->from($this->_sTable, 'uv')->where('uv.hash_code = \'' . Phpfox::getLib('parse.input')->clean($sHash) . '\'')->execute('getSlaveRow');
if (empty($aVerify)) {
return false;
}
/**
* @ToDo what do we do if the entry is not found? do we allow the user to log in? */
// Delete the entry from the user_verify table
$this->database()->delete($this->_sTable, 'user_id = ' . $aVerify['user_id']);
if (Phpfox::getParam('user.verify_email_timeout') == 0 || $aVerify['time_stamp'] + Phpfox::getParam('user.verify_email_timeout') * 60 >= Phpfox::getTime()) {
$bValid = true;
($sPlugin = Phpfox_Plugin::get('user.service_verify_process_verify_pass')) ? eval($sPlugin) : false;
$this->database()->update(Phpfox::getT('user'), array('status_id' => 0, 'email' => $aVerify['newMail']), 'user_id = ' . $aVerify['user_id']);
$this->database()->update(Phpfox::getT('photo'), array('view_id' => '0'), 'view_id = 3 AND user_id = ' . $aVerify['user_id']);
// update the friends count when "on signup new friend is enabled
if (Phpfox::getParam('user.on_signup_new_friend')) {
Phpfox::getService('friend.process')->updateFriendCount($aVerify['user_id'], Phpfox::getParam('user.on_signup_new_friend'));
Phpfox::getService('friend.process')->updateFriendCount(Phpfox::getParam('user.on_signup_new_friend'), $aVerify['user_id']);
}
// Send the welcome email
Phpfox::getLib('mail')->to($aVerify['user_id'])->subject(array('core.welcome_email_subject', array('site' => Phpfox::getParam('core.site_title'))))->message(array('core.welcome_email_content'))->send();
return true;
} else {
$bValid = false;
}
if ($bStrict === false) {
return true;
}
// Its invalid (timeout) so add the entry to the error log table
$aError = array('ip_address' => Phpfox::getIp(), 'hash_code' => Phpfox::getLib('parse.input')->prepare($sHash), 'email' => $aVerify['newMail'], 'time_stamp' => Phpfox::getTime());
$this->database()->insert(Phpfox::getT('user_verify_error'), $aError);
return false;
}
示例7: setUserSession
public function setUserSession()
{
$oSession = Phpfox::getLib('session');
$oRequest = Phpfox::getLib('request');
$sSessionHash = $oSession->get('session');
if ($sSessionHash)
{
$this->_aSession = Phpfox::getService('user.auth')->getUserSession();
if (!isset($this->_aSession['session_hash']))
{
$this->_aSession = $this->database()->select('s.session_hash, s.id_hash, s.captcha_hash, s.user_id')
->from($this->_sTable, 's')
->where("s.session_hash = '" . $this->database()->escape($oSession->get('session')) . "' AND s.id_hash = '" . $this->database()->escape($oRequest->getIdHash()) . "'")
->execute('getRow');
}
}
$sLocation = $oRequest->get(PHPFOX_GET_METHOD);
$sLocation = substr($sLocation, 0, 244);
$sBrowser = substr(Phpfox::getLib('request')->getBrowser(), 0, 99);
$sIp = Phpfox::getLib('request')->getIp();
if (Phpfox::getParam('core.log_site_activity'))
{
$this->database()->insert(Phpfox::getT('log_view'), array(
'user_id' => Phpfox::getUserId(),
'ip_address' => $sIp,
'protocal' => $_SERVER['REQUEST_METHOD'],
'cache_data' => serialize(array(
'location' => $_SERVER['REQUEST_URI'],
'referrer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null),
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
'request' => (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ? serialize($_POST) : serialize($_GET))
)
),
'time_stamp' => PHPFOX_TIME
)
);
}
/**
* @todo Needs to be added into the 'setting' db table
*/
$aDisAllow = array(
'captcha/image'
);
// Don't log a session into the DB if we disallow it
if (Phpfox::getLib('url')->isUrl($aDisAllow))
{
return;
}
$bIsForum = (strstr($sLocation, Phpfox::getParam('core.module_forum')) ? true : false);
$iForumId = 0;
if ($bIsForum)
{
$aForumIds = explode('-', $oRequest->get('req2'));
if (isset($aForumIds[(count($aForumIds) - 1)]))
{
$iForumId = (int) $aForumIds[(count($aForumIds) - 1)];
}
}
$iIsHidden = 0;
if (Phpfox::isUser())
{
if (Phpfox::getUserBy('im_hide'))
{
$iIsHidden = 1;
}
}
if (!isset($this->_aSession['session_hash']))
{
$sSessionHash = $oRequest->getSessionHash();
$this->database()->insert($this->_sTable, array(
'session_hash' => $sSessionHash,
'id_hash' => $oRequest->getIdHash(),
'user_id' => Phpfox::getUserId(),
'last_activity' => PHPFOX_TIME,
'location' => $sLocation,
'is_forum' => ($bIsForum ? '1' : '0'),
'forum_id' => $iForumId,
'im_hide' => $iIsHidden,
'ip_address' => $sIp,
'user_agent' => $sBrowser
)
);
$oSession->set('session', $sSessionHash);
}
else
{
$this->database()->update($this->_sTable, array(
'last_activity' => PHPFOX_TIME,
'user_id' => Phpfox::getUserId(),
"location" => $sLocation,
//.........这里部分代码省略.........
示例8: _completed
private function _completed()
{
if (Phpfox::getLib('file')->isWritable(PHPFOX_DIR_SETTING . 'server.sett.php'))
{
$sContent = file_get_contents(PHPFOX_DIR_SETTING . 'server.sett.php');
$sContent = preg_replace("/\\\$_CONF\['core.is_installed'\] = (.*?);/i", "\\\$_CONF['core.is_installed'] = true;", $sContent);
if ($hServerConf = @fopen(PHPFOX_DIR_SETTING . 'server.sett.php', 'w'))
{
fwrite($hServerConf, $sContent);
fclose($hServerConf);
}
}
if (!defined('PHPFOX_SKIP_INSTALL_KEY'))
{
$oApi = Phpfox::getLib('phpfox.api');
if ($oApi->send('brandingRemoval'))
{
Phpfox::getLib('database')->update(Phpfox::getT('setting'), array('value_actual' => '1'), "var_name = 'branding'");
}
}
$this->_db()->update(Phpfox::getT('setting'), array('value_actual' => Phpfox::getVersion()), 'var_name = \'phpfox_version\'');
if ($this->_bUpgrade)
{
$iCurrentVersion = $this->_getCurrentVersion();
if (!$this->_db()->select('COUNT(*)')
->from(Phpfox::getT('install_log'))
->where('is_upgrade = 1 AND version_id = \'' . $iCurrentVersion . '\' AND upgrade_version_id = \'' . Phpfox::getVersion() . '\'')
->execute('getField')
)
{
$this->_db()->insert(Phpfox::getT('install_log'), array(
'is_upgrade' => '1',
'version_id' => $this->_getCurrentVersion(),
'upgrade_version_id' => Phpfox::getVersion(),
'time_stamp' => PHPFOX_TIME,
'ip_address' => Phpfox::getIp()
)
);
}
}
else
{
if (!$this->_db()->select('COUNT(*)')
->from(Phpfox::getT('install_log'))
->where('is_upgrade = 0 AND version_id = \'' . Phpfox::getVersion() . '\' AND ' . $this->_db()->isNull('upgrade_version_id') . '')
->execute('getField')
)
{
$this->_db()->insert(Phpfox::getT('install_log'), array(
'version_id' => Phpfox::getVersion(),
'time_stamp' => PHPFOX_TIME,
'ip_address' => Phpfox::getIp()
)
);
}
}
Phpfox::getLib('cache')->remove();
$this->_oTpl->assign(array(
'bIsUpgrade' => $this->_bUpgrade,
'sUpgradeVersion' => Phpfox::getVersion()
)
);
}
示例9: snoop
/**
* This function allows a user to log in as another user.
* @param array $aUser
* @return boolean
*/
public function snoop($aUser)
{
Phpfox::isUser(true);
if (!Phpfox::getUserParam('user.can_member_snoop')) {
return Phpfox_Error::set('Admin lacks permissions');
}
$sPasswordHash = Phpfox::getLib('hash')->setRandomHash(Phpfox::getLib('hash')->setHash($aUser['password'], $aUser['password_salt']));
// Set cookie (yummy)
$iTime = 0;
$this->database()->insert(Phpfox::getT('user_snoop'), array('time_stamp' => PHPFOX_TIME, 'user_id' => Phpfox::getUserId(), 'logging_in_as' => $aUser['user_id']));
Phpfox::setCookie($this->_sNameCookieUserId, $aUser['user_id'], $iTime);
Phpfox::setCookie($this->_sNameCookieHash, $sPasswordHash, $iTime);
if (!defined('PHPFOX_INSTALLER')) {
Phpfox::getLib('session')->remove(Phpfox::getParam('core.theme_session_prefix') . 'theme');
}
$this->database()->update($this->_sTable, array('last_login' => PHPFOX_TIME), 'user_id = ' . $aUser['user_id']);
$this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => $aUser['user_id'], 'type_id' => 'login', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME));
return true;
}
示例10: _completed
private function _completed()
{
if (Phpfox_File::instance()->isWritable(PHPFOX_DIR_SETTINGS . 'server.sett.php')) {
$sContent = file_get_contents(PHPFOX_DIR_SETTINGS . 'server.sett.php');
$sContent = preg_replace("/\\\$_CONF\\['core.is_installed'\\] = (.*?);/i", "\\\$_CONF['core.is_installed'] = true;", $sContent);
if ($hServerConf = @fopen(PHPFOX_DIR_SETTINGS . 'server.sett.php', 'w')) {
fwrite($hServerConf, $sContent);
fclose($hServerConf);
}
}
$license = file_get_contents(PHPFOX_DIR_SETTINGS . 'license.php');
file_put_contents(PHPFOX_DIR_SETTINGS . 'license.sett.php', $license);
unlink(PHPFOX_DIR_SETTINGS . 'license.php');
/*
if (!defined('PHPFOX_SKIP_INSTALL_KEY'))
{
$oApi = Phpfox::getLib('phpfox.api');
if ($oApi->send('brandingRemoval'))
{
Phpfox_Database::instance()->update(Phpfox::getT('setting'), array('value_actual' => '1'), "var_name = 'branding'");
}
}
*/
$this->_db()->update(Phpfox::getT('setting'), array('value_actual' => Phpfox::getVersion()), 'var_name = \'phpfox_version\'');
$this->_db()->update(Phpfox::getT('setting'), array('value_actual' => date('j/n/Y', PHPFOX_TIME)), 'var_name = \'official_launch_of_site\'');
$this->_db()->update(Phpfox::getT('module'), array('is_active' => '0'), 'module_id = \'microblog\'');
$this->_db()->update(Phpfox::getT('user_group_setting'), array('is_hidden' => '1'), 'name = \'custom_table_name\'');
if ($this->_bUpgrade) {
$iCurrentVersion = $this->_getCurrentVersion();
if (!$this->_db()->select('COUNT(*)')->from(Phpfox::getT('install_log'))->where('is_upgrade = 1 AND version_id = \'' . $iCurrentVersion . '\' AND upgrade_version_id = \'' . Phpfox::getVersion() . '\'')->execute('getField')) {
$this->_db()->insert(Phpfox::getT('install_log'), array('is_upgrade' => '1', 'version_id' => $this->_getCurrentVersion(), 'upgrade_version_id' => Phpfox::getVersion(), 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp()));
}
} else {
// $this->_db()->update(Phpfox::getT('theme_style'), array('is_default' => '0'), 'style_id > 0');
// $this->_db()->update(Phpfox::getT('theme_style'), array('is_default' => '1'), 'folder = \'nebula\'');
if (!$this->_db()->select('COUNT(*)')->from(Phpfox::getT('install_log'))->where('is_upgrade = 0 AND version_id = \'' . Phpfox::getVersion() . '\' AND ' . $this->_db()->isNull('upgrade_version_id') . '')->execute('getField')) {
$this->_db()->insert(Phpfox::getT('install_log'), array('version_id' => Phpfox::getVersion(), 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp()));
}
}
Phpfox::getLib('cache')->remove();
$this->_oTpl->assign(array('bIsUpgrade' => $this->_bUpgrade, 'sUpgradeVersion' => Phpfox::getVersion()));
}
示例11: getAdRedirect
/**
* Get an ads redirection URL and update the "click" count for the ad.
*
* @param int $iId ID# for the ad.
* @return string URL of the ad, which can be used to send the user to that page.
*/
public function getAdRedirect($iId)
{
($sPlugin = Phpfox_Plugin::get('ad.service_ad_getadredirect__start')) ? eval($sPlugin) : false;
$aAd = $this->database()->select('ad_id, location, url_link, is_cpm, total_click, count_click')->from($this->_sTable)->where('ad_id = ' . (int) $iId)->execute('getSlaveRow');
if (!isset($aAd['ad_id'])) {
return Phpfox_Error::set(Phpfox::getPhrase('ad.the_ad_you_are_looking_for_does_not_exist'));
}
$this->cache()->remove('ad_' . $aAd['location']);
if ($aAd['is_cpm'] != 1 && $aAd['count_click'] >= $aAd['total_click']) {
$this->database()->update(Phpfox::getT('ad'), array('is_active' => '0'), 'ad_id =' . $aAd['ad_id']);
return Phpfox_Error::set(Phpfox::getPhrase('ad.the_ad_you_are_looking_for_does_not_exist'));
}
$aTrack = $this->database()->select('track_id')->from(Phpfox::getT('ad_track'))->where(Phpfox::isUser() ? 'ad_id = ' . $aAd['ad_id'] . ' AND user_id = ' . Phpfox::getUserId() : 'ad_id = ' . $aAd['ad_id'] . ' AND ip_address = \'' . $this->database()->escape(Phpfox::getIp()) . '\'')->execute('getRow');
if (!isset($aTrack['track_id'])) {
$this->database()->updateCounter('ad', 'count_click', 'ad_id', $aAd['ad_id']);
$this->database()->insert(Phpfox::getT('ad_track'), array('ad_id' => $aAd['ad_id'], 'user_id' => Phpfox::getUserId(), 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME));
}
($sPlugin = Phpfox_Plugin::get('ad.service_ad_getadredirect__end')) ? eval($sPlugin) : false;
return $aAd['url_link'];
}
示例12: login
public function login($iPageId)
{
$aPage = $this->database()->select('p.*, p.user_id AS owner_user_id, u.*')->from(Phpfox::getT('pages'), 'p')->join(Phpfox::getT('user'), 'u', 'u.profile_page_id = p.page_id')->where('p.page_id = ' . (int) $iPageId)->execute('getSlaveRow');
if (!isset($aPage['page_id'])) {
return Phpfox_Error::set(Phpfox::getPhrase('pages.unable_to_find_the_page_you_are_trying_to_login_to'));
}
$iCurrentUserId = Phpfox::getUserId();
$bCanLogin = false;
if ($aPage['owner_user_id'] == Phpfox::getUserId()) {
$bCanLogin = true;
}
if (!$bCanLogin) {
$iAdmin = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('pages_admin'))->where('page_id = ' . (int) $aPage['page_id'] . ' AND user_id = ' . (int) Phpfox::getUserId())->execute('getSlaveField');
if ($iAdmin) {
$bCanLogin = true;
}
}
if (!$bCanLogin) {
return Phpfox_Error::set(Phpfox::getPhrase('pages.unable_to_log_in_as_this_page'));
}
if (Phpfox::getParam('core.auth_user_via_session')) {
$this->database()->delete(Phpfox::getT('session'), 'user_id = ' . (int) Phpfox::getUserId());
$this->database()->insert(Phpfox::getT('session'), array('user_id' => $aPage['user_id'], 'last_activity' => PHPFOX_TIME, 'id_hash' => Phpfox_Request::instance()->getIdHash()));
}
$sPasswordHash = Phpfox::getLib('hash')->setRandomHash(Phpfox::getLib('hash')->setHash($aPage['password'], $aPage['password_salt']));
$iTime = 0;
$aUserCookieNames = Phpfox::getService('user.auth')->getCookieNames();
Phpfox::setCookie($aUserCookieNames[0], $aPage['user_id'], $iTime);
Phpfox::setCookie($aUserCookieNames[1], $sPasswordHash, $iTime);
Phpfox::getLib('session')->remove(Phpfox::getParam('core.theme_session_prefix') . 'theme');
$this->database()->update(Phpfox::getT('user'), array('last_login' => PHPFOX_TIME), 'user_id = ' . $aPage['user_id']);
$this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => $aPage['user_id'], 'type_id' => 'login', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME));
$iLoginId = $this->database()->insert(Phpfox::getT('pages_login'), array('page_id' => $aPage['page_id'], 'user_id' => $iCurrentUserId, 'time_stamp' => PHPFOX_TIME));
Phpfox::setCookie('page_login', $iLoginId, $iTime);
return true;
}
示例13: getFeed
public function getFeed($iId)
{
$sCacheId = $this->cache()->set('rss_feed_' . $iId);
if (!($aFeed = $this->cache()->get($sCacheId))) {
$aFeed = $this->database()->select('r.*')->from($this->_sTable, 'r')->where('r.feed_id = ' . (int) $iId . ' AND r.is_active = 1')->order('r.ordering ASC')->execute('getSlaveRow');
if (!isset($aFeed['feed_id'])) {
return Phpfox_Error::set(Phpfox::getPhrase('rss.unable_to_find_rss_feed'));
}
$this->cache()->save($sCacheId, $aFeed);
}
$sDescription = Phpfox::getPhrase($aFeed['description_var']);
eval($aFeed['php_view_code']);
if (!isset($aRows) || isset($aRows) && !is_array($aRows)) {
return Phpfox_Error::trigger(Phpfox::getPhrase('rss.not_a_valid_rss_feed_php_code_failed'), E_USER_ERROR);
}
$iLog = $this->database()->select('COUNT(*)')->from(Phpfox::getT('rss_log'))->where('feed_id = ' . $aFeed['feed_id'] . ' AND id_hash = \'' . Phpfox::getLib('request')->getIdHash() . '\'')->execute('getSlaveField');
if (!$iLog) {
$this->database()->insert(Phpfox::getT('rss_log'), array('feed_id' => $aFeed['feed_id'], 'id_hash' => Phpfox::getLib('request')->getIdHash(), 'ip_address' => Phpfox::getIp(), 'user_agent' => Phpfox::getLib('request')->getBrowser(), 'time_stamp' => PHPFOX_TIME));
$this->database()->updateCounter('rss', 'total_subscribed', 'feed_id', $aFeed['feed_id']);
}
$oXmlBuilder = Phpfox::getLib('xml.builder');
$oXmlBuilder->setXml(array('version' => '1.0', 'encoding' => 'UTF-8'));
$oXmlBuilder->addGroup('rss', array('version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', 'xmlns:atom' => 'http://www.w3.org/2005/Atom'));
$oXmlBuilder->addGroup('channel');
$oXmlBuilder->addTag('atom:link', '', array('href' => Phpfox::getLib('url')->makeUrl('rss', array('id' => $aFeed['feed_id'])), 'rel' => 'self', 'type' => 'application/rss+xml'))->addTag('title', html_entity_decode(Phpfox::getPhrase($aFeed['title_var'])), null, 'UTF-8')->addTag('link', Phpfox::getLib('url')->makeUrl($aFeed['feed_link']))->addTag('description', html_entity_decode($sDescription, null, 'UTF-8'));
foreach ($aRows as $aItem) {
$aItem['title'] = html_entity_decode($aItem['title'], null, 'UTF-8');
$aItem['title'] = str_replace('"', '"', $aItem['title']);
$oXmlBuilder->addGroup('item');
$oXmlBuilder->addTag('title', $aItem['title']);
$oXmlBuilder->addTag('link', $aItem['link']);
$oXmlBuilder->addTag('description', Phpfox::getLib('parse.output')->shorten($aItem['description'], 150, '...'));
$oXmlBuilder->addTag('content:encoded', $aItem['description']);
$oXmlBuilder->addTag('guid', $aItem['link']);
$oXmlBuilder->addTag('pubDate', date('r', $aItem['time_stamp']));
$oXmlBuilder->addTag('dc:creator', Phpfox::getLib('parse.output')->clean($aItem['creator']));
$oXmlBuilder->closeGroup('item');
// item
}
$oXmlBuilder->closeGroup();
// channel
$oXmlBuilder->closeGroup();
// rss
return $oXmlBuilder->output();
}
示例14: run
/**
* Starts the phpFox engine. Used to get and display the pages controller.
*
*/
public static function run()
{
$oTpl = Phpfox::getLib('template');
$aLocale = Phpfox::getLib('locale')->getLang();
$oReq = Phpfox::getLib('request');
$oModule = Phpfox::getLib('module');
$cache_id = Phpfox::getLib('cache')->set('auth_token_' . $_SERVER['REMOTE_ADDR']);
if (defined('PHPFOX_FORCE_TOKEN') && !Phpfox::getLib('cache')->get($cache_id, 60)) {
require_once PHPFOX_DIR_LIB . 'recaptcha' . PHPFOX_DS . 'recaptchalib.php';
$failed = '';
if (!empty($_POST["recaptcha_challenge_field"])) {
$resp = recaptcha_check_answer(PHPFOX_FORCE_PRIVATE, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$failed = '<div class="error">Captcha Failed. Try again!</div>';
} else {
Phpfox::getLib('cache')->save($cache_id, true);
ob_clean();
header('Location: ' . Phpfox::getParam('core.path'));
exit;
}
}
$html = '
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
<title>Human Verification</title>
<style type="text/css">
body { background:#e2e2e2; margin:0px; font-size:90%; font:inherit; vertical-align: baseline; font-family: "Helvetica Neue", Arial, sans-serif; font-size:90%; color:#333; line-height:1.5; word-wrap:break-word; }
#site_auth { background:#fff; margin-top:200px; text-align:center; padding:50px 0px 50px 0px; }
#site_auth form { margin:0px; padding:0px; max-width:500px; margin:auto; }
h1 { font-size:2.6em; font-weight:300; letter-spacing:2px; }
p { padding:0px 0px 20px 0px; margin:0px; color:#808080; font-size:0.9em; }
.submit { margin:20px 0px 0px 0px; padding:10px 30px 10px 30px; background:#71B33D; color:#fff; font-size:1.1em; border:0px; text-transform:uppercase; cursor:pointer; border-radius:3px; }
.error { background:#EA5859; color:#fff; padding:20px; margin-bottom:10px; font-size:1.2em; }
</style>
</head>
<body>
<div id="site_auth">
<form method="post" action="' . Phpfox::getParam('core.path') . '">
<h1>Human Verification</h1>
<p>
This site requires you to be a human in order to view the site. Please take a moment to pass the captcha below.
Once you have verified you are human you will get a 1 hour token to view the site, thereafter you must renew your token.
</p>
' . $failed . '
<div style="margin:auto; display:inline-block;">' . recaptcha_get_html(PHPFOX_FORCE_KEY) . '</div>
<div>
<input type="submit" value="Submit" class="submit" />
</div>
</form>
</div>
</body>
</html>
';
echo $html;
exit;
}
($sPlugin = Phpfox_Plugin::get('run_start')) ? eval($sPlugin) : false;
// Load module blocks
$oModule->loadBlocks();
if (Phpfox::isMobile() && $oReq->get('req1') == 'go-to-full-site') {
Phpfox::getLib('session')->set('mobilestatus', 'true');
Phpfox::getLib('url')->send('phpfox_full_site');
}
if (!Phpfox::getParam('core.branding')) {
$oTpl->setHeader(array('<meta name="author" content="phpFox" />'));
}
if (strtolower(Phpfox::getLib('request')->get('req1')) == Phpfox::getParam('admincp.admin_cp')) {
self::$_bIsAdminCp = true;
}
$sImage = Phpfox::getUserBy('user_image');
$bIsAd = false;
$oRequest = Phpfox::getLib('request');
if ($oRequest->get('id') && $oRequest->get('req1') == 'ad' && $oRequest->get('req2') == 'iframe') {
$bIsAd = true;
}
if (!Phpfox::getService('ban')->check('ip', Phpfox::getIp())) {
$oModule->setController('ban.message');
} else {
if (!self::$_bIsAdminCp && Phpfox::getParam('core.site_is_offline') && !Phpfox::getUserParam('core.can_view_site_offline') && $bIsAd != true) {
if (Phpfox::getLib('request')->get('req1') == 'user' && (Phpfox::getLib('request')->get('req2') == 'login' || Phpfox::getLib('request')->get('req2') == 'logout') || Phpfox::getLib('request')->get('req1') == 'contact' || Phpfox::getLib('request')->get('req1') == 'captcha') {
$oModule->setController();
} else {
$oModule->setController('core.offline');
}
} else {
$oModule->setController();
}
}
if (!PHPFOX_IS_AJAX_PAGE) {
if (Phpfox::isMobile()) {
$oTpl->setMobileHeader(array('<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />'));
}
$oTpl->setImage(array('ajax_small' => 'ajax/small.gif', 'ajax_large' => 'ajax/large.gif', 'loading_animation' => 'misc/loading_animation.gif', 'close' => 'misc/close.gif', 'move' => 'misc/move.png', 'calendar' => 'jquery/calendar.gif'));
$oTpl->setHeader(array('<meta http-equiv="Content-Type" content="text/html; charset=' . $aLocale['charset'] . '" />', '<meta http-equiv="cache-control" content="no-cache" />', '<meta http-equiv="expires" content="-1" />', '<meta http-equiv="pragma" content="no-cache" />', '<link rel="shortcut icon" type="image/x-icon" href="' . Phpfox::getParam('core.path') . 'favicon.ico?v=' . $oTpl->getStaticVersion() . '" />'))->setMeta('keywords', Phpfox::getLib('locale')->convert(Phpfox::getParam('core.keywords')))->setMeta('robots', 'index,follow');
if (Phpfox::getParam('core.include_master_files') && Phpfox::isAdminPanel() != true) {
//.........这里部分代码省略.........
示例15: updatePassword
public function updatePassword($aVals)
{
Phpfox::isUser(true);
if (empty($aVals['old_password'])) {
return Phpfox_Error::set(Phpfox::getPhrase('user.missing_old_password'));
}
if (empty($aVals['new_password'])) {
return Phpfox_Error::set(Phpfox::getPhrase('user.missing_new_password'));
}
if (empty($aVals['confirm_password'])) {
return Phpfox_Error::set(Phpfox::getPhrase('user.confirm_your_new_password'));
}
if ($aVals['confirm_password'] != $aVals['new_password']) {
return Phpfox_Error::set(Phpfox::getPhrase('user.your_confirmed_password_does_not_match_your_new_password'));
}
$aUser = Phpfox::getService('user')->getUser(Phpfox::getUserId());
if (Phpfox::getLib('hash')->setHash($aVals['old_password'], $aUser['password_salt']) != $aUser['password']) {
return Phpfox_Error::set(Phpfox::getPhrase('user.your_current_password_does_not_match_your_old_password'));
}
$sSalt = $this->_getSalt();
$aInsert = array();
$aInsert['password'] = Phpfox::getLib('hash')->setHash($aVals['new_password'], $sSalt);
$aInsert['password_salt'] = $sSalt;
$this->database()->update($this->_sTable, $aInsert, 'user_id = ' . Phpfox::getUserId());
list($bLogged, $aUser) = Phpfox::getService('user.auth')->login($aUser['email'], $aVals['new_password'], false, 'email');
$this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => Phpfox::getUserId(), 'type_id' => 'update_password', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME));
($sPlugin = Phpfox_Plugin::get('user.service_process_updatepassword')) ? eval($sPlugin) : false;
return $bLogged ? true : false;
}