/** * Sets the controller for the page we are on. This method controlls what component to load, which * will be used to display the content on that page. * * @param string $sController (Optional) We find the controller by default, however you can override our default findings by passing the name of the controller with this argument. */ public function setController($sController = '') { if ($sController) { $aParts = explode('.', $sController); $this->_sModule = $aParts[0]; $this->_sController = substr_replace($sController, '', 0, strlen($this->_sModule . '_')); ($sPlugin = Phpfox_Plugin::get('set_defined_controller')) ? eval($sPlugin) : false; $this->getController(); return null; } if ($View = (new Core\Route\Controller())->get()) { return $View; } ($sPlugin = Phpfox_Plugin::get('module_setcontroller_start')) ? eval($sPlugin) : false; $oReq = Phpfox_Request::instance(); $oPage = Phpfox::getService('page'); $this->_sModule = ($sReq1 = $oReq->get('req1')) ? strtolower($sReq1) : Phpfox::getParam('core.module_core'); if (($sFrame = $oReq->get('frame')) && in_array($sFrame, $this->_aFrames)) { $aFrameParts = explode('-', $sFrame); $this->_sModule = strtolower($aFrameParts[0]); $this->_sController = strtolower($aFrameParts[1]); } $this->_aPages = $oPage->getCache(); if (isset($this->_aPages[$oReq->get('req1')])) { $this->_sModule = 'page'; $this->_sController = 'view'; } $sDir = PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS; if ($oReq->get('req2') == Phpfox::getParam('admincp.admin_cp')) { Phpfox_Url::instance()->send($oReq->get('req2') . '.' . $oReq->get('req1')); } if ($oReq->get('req1') == 'admincp' && Phpfox::getParam('admincp.admin_cp') != 'admincp') { Phpfox_Url::instance()->send('error.404'); } if ($oReq->get('req2') && file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . strtolower($oReq->get('req2')) . '.class.php')) { $this->_sController = strtolower($oReq->get('req2')); } elseif (strtolower($this->_sModule) != Phpfox::getParam('admincp.admin_cp') && $oReq->get('req3') && file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . strtolower($oReq->get('req2')) . PHPFOX_DS . strtolower($oReq->get('req3')) . '.class.php')) { $this->_sController = strtolower($oReq->get('req2') . '.' . $oReq->get('req3')); } elseif (strtolower($this->_sModule) != Phpfox::getParam('admincp.admin_cp') && $oReq->get('req2') && file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . strtolower($oReq->get('req2')) . PHPFOX_DS . 'index.class.php')) { $this->_sController = strtolower($oReq->get('req2')) . '.index'; } else { // Over-ride the index page to display the content for guests or members if ($this->_sModule == Phpfox::getParam('core.module_core') && $this->_sController == 'index' && Phpfox::getParam('core.module_core') == PHPFOX_MODULE_CORE) { $this->_sController = Phpfox::isUser() ? 'index-member' : 'index-visitor'; } if (!file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . $this->_sController . '.class.php')) { $this->_sModule = 'profile'; } ($sPlugin = Phpfox_Plugin::get('set_controller_else_end')) ? eval($sPlugin) : false; } if ($this->_sModule == 'theme') { if (preg_match('/^(.*?)\\.(jpg|jpeg|gif|png|css|js)$/i', $_GET[PHPFOX_GET_METHOD])) { $this->_sModule = 'error'; $this->_sController = '404'; } } if ($this->_sModule != 'profile' && !isset($this->_aModules[$this->_sModule])) { $this->_sModule = 'error'; $this->_sController = '404'; } if (Phpfox::getParam('admincp.admin_cp') != 'admincp' && $oReq->get('req1') == Phpfox::getParam('admincp.admin_cp')) { $this->_sModule = 'admincp'; } /* if (Phpfox::isUser() && Phpfox::getParam('core.is_auto_hosted') && Phpfox::getService('log.session')->getOnlineMembers() > Phpfox::getParam('core.phpfox_max_users_online')) { $this->_sModule = 'core'; $this->_sController = 'full'; } */ if ($oReq->segment(1) == 'hashtag') { $this->_sModule = 'core'; $this->_sController = Phpfox::isUser() ? 'index-member' : 'index-visitor'; } ($sPlugin = Phpfox_Plugin::get('module_setcontroller_end')) ? eval($sPlugin) : false; // Set the language pack cache if (Phpfox::getParam('language.cache_phrases')) { Phpfox_Locale::instance()->setCache(); } $bCookie = Phpfox::getCookie('page_login') && Phpfox::getUserBy('profile_page_id') > 0; if (Phpfox::isUser() && $bCookie != 1 && Phpfox::getUserParam('user.require_profile_image') && Phpfox::getUserBy('user_image') == '' && !($this->_sModule == 'user' && $this->_sController == 'photo' || $this->_sModule == 'user' && $this->_sController == 'logout' || $this->_sModule == 'subscribe')) { Phpfox_Url::instance()->send('user.photo', null, Phpfox::getPhrase('user.you_are_required_to_upload_a_profile_image')); } if (Phpfox::getParam('core.force_https_secure_pages')) { $sController = str_replace('mobile.', '', $this->getFullControllerName()); if ($sController == 'core.index-member' || $sController == 'core.index-visitor') { // fixes 14276 $sController = ''; } if (in_array(str_replace('mobile.', '', $this->getFullControllerName()), Phpfox::getService('core')->getSecurePages())) { if (!isset($_SERVER['HTTPS'])) { Phpfox_Url::instance()->send($sController); } } else { if (Phpfox::getParam('core.force_secure_site')) { if (!isset($_SERVER['HTTPS'])) { Phpfox_Url::instance()->send($sController); } } } } if (Phpfox::getParam('core.site_is_offline') && !Phpfox::getUserParam('core.can_view_site_offline') && ($this->_sModule != 'user' && $this->_sModule != 'captcha' && !in_array($this->_sController, ['login', 'logout']))) { $this->_sModule = 'core'; $this->_sController = 'offline'; define('PHPFOX_SITE_IS_OFFLINE', true); } }
/** * 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)); }
public function __construct() { parent::__construct(); if (!self::$_active) { $cookie = \Phpfox::getCookie('flavor_id'); if ($cookie) { self::$_active = $this->db->select('t.*, ts.folder AS flavor_folder')->from(':theme_style', 'ts')->join(':theme', 't', ['t.theme_id' => ['=' => 'ts.theme_id']])->where(['ts.style_id' => (int) $cookie])->get(); } else { self::$_active = $this->db->select('t.*, ts.folder AS flavor_folder')->from(':theme', 't')->join(':theme_style', 'ts', ['t.theme_id' => ['=' => 'ts.theme_id'], 'ts.is_default' => 1])->where($cookie ? ['t.theme_id' => (int) $cookie] : ['t.is_default' => 1])->get(); } if (!self::$_active || defined('PHPFOX_CSS_FORCE_DEFAULT')) { self::$_active = ['name' => 'Default', 'folder' => 'default', 'flavor_folder' => 'default']; } } }
/** * 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'); }
public function add($aVals, $iUserGroupId = null) { if (!defined('PHPFOX_INSTALLER') && defined('PHPFOX_IS_HOSTED_SCRIPT')) { $iTotalMembersMax = (int) Phpfox::getParam('core.phpfox_grouply_members'); $iCurrentTotalMembers = $this->database()->select('COUNT(*)')->from(Phpfox::getT('user'))->where('view_id = 0')->execute('getSlaveField'); if ($iTotalMembersMax > 0 && $iCurrentTotalMembers >= $iTotalMembersMax) { Phpfox_Error::set('We are unable to setup an account for you at this time. This site has currently reached its limit on users.'); } } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.split_full_name')) { if (empty($aVals['first_name']) || empty($aVals['last_name'])) { Phpfox_Error::set(Phpfox::getPhrase('user.please_fill_in_both_your_first_and_last_name')); } } if (!defined('PHPFOX_INSTALLER') && !Phpfox::getParam('user.allow_user_registration')) { return Phpfox_Error::display(Phpfox::getPhrase('user.user_registration_has_been_disabled')); } $oParseInput = Phpfox::getLib('parse.input'); $sSalt = $this->_getSalt(); $aCustom = Phpfox::getLib('request')->getArray('custom'); ($sPlugin = Phpfox_Plugin::get('user.service_process_add_1')) ? eval($sPlugin) : false; $aCustomFields = Phpfox::getService('custom')->getForEdit(array('user_main', 'user_panel', 'profile_panel'), null, null, true); foreach ($aCustomFields as $aCustomField) { if ($aCustomField['on_signup'] && $aCustomField['is_required'] && empty($aCustom[$aCustomField['field_id']])) { Phpfox_Error::set(Phpfox::getPhrase('user.the_field_field_is_required', array('field' => Phpfox::getPhrase($aCustomField['phrase_var_name'])))); } } /* Check if there should be a spam question answered */ $aSpamQuestions = $this->database()->select('*')->from(Phpfox::getT('user_spam'))->execute('getSlaveRows'); if (!defined('PHPFOX_INSTALLER') && !defined('PHPFOX_IS_FB_USER') && !empty($aSpamQuestions) && isset($aVals['spam'])) { $oParse = Phpfox::getLib('parse.input'); // The visitor's current language is... $sLangId = Phpfox::getLib('locale')->getLangId(); foreach ($aVals['spam'] as $iQuestionId => $sAnswer) { $aDbQuestion = $this->database()->select('us.*')->from(Phpfox::getT('user_spam'), 'us')->where('us.question_id = ' . (int) $iQuestionId)->execute('getSlaveRow'); if (!isset($aDbQuestion['answers_phrases']) || empty($aDbQuestion['answers_phrases'])) { Phpfox_Error::set(Phpfox::getPhrase('user.that_question_does_not_exist_all_hack_attempts_are_forbidden_and_logged')); break; } // now to compare the answers $aAnswers = json_decode($aDbQuestion['answers_phrases']); $bValidAnswer = false; foreach ($aAnswers as $sDbAnswer) { if (preg_match('/phrase var='([a-z\\._0-9]+)/', $sDbAnswer, $aMatch)) { $sDbAnswer = Phpfox::getPhrase($aMatch[1], array(), false, null, $sLangId); $sDbAnswer = html_entity_decode($sDbAnswer, null, 'UTF-8'); } if (strcmp($sAnswer, $sDbAnswer) == 0) { $bValidAnswer = true; break; } } if ($bValidAnswer == false) { Phpfox_Error::set(Phpfox::getPhrase('user.captcha_failed')); break; } // $this->database()->delete(Phpfox::getT('upload_track'), 'user_hash = "' . $sHash . '" OR time_stamp < ' . (PHPFOX_TIME - (60*15))); } } else { if (!defined('PHPFOX_INSTALLER') && !defined('PHPFOX_IS_FB_USER') && !empty($aSpamQuestions) && !isset($aVals['spam'])) { Phpfox_Error::set('You forgot to answer the CAPTCHA questions'); } } if (!Phpfox_Error::isPassed()) { return false; } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.split_full_name')) { $aVals['full_name'] = $aVals['first_name'] . ' ' . $aVals['last_name']; } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.validate_full_name')) { if (!Phpfox::getLib('validator')->check($aVals['full_name'], array('html', 'url'))) { return Phpfox_Error::set(Phpfox::getPhrase('user.not_a_valid_name')); } } if (!defined('PHPFOX_INSTALLER') && $aVals['full_name'] == '­') { return Phpfox_Error::set(Phpfox::getPhrase('user.not_a_valid_name')); } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.city_in_registration') && isset($aVals['city_location']) && !Phpfox::getLib('validator')->check($aVals['city_location'], array('html', 'url'))) { return Phpfox_Error::set(Phpfox::getPhrase('user.not_a_valid_city')); } if (!defined('PHPFOX_INSTALLER') && !Phpfox::getService('ban')->check('display_name', $aVals['full_name'])) { Phpfox_Error::set(Phpfox::getPhrase('user.this_display_name_is_not_allowed_to_be_used')); } if (!defined('PHPFOX_INSTALLER') && Phpfox::isModule('subscribe') && Phpfox::getParam('subscribe.enable_subscription_packages') && Phpfox::getParam('subscribe.subscribe_is_required_on_sign_up') && empty($aVals['package_id'])) { $aPackages = Phpfox::getService('subscribe')->getPackages(true); if (count($aPackages)) { return Phpfox_Error::set(Phpfox::getPhrase('user.select_a_membership_package')); } } if (!defined('PHPFOX_INSTALLER')) { if (!defined('PHPFOX_SKIP_EMAIL_INSERT')) { if (!Phpfox::getLib('mail')->checkEmail($aVals['email'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.email_is_not_valid')); } } if (Phpfox::getLib('parse.format')->isEmpty($aVals['full_name'])) { Phpfox_Error::set(Phpfox::getPhrase('user.provide_a_name_that_is_not_representing_an_empty_name')); } } $bHasImage = false; if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.force_user_to_upload_on_sign_up')) { if (Phpfox::getParam('user.verify_email_at_signup')) { define('PHPFOX_FORCE_PHOTO_VERIFY_EMAIL', true); } if (!isset($_FILES['image']['name']) || empty($_FILES['image']['name'])) { Phpfox_Error::set(Phpfox::getPhrase('photo.please_upload_an_image_for_your_profile')); } else { $aImage = Phpfox::getLib('file')->load('image', array('jpg', 'gif', 'png'), Phpfox::getUserParam('user.max_upload_size_profile_photo') === 0 ? null : Phpfox::getUserParam('user.max_upload_size_profile_photo') / 1024); if ($aImage !== false) { $bHasImage = true; } } } $aInsert = array('user_group_id' => $iUserGroupId === null ? NORMAL_USER_ID : $iUserGroupId, 'full_name' => $oParseInput->clean($aVals['full_name'], 255), 'password' => Phpfox::getLib('hash')->setHash($aVals['password'], $sSalt), 'password_salt' => $sSalt, 'email' => $aVals['email'], 'joined' => PHPFOX_TIME, 'gender' => defined('PHPFOX_INSTALLER') || !defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_gender') ? $aVals['gender'] : 0, 'birthday' => defined('PHPFOX_INSTALLER') || !defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_dob') ? Phpfox::getService('user')->buildAge($aVals['day'], $aVals['month'], $aVals['year']) : null, 'birthday_search' => defined('PHPFOX_INSTALLER') || !defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_dob') ? Phpfox::getLib('date')->mktime(0, 0, 0, $aVals['month'], $aVals['day'], $aVals['year']) : 0, 'country_iso' => defined('PHPFOX_INSTALLER') || !defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_location') ? $aVals['country_iso'] : null, 'language_id' => !defined('PHPFOX_INSTALLER') && Phpfox::getLib('session')->get('language_id') ? Phpfox::getLib('session')->get('language_id') : null, 'time_zone' => isset($aVals['time_zone']) && (defined('PHPFOX_INSTALLER') || !defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_timezone')) ? $aVals['time_zone'] : null, 'last_ip_address' => Phpfox::getIp(), 'last_activity' => PHPFOX_TIME); if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.invite_only_community') && !Phpfox::getService('invite')->isValidInvite($aVals['email'])) { // the isValidInvite runs Phpfox_Error::set so we don't have to do it here } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.verify_email_at_signup')) { $aInsert['status_id'] = 1; // 1 = need to verify email } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.approve_users')) { $aInsert['view_id'] = '1'; // 1 = need to approve the user } if (!Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up')) { $aVals['user_name'] = str_replace(' ', '_', $aVals['user_name']); $aInsert['user_name'] = $oParseInput->clean($aVals['user_name']); } ($sPlugin = Phpfox_Plugin::get('user.service_process_add_start')) ? eval($sPlugin) : false; if (!Phpfox_Error::isPassed()) { return false; } $iId = $this->database()->insert($this->_sTable, $aInsert); $aInsert['user_id'] = $iId; $aExtras = array('user_id' => $iId); ($sPlugin = Phpfox_Plugin::get('user.service_process_add_extra')) ? eval($sPlugin) : false; $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); if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.city_in_registration') && isset($aVals['city_location'])) { Phpfox::getService('user.field.process')->update($iId, 'city_location', Phpfox::getLib('parse.input')->clean($aVals['city_location'], 100)); } if (Phpfox::getParam('user.profile_use_id') || Phpfox::getParam('user.disable_username_on_sign_up')) { $this->database()->update($this->_sTable, array('user_name' => 'profile-' . $iId), 'user_id = ' . $iId); } if ($bHasImage) { $this->uploadImage($iId, true, null, true); } if (Phpfox::isModule('invite') && (Phpfox::getCookie('invited_by_email') || Phpfox::getCookie('invited_by_user'))) { Phpfox::getService('invite.process')->registerInvited($iId); } elseif (Phpfox::isModule('invite')) { Phpfox::getService('invite.process')->registerByEmail($aInsert); } ($sPlugin = Phpfox_Plugin::get('user.service_process_add_feed')) ? eval($sPlugin) : false; if (!defined('PHPFOX_INSTALLER') && !Phpfox::getParam('user.verify_email_at_signup') && !Phpfox::getParam('user.approve_users') && !isset($bDoNotAddFeed)) { //(Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->allowGuest()->add('user_joined', $iId, null, $iId) : null); } if (isset($aVals['country_child_id'])) { Phpfox::getService('user.field.process')->update($iId, 'country_child_id', $aVals['country_child_id']); } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.split_full_name')) { Phpfox::getService('user.field.process')->update($iId, 'first_name', empty($aVals['first_name']) ? null : $aVals['first_name']); Phpfox::getService('user.field.process')->update($iId, 'last_name', empty($aVals['last_name']) ? null : $aVals['last_name']); } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_dob')) { // Updating for the birthday range $this->database()->update(Phpfox::getT('user_field'), array('birthday_range' => '\'' . Phpfox::getService('user')->buildAge($aVals['day'], $aVals['month']) . '\''), 'user_id = ' . $iId, false); } if (!defined('PHPFOX_INSTALLER')) { $iFriendId = (int) Phpfox::getParam('user.on_signup_new_friend'); if ($iFriendId > 0 && Phpfox::isModule('friend')) { $iCheckFriend = $this->database()->select('COUNT(*)')->from(Phpfox::getT('friend'))->where('user_id = ' . (int) $iId . ' AND friend_user_id = ' . (int) $iFriendId)->execute('getSlaveField'); if (!$iCheckFriend) { $this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iId, 'friend_user_id' => $iFriendId, 'time_stamp' => PHPFOX_TIME)); $this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iFriendId, 'friend_user_id' => $iId, 'time_stamp' => PHPFOX_TIME)); Phpfox::getService('friend.process')->updateFriendCount($iId, $iFriendId); Phpfox::getService('friend.process')->updateFriendCount($iFriendId, $iId); } } if ($sPlugin = Phpfox_Plugin::get('user.service_process_add_check_1')) { eval($sPlugin); } // Allow to send an email even if verify email is disabled if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.verify_email_at_signup') == false && !isset($bDoNotSendWelcomeEmail) || isset($bSendWelcomeEmailPlg)) { Phpfox::getLib('mail')->to($iId)->subject(array('core.welcome_email_subject', array('site' => Phpfox::getParam('core.site_title'))))->message(array('core.welcome_email_content'))->send(); } switch (Phpfox::getParam('user.on_register_privacy_setting')) { case 'network': $iPrivacySetting = '1'; break; case 'friends_only': $iPrivacySetting = '2'; break; case 'no_one': $iPrivacySetting = '4'; break; default: break; } if (isset($iPrivacySetting)) { $this->database()->insert(Phpfox::getT('user_privacy'), array('user_id' => $iId, 'user_privacy' => 'profile.view_profile', 'user_value' => $iPrivacySetting)); } } ($sPlugin = Phpfox_Plugin::get('user.service_process_add_end')) ? eval($sPlugin) : false; if (!empty($aCustom)) { if (!Phpfox::getService('custom.process')->updateFields($iId, $iId, $aCustom, true)) { return false; } } $this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => $iId, 'type_id' => 'register', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME)); if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.verify_email_at_signup') && !isset($bSkipVerifyEmail)) { $aVals['user_id'] = $iId; $sHash = Phpfox::getService('user.verify')->getVerifyHash($aVals); $this->database()->insert(Phpfox::getT('user_verify'), array('user_id' => $iId, 'hash_code' => $sHash, 'time_stamp' => Phpfox::getTime(), 'email' => $aVals['email'])); // send email $sLink = Phpfox::getLib('url')->makeUrl('user.verify', array('link' => $sHash)); Phpfox::getLib('mail')->to($iId)->subject(array('user.please_verify_your_email_for_site_title', array('site_title' => Phpfox::getParam('core.site_title'))))->message(array('user.you_registered_an_account_on_site_title_before_being_able_to_use_your_account_you_need_to_verify_that_this_is_your_email_address_by_clicking_here_a_href_link_link_a', array('site_title' => Phpfox::getParam('core.site_title'), 'link' => $sLink)))->send(); } if (!defined('PHPFOX_INSTALLER') && Phpfox::isModule('subscribe') && Phpfox::getParam('subscribe.enable_subscription_packages') && !empty($aVals['package_id'])) { $aPackage = Phpfox::getService('subscribe')->getPackage($aVals['package_id']); if (isset($aPackage['package_id'])) { $iPurchaseId = Phpfox::getService('subscribe.purchase.process')->add(array('package_id' => $aPackage['package_id'], 'currency_id' => $aPackage['default_currency_id'], 'price' => $aPackage['default_cost']), $iId); $iDefaultCost = (int) str_replace('.', '', $aPackage['default_cost']); if ($iPurchaseId) { if ($iDefaultCost > 0) { define('PHPFOX_MUST_PAY_FIRST', $iPurchaseId); Phpfox::getService('user.field.process')->update($iId, 'subscribe_id', $iPurchaseId); return array(Phpfox::getLib('url')->makeUrl('subscribe.register', array('id' => $iPurchaseId))); } else { Phpfox::getService('subscribe.purchase.process')->update($iPurchaseId, $aPackage['package_id'], 'completed', $iId, $aPackage['user_group_id'], $aPackage['fail_user_group']); } } else { return false; } } } return $iId; }
/** * Displays an image on the site based on params passed * * @param array $aParams Holds an ARRAY of params about the image * @return string Returns the HTML <image> or the full path to the image based on the params passed with the 1st argument */ public function display($aParams, $bIsLoop = false) { static $aImages = array(); // Create hash for cache $sHash = md5(serialize($aParams)); // Return cached image if (isset($aImages[$sHash])) { return $aImages[$sHash]; } $bIsServer = !empty($aParams['server_id']) ? true : false; $isObject = false; if ($sPlugin = Phpfox_Plugin::get('image_helper_display_start')) { eval($sPlugin); if (isset($mReturnPlugin)) { return $mReturnPlugin; } } if (isset($aParams['theme'])) { if (substr($aParams['theme'], 0, 5) == 'ajax/') { $type = str_replace(['ajax/', '.gif'], '', $aParams['theme']); // $image = '<span class="_ajax_image_' . $type . '"></span>'; $image = ''; switch ($type) { case 'large': $image = '<i class="fa fa-spin fa-circle-o-notch _ajax_image_' . $type . '"></i>'; break; } return $image; } $sSrc = Phpfox_Template::instance()->getStyle('image', $aParams['theme']); return '<img src="' . $sSrc . '">'; } if (isset($aParams['max_height']) && !is_numeric($aParams['max_height'])) { $aParams['max_height'] = Phpfox::getParam($aParams['max_height']); } if (isset($aParams['max_width']) && !is_numeric($aParams['max_width'])) { $aParams['max_width'] = Phpfox::getParam($aParams['max_width']); } // Check if this is a users profile image $bIsOnline = false; $sSuffix = ''; if (isset($aParams['user'])) { if (isset($aParams['user_suffix'])) { $sSuffix = $aParams['user_suffix']; } // Create the local params $aParams['server_id'] = isset($aParams['user']['user_' . $sSuffix . 'server_id']) ? $aParams['user']['user_' . $sSuffix . 'server_id'] : (isset($aParams['user'][$sSuffix . 'server_id']) ? $aParams['user'][$sSuffix . 'server_id'] : ''); $aParams['file'] = $aParams['user'][$sSuffix . 'user_image']; $aParams['path'] = 'core.url_user'; if (isset($aParams['user']['' . $sSuffix . 'is_user_page'])) { $aParams['path'] = 'pages.url_image'; $aParams['suffix'] = '_120'; } $aParams['title'] = $bIsOnline ? Phpfox::getPhrase('core.full_name_is_online', array('full_name' => Phpfox::getLib('parse.output')->shorten($aParams['user'][$sSuffix . 'full_name'], Phpfox::getParam('user.maximum_length_for_full_name')))) : Phpfox::getLib('parse.output')->shorten($aParams['user'][$sSuffix . 'full_name'], Phpfox::getParam('user.maximum_length_for_full_name')); // Create the users link if (!empty($aParams['user']['profile_page_id']) && !empty($aParams['user']['page_id'])) { if (empty($aParams['user']['user_name'])) { $sLink = Phpfox_Url::instance()->makeUrl('pages', $aParams['user']['page_id']); } } else { $sLink = Phpfox_Url::instance()->makeUrl('profile', $aParams['user'][$sSuffix . 'user_name']); } if (Phpfox::getParam('user.prevent_profile_photo_cache') && isset($aParams['user'][$sSuffix . 'user_id']) && $aParams['user'][$sSuffix . 'user_id'] == Phpfox::getUserId()) { $aParams['time_stamp'] = true; } if (Phpfox::getCookie('recache_image') && isset($aParams['user'][$sSuffix . 'user_id']) && $aParams['user'][$sSuffix . 'user_id'] == Phpfox::getUserId()) { $aParams['time_stamp'] = true; } if (substr($aParams['file'], 0, 1) == '{') { $isObject = true; $aParams['org_file'] = $aParams['file']; } } if (empty($aParams['file'])) { /* if (isset($aParams['return_url']) && $aParams['return_url']) { return ''; } */ $iWidth = 80; $iHeight = 70; if (isset($aParams['path']) && ($aParams['path'] == 'core.url_user' || $aParams['path'] == 'pages.url_image')) { static $aGenders = null; if ($aGenders === null) { $aGenders = array(); foreach ((array) Phpfox::getParam('core.global_genders') as $iKey => $aGender) { if (isset($aGender[3])) { $aGenders[$iKey] = $aGender[3]; } } } $sGender = ''; if (isset($aParams['user']) && isset($aParams['user'][$sSuffix . 'gender'])) { if (isset($aGenders[$aParams['user'][$sSuffix . 'gender']])) { $sGender = $aGenders[$aParams['user'][$sSuffix . 'gender']] . '_'; } } $sImageSuffix = ''; if (!empty($aParams['suffix'])) { $aParams['suffix'] = str_replace('_square', '', $aParams['suffix']); $iHeight = ltrim($aParams['suffix'], '_'); $iWidth = ltrim($aParams['suffix'], '_'); if ((int) $iWidth >= 200) { // $sSrc .= '_noimage'; } else { $sImageSuffix = $aParams['suffix']; } } // $sSrc = Phpfox_Template::instance()->getStyle('image', 'noimage/' . $sGender . 'profile' . $sImageSuffix . '.png'); $sImageSize = $sImageSuffix; // if (isset($aParams['user'])) { $name = isset($aParams['user']) ? $aParams['user'][$sSuffix . 'full_name'] : (isset($aParams['title']) ? $aParams['title'] : ''); if (function_exists('iconv')) { setlocale(LC_ALL, 'en_US.UTF-8'); $name = iconv('UTF-8', 'ASCII//TRANSLIT', $name); } $parts = explode(' ', $name); $first = ''; $last = ''; if (strlen($name) > 2) { $first = $name[0]; $last = $name[1]; if (isset($parts[1])) { $last = $parts[1][0]; } } if (isset($aParams['max_width'])) { $sImageSize = '_' . $aParams['max_width']; } $ele = 'a'; if (isset($aParams['no_link']) || !isset($sLink) || isset($aParams['user']) && isset($aParams['user'][$sSuffix . 'no_link'])) { $ele = 'span'; } $image = '<' . $ele . '' . ($ele == 'a' ? ' href="' . $sLink . '"' : '') . ' class="no_image_user _size_' . $sImageSize . ' _gender_' . $sGender . ' _first_' . strtolower($first . $last) . '"><span>' . $first . $last . '</span></' . $ele . '>'; return $image; // } } else { $ele = 'span'; $sImageSize = ''; if (isset($aParams['suffix'])) { $sImageSize = $aParams['suffix']; } if (isset($aParams['max_width'])) { $sImageSize = $aParams['max_width']; } $image = '<' . $ele . ' class="no_image_item i_size_' . $sImageSize . '"><span></span></' . $ele . '>'; return $image; } $bIsValid = false; } if (isset($aParams['no_link']) && $aParams['no_link']) { unset($sLink); } $aParams['file'] = preg_replace('/%[^s]/', '%%', $aParams['file']); $sSrc = Phpfox::getParam($aParams['path']) . sprintf($aParams['file'], isset($aParams['suffix']) ? $aParams['suffix'] : ''); $sDirSrc = str_replace(Phpfox::getParam('core.path'), PHPFOX_DIR, $sSrc); if (isset($aParams['server_id']) && $aParams['server_id']) { $newPath = Phpfox_Cdn::instance()->getUrl($sSrc); if (!empty($newPath)) { $sSrc = $newPath; } } if (!file_exists($sDirSrc)) { $aParams['file'] = ''; } // Windows slash fix $sSrc = str_replace("\\", '/', $sSrc); $sSrc = str_replace("\"", '\'', $sSrc); if (isset($aParams['return_url']) && $aParams['return_url']) { return $sSrc . (isset($aParams['time_stamp']) ? '?t=' . uniqid() : ''); } if (isset($aParams['title'])) { $aParams['title'] = Phpfox::getLib('parse.output')->clean(html_entity_decode($aParams['title'], null, 'UTF-8')); } $sImage = ''; $sAlt = ''; if (isset($aParams['alt_phrase'])) { $sAlt = html_entity_decode(Phpfox::getPhrase($aParams['alt_phrase']), null, 'UTF-8'); unset($aParams['alt_phrase']); } if (isset($aParams['class']) && $aParams['class'] == 'js_hover_title') { $aParams['title'] = Phpfox::getLib('parse.output')->shorten($aParams['title'], 100, '...'); } if (isset($sLink)) { $sImage .= '<a href="' . $sLink; if (isset($aParams['thickbox']) && isset($aParams['time_stamp'])) { $sImage .= '?t=' . uniqid(); } $sImage .= '"'; if (isset($aParams['title'])) { $sImage .= ' title="' . htmlspecialchars($aParams['title']) . '"'; } if (isset($aParams['thickbox'])) { $sImage .= ' class="thickbox"'; } if (isset($aParams['target'])) { $sImage .= ' target="' . $aParams['target'] . '"'; } $sImage .= '>'; } $bDefer = true; $sImage .= '<img'; if ($bDefer == true) { if ($isObject) { $object = json_decode($aParams['org_file'], true); $sSrc = array_values($object)[0]; $sImage .= ' data-object="' . array_keys($object)[0] . '" '; // ob_clean(); d($sSrc); exit; } $size = isset($aParams['suffix']) ? $aParams['suffix'] : ''; if (isset($aParams['max_width'])) { $size = $aParams['max_width']; } $aParams['class'] = ' _image_' . $size . ' ' . ($isObject ? 'image_object' : 'image_deferred') . ' ' . (isset($aParams['class']) ? ' ' . $aParams['class'] : ''); $sImage .= ' data-src="' . $sSrc . (isset($aParams['time_stamp']) ? '?t=' . uniqid() : '') . '" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" '; } else { $sImage .= ' src="' . $sSrc . (isset($aParams['time_stamp']) ? '?t=' . uniqid() : '') . '" '; } if (isset($aParams['title'])) { $sImage .= ' alt="' . htmlspecialchars($aParams['title']) . '" '; } else { $sImage .= ' alt="' . htmlspecialchars($sAlt) . '" '; } if (isset($aParams['js_hover_title'])) { $sImage .= ' class="js_hover_title" '; unset($aParams['js_hover_title']); } if (isset($aParams['force_max'])) { $iHeight = $aParams['max_height']; $iWidth = $aParams['max_width']; } if (!empty($iHeight)) { $sImage .= 'height="' . $iHeight . '" '; } if (!empty($iWidth)) { $sImage .= 'width="' . $iWidth . '" '; } unset($aParams['server_id'], $aParams['force_max'], $aParams['org_file'], $aParams['src'], $aParams['max_height'], $aParams['max_width'], $aParams['href'], $aParams['user_name'], $aParams['file'], $aParams['suffix'], $aParams['path'], $aParams['thickbox'], $aParams['no_default'], $aParams['full_name'], $aParams['user_id'], $aParams['time_stamp'], $aParams['user'], $aParams['title'], $aParams['theme'], $aParams['default'], $aParams['user_suffix'], $aParams['target'], $aParams['alt']); foreach ($aParams as $sKey => $sValue) { $sImage .= ' ' . $sKey . '="' . str_replace('"', '\\"', $sValue) . '" '; } $sImage .= '/>' . (isset($sLink) ? '</a>' : ''); $aImages[$sHash] = $sImage; return $sImage; }
/** * 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 getThread($aThreadCondition = array(), $mConditions = array(), $sOrder = 'fp.time_stamp ASC', $iPage = '', $iPageSize = '', $sPermaView = null) { if (Phpfox::getParam('forum.forum_database_tracking')) { $this->database()->select('ftr.thread_id AS is_seen, ftr.time_stamp AS last_seen_time, ')->leftJoin(Phpfox::getT('forum_thread_track'), 'ftr', 'ftr.thread_id = ft.thread_id AND ftr.user_id = ' . Phpfox::getUserId()); } $aThread = $this->database()->select('ft.thread_id, ft.time_stamp, ft.time_update, ft.group_id, ft.view_id, ft.forum_id, ft.is_closed, ft.user_id, ft.is_announcement, ft.order_id, ft.title_url, ft.time_update AS last_time_stamp, ft.title, fs.subscribe_id AS is_subscribed, ft.poll_id')->from($this->_sTable, 'ft')->leftJoin(Phpfox::getT('forum_subscribe'), 'fs', 'fs.thread_id = ft.thread_id AND fs.user_id = ' . Phpfox::getUserId())->where($aThreadCondition)->execute('getSlaveRow'); if (!isset($aThread['thread_id'])) { return array(0, array()); } if (!isset($aThread['is_seen'])) { $aThread['is_seen'] = 0; } // Thread not seen if (!$aThread['is_seen']) { // User has signed up after the post so they have already seen the post if (Phpfox::isUser() && Phpfox::getUserBy('joined') > $aThread['last_time_stamp'] || !Phpfox::isUser() && Phpfox::getCookie('visit') > $aThread['last_time_stamp']) { $aThread['is_seen'] = 1; } elseif (($iLastTimeViewed = Phpfox::getLib('session')->getArray('forum_view', $aThread['thread_id'])) && (int) $iLastTimeViewed > $aThread['last_time_stamp']) { $aThread['is_seen'] = 1; } elseif (PHPFOX_TIME - Phpfox::getParam('forum.keep_active_posts') * 60 > $aThread['last_time_stamp']) { $aThread['is_seen'] = 1; } // http://www.phpfox.com/tracker/view/14893/ /*elseif (!empty($aThread['last_time_stamp']) && Phpfox::isUser() && $aThread['last_time_stamp'] < Phpfox::getCookie('last_login')) { $aThread['is_seen'] = 1; }*/ } else { // New post was added if ($aThread['last_time_stamp'] > $aThread['last_seen_time']) { $aThread['is_seen'] = 0; } } $sViewId = ' AND fp.view_id = 0'; if (Phpfox::getUserParam('forum.can_approve_forum_post') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'approve_post')) { $sViewId = ''; } $mConditions[] = 'fp.thread_id = ' . $aThread['thread_id'] . $sViewId; $iCnt = $this->database()->select('COUNT(*)')->from(Phpfox::getT('forum_post'), 'fp')->where($mConditions)->execute('getSlaveField'); $aThread['last_update_on'] = ''; if ($sPermaView !== null) { $iCurrentPage = Phpfox::getService('forum.post')->getPostPage($aThread['thread_id'], $sPermaView, $iPageSize); $mConditions[] = 'AND fp.post_id = ' . (int) $sPermaView; } if (!empty($aThread['poll_id']) && Phpfox::isModule('poll')) { $aThread['poll'] = Phpfox::getService('poll')->getPollByUrl((int) $aThread['poll_id']); $aThread['poll']['bCanEdit'] = false; } ($sPlugin = Phpfox_Plugin::get('forum.service_thread_getthread_query')) ? eval($sPlugin) : false; if (!isset($bLeftJoinQuery)) { $bLeftJoinQuery = false; } $theJoins = function () use($bLeftJoinQuery) { if (isset($bLeftJoinQuery) && $bLeftJoinQuery !== false) { $this->database()->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = fp.user_id')->leftJoin(Phpfox::getT('user_field'), 'uf', 'uf.user_id = fp.user_id'); } else { $this->database()->join(Phpfox::getT('user'), 'u', 'u.user_id = fp.user_id')->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = fp.user_id'); } if (Phpfox::isModule('like')) { $this->database()->select('l.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'forum_post\' AND l.item_id = fp.post_id AND l.user_id = ' . Phpfox::getUserId()); } }; if (!$iPage) { $theJoins(); $aThread['post_starter'] = $this->database()->select('fp.*, ' . (Phpfox::getParam('core.allow_html') ? 'fpt.text_parsed' : 'fpt.text') . ' AS text, ' . Phpfox::getUserField() . ', u.joined, u.country_iso, uf.signature, uf.total_post')->from(Phpfox::getT('forum_post'), 'fp')->join(Phpfox::getT('forum_post_text'), 'fpt', 'fpt.post_id = fp.post_id')->where($mConditions)->order('fp.time_stamp ASC')->limit(1)->get(); } if (!$iPage) { $iPageSize = 4; $sOrder = 'fp.time_stamp DESC'; } $theJoins(); $aThread['posts'] = $this->database()->select('fp.*, ' . (Phpfox::getParam('core.allow_html') ? 'fpt.text_parsed' : 'fpt.text') . ' AS text, ' . Phpfox::getUserField() . ', u.joined, u.country_iso, uf.signature, uf.total_post')->from(Phpfox::getT('forum_post'), 'fp')->join(Phpfox::getT('forum_post_text'), 'fpt', 'fpt.post_id = fp.post_id')->where($mConditions)->order($sOrder)->limit($iPage, $iPageSize, $iCnt, false, false)->execute('getSlaveRows'); if (!count($aThread['posts'])) { throw error('no_items'); } if (isset($aThread['post_starter'])) { // $aThread['posts'] = array_merge($aThread['post_starter'], $aThread['posts']); $aThread['posts'][] = $aThread['post_starter']; $aThread['posts'] = array_reverse($aThread['posts']); } $sPostIds = ''; $iTotal = $iPage > 1 ? $iPageSize * $iPage - $iPageSize : 0; foreach ($aThread['posts'] as $iKey => $aPost) { $iTotal++; /* if ($aPost['cache_name']) { $aThread['posts'][$iKey]['user_id'] = 0; $aThread['posts'][$iKey]['user_image'] = ''; $aThread['posts'][$iKey]['full_name'] = $aPost['cache_name']; $aThread['posts'][$iKey]['no_link'] = true; } */ $aThread['posts'][$iKey]['count'] = $sPermaView === null ? $iTotal : Phpfox::getService('forum.post')->getPostCount(); $aThread['posts'][$iKey]['forum_id'] = $aThread['forum_id']; $aThread['posts'][$iKey]['last_update_on'] = Phpfox::getPhrase('forum.last_update_on_time_stamp_by_update_user', array('time_stamp' => Phpfox::getTime(Phpfox::getParam('forum.forum_time_stamp'), $aPost['update_time']), 'update_user' => $aPost['update_user'])); $aThread['posts'][$iKey]['aFeed'] = array('privacy' => 0, 'comment_privacy' => 0, 'like_type_id' => 'forum_post', 'feed_is_liked' => $aPost['is_liked'] ? true : false, 'item_id' => $aPost['post_id'], 'user_id' => $aPost['user_id'], 'total_like' => $aPost['total_like'], 'feed_link' => Phpfox::permalink('forum.thread', $aThread['thread_id'], $aThread['title']) . 'view_' . $aPost['post_id'] . '/', 'feed_title' => $aThread['title'], 'feed_display' => 'mini', 'feed_total_like' => $aPost['total_like'], 'report_module' => 'forum_post', 'report_phrase' => Phpfox::getPhrase('forum.report_this_post'), 'force_report' => true, 'time_stamp' => $aPost['time_stamp'], 'type_id' => 'forum_post'); if (Phpfox::isModule('like') && Phpfox::isModule('feed')) { $aThread['posts'][$iKey]['aFeed']['feed_like_phrase'] = Feed_Service_Feed::instance()->getPhraseForLikes($aThread['posts'][$iKey]['aFeed']); } if (isset($aThread['post_starter']) && $aThread['post_starter']['post_id'] == $aPost['post_id']) { $aThread['post_starter'] = array_merge($aThread['post_starter'], $aThread['posts'][$iKey]); unset($aThread['posts'][$iKey]); continue; } if ($aPost['total_attachment']) { $sPostIds .= $aPost['post_id'] . ','; } } $sPostIds = rtrim($sPostIds, ','); if (!empty($sPostIds)) { list($iAttachmentCnt, $aAttachments) = Phpfox::getService('attachment')->get('attachment.item_id IN(' . $sPostIds . ') AND attachment.view_id = 0 AND attachment.category_id = \'forum\' AND attachment.is_inline = 0', 'attachment.attachment_id DESC', '', '', false); $aAttachmentCache = array(); foreach ($aAttachments as $aAttachment) { $aAttachmentCache[$aAttachment['item_id']][] = $aAttachment; } foreach ($aThread['posts'] as $iKey => $aPost) { if (isset($aAttachmentCache[$aPost['post_id']])) { $aThread['posts'][$iKey]['attachments'] = $aAttachmentCache[$aPost['post_id']]; } } } return array($iCnt, $aThread); }
public function getLastLogin() { static $aUser = null; if ($aUser !== null) { return $aUser; } $this->database()->join(Phpfox::getT('user'), 'u', 'u.user_id = pl.user_id'); if (($sPlugin = Phpfox_Plugin::get('pages.service_pages_getlastlogin'))) { eval($sPlugin); } $aUser = $this->database()->select(Phpfox::getUserField() . ', u.email, u.style_id, u.password') ->from(Phpfox::getT('pages_login'), 'pl') ->where('pl.login_id = ' . (int) Phpfox::getCookie('page_login') . ' AND pl.page_id = ' . Phpfox::getUserBy('profile_page_id')) ->execute('getSlaveRow'); if (!isset($aUser['user_id'])) { $aUser = false; return false; } return $aUser; }
/** * Refreshes and returns the hash that allows SWFU file uploads. This is used * together with the auth service to allow the massuploader * @return string */ public function getHashForUpload() { Phpfox::getLib('database')->delete(Phpfox::getT('upload_track'), 'user_id = ' . Phpfox::getUserId()); $sHash = md5(uniqid() . Phpfox::getUserBy('email') . uniqid() . Phpfox::getUserBy('password_salt')); /* $hFile = fopen(PHPFOX_DIR_FILE . 'create.log', 'a+'); fwrite($hFile, $sHash . "\n"); fclose($hFile); */ Phpfox::getLib('database')->insert(Phpfox::getT('upload_track'), array( 'user_id' => Phpfox::getUserId(), 'hash' => $sHash, 'user_hash' => Phpfox::getLib('parse.input')->clean(Phpfox::getCookie('user_hash')), 'ip_address' => $_SERVER['REMOTE_ADDR'] )); return $sHash; }
public function isInviteOnly() { if (Phpfox::getCookie('invite_only_pass') != '') { return false; } if (Phpfox::getParam('user.invite_only_community')) { return true; } return false; }
public function add($aVals, $iUserGroupId = null) { if (!defined('PHPFOX_INSTALLER') && !Phpfox::getParam('user.allow_user_registration')) { return Phpfox_Error::display('User registration has been disabled.'); } $oParseInput = Phpfox::getLib('parse.input'); $sSalt = $this->_getSalt(); $aCustom = Phpfox::getLib('request')->getArray('custom'); $aCustomFields = Phpfox::getService('custom')->getForEdit(array('user_main', 'user_panel', 'profile_panel'), null, null, true); foreach ($aCustomFields as $aCustomField) { if ($aCustomField['on_signup'] && $aCustomField['is_required'] && empty($aCustom[$aCustomField['field_id']])) { Phpfox_Error::set(Phpfox::getPhrase('user.the_field_field_is_required', array('field' => Phpfox::getPhrase($aCustomField['phrase_var_name'])))); } } if (!Phpfox_Error::isPassed()) { return false; } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.validate_full_name')) { if (!Phpfox::getLib('validator')->check($aVals['full_name'], array('html', 'url'))) { return Phpfox_Error::set(Phpfox::getPhrase('user.not_a_valid_name')); } } if (!defined('PHPFOX_INSTALLER') && !Phpfox::getService('ban')->check('display_name', $aVals['full_name'])) { Phpfox_Error::set(Phpfox::getPhrase('user.this_display_name_is_not_allowed_to_be_used')); } if (!defined('PHPFOX_INSTALLER') && Phpfox::isModule('subscribe') && Phpfox::getParam('subscribe.enable_subscription_packages') && Phpfox::getParam('subscribe.subscribe_is_required_on_sign_up') && empty($aVals['package_id'])) { $aPackages = Phpfox::getService('subscribe')->getPackages(true); if (count($aPackages)) { return Phpfox_Error::set(Phpfox::getPhrase('user.select_a_membership_package')); } } if (!defined('PHPFOX_INSTALLER')) { if (!defined('PHPFOX_SKIP_EMAIL_INSERT')) { if (!Phpfox::getLib('mail')->checkEmail($aVals['email'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.email_is_not_valid')); } } if (Phpfox::getLib('parse.format')->isEmpty($aVals['full_name'])) { Phpfox_Error::set(Phpfox::getPhrase('user.provide_a_name_that_is_not_representing_an_empty_name')); } } $bHasImage = false; if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.force_user_to_upload_on_sign_up')) { if (!isset($_FILES['image']['name']) || empty($_FILES['image']['name']) ) { Phpfox_Error::set('Please upload an image for your profile.'); } else { $aImage = Phpfox::getLib('file')->load('image', array('jpg', 'gif', 'png'), (Phpfox::getUserParam('user.max_upload_size_profile_photo') === 0 ? null : (Phpfox::getUserParam('user.max_upload_size_profile_photo') / 1024))); if ($aImage !== false) { $bHasImage = true; } } } $aInsert = array( 'user_group_id' => ($iUserGroupId === null ? NORMAL_USER_ID : $iUserGroupId), 'full_name' => $oParseInput->clean($aVals['full_name'], 255), 'password' => Phpfox::getLib('hash')->setHash($aVals['password'], $sSalt), 'password_salt' => $sSalt, 'email' => $aVals['email'], 'joined' => PHPFOX_TIME, 'gender' => (defined('PHPFOX_INSTALLER') || (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_gender')) ? $aVals['gender'] : 0), 'birthday' => (defined('PHPFOX_INSTALLER') || (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_dob')) ? Phpfox::getService('user')->buildAge($aVals['day'],$aVals['month'],$aVals['year']) : null), 'birthday_search' => (defined('PHPFOX_INSTALLER') || (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_dob')) ? Phpfox::getLib('date')->mktime(0, 0, 0, $aVals['month'], $aVals['day'], $aVals['year']) : 0), 'country_iso' => (defined('PHPFOX_INSTALLER') || (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_location')) ? $aVals['country_iso'] : null), 'language_id' => ((!defined('PHPFOX_INSTALLER') && Phpfox::getLib('session')->get('language_id')) ? Phpfox::getLib('session')->get('language_id') : null), 'time_zone' => (isset($aVals['time_zone']) && (defined('PHPFOX_INSTALLER') || (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_timezone'))) ? $aVals['time_zone'] : null), 'last_ip_address' => Phpfox::getIp(), 'last_activity' => PHPFOX_TIME ); if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.verify_email_at_signup')) { $aInsert['status_id'] = 1;// 1 = need to verify email } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.approve_users')) { $aInsert['view_id'] = '1';// 1 = need to approve the user } if (!Phpfox::getParam('user.profile_use_id') && !Phpfox::getParam('user.disable_username_on_sign_up')) { $aVals['user_name'] = str_replace(' ', '_', $aVals['user_name']); $aInsert['user_name'] = $oParseInput->clean($aVals['user_name']); } (($sPlugin = Phpfox_Plugin::get('user.service_process_add_start')) ? eval($sPlugin) : false); if (!Phpfox_Error::isPassed()) { return false; } $iId = $this->database()->insert($this->_sTable, $aInsert); $aExtras = array( 'user_id' => $iId ); (($sPlugin = Phpfox_Plugin::get('user.service_process_add_extra')) ? eval($sPlugin) : false); $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); if (Phpfox::getParam('user.profile_use_id') || Phpfox::getParam('user.disable_username_on_sign_up')) { $this->database()->update($this->_sTable, array('user_name' => 'profile-' . $iId), 'user_id = ' . $iId); } if ($bHasImage) { $this->uploadImage($iId, true, null, true); } ((Phpfox::getCookie('invited_by_email') || Phpfox::getCookie('invited_by_user')) ? Phpfox::getService('invite.process')->registerInvited($iId) : null); (($sPlugin = Phpfox_Plugin::get('user.service_process_add_feed')) ? eval($sPlugin) : false); if (!defined('PHPFOX_INSTALLER') && !Phpfox::getParam('user.verify_email_at_signup') && !Phpfox::getParam('user.approve_users') && !isset($bDoNotAddFeed)) { //(Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->allowGuest()->add('user_joined', $iId, null, $iId) : null); } if (isset($aVals['country_child_id'])) { Phpfox::getService('user.field.process')->update($iId, 'country_child_id', $aVals['country_child_id']); } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.registration_enable_dob')) { // Updating for the birthday range $this->database()->update(Phpfox::getT('user_field'), array('birthday_range' => '\''.Phpfox::getService('user')->buildAge($aVals['day'], $aVals['month']) .'\''), 'user_id = ' . $iId, false); } if (!defined('PHPFOX_INSTALLER')) { $iFriendId = (int) Phpfox::getParam('user.on_signup_new_friend'); if ($iFriendId > 0) { $this->database()->insert(Phpfox::getT('friend'), array( 'list_id' => 0, 'user_id' => $iId, 'friend_user_id' => $iFriendId, 'time_stamp' => PHPFOX_TIME ) ); $this->database()->insert(Phpfox::getT('friend'), array( 'list_id' => 0, 'user_id' => $iFriendId, 'friend_user_id' => $iId, 'time_stamp' => PHPFOX_TIME ) ); Phpfox::getService('friend.process')->updateFriendCount($iId, $iFriendId); Phpfox::getService('friend.process')->updateFriendCount($iFriendId, $iId); } if ($sPlugin = Phpfox_Plugin::get('user.service_process_add_check_1')) { eval($sPlugin); } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.verify_email_at_signup') == false && !isset($bDoNotSendWelcomeEmail)) { Phpfox::getLib('mail') ->to($iId) ->subject(array('core.welcome_email_subject', array('site' => Phpfox::getParam('core.site_title')))) ->message(array('core.welcome_email_content')) ->send(); } switch (Phpfox::getParam('user.on_register_privacy_setting')) { case 'network': $iPrivacySetting = '1'; break; case 'friends_only': $iPrivacySetting = '2'; break; case 'no_one': $iPrivacySetting = '4'; break; default: break; } if (isset($iPrivacySetting)) { $this->database()->insert(Phpfox::getT('user_privacy'), array( 'user_id' => $iId, 'user_privacy' => 'profile.view_profile', 'user_value' => $iPrivacySetting ) ); } } (($sPlugin = Phpfox_Plugin::get('user.service_process_add_end')) ? eval($sPlugin) : false); if (!empty($aCustom)) { if (!Phpfox::getService('custom.process')->updateFields($iId, $iId, $aCustom, true)) { return false; } } $this->database()->insert(Phpfox::getT('user_ip'), array( 'user_id' => $iId, 'type_id' => 'register', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME ) ); if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.verify_email_at_signup') && !isset($bSkipVerifyEmail)) { $aVals['user_id'] = $iId; $sHash = Phpfox::getService('user.verify')->getVerifyHash($aVals); $this->database()->insert(Phpfox::getT('user_verify'), array('user_id' => $iId, 'hash_code' => $sHash, 'time_stamp' => Phpfox::getTime(), 'email' => $aVals['email'])); // send email $sLink = Phpfox::getLib('url')->makeUrl('user.verify', array('link' => $sHash)); Phpfox::getLib('mail') ->to($iId) ->subject(array('user.please_verify_your_email_for_site_title', array('site_title' => Phpfox::getParam('core.site_title')))) ->message(array('user.you_registered_an_account_on_site_title_before_being_able_to_use_your_account_you_need_to_verify_that_this_is_your_email_address_by_clicking_here_a_href_link_link_a', array( 'site_title' => Phpfox::getParam('core.site_title'), 'link' => $sLink ) ) ) ->send(); } if (!defined('PHPFOX_INSTALLER') && Phpfox::isModule('subscribe') && Phpfox::getParam('subscribe.enable_subscription_packages') && !empty($aVals['package_id'])) { $aPackage = Phpfox::getService('subscribe')->getPackage($aVals['package_id']); if (isset($aPackage['package_id'])) { $iPurchaseId = Phpfox::getService('subscribe.purchase.process')->add(array( 'package_id' => $aPackage['package_id'], 'currency_id' => $aPackage['default_currency_id'], 'price' => $aPackage['default_cost'] ), $iId ); $iDefaultCost = (int) str_replace('.', '', $aPackage['default_cost']); if ($iPurchaseId) { if ($iDefaultCost > 0) { define('PHPFOX_MUST_PAY_FIRST', $iPurchaseId); Phpfox::getService('user.field.process')->update($iId, 'subscribe_id', $iPurchaseId); return array(Phpfox::getLib('url')->makeUrl('subscribe.register', array('id' => $iPurchaseId))); } else { Phpfox::getService('subscribe.purchase.process')->update($iPurchaseId, $aPackage['package_id'], 'completed', $iId, $aPackage['user_group_id'], $aPackage['fail_user_group']); } } else { return false; } } } return $iId; }
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()); } }
/** * Class process method wnich is used to execute this component. */ public function process() { // When they first submit the newsletter this block adds it to the ongoing or scheduling if ($aVals = $this->request()->getArray('val')) { $aNewsletter = Phpfox::getService('newsletter.process')->add($aVals, Phpfox::getUserId()); if ($aNewsletter['state'] == 1) { $this->url()->send('admincp.newsletter.add', array('job' => $aNewsletter['newsletter_id']), Phpfox::getPhrase('newsletter.processing_job_newsletter_id', array('newsletter_id' => $aNewsletter['newsletter_id']))); } elseif ($aNewsletter === false) { } else { $this->url()->send('admincp.newsletter.manage', null, null); } } // when refreshed by the flow we should get an integer here pointing to the pending job elseif ($iJob = $this->request()->getInt('job')) { list($iContinue,$iPerc) = Phpfox::getService('newsletter.process')->processJob($iJob); if (is_int($iContinue) && $iPerc < 100) { $sMessage = Phpfox::getPhrase('newsletter.5_seconds_break_processing_job_continue_total_completed_perc', array('continue' => $iContinue, 'perc' => $iPerc)); $sLink = $this->url()->makeUrl('admincp.newsletter.add', array('job' => $iContinue)); $this->template()->setHeader('<META HTTP-EQUIV="refresh" content="5;URL='.$sLink.'">') ->assign(array('sMessage' => $sMessage)); //$this->url()->send('admincp.newsletter.add', array('job' => $iContinue)); } elseif ($iContinue === true || $iPerc >= 100) // completed successfully { $this->url()->send('admincp.newsletter.manage', null, Phpfox::getPhrase('newsletter.job_completed_successfully')); } elseif ($iContinue === false) { $this->url()->send('admincp.newsletter.manage', null, Phpfox::getPhrase('newsletter.there_was_a_problem_with_this_job_feel_free_to_resume_it_at_any_time')); } } if ($iId = $this->request()->getInt('id') || $iId = $this->request()->getInt('job')) { $aNewsletter = Phpfox::getService('newsletter')->get($iId); $this->template()->assign(array( 'aForms' => $aNewsletter ) ); } $aValidation = array( 'type_id' => array( 'title' => Phpfox::getPhrase('newsletter.select_a_newsletter_type'), 'def' => 'int' ), ); // 2 = html; 1 = plain text; $oValidator = Phpfox::getLib('validator')->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $aAge = array(); for ($i = 18; $i <= 68; $i++) { $aAge[$i] = $i; } $this->template()->assign(array( 'aAge' => $aAge, 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValidator->createJS(), 'sGetJsForm' => $oValidator->getJsForm() ) ) ->setTitle(Phpfox::getPhrase('newsletter.newsletter')) ->setBreadCrumb(Phpfox::getPhrase('newsletter.newsletter'), $this->url()->makeUrl('admincp.newsletter.add')) ->setBreadCrumb(Phpfox::getPhrase('newsletter.add_newsletter'), null, true) ->setPhrase(array( 'newsletter.min_age_cannot_be_higher_than_max_age', 'newsletter.max_age_cannot_be_lower_than_the_min_age' ) ) ->setEditor(array( 'wysiwyg' => Phpfox::getCookie('editor_wysiwyg'), 'toggle' => Phpfox::getCookie('editor_wysiwyg') ) ) ->setHeader(array('add.js' => 'module_newsletter')); }
/** * Sets the controller for the page we are on. This method controlls what component to load, which * will be used to display the content on that page. * * @param string $sController (Optional) We find the controller by default, however you can override our default findings by passing the name of the controller with this argument. */ public function setController($sController = '') { if ($sController) { $aParts = explode('.', $sController); $this->_sModule = $aParts[0]; $this->_sController = substr_replace($sController, '', 0, strlen($this->_sModule . '_')); $this->getModuleBlocks(1, true); ($sPlugin = Phpfox_Plugin::get('set_defined_controller')) ? eval($sPlugin) : false; // Reset the lang. pack cache since we are using a new controller if (Phpfox::getParam('language.cache_phrases')) { Phpfox::getLib('locale')->cache(); Phpfox::getLib('locale')->setCache(); } $this->getController(); return; } ($sPlugin = Phpfox_Plugin::get('module_setcontroller_start')) ? eval($sPlugin) : false; $oUrl = Phpfox::getLib('url'); $oReq = Phpfox::getLib('request'); $oPage = Phpfox::getService('page'); $this->_sModule = ($sReq1 = $oReq->get('req1')) ? strtolower($sReq1) : Phpfox::getParam('core.module_core'); if (Phpfox::isMobile() && empty($sReq1)) { $this->_sModule = 'mobile'; } if (($sFrame = $oReq->get('frame')) && in_array($sFrame, $this->_aFrames)) { $aFrameParts = explode('-', $sFrame); $this->_sModule = strtolower($aFrameParts[0]); $this->_sController = strtolower($aFrameParts[1]); } $this->_aPages = $oPage->getCache(); if (isset($this->_aPages[$oReq->get('req1')])) { $this->_sModule = 'page'; $this->_sController = 'view'; } $sDir = PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS; if ($oReq->get('req2') == Phpfox::getParam('admincp.admin_cp')) { Phpfox::getLib('url')->send($oReq->get('req2') . '.' . $oReq->get('req1')); } if ($oReq->get('req1') == 'admincp' && Phpfox::getParam('admincp.admin_cp') != 'admincp') { Phpfox::getLib('url')->send('error.404'); } if ($oReq->get('req2') && file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . strtolower($oReq->get('req2')) . '.class.php')) { $this->_sController = strtolower($oReq->get('req2')); } elseif (strtolower($this->_sModule) != Phpfox::getParam('admincp.admin_cp') && $oReq->get('req3') && file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . strtolower($oReq->get('req2')) . PHPFOX_DS . strtolower($oReq->get('req3')) . '.class.php')) { $this->_sController = strtolower($oReq->get('req2') . '.' . $oReq->get('req3')); } elseif (strtolower($this->_sModule) != Phpfox::getParam('admincp.admin_cp') && $oReq->get('req2') && file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . strtolower($oReq->get('req2')) . PHPFOX_DS . 'index.class.php')) { $this->_sController = strtolower($oReq->get('req2')) . '.index'; } else { // Over-ride the index page to display the content for guests or members if ($this->_sModule == Phpfox::getParam('core.module_core') && $this->_sController == 'index' && Phpfox::getParam('core.module_core') == PHPFOX_MODULE_CORE) { $this->_sController = Phpfox::isUser() ? 'index-member' : 'index-visitor'; } if (!file_exists($sDir . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . $this->_sController . '.class.php')) { $this->_sModule = 'profile'; } ($sPlugin = Phpfox_Plugin::get('set_controller_else_end')) ? eval($sPlugin) : false; } if ($this->_sModule == 'theme') { if (preg_match('/^(.*?)\\.(jpg|jpeg|gif|png|css|js)$/i', $_GET[PHPFOX_GET_METHOD])) { $this->_sModule = 'error'; $this->_sController = '404'; } } if ($this->_sModule != 'profile' && !isset($this->_aModules[$this->_sModule])) { $this->_sModule = 'error'; $this->_sController = '404'; } if (Phpfox::getParam('admincp.admin_cp') != 'admincp' && $oReq->get('req1') == Phpfox::getParam('admincp.admin_cp')) { $this->_sModule = 'admincp'; } ($sPlugin = Phpfox_Plugin::get('module_setcontroller_end')) ? eval($sPlugin) : false; // Set the language pack cache if (Phpfox::getParam('language.cache_phrases')) { Phpfox::getLib('locale')->setCache(); } $bCookie = Phpfox::getCookie('page_login') && Phpfox::getUserBy('profile_page_id') > 0; if (Phpfox::isUser() && $bCookie != 1 && Phpfox::getUserParam('user.require_profile_image') && Phpfox::getUserBy('user_image') == '' && !($this->_sModule == 'user' && $this->_sController == 'photo' || $this->_sModule == 'user' && $this->_sController == 'logout' || $this->_sModule == 'subscribe')) { Phpfox::getLib('url')->send('user.photo', null, Phpfox::getPhrase('user.you_are_required_to_upload_a_profile_image')); } if (Phpfox::getParam('core.force_https_secure_pages')) { $sController = str_replace('mobile.', '', $this->getFullControllerName()); if ($sController == 'core.index-member' || $sController == 'core.index-visitor') { // fixes 14276 $sController = ''; } if (in_array(str_replace('mobile.', '', $this->getFullControllerName()), Phpfox::getService('core')->getSecurePages())) { if (!isset($_SERVER['HTTPS'])) { Phpfox::getLib('url')->send($sController); } } else { if (Phpfox::getParam('core.force_secure_site')) { if (!isset($_SERVER['HTTPS'])) { Phpfox::getLib('url')->send($sController); } } } } }
/** * Refreshes and returns the hash that allows SWFU file uploads. This is used * together with the auth service to allow the massuploader * @return string */ public function getHashForUpload() { if (Phpfox::isUser()) { Phpfox_Database::instance()->delete(Phpfox::getT('upload_track'), 'user_id = ' . Phpfox::getUserId()); } $sHash = md5(uniqid() . Phpfox::getUserBy('email') . uniqid() . Phpfox::getUserBy('password_salt')); $aCookieNames = Phpfox::getService('user.auth')->getCookieNames(); Phpfox::getLib('session')->set('flashuploadhash', Phpfox::getCookie($aCookieNames[1])); $sCacheId = $this->cache()->set(array('uagent', $sHash)); $this->cache()->remove($sCacheId); $this->cache()->save($sCacheId, $_SERVER['HTTP_USER_AGENT']); Phpfox_Database::instance()->insert(Phpfox::getT('upload_track'), array('user_id' => Phpfox::getUserId(), 'hash' => $sHash, 'user_hash' => Phpfox::getLib('parse.input')->clean(Phpfox::getCookie($aCookieNames[1])), 'ip_address' => Phpfox_Request::instance()->getServer('REMOTE_ADDR'))); return $sHash; }
/** * This function inserts into phpfox_upload_track to identify a user when uploading via the massuploader */ public function trackUpload($sFile, $bInsert = true) { Phpfox::isUser(); $this->database()->delete(Phpfox::getT('upload_track'), 'user_id = ' . Phpfox::getUserId()); if ($bInsert == true) { $this->database()->insert(Phpfox::getT('upload_track'), array('user_id' => Phpfox::getUserId(), 'user_hash' => Phpfox::getCookie('user_hash'), 'file_hash' => md5($sFile))); } }
/** * 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') ) ); }
/** * 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'] : '')); } } }
/** * Get a session ARRAY. * * @param string $sName Name of the session. * @param string $sValue Name of the group session. * @return mixed Session exists we return its value, otherwise we return FALSE. */ public function getArray($sName, $sValue) { $mCookie = Phpfox::getCookie($sName . $sValue); if (!empty($mCookie)) { return $mCookie; } return false; }
private function _getPhoto($sCondition, $sOrder, $bNoPrivacy = false, $iCategory = null) { if ($bNoPrivacy === true) { $iCategoryChecked = null; if ($iCategory !== null) { $iCategoryChecked = (int) $iCategory; } else { if (Phpfox::getCookie('photo_category')) { $iCategoryChecked = Phpfox::getCookie('photo_category'); } else { if (isset($_SESSION['photo_category']) && $_SESSION['photo_category'] != '') { $iCategoryChecked = $_SESSION['photo_category']; } } } if ($iCategoryChecked !== null) { $this->database()->join(Phpfox::getT('photo_category_data'), 'pcd', 'pcd.photo_id = photo.photo_id AND pcd.category_id = ' . (int) $iCategoryChecked); } $iPreviousCnt = $this->database()->select('COUNT(*)')->from(Phpfox::getT('photo'), 'photo')->join(Phpfox::getT('user'), 'u', 'u.user_id = photo.user_id')->where(array($sCondition))->execute('getSlaveField'); if ($iCategoryChecked !== null) { $this->database()->select('pcd.category_id,')->join(Phpfox::getT('photo_category_data'), 'pcd', 'pcd.photo_id = photo.photo_id AND pcd.category_id = ' . (int) $iCategoryChecked); } $aPrevious = (array) $this->database()->select('photo.*')->from(Phpfox::getT('photo'), 'photo')->join(Phpfox::getT('user'), 'u', 'u.user_id = photo.user_id')->where(array($sCondition))->order('photo.photo_id ' . $sOrder)->execute('getSlaveRow'); if (!empty($aPrevious['photo_id'])) { $aPrevious['link'] = Phpfox::getLib('url')->permalink('photo', $aPrevious['photo_id'], $aPrevious['title']) . ($iCategoryChecked !== null ? 'category_' . $iCategoryChecked : ''); } return array($iPreviousCnt, $aPrevious); } $aBrowseParams = array('module_id' => 'photo', 'alias' => 'photo', 'field' => 'photo_id', 'table' => Phpfox::getT('photo'), 'hide_view' => array('pending', 'my')); $this->search()->set(array('type' => 'photo', 'filters' => array('display' => array('type' => 'option', 'default' => '1'), 'sort' => array('type' => 'option', 'default' => 'photo_id'), 'sort_by' => array('type' => 'option', 'default' => $sOrder)))); $this->search()->setCondition($sCondition); $this->search()->setCondition('AND photo.view_id = 0 AND photo.group_id = 0 AND photo.type_id = 0 AND photo.privacy IN(%PRIVACY%)'); $this->search()->browse()->params($aBrowseParams)->execute(); $iPreviousCnt = $this->search()->browse()->getCount(); $aPreviousRows = $this->search()->browse()->getRows(); $this->search()->browse()->reset(); $aPrevious = array(); if (isset($aPreviousRows[0])) { $aPrevious = $aPreviousRows[0]; } return array($iPreviousCnt, $aPrevious); }
private function _getFromCache() { static $bIsSet = false; if ($bIsSet === true) { return $this; } $sCacheId = $this->cache()->set('forum'); if (!($this->_aForums = $this->cache()->get($sCacheId))) { $aForums = $this->database()->select('f.forum_id, f.parent_id, f.view_id, f.is_category, f.name, f.name_url, f.description, f.is_closed')->from($this->_sTable, 'f')->where('f.view_id = 0')->order('f.ordering ASC')->execute('getRows'); foreach ($aForums as $aForum) { $aModerators = $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('forum_moderator'), 'fm')->join(Phpfox::getT('user'), 'u', 'u.user_id = fm.user_id')->where('forum_id = ' . $aForum['forum_id'])->execute('getRows'); foreach ($aModerators as $iModKey => $aModerator) { foreach ($aModerator as $sKey => $sValue) { $aForum['moderators'][$iModKey][$sKey] = $sValue; } } $this->_aForums[$aForum['forum_id']] = $aForum; } $this->cache()->save($sCacheId, $this->_aForums); } if (is_bool($this->_aForums)) { $this->_aForums = array(); } foreach ($this->_aForums as $key => $value) { $this->_aForums[$key]['toggle_class'] = Phpfox::getCookie('forum_toggle_' . $value['forum_id']) ? ' is_toggled' : ''; } // d($this->_aForums); exit; $bIsSet = true; return $this; }
/** * This function tells if the user is in Design mode with Drag and Drop support * it was moved from the template library so it can be referenced by ajax * calls * @return boolean */ public function isInDnDMode() { $aUrl = Phpfox::getLib('url')->getParams(); $bIsCustomize = !isset($aUrl['req3']) || $aUrl['req3'] != 'customize' && isset($aUrl['req2']) && $aUrl['req2'] == 'index-member'; $bIsMusic = !isset($aUrl['req3']) || $aUrl['req1'] == 'music'; if (Phpfox::getUserParam('core.can_design_dnd') && Phpfox::getCookie('doDnD') == 1 && (!isset($aUrl['req2']) || $aUrl['req2'] != 'designer')) { return true; } return false; }
/** * Class constructor */ public function __construct() { if (Phpfox::getParam('core.use_custom_cookie_names')) { $this->_sNameCookieUserId = md5(Phpfox::getParam('core.custom_cookie_names_hash') . $this->_sNameCookieUserId); $this->_sNameCookieHash = md5(Phpfox::getParam('core.custom_cookie_names_hash') . $this->_sNameCookieHash); } $this->_sTable = Phpfox::getT('user'); $iUserId = (int) Phpfox::getCookie($this->_sNameCookieUserId); $sPasswordHash = Phpfox::getCookie($this->_sNameCookieHash); if (isset($_POST['flash_user_id']) && isset($_POST['sHash'])) { /* $hFile = fopen(PHPFOX_DIR_FILE . 'upload.log', 'a+'); fwrite($hFile, 'user_id = ' . $iUserId . ' AND hash = "' . Phpfox::getLib('parse.input')->clean($_POST['sHash']).'"' . "\n"); fclose($hFile); */ $iUserId = (int) $_POST['flash_user_id']; $aRow = $this->database()->select('*')->from(Phpfox::getT('upload_track'))->where('user_id = ' . $iUserId . ' AND hash = "' . Phpfox::getLib('parse.input')->clean($_POST['sHash']) . '"')->execute('getSlaveRow'); $sPasswordHash = $aRow['user_hash']; $sIpAddress = $aRow['ip_address']; if ($sIpAddress != Phpfox::getLib('request')->getServer('REMOTE_ADDR')) { $iUserId = 0; $this->_setDefault(); $this->logout(); } else { $sCacheId = Phpfox::getLib('cache')->set(array('uagent', $aRow['hash'])); $sUserAgent = Phpfox::getLib('cache')->get($sCacheId); if (!empty($sUserAgent)) { $_SERVER['HTTP_USER_AGENT'] = $sUserAgent; define('PHPFOX_IS_FLASH_UPLOADER', true); } else { $iUserId = 0; $this->_setDefault(); $this->logout(); } // Phpfox::getLib('cache')->remove($sCacheId); } } if (defined('PHPFOX_INSTALLER')) { $this->_setDefault(); } else { if ($iUserId > 0) { $sSelect = ''; $sJoin = ''; ($sPlugin = Phpfox_Plugin::get('user.service_auth___construct_start')) ? eval($sPlugin) : false; $oSession = Phpfox::getLib('session'); $oRequest = Phpfox::getLib('request'); $bLoadUserField = false; $sUserFieldSelect = ''; ($sPlugin = Phpfox_Plugin::get('user.service_auth___construct_query')) ? eval($sPlugin) : false; if (Phpfox::getParam('core.store_only_users_in_session')) { if (Phpfox::getParam('core.auth_user_via_session')) { $this->database()->select('ls.user_id AS session_hash, ls.id_hash, ')->join(Phpfox::getT('session'), 'ls', "ls.user_id = u.user_id"); } else { $this->database()->select('ls.user_id AS session_hash, ')->leftJoin(Phpfox::getT('session'), 'ls', "ls.user_id = u.user_id"); } } else { if ($oSession->get('session')) { $this->database()->select('ls.session_hash, ls.id_hash, ls.captcha_hash, ls.user_id, ls.im_status, ')->leftJoin(Phpfox::getT('log_session'), 'ls', "ls.session_hash = '" . $this->database()->escape($oSession->get('session')) . "' AND ls.id_hash = '" . $this->database()->escape($oRequest->getIdHash()) . "'"); } } if (Phpfox::getLib('request')->get('req1') == '' || Phpfox::getLib('request')->get('req1') == 'request' || Phpfox::getLib('request')->get('req1') == 'theme' && Phpfox::getLib('request')->get('req2') == 'select' || Phpfox::isModule('mail') && Phpfox::getParam('mail.display_total_mail_count')) { $this->database()->select('uc.*, ')->join(Phpfox::getT('user_count'), 'uc', 'uc.user_id = u.user_id'); } if (Phpfox::getLib('request')->get('req1') == '' || Phpfox::getLib('request')->get('req1') == 'core') { $bLoadUserField = true; $sUserFieldSelect .= 'uf.total_view, u.last_login, uf.location_latlng, '; } if (strtolower(Phpfox::getLib('request')->get('req1')) == Phpfox::getParam('admincp.admin_cp')) { $bLoadUserField = true; $sUserFieldSelect .= 'uf.in_admincp, '; } if (Phpfox::isModule('ad') && Phpfox::getParam('ad.advanced_ad_filters')) { $bLoadUserField = true; $sUserFieldSelect .= 'uf.postal_code, uf.city_location, uf.country_child_id, '; } if ($bLoadUserField === true) { $this->database()->select($sUserFieldSelect)->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = u.user_id'); } /* Hook for http://www.phpfox.com/tracker/view/13054/ */ if ((Phpfox::getParam('user.check_promotion_system') || $bLoadUserField === true) && (!isset($bDoActivityPoints) || isset($bDoActivityPoints) && $bDoActivityPoints == true)) { $this->database()->select('uactivity.activity_points, uactivity.user_id AS activity_user_id, ')->leftJoin(Phpfox::getT('user_activity'), 'uactivity', 'uactivity.user_id = u.user_id'); } $this->_aUser = $this->database()->select('u.profile_page_id, u.status_id, u.view_id, u.user_id, u.server_id, u.user_group_id, u.user_name, u.email, u.gender, u.style_id, u.language_id, u.birthday, u.full_name, u.user_image, u.password, u.password_salt, u.joined, u.hide_tip, u.status, u.footer_bar, u.country_iso, u.time_zone, u.dst_check, u.last_activity, u.im_beep, u.im_hide, u.is_invisible, u.total_spam, u.feed_sort ' . $sSelect)->from($this->_sTable, 'u')->where("u.user_id = '" . $this->database()->escape($iUserId) . "'")->execute('getRow'); if (!isset($this->_aUser['user_id'])) { $this->_setDefault(); $this->logout(); } if (empty($this->_aUser['activity_user_id']) && (Phpfox::getParam('user.check_promotion_system') || $bLoadUserField === true)) { $this->database()->delete(Phpfox::getT('user_activity'), 'user_id = ' . $this->_aUser['user_id']); $this->database()->insert(Phpfox::getT('user_activity'), array('user_id' => $this->_aUser['user_id'])); } if (isset($this->_aUser['password']) && isset($this->_aUser['password_salt']) && !Phpfox::getLib('hash')->getRandomHash(Phpfox::getLib('hash')->setHash($this->_aUser['password'], $this->_aUser['password_salt']), $sPasswordHash)) { $this->_setDefault(); $this->logout(); } if (isset($this->_aUser['user_id'])) { $this->_aUser['age'] = Phpfox::getService('user')->age(isset($this->_aUser['birthday']) ? $this->_aUser['birthday'] : ''); $this->_aUser['im_hide'] = isset($this->_aUser['is_invisible']) && $this->_aUser['is_invisible'] ? 1 : (isset($this->_aUser['im_hide']) ? $this->_aUser['im_hide'] : 1); if (Phpfox::getParam('core.auth_user_via_session')) { if (empty($this->_aUser['id_hash'])) { $this->_setDefault(); $this->logout(); } if (isset($this->_aUser['id_hash']) && $oRequest->getIdHash() != $this->_aUser['id_hash']) { $this->_setDefault(); $this->logout(); } } } ($sPlugin = Phpfox_Plugin::get('user.service_auth___construct_end')) ? eval($sPlugin) : false; unset($this->_aUser['password'], $this->_aUser['password_salt']); if (isset($this->_aUser['fb_user_id']) && $this->_aUser['fb_user_id'] > 0 && $this->_aUser['fb_is_unlinked']) { $this->_aUser['fb_user_id'] = 0; } } else { $this->_setDefault(); } } }
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()); } } }
private function _buildForum($iForumId) { $oUrl = Phpfox::getLib('url'); $aForums = array(); foreach ($this->_aForums as $aForum) { if ($aForum['parent_id'] != $iForumId) { continue; } if (!Phpfox::getService('forum')->hasAccess($aForum['forum_id'], 'can_view_forum')) { continue; } if ($aForum['is_category'] && $this->_bHasCategory === false) { $this->_bHasCategory = true; } $aForum['sub_forum'] = $this->_buildForum($aForum['forum_id']); if (isset($this->_aLive[$aForum['forum_id']])) { foreach ($this->_aLive[$aForum['forum_id']] as $sKey => $mValue) { if (isset($aForum[$sKey])) { continue; } $aForum[$sKey] = $mValue; } if (!isset($aForum['is_seen'])) { $aForum['is_seen'] = 0; } if (!$aForum['is_seen']) { // User has signed up after the post so they have already seen the post if (Phpfox::isUser() && Phpfox::getUserBy('joined') > $aForum['thread_time_stamp'] || !Phpfox::isUser() && Phpfox::getCookie('visit') > $aForum['thread_time_stamp']) { $aForum['is_seen'] = 1; } elseif (($iLastTimeViewed = Phpfox::getLib('session')->getArray('forum_view', $aForum['thread_id'])) && (int) $iLastTimeViewed > $aForum['thread_time_stamp']) { $aForum['is_seen'] = 1; } elseif (!empty($aForum['thread_time_stamp']) && PHPFOX_TIME - Phpfox::getParam('forum.keep_active_posts') * 60 > $aForum['thread_time_stamp']) { $aForum['is_seen'] = 1; } elseif (!empty($aForum['thread_time_stamp']) && Phpfox::isUser() && $aForum['thread_time_stamp'] < Phpfox::getCookie('last_login')) { $aForum['is_seen'] = 1; } } else { // New post was added if ($aForum['thread_time_stamp'] > $aForum['last_seen_time']) { $aForum['is_seen'] = 0; } } if (!$aForum['parent_id']) { $this->_aStat['thread'] += $aForum['total_thread']; $this->_aStat['post'] += $aForum['total_post']; } } if (isset($aForum['post_id']) && $aForum['post_id']) { $sLink = $oUrl->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aForum['thread_title_url'], 'post' => $aForum['post_id'])); } else { if (isset($aForum['thread_title_url'])) { $sLink = $oUrl->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aForum['thread_title_url'])); } } /* $aForum['last_posted_phrase'] = Phpfox::getPhrase('forum.by_user_link_on_time_stamp_phrase', array( 'user' => $aForum, 'link' => $sLink, 'time_stamp_phrase' => Phpfox::getTime(Phpfox::getParam('forum.forum_time_stamp'), $aForum['thread_time_stamp']) ) ); */ $aForums[$aForum['forum_id']] = $aForum; if ($this->_iForumId !== null && $aForum['forum_id'] == $this->_iForumId) { $this->_aBuild[$aForum['forum_id']] = $aForum; } } return $aForums; }
/** * Debug output found at the bottom of the site when debug mode is enabled. * * @static * @return mixed Only returns something if the installer is being used and in that case it returns FALSE */ public static function getDetails() { if (defined('PHPFOX_INSTALLER')) { return false; } // SQL $iSqlCount = 0; $fSum = 0.0; $fLimit = 0.05 * 128; $iSqlMemory = 0; $aKeywords = array('SELECT', 'SELECT ', 'FROM', 'FROM ', 'WHERE ', 'UPDATE ', 'OFFSET', ' AS ', 'UNION ALL', 'INNER JOIN ', 'LEFT JOIN ', 'INSERT INTO ', 'SHOW COLUMNS ', 'ON', 'SET', 'USING', 'USE INDEX', 'JOIN ', 'ORDER BY', 'DESC', 'LIMIT', 'DELETE'); $oRequest = Phpfox_Request::instance(); $oFile = Phpfox_File::instance(); $aReplaces = array_map(array('self', '_addKeywordSyntax'), $aKeywords); $sDriver = Phpfox::getParam(array('db', 'driver')); $sSql = ''; $bIsCmd = PHP_SAPI == 'cli' || defined('PHPFOX_IS_AJAX') && PHPFOX_IS_AJAX; if (!isset(self::$_aDebugHistory['sql'])) { self::$_aDebugHistory['sql'] = array(); } // Fresh install, no need to display sql debug if ($sDriver == 'DATABASE_DRIVER') { self::$_aDebugHistory['sql'] = array(); } foreach (self::$_aDebugHistory['sql'] as $aLine) { if (!isset($aLine['sql'])) { continue; } $iSqlCount++; $sExtra = Phpfox_Database::instance()->sqlReport($aLine['sql']); if ($bIsCmd) { $sSql .= "\n ----------------- \n Rows: " . $aLine['rows'] . " Slave: " . ($aLine['slave'] ? 'Yes' : 'No') . " \n " . $aLine['sql'] . " \n\n"; } else { if ($aLine['time'] == '0.0000000') { $aLine['time'] = '0.0000001'; } $sColor = sprintf('%02X', min(255, $fLimit / $aLine['time'])); $aLine['sql'] = str_replace($aKeywords, $aReplaces, htmlspecialchars($aLine['sql'])); $sSql .= '<div class="nDebugInfo"> <span style="background-color: #FF' . $sColor . $sColor . '; color:#000; padding:2px;">' . $aLine['time'] . '</span> | <b>Memory Before:</b> ' . $oFile->filesize($aLine['memory_before']) . ' | <b>Memory After:</b> ' . $oFile->filesize($aLine['memory_after']) . ' | <b>Memory Used:</b> ' . $oFile->filesize($aLine['memory_after'] - $aLine['memory_before']) . ' | <b>Rows:</b> ' . $aLine['rows'] . ' | <b>Slave:</b> ' . ($aLine['slave'] ? 'Yes' : 'No') . ' </div>'; $sSql .= '<div class="nDebugItems">' . self::_parseSQL($aLine['sql']) . '' . $sExtra . '</div>'; } $fSum += $aLine['time']; $iSqlMemory += $aLine['memory_after'] - $aLine['memory_before']; } // General Stats $iTotalTime = sprintf('%0.7f', array_sum(explode(' ', microtime())) - PHPFOX_TIME_START); $iTotalSqlTime = sprintf('%0.7f', $fSum); $sDebugReturn = '<div id="js_main_debug_holder">'; if (!defined('PHPFOX_MEM_END')) { define('PHPFOX_MEM_END', memory_get_usage()); } if (PHPFOX_DEBUG_LEVEL === 1) { $sDebugReturn .= '<div style="font-size:9pt; text-align:center; padding-bottom:50px;">Page generated in ' . round($iTotalTime, 4) . ' seconds with ' . $iSqlCount . ' queries and GZIP ' . (Phpfox::getParam('core.use_gzip') ? 'enabled' : 'disabled') . ' on ' . $_SERVER['SERVER_ADDR'] . '.</div>'; } elseif (PHPFOX_DEBUG_LEVEL === 2 || PHPFOX_DEBUG_LEVEL === 3) { $bSlaveEnabled = Phpfox::getParam(array('db', 'slave')); $aStats = array('Version' => PhpFox::getVersion(), 'Product Code Name' => PhpFox::getCodeName(), '1' => '', 'Total Time' => $iTotalTime, 'PHP General Time' => $iTotalTime - $iTotalSqlTime, 'GZIP' => Phpfox::getParam('core.use_gzip') ? 'enabled' : 'disabled', '2' => '', 'Driver Version' => $sDriver == 'DATABASE_DRIVER' ? 'N/A' : Phpfox_Database::instance()->getServerInfo(), 'SQL Time' => $iTotalSqlTime, 'SQL Queries' => $iSqlCount, 'SQL Memory Usage' => $oFile->filesize($iSqlMemory), 'SQL Slave Enabled' => $bSlaveEnabled ? 'Yes' : 'No', 'SQL Total Slaves' => $bSlaveEnabled ? count(Phpfox::getParam(array('db', 'slave_servers'))) : 'N/A', 'SQL Slave Server' => $bSlaveEnabled ? Phpfox_Database::instance()->sSlaveServer : 'N/A', '3' => '', 'Total Memory Usage' => $oFile->filesize(PHPFOX_MEM_END), 'Total Memory Usage (Including Debug)' => $oFile->filesize(memory_get_usage()), 'Memory Limit' => $oFile->filesize(self::_getUsableMemory()) . ' (' . @ini_get('memory_limit') . ')', '4' => '', 'Load Balancing Enabled' => Phpfox::getParam(array('balancer', 'enabled')) ? 'Yes' : 'No', 'Requests From' => $oRequest->getServer('SERVER_ADDR'), 'Server ID#' => $oRequest->getServer('PHPFOX_SERVER_ID'), '5' => '', 'Server Time Stamp' => date('F j, Y, g:i a', PHPFOX_TIME), 'PHP Version' => PHP_VERSION, 'PHP Sapi' => php_sapi_name(), 'PHP safe_mode' => PHPFOX_SAFE_MODE ? 'true' : 'false', 'PHP open_basedir' => PHPFOX_OPEN_BASE_DIR ? 'true' : 'false', 'Operating System' => PHP_OS, '6' => '', 'Cache' => Phpfox::getParam('core.cache_storage')); if (extension_loaded('xdebug')) { $aXdebug = array('4' => '', 'xDebug File Name' => xdebug_get_profiler_filename(), 'xDebug Total Time' => xdebug_time_index()); $aStats = array_merge($aStats, $aXdebug); } $sDebugStats = ''; foreach ($aStats as $sStatTitle => $mStatValue) { if (!$mStatValue) { $sDebugStats .= $bIsCmd ? "\n" : "<br />"; } else { $sDebugStats .= $bIsCmd ? "" . $sStatTitle . ": " . $mStatValue . "\n" : "<div class=\"nDebugLeft\">" . $sStatTitle . ":</div><div>" . $mStatValue . "</div>\n<div class=\"nClear\"></div>\n"; } } $aCookies = array(); $sCookiePrefix = Phpfox::getParam('core.session_prefix'); $iPrefixLength = strlen($sCookiePrefix); foreach ($_COOKIE as $sKey => $sValue) { if (substr($sKey, 0, $iPrefixLength) != $sCookiePrefix) { continue; } $aCookies[$sKey] = $sValue; } if ($bIsCmd) { $sDebugReturn .= $sDebugStats; $sDebugReturn .= "##############################################"; } else { $sDebugReturn .= ' <div id="n_debug"> <div id="n_debug_header"> phpFox Developers Debug <a href="#" onclick="if (getCookie(\'js_console\')) { deleteCookie(\'js_console\'); $(\'#firebug_no_console\').remove(); } else { setCookie(\'js_console\', \'1\', 365); p(\'Enabled JavaScript Console\'); } return false;">Toggle JavaScript Console</a> </div> <div class="nDebugItem"><a href="#" onclick="if (getCookie(\'phpfox_debug_detail\')) { deleteCookie(\'phpfox_debug_detail\'); $(\'#phpfox_debug_detail\').slideDown(); } else { $(\'#phpfox_debug_detail\').slideUp(); setCookie(\'phpfox_debug_detail\', \'1\', 365); } return false;">Debug Details</a></div> <div class="nDebugContent nDebugContentShell" id="phpfox_debug_detail"' . (Phpfox::getCookie('phpfox_debug_detail') ? ' style="display:none;"' : '') . '> <div class="nDebugContentShell"> ' . $sDebugStats . ' </div> </div> '; } if (PHPFOX_DEBUG_LEVEL === 3) { if ($bIsCmd) { $sDebugReturn .= $sSql; $sDebugReturn .= "##############################################"; } else { $sDebugReturn .= ' <div class="nDebugItem">SQL Queries</div> <div class="nDebugContent nDebugContentShell" style="height:400px;"> ' . $sSql . ' </div> '; } } /* <div class="nDebugItem">Debug History</div> <div class="nDebugContent nDebugContentShell" style="height:200px;"> <pre>'. self::_loadData(self::$_aDebugHistory) .'</pre> </div> */ if (!$bIsCmd) { $sDebugReturn .= ' <div class="nDebugItem"><a href="#" onclick="if (getCookie(\'phpfox_debug_session\')) { deleteCookie(\'phpfox_debug_session\'); $(\'#phpfox_debug_session\').slideDown(); } else { $(\'#phpfox_debug_session\').slideUp(); setCookie(\'phpfox_debug_session\', \'1\', 365); } return false;">Session</a></div> <div class="nDebugContent nDebugContentShell" id="phpfox_debug_session"' . (Phpfox::getCookie('phpfox_debug_session') ? ' style="display:none;"' : '') . '> <pre>' . self::_loadData($_SESSION[Phpfox::getParam('core.session_prefix')]) . '</pre> </div> <div class="nDebugItem"><a href="#" onclick="if (getCookie(\'phpfox_debug_cookie\')) { deleteCookie(\'phpfox_debug_cookie\'); $(\'#phpfox_debug_cookie\').slideDown(); } else { $(\'#phpfox_debug_cookie\').slideUp(); setCookie(\'phpfox_debug_cookie\', \'1\', 365); } return false;">Cookie</a></div> <div class="nDebugContent nDebugContentShell" id="phpfox_debug_cookie"' . (Phpfox::getCookie('phpfox_debug_cookie') ? ' style="display:none;"' : '') . '> <pre>' . self::_loadData($aCookies) . '</pre> </div> </div> '; } } $sDebugReturn .= '</div>'; if (defined('PHPFOX_DEBUG_SHOW_FIXED')) { $sDebugReturn .= '<div style="position:fixed; bottom:0px; right:5px; background:#fff; border:1px #dfdfdf solid; width:200px; padding:5px; font-size:16px;"> Generated in: ' . round($iTotalTime, 4) . ' <br /> SQL: ' . $iSqlCount . ' (' . $iTotalSqlTime . ') <br /> Server: ' . $_SERVER['SERVER_ADDR'] . ' </div>'; } return $sDebugReturn; }
public function trackUpload() { $sFiles = $this->get('sFiles'); $aFiles = explode(',', $sFiles); $aValues = array(); foreach ($aFiles as $iKey => $sFile) { if (empty($sFile) || $sFile == '.' || $sFile == '..' || strlen($sFile) < 4) { continue; } $aValues[] = array(Phpfox::getUserId(), Phpfox::getCookie('user_hash'), md5($sFile)); } if (!empty($aValues)) { Phpfox::getLib('database')->multiInsert(Phpfox::getT('upload_track'), array('user_id', 'user_hash', 'file_hash'), $aValues); echo 'swfu.startUpload()'; } else { echo 'alert("No valid files were submitted");'; } }
/** * Class constructor */ public function __construct() { $this->_sTable = Phpfox::getT('user'); $iUserId = (int) Phpfox::getCookie('user_id'); $sPasswordHash = Phpfox::getCookie('user_hash'); if (isset($_POST['flash_user_id']) && isset($_POST['sHash'])) { /* $hFile = fopen(PHPFOX_DIR_FILE . 'upload.log', 'a+'); fwrite($hFile, 'user_id = ' . $iUserId . ' AND hash = "' . Phpfox::getLib('parse.input')->clean($_POST['sHash']).'"' . "\n"); fclose($hFile); */ $iUserId = (int)$_POST['flash_user_id']; $aRow = $this->database()->select('*') ->from(Phpfox::getT('upload_track')) ->where('user_id = ' . $iUserId . ' AND hash = "' . Phpfox::getLib('parse.input')->clean($_POST['sHash']).'"') ->execute('getSlaveRow'); $sPasswordHash = $aRow['user_hash']; $sIpAddress = $aRow['ip_address']; if ($sIpAddress != $_SERVER['REMOTE_ADDR']) { $this->_setDefault(); $this->logout(); } } if (defined('PHPFOX_INSTALLER')) { $this->_setDefault(); } else { if ($iUserId > 0) { $sSelect = ''; $sJoin = ''; (($sPlugin = Phpfox_Plugin::get('user.service_auth___construct_start')) ? eval($sPlugin) : false); $oSession = Phpfox::getLib('session'); $oRequest = Phpfox::getLib('request'); $bLoadUserField = false; $sUserFieldSelect = ''; (($sPlugin = Phpfox_Plugin::get('user.service_auth___construct_query')) ? eval($sPlugin) : false); if ($oSession->get('session')) { $this->database()->select('ls.session_hash, ls.id_hash, ls.captcha_hash, ls.user_id, ls.im_status, ')->leftJoin(Phpfox::getT('log_session'), 'ls', "ls.session_hash = '" . $this->database()->escape($oSession->get('session')) . "' AND ls.id_hash = '" . $this->database()->escape($oRequest->getIdHash()) . "'"); } if ((Phpfox::getLib('request')->get('req1') == '' || Phpfox::getLib('request')->get('req1') == 'request' || (Phpfox::getLib('request')->get('req1') == 'theme' && Phpfox::getLib('request')->get('req2') == 'select')) || (Phpfox::isModule('mail') && Phpfox::getParam('mail.display_total_mail_count'))) { $this->database()->select('uc.*, ')->join(Phpfox::getT('user_count'), 'uc', 'uc.user_id = u.user_id'); } if ((Phpfox::getLib('request')->get('req1') == '') || (Phpfox::getLib('request')->get('req1') == 'core')) { $bLoadUserField = true; $sUserFieldSelect .= 'uf.total_view, u.last_login, '; } if (strtolower(Phpfox::getLib('request')->get('req1')) == Phpfox::getParam('admincp.admin_cp')) { $bLoadUserField = true; $sUserFieldSelect .= 'uf.in_admincp, '; } if ($bLoadUserField === true) { $this->database()->select($sUserFieldSelect)->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = u.user_id'); } if (Phpfox::getParam('user.check_promotion_system') || $bLoadUserField === true) { $this->database()->select('uactivity.activity_points, ')->join(Phpfox::getT('user_activity'), 'uactivity', 'uactivity.user_id = u.user_id'); } $this->_aUser = $this->database()->select('u.profile_page_id, u.status_id, u.view_id, u.user_id, u.server_id, u.user_group_id, u.user_name, u.email, u.gender, u.style_id, u.language_id, u.birthday, u.full_name, u.user_image, u.password, u.password_salt, u.joined, u.hide_tip, u.status, u.footer_bar, u.country_iso, u.time_zone, u.dst_check, u.last_activity, u.im_beep, u.im_hide, u.is_invisible, u.total_spam ' . $sSelect) ->from($this->_sTable, 'u') ->where("u.user_id = '" . $this->database()->escape($iUserId) . "'") ->execute('getRow'); if (!isset($this->_aUser['user_id'])) { $this->_setDefault(); $this->logout(); } if (isset($this->_aUser['password']) && isset($this->_aUser['password_salt']) && !Phpfox::getLib('hash')->getRandomHash(Phpfox::getLib('hash')->setHash($this->_aUser['password'], $this->_aUser['password_salt']), $sPasswordHash)) { $this->_setDefault(); $this->logout(); } if (isset($this->_aUser['user_id'])) { $this->_aUser['age'] = Phpfox::getService('user')->age(isset($this->_aUser['birthday']) ? $this->_aUser['birthday'] : ''); $this->_aUser['im_hide'] = ((isset($this->_aUser['is_invisible']) && $this->_aUser['is_invisible']) ? 1 : (isset($this->_aUser['im_hide']) ? $this->_aUser['im_hide'] : 1)); } (($sPlugin = Phpfox_Plugin::get('user.service_auth___construct_end')) ? eval($sPlugin) : false); unset($this->_aUser['password'], $this->_aUser['password_salt']); //Phpfox::getService('core.process')->trackUpload(); } else { $this->_setDefault(); } } }