public function process() { if (!defined('PHPFOX_ALLOW_MODE')) { exit; } $demoId = 0; if ($demoId = $this->request()->get('id')) { $Themes = new Core\Theme($demoId); Phpfox::setCookie('flavor_id', $demoId); $this->url()->send(''); } /* else { $this->url()->send(''); } */ Core\View::$template = 'blank'; $Themes = new Core\Theme(); $flavors = []; foreach ($Themes->all() as $Theme) { foreach ($Theme->flavors() as $Flavor) { $flavors[] = $Flavor; } } $this->template()->assign(['flavors' => $flavors, 'demoId' => $demoId]); }
/** * Class process method wnich is used to execute this component. */ public function process() { if (defined('PHPFOX_IS_AD_PREVIEW')) { return false; } if (Phpfox::getUserBy('profile_page_id') > 0) { return false; } $oRequest = Phpfox::getLib('request'); if ($this->template()->bIsSample || $oRequest->get('req2') == 'designer' || $oRequest->get('req2') == 'index-member' && $oRequest->get('req3') == 'customize') { return false; } if (!Phpfox::isModule('friend')) { return false; } $sLastOpenWindow = null; $sLastWindowParam = null; if ($sLastOpenWindow = Phpfox::getCookie('im_last_open_window')) { if (preg_match("/chat_(.*)/i", $sLastOpenWindow, $aMatches)) { $sLastOpenWindow = 'chat'; $sLastWindowParam = (int) $aMatches[1]; } elseif ($sLastOpenWindow == 'messenger') { $sLastOpenWindow = 'messenger'; } Phpfox::setCookie('im_last_open_window', '', -1); } $iCnt = 0; if (Phpfox::getUserBy('im_hide') != '1') { $aCond = array('AND f.user_id = ' . Phpfox::getUserId() . ' AND u.im_hide != 1'); list($iCnt, $aFriends) = Phpfox::getService('im')->getOnlineFriends(Phpfox::getUserId(), $aCond); } $this->template()->assign(array('iTotalFriendsOnline' => $iCnt, 'sLastOpenWindow' => $sLastOpenWindow, 'sLastWindowParam' => $sLastWindowParam)); }
/** * Removes a session. * * @param mixed $mName STRING name of session, ARRAY of sessions. */ public function remove($mName) { if (!is_array($mName)) { $mName = array($mName); } foreach ($mName as $sName) { Phpfox::setCookie($sName, '', -1); } }
public function designdnd() { if ($this->get('enable') == 1 && Phpfox::getUserParam('core.can_design_dnd')) { Phpfox::setCookie('doDnD', '1', PHPFOX_TIME + 3600); if ($this->get('inline')) { $this->call('windowjavascript:location.reload(true);'); } else { $this->call('window.location.href = \'' . Phpfox::getLib('url')->makeUrl('') . '\';'); } } else { Phpfox::setCookie('doDnD', -1, PHPFOX_TIME); $this->call('windowjavascript:location.reload(true);'); } }
/** * Controller */ public function process() { Phpfox::isUser(true); $bCanEditPersonalData = true; $aCallback = false; if ($this->request()->get('module')) { $this->template()->assign(array('bIsGroup' => '1')); } if (($sModule = $this->request()->get('module')) && Phpfox::isModule($sModule) && ($iItemId = $this->request()->getInt('item')) && Phpfox::hasCallback($sModule, 'addForum')) { $aCallback = Phpfox::callback($sModule . '.addForum', $iItemId); $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.pages'), $this->url()->makeUrl('pages')); $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']); $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.discussions'), $aCallback['url_home'] . 'forum/'); if ($sModule == 'pages' && !Phpfox::getService('pages')->hasPerm($iItemId, 'forum.share_forum')) { return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings')); } } else { $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum')); } $iId = $this->request()->getInt('id'); $aAccess = Forum_Service_Forum::instance()->getUserGroupAccess($iId, Phpfox::getUserBy('user_group_id')); if ($aAccess['can_view_thread_content']['value'] != true) { return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings')); } if (Phpfox::isModule('poll')) { $this->template()->setHeader('cache', array('poll.js' => 'module_poll', '<script type="text/javascript">$Behavior.loadSortableAnswers = function() {$(".sortable").sortable({placeholder: "placeholder", axis: "y"});}</script>')); } $this->template()->setEditor()->setTitle(Phpfox::getPhrase('forum.forum'))->setHeader('cache', array('switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'pager.css' => 'style_css', 'forum.css' => 'style_css')); $bIsEdit = false; if ($this->request()->get('req3') == 'thread') { if ($iEditId = $this->request()->getInt('edit')) { $aThread = Forum_Service_Thread_Thread::instance()->getForEdit($iEditId); if (!isset($aThread['thread_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread')); } if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post')) { $bIsEdit = true; if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aThread['user_id']) { $bCanEditPersonalData = false; } $iId = $aThread['forum_id']; if (Phpfox::isModule('tag')) { $aThread['tag_list'] = Tag_Service_Tag::instance()->getForEdit('forum', $aThread['thread_id']); } $this->template()->assign(array('aForms' => $aThread, 'iEditId' => $aThread['thread_id'])); } else { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread')); } } if ($aCallback === false) { $aForum = Phpfox::getService('forum')->id($iId)->getForum(); if (!isset($aForum['forum_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum')); } if ($aForum['is_closed']) { return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed')); } } if (!$bIsEdit) { $bPass = false; if (Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) { $bPass = true; } if ($bPass === false) { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread')); } } if (!Forum_Service_Forum::instance()->hasAccess($iId, 'can_start_thread')) { return Phpfox_Error::display('You are unable to create a new post in this forum.'); } $aValidation = array('title' => Phpfox::getPhrase('forum.provide_a_title_for_your_thread'), 'text' => Phpfox::getPhrase('forum.provide_some_text')); if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) { $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge'); } $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $bPosted = false; if ($aVals = $this->request()->getArray('val')) { if (isset($aVals['type_id']) && $aVals['type_id'] == 'announcement') { $bPosted = true; } if ($oValid->isValid($aVals)) { if ($bIsEdit) { $aVals['post_id'] = $aThread['start_id']; $aVals['was_announcement'] = $aThread['is_announcement']; $aVals['forum_id'] = $aThread['forum_id']; if (Phpfox::getService('forum.thread.process')->update($aThread['thread_id'], $aThread['user_id'], $aVals)) { $this->url()->permalink('forum.thread', $aThread['thread_id'], Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true, Phpfox::getPhrase('forum.thread_successfully_updated')); } } else { if (($iFlood = Phpfox::getUserParam('forum.forum_thread_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_thread'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_new_thread_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('forum.thread.process')->add($aVals, $aCallback))) { $this->url()->permalink('forum.thread', $iId, Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true); } } } } if ($aCallback === false) { $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true); } else { $this->template()->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true); } $this->template()->assign(array('iForumId' => $iId, 'iActualForumId' => $iId, 'sFormLink' => $aCallback == false ? $this->url()->makeUrl('forum.post.thread', array('id' => $iId)) : $this->url()->makeUrl('forum.post.thread', array('module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sForumParents' => $aCallback === false ? Phpfox::getUserParam('forum.can_post_announcement') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'post_announcement') ? Phpfox::getService('forum')->active($aForum['forum_id'])->getJumpTool(true) : '' : '', 'bPosted' => $bPosted, 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback)); if (Phpfox::getUserParam('forum.can_add_forum_attachments')) { $this->setParam('attachment_share', array('type' => 'forum', 'id' => 'js_forum_form')); } } else { if ($iEditId = $this->request()->getInt('edit')) { $aPost = Phpfox::getService('forum.post')->getForEdit($iEditId); if (!isset($aPost['post_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_post')); } $bCanEditPost = Phpfox::getUserParam('forum.can_edit_own_post') && $aPost['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aPost['forum_id'], 'edit_post'); if ($bCanEditPost) { $bIsEdit = true; if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aPost['user_id']) { $bCanEditPersonalData = false; } $iId = $aPost['thread_id']; $this->template()->assign(array('aForms' => $aPost, 'iEditId' => $aPost['post_id'])); if (PHPFOX_IS_AJAX) { Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : Phpfox::getLib('parse.output')->shorten($aPost['title'], 80, '...'))); } } else { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread')); } } $aThread = Forum_Service_Thread_Thread::instance()->getActualThread($iId, $aCallback); if (!isset($aThread['thread_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread')); } if ($aThread['is_closed'] && (isset($bCanEditPost) && !$bCanEditPost || !isset($bCanEditPost))) { return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_closed')); } if ($aCallback === false && $aThread['forum_is_closed']) { return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed')); } if (!$iEditId && $aThread['is_announcement']) { return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_an_announcement_not_allowed_to_leave_a_reply')); } if (!$bIsEdit) { $bPass = false; if (Phpfox::getUserParam('forum.can_reply_to_own_thread') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_reply_on_other_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'can_reply')) { $bPass = true; } if ($bPass === false) { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread')); } } $sExtraText = ''; if ($sSavedText = $this->request()->get('save_text')) { $sExtraText .= Phpfox::getLib('parse.output')->clean($sSavedText); } if (Phpfox::getUserParam('forum.can_multi_quote_forum') && (($iQuote = $this->request()->getInt('quote')) || ($sCookie = Phpfox::getCookie('forum_quote')) && !empty($sCookie))) { $sCookie = Phpfox::getCookie('forum_quote'); if (!empty($sCookie)) { $iQuote = $sCookie . $iQuote; } $sExtraText .= Phpfox::getService('forum.post')->getQuotes($aThread['thread_id'], $iQuote); } if (($iQuoteId = $this->request()->getInt('quote')) && ($aQuotePost = Phpfox::getService('forum.post')->getForEdit($iQuoteId))) { Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.replying_to_a_post_by_full_name', array('full_name' => Phpfox::getLib('parse.output')->shorten($aQuotePost['full_name'], 80, '...')))); } $aSubForms = array(); if (isset($aThread['is_subscribed'])) { $aSubForms['is_subscribed'] = $aThread['is_subscribed']; } if (!empty($sExtraText)) { $aSubForms['text'] = $sExtraText; } if (isset($bCanEditPost) && $bCanEditPost) { $aSubForms = array_merge($aSubForms, $aPost); } $this->template()->assign('aForms', $aSubForms); $aValidation = array('text' => Phpfox::getPhrase('forum.provide_some_text')); if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) { $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge'); } $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $aForum = Phpfox::getService('forum')->id($aThread['forum_id'])->getForum(); if ($aVals = $this->request()->getArray('val')) { $aVals['forum_id'] = $aThread['forum_id']; if ($oValid->isValid($aVals)) { Phpfox::setCookie('forum_quote', '', -1); if ($bIsEdit) { if (Phpfox::getService('forum.post.process')->update($aPost['post_id'], $aPost['user_id'], $aVals)) { $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $aPost['post_id'])); } } else { if (($iFlood = Phpfox::getUserParam('forum.forum_post_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_post'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_reply_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } if (Phpfox_Error::isPassed()) { if ($iId = Phpfox::getService('forum.post.process')->add($aVals, $aCallback)) { $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $iId)); } else { if (Phpfox::getUserParam('forum.approve_forum_post')) { $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, Phpfox::getPhrase('forum.your_post_has_successfully_been_added_however_it_is_pending_an_admins_approval_before_it_can_be_displayed_publicly'), array('post' => $iId)); } } } } } } if ($aCallback === false) { $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->makeUrl('forum', $aForum['name_url'] . '-' . $aForum['forum_id'])); } else { } $this->template()->setBreadcrumb($aThread['title'], $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : $aPost['title']) : Phpfox::getPhrase('forum.post_new_reply'), $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', array($aThread['title_url'], 'post' => $aPost['post_id'])) : null, true)->assign(array('iThreadId' => $iId, 'iActualForumId' => $aForum['forum_id'], 'sFormLink' => $aCallback === false ? $this->url()->makeUrl('forum.post.reply', array('id' => $iId)) : $this->url()->makeUrl('forum.post.reply', array('id' => $iId, 'module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(PHPFOX_IS_AJAX ? false : true), 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'sThreadReturnLink' => $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'], array('forum', $aThread['title_url'])), 'aPreviews' => Phpfox::getService('forum.post')->getPreview($aThread['thread_id']), 'iTotalPosts' => $aThread['total_post'], 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback, 'iTotalPostPreview' => Phpfox::getParam('forum.total_forum_post_preview'))); if (Phpfox::getUserParam('forum.can_add_forum_attachments')) { $this->setParam('attachment_share', array('type' => 'forum', 'inline' => PHPFOX_IS_AJAX ? true : false, 'id' => 'js_forum_form', 'edit_id' => $bIsEdit ? $aPost['post_id'] : '')); } } }
/** * 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; }
/** * Actions to take after an invited guest signs up * @param <type> $iGuestId * @param <type> $iUser * @return <type> */ public function registerInvited($iUserId) { if ($iInviteId = Phpfox::getCookie('invited_by_user')) { $aInvite = $this->database()->select('user_id')->from(Phpfox::getT('user'))->where('user_id = ' . (int) $iInviteId)->execute('getSlaveRow'); } elseif ($iInviteId = Phpfox::getCookie('invited_by_email')) { $aInvite = $this->database()->select('invite_id, user_id')->from($this->_sTable)->where('invite_id = ' . (int) $iInviteId)->execute('getSlaveRow'); if (isset($aInvite['invite_id'])) { $this->database()->delete(Phpfox::getT('invite'), "invite_id = '" . $aInvite['invite_id'] . "'"); } } if (isset($aInvite['user_id'])) { // Both should now be friends $this->_makeFriends($iUserId, $aInvite['user_id']); // update the user table field for invite_user_id $this->database()->update(Phpfox::getT('user'), array('invite_user_id' => (int) $aInvite['user_id']), 'user_id = ' . $iUserId); // award points // relying on the script's type validation as its defined as integer Phpfox::getService('user.activity')->update($iUserId, 'invite', '+'); Phpfox::getService('user.activity')->update($aInvite['user_id'], 'invite', '+'); } Phpfox::setCookie('invited_by_user', 0, '-1'); Phpfox::setCookie('invited_by_email', 0, '-1'); }
/** * Class process method wnich is used to execute this component. */ public function process() { if (!Phpfox::getParam('user.allow_user_registration')) { $this->url()->send(''); } define('PHPFOX_DONT_SAVE_PAGE', true); if (Phpfox::isUser()) { $this->url()->send('profile'); } $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_form', 'aParams' => Phpfox::getService('user.register')->getValidation())); if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getService('invite')->isInviteOnly()) { if (Phpfox::getService('invite')->isValidInvite($aVals['invite_email'])) { $iExpire = (Phpfox::getParam('invite.invite_expire') > 0 ? (Phpfox::getParam('invite.invite_expire')*60*60*24) : (7*60*60*24)); Phpfox::setCookie('invite_only_pass', $aVals['invite_email'], PHPFOX_TIME + $iExpire); $this->url()->send('user.register'); } } else { if (!Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up')) { $aVals['user_name'] = str_replace(' ', '_', $aVals['user_name']); Phpfox::getService('user.validate')->user($aVals['user_name']); } (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_1')) ? eval($sPlugin) : false); Phpfox::getService('user.validate')->email($aVals['email']); (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_2')) ? eval($sPlugin) : false); if ($oValid->isValid($aVals)) { if ($iId = Phpfox::getService('user.process')->add($aVals)) { if (Phpfox::getService('user.auth')->login($aVals['email'], $aVals['password'])) { if (is_array($iId)) { (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_3')) ? eval($sPlugin) : false); $this->url()->forward($iId[0]); } else { $sRedirect = Phpfox::getParam('user.redirect_after_signup'); if (!empty($sRedirect)) { (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_4')) ? eval($sPlugin) : false); $this->url()->send($sRedirect); } if (Phpfox::getParam('user.multi_step_registration_form') && is_array(Phpfox::getParam('user.registration_steps')) && count(Phpfox::getParam('user.registration_steps'))) { $aUrls = Phpfox::getParam('user.registration_steps'); (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_5')) ? eval($sPlugin) : false); $this->url()->send($aUrls[0], 'register'); } else { (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_6')) ? eval($sPlugin) : false); $this->url()->send(''); } } } } else { if (Phpfox::getParam('user.multi_step_registration_form')) { $this->template()->assign('bIsPosted', true); (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_7')) ? eval($sPlugin) : false); } } } else { $this->template()->assign(array( 'bCorrectUsername' => (!Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up') ? Phpfox::getService('user.validate')->user($aVals['user_name']) : ''), 'sUsername' => ((!Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up')) ? $aVals['user_name'] : ''), 'iTimeZonePosted' => (isset($aVals['time_zone']) ? $aVals['time_zone'] : 0) ) ); if (Phpfox::getParam('user.multi_step_registration_form')) { $this->template()->assign('bIsPosted', true); } $this->setParam(array( 'country_child_value' => (isset($aVals['country_iso']) ? $aVals['country_iso'] : 0), 'country_child_id' => (isset($aVals['country_child_id']) ? $aVals['country_child_id'] : 0) ) ); } } } else { if (($sSentCookie = Phpfox::getCookie('invited_by_email_form'))) { $this->template()->assign('aForms', array('email' => $sSentCookie)); } } $sTitle = Phpfox::getPhrase('user.sign_and_start_using_site', array('site' => Phpfox::getParam('core.site_title'))); (($sPlugin = Phpfox_Plugin::get('user.component_controller_register_8')) ? eval($sPlugin) : false); $this->template()->setTitle($sTitle) // ->setBreadcrumb($sTitle) ->setFullSite() ->setPhrase(array( 'user.continue' ) ) ->setHeader('cache', array( 'register.css' => 'module_user', 'register.js' => 'module_user', 'country.js' => 'module_core' ) ) ->assign(array( 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sSiteUrl' => Phpfox::getParam('core.path'), 'aTimeZones' => Phpfox::getService('core')->getTimeZones(), 'aPackages' => (Phpfox::isModule('subscribe') ? Phpfox::getService('subscribe')->getPackages(true) : null), 'aSettings' => Phpfox::getService('custom')->getForEdit(array('user_main', 'user_panel', 'profile_panel'), null, null, true), 'sDobStart' => Phpfox::getParam('user.date_of_birth_start'), 'sDobEnd' => Phpfox::getParam('user.date_of_birth_end'), 'sJanrainUrl' => (Phpfox::isModule('janrain') ? Phpfox::getService('janrain')->getUrl() : ''), 'sUserEmailCookie' => Phpfox::getCookie('invited_by_email_form') ) ); }
public function cropPhoto() { $aPostVals = $this->get('val'); if (empty($aPostVals['w']) && !isset($aPostVals['skip_croping'])) { $this->show('#js_photo_preview_ajax')->html('#js_photo_preview_ajax', ''); return Phpfox_Error::set(Phpfox::getPhrase('photo.select_an_area_on_your_photo_to_crop')); } if ($this->get('in_process')) { $oImage = Phpfox_Image::instance(); $sFileName = $this->get('in_process'); $aImages = array(); if ($sPhotos = $this->get('photos')) { $aImages = unserialize(base64_decode(urldecode($this->get('photos')))); } $iNotCompleted = 0; foreach (Phpfox::getParam('user.user_pic_sizes') as $iSize) { if (isset($aImages[sprintf($sFileName, '_' . $iSize)])) { continue; } if (Phpfox::getParam('core.keep_non_square_images')) { $oImage->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sFileName, ''), Phpfox::getParam('core.dir_user') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); } $oImage->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sFileName, ''), Phpfox::getParam('core.dir_user') . sprintf($sFileName, '_' . $iSize . '_square'), $iSize, $iSize, false); $aImages[sprintf($sFileName, '_' . $iSize)] = true; $iNotCompleted++; $this->call('p(\'Processing photo: ' . sprintf($sFileName, '_' . $iSize) . '\');'); break; } $sValues = ''; foreach ($this->get('val') as $sKey => $mValue) { $sValues .= '&val[' . $sKey . ']=' . urlencode($mValue); } if ($iNotCompleted) { $this->call('$.ajaxCall(\'user.cropPhoto\', \'js_disable_ajax_restart=true&photos=' . urlencode(base64_encode(serialize($aImages))) . '&in_process=' . $this->get('in_process') . '&file=' . $this->get('in_process') . '' . $sValues . '\');'); } else { $oFile = Phpfox_File::instance(); $iServerId = Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID'); $this->call('p(\'Completed resizing photos.\');'); if (Phpfox::getUserBy('user_image') != '') { if (file_exists(Phpfox::getParam('core.dir_user') . sprintf(Phpfox::getUserBy('user_image'), ''))) { $oFile->unlink(Phpfox::getParam('core.dir_user') . sprintf(Phpfox::getUserBy('user_image'), '')); foreach (Phpfox::getParam('user.user_pic_sizes') as $iSize) { if (file_exists(Phpfox::getParam('core.dir_user') . sprintf(Phpfox::getUserBy('user_image'), '_' . $iSize))) { $oFile->unlink(Phpfox::getParam('core.dir_user') . sprintf(Phpfox::getUserBy('user_image'), '_' . $iSize)); } if (file_exists(Phpfox::getParam('core.dir_user') . sprintf(Phpfox::getUserBy('user_image'), '_' . $iSize . '_square'))) { $oFile->unlink(Phpfox::getParam('core.dir_user') . sprintf(Phpfox::getUserBy('user_image'), '_' . $iSize . '_square')); } } } } $sFileName = $this->get('file'); Phpfox_Database::instance()->update(Phpfox::getT('user'), array('user_image' => $sFileName, 'server_id' => $iServerId), 'user_id = ' . Phpfox::getUserId()); Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->delete('user_photo', Phpfox::getUserId()) : null; Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->add('user_photo', Phpfox::getUserId(), serialize(array('destination' => $sFileName, 'server_id' => $iServerId))) : null; $this->call('$.ajaxCall(\'user.cropPhoto\', \'crop=true&js_disable_ajax_restart=true' . $sValues . '\');'); if (Phpfox::isModule('photo')) { Phpfox::getService('photo.album')->getForProfileView(Phpfox::getUserId(), true); } } return; } $aVals = $this->get('val'); if (isset($aVals['skip_croping']) || !isset($aVals['skip_croping'])) { $this->call('p(\'Cropping photo.\');'); if (Phpfox::getService('user.process')->cropPhoto($this->get('val'))) { /* if ($this->get('crop')) { * */ Phpfox::addMessage(Phpfox::getPhrase('user.profile_photo_successfully_updated')); Phpfox::setCookie('recache_image', 'yes', PHPFOX_TIME + 600); $this->call('window.location.href = \'' . Phpfox_Url::instance()->makeUrl('profile') . '\';'); /* } else { $this->show('#js_photo_preview_ajax')->html('#js_photo_preview_ajax', '<span class="valid_message">' . Phpfox::getPhrase('user.done') . '</span>', '.fadeOut(5000)'); $sImageAvatar = Phpfox::getLib('image.helper')->display(array( 'server_id' => Phpfox::getUserBy('server_id'), 'title' => Phpfox::getUserBy('full_name'), 'path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_75_square', 'max_width' => 75, 'max_height' => 75, 'no_default' => true, 'time_stamp' => true, 'class' => 'border' ) ); $this->html('#js_user_avatar', $sImageAvatar); } * */ } else { $this->show('#js_photo_preview_ajax')->html('#js_photo_preview_ajax', ''); } } }
/** * Class process method wnich is used to execute this component. */ public function process() { if (!Phpfox::getParam('user.allow_user_registration')) { $this->url()->send(''); } define('PHPFOX_DONT_SAVE_PAGE', true); if (Phpfox::isUser()) { $this->url()->send('profile'); } $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_form', 'aParams' => Phpfox::getService('user.register')->getValidation())); if ($aVals = $this->request()->getArray('val')) { $sTab = 'individual_tab'; if (isset($aVals['type_register']) && $aVals['type_register'] == 'organization') { $sTab = 'organization_tab'; $oValid = Phpfox::getLib('validator')->set(array('sFormName' => 'js_form', 'aParams' => Phpfox::getService('organization.user')->getValidation())); } if (Phpfox::isModule('invite') && Phpfox::getService('invite')->isInviteOnly()) { if (Phpfox::getService('invite')->isValidInvite($aVals['invite_email'])) { $iExpire = Phpfox::getParam('invite.invite_expire') > 0 ? Phpfox::getParam('invite.invite_expire') * 60 * 60 * 24 : 7 * 60 * 60 * 24; Phpfox::setCookie('invite_only_pass', $aVals['invite_email'], PHPFOX_TIME + $iExpire); $this->url()->send('user.register'); } } else { if (!Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up')) { // http://www.phpfox.com/tracker/view/15155/ $aVals['user_name'] = str_replace(' ', '-', $aVals['user_name']); $aVals['user_name'] = str_replace('_', '-', $aVals['user_name']); Phpfox::getService('user.validate')->user($aVals['user_name']); } ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_1')) ? eval($sPlugin) : false; if (isset($aVals['type_register']) && $aVals['type_register'] == 'organization') { Phpfox::getService('user.validate')->email($aVals['organization_email']); } else { Phpfox::getService('user.validate')->email($aVals['email']); } if (Phpfox::getParam('user.reenter_email_on_signup')) { if (empty($aVals['email']) || empty($aVals['confirm_email'])) { Phpfox_Error::set(Phpfox::getPhrase('user.email_s_do_not_match')); } else { if ($aVals['email'] != $aVals['confirm_email']) { Phpfox_Error::set(Phpfox::getPhrase('user.email_s_do_not_match')); } } } ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_2')) ? eval($sPlugin) : false; if ($oValid->isValid($aVals)) { if ($iId = Phpfox::getService('user.process')->add($aVals)) { if (isset($aVals['type_register']) && $aVals['type_register'] == 'organization') { $aVals['email'] = $aVals['organization_email']; $aVals['password'] = $aVals['organization_password']; } if (Phpfox::getService('user.auth')->login($aVals['email'], $aVals['password'])) { if (is_array($iId)) { ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_3')) ? eval($sPlugin) : false; $this->url()->forward($iId[0]); } else { $sRedirect = Phpfox::getParam('user.redirect_after_signup'); if (!empty($sRedirect)) { ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_4')) ? eval($sPlugin) : false; if (PHPFOX_IS_AJAX) { echo 'window.location.href="' . Phpfox::getLib('url')->makeUrl($sRedirect) . '";'; die; } $this->url()->send($sRedirect); } if (Phpfox::getParam('user.multi_step_registration_form') && is_array(Phpfox::getParam('user.registration_steps')) && count(Phpfox::getParam('user.registration_steps'))) { $aUrls = Phpfox::getParam('user.registration_steps'); ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_5')) ? eval($sPlugin) : false; $this->url()->send($aUrls[0], 'register'); } else { ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_6')) ? eval($sPlugin) : false; if (Phpfox::getLib('session')->get('appinstall') != '') { $this->url()->send('apps.install.' . Phpfox::getLib('session')->get('appinstall')); } else { if (PHPFOX_IS_AJAX) { echo 'window.location.href="' . Phpfox::getLib('url')->makeUrl('') . '";'; die; } $this->url()->send(''); } } } } } else { if (PHPFOX_IS_AJAX) { $aErrors = Phpfox_Error::get(); echo '$(".' . $sTab . ' .register_error_panel").html("");'; foreach ($aErrors as $key => $value) { $value = str_replace('"', "'", $value); echo '$(".' . $sTab . ' .register_error_panel").append("<div>' . $value . '</div>");'; } echo '$(".' . $sTab . ' .register_error_panel").fadeIn();'; die; } if (Phpfox::getParam('user.multi_step_registration_form')) { $this->template()->assign('bIsPosted', true); ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_7')) ? eval($sPlugin) : false; } } } else { if (PHPFOX_IS_AJAX) { $aErrors = Phpfox_Error::get(); echo '$(".' . $sTab . ' .register_error_panel").html("");'; foreach ($aErrors as $key => $value) { $value = str_replace('"', "'", $value); echo '$(".' . $sTab . ' .register_error_panel").append("<div>' . $value . '</div>");'; } echo '$(".' . $sTab . ' .register_error_panel").fadeIn();'; die; } $this->template()->assign(array('bCorrectUsername' => !Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up') ? Phpfox::getService('user.validate')->user($aVals['user_name']) : '', 'sUsername' => !Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up') ? $aVals['user_name'] : '', 'iTimeZonePosted' => isset($aVals['time_zone']) ? $aVals['time_zone'] : 0)); if (Phpfox::getParam('user.multi_step_registration_form')) { $this->template()->assign('bIsPosted', true); } $this->setParam(array('country_child_value' => isset($aVals['country_iso']) ? $aVals['country_iso'] : 0, 'country_child_id' => isset($aVals['country_child_id']) ? $aVals['country_child_id'] : 0)); } } } else { if ($sSentCookie = Phpfox::getCookie('invited_by_email_form')) { $this->template()->assign('aForms', array('email' => $sSentCookie)); } } $sTitle = Phpfox::getPhrase('user.sign_and_start_using_site', array('site' => Phpfox::getParam('core.site_title'))); ($sPlugin = Phpfox_Plugin::get('user.component_controller_register_8')) ? eval($sPlugin) : false; $this->template()->setTitle($sTitle)->setFullSite()->setPhrase(array('user.continue'))->setHeader('cache', array('register.css' => 'module_user', 'register.js' => 'module_user', 'country.js' => 'module_core'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sSiteUrl' => Phpfox::getParam('core.path'), 'aTimeZones' => Phpfox::getService('core')->getTimeZones(), 'aPackages' => Phpfox::isModule('subscribe') ? Phpfox::getService('subscribe')->getPackages(true) : null, 'aSettings' => Phpfox::getService('custom')->getForEdit(array('user_main', 'user_panel', 'profile_panel'), null, null, true), 'sDobStart' => Phpfox::getParam('user.date_of_birth_start'), 'sDobEnd' => Phpfox::getParam('user.date_of_birth_end'), 'sJanrainUrl' => Phpfox::isModule('janrain') ? Phpfox::getService('janrain')->getUrl() : '', 'sUserEmailCookie' => Phpfox::getCookie('invited_by_email_form'), 'sSiteTitle' => Phpfox::getParam('core.site_title'), 'aCitys' => Phpfox::getService('community')->getAllCity())); }
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()); } } }
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, "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 ) ); } } $this->database()->update(Phpfox::getT('user'), array('last_activity' => PHPFOX_TIME, 'last_ip_address' => Phpfox::getIp()), 'user_id = ' . Phpfox::getUserId()); } }
public function clearLogin($iUserId) { $this->database()->delete(Phpfox::getT('pages_login'), 'user_id = ' . (int) $iUserId); Phpfox::setCookie('page_login', '', -1); }