public function add($iBlockedUserId) { Phpfox::isUser(true); Phpfox::getUserParam('user.can_block_other_members', true); if ($iBlockedUserId == Phpfox::getUserId()) { return Phpfox_Error::set(Phpfox::getPhrase('user.not_able_to_block_yourself')); } if (Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $iBlockedUserId)) { return Phpfox_Error::set(Phpfox::getPhrase('user.you_have_already_blocked_this_user')); } $aUser = Phpfox::getService('user')->getUser($iBlockedUserId, 'u.user_id, u.user_group_id'); if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_be_blocked_by_others')) { return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_block_this_user')); } $this->database()->insert($this->_sTable, array( 'user_id' => Phpfox::getUserId(), 'block_user_id' => (int) $iBlockedUserId, 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp() ) ); Phpfox::getService('friend.process')->deleteFromConnection(Phpfox::getUserId(), $iBlockedUserId); Phpfox::getService('friend.process')->deleteFromConnection($iBlockedUserId, Phpfox::getUserId()); return true; }
public function add($aUserInfo) { $aVals = array('user_group_id' => NORMAL_USER_ID, 'joined' => PHPFOX_TIME, 'last_ip_address' => Phpfox::getIp(), 'last_activity' => PHPFOX_TIME); $aVals['full_name'] = $aUserInfo['displayName']; if (empty($aVals['full_name'])) { Phpfox::getLib('url')->send('janrain.account', array('type' => 'full-name')); } if (!empty($aUserInfo['preferredUsername'])) { $aVals['user_name'] = $aUserInfo['preferredUsername']; } if (empty($aVals['user_name'])) { $aVals['user_name'] = $aUserInfo['displayName']; } if (!empty($aUserInfo['email'])) { Phpfox::getService('user.validate')->email($aUserInfo['email']); if (Phpfox_Error::get()) { Phpfox::getLib('url')->send('janrain.account', array('type' => 'email')); } } $aVals['user_name'] = Phpfox::getLib('parse.input')->prepareTitle('user', $aVals['user_name'], 'user_name', null, Phpfox::getT('user')); $aVals['email'] = empty($aUserInfo['email']) ? null : $aUserInfo['email']; $aVals['gender'] = !isset($aUserInfo['gender']) ? '0' : ($aUserInfo['gender'] == 'female' ? '2' : '1'); $iUserId = $this->database()->insert(Phpfox::getT('user'), $aVals); $aExtras = array('user_id' => $iUserId); $this->database()->insert(Phpfox::getT('user_activity'), $aExtras); $this->database()->insert(Phpfox::getT('user_field'), $aExtras); $this->database()->insert(Phpfox::getT('user_space'), $aExtras); $this->database()->insert(Phpfox::getT('user_count'), $aExtras); $this->database()->insert($this->_sTable, array('user_id' => $iUserId, 'identifier' => md5($aUserInfo['identifier']), 'time_stamp' => PHPFOX_TIME)); if (!empty($aUserInfo['photo'])) { $sImage = $aUserInfo['photo']; $sNewImage = md5($iUserId . PHPFOX_TIME . uniqid()) . '%s.jpg'; Phpfox::getLib('file')->writeToCache($sNewImage, file_get_contents($sImage)); copy(PHPFOX_DIR_CACHE . $sNewImage, Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '')); unlink(PHPFOX_DIR_CACHE . $sNewImage); foreach (Phpfox::getParam('user.user_pic_sizes') as $iSize) { Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize), $iSize, $iSize); Phpfox::getLib('image')->createThumbnail(Phpfox::getParam('core.dir_user') . sprintf($sNewImage, ''), Phpfox::getParam('core.dir_user') . sprintf($sNewImage, '_' . $iSize . '_square'), $iSize, $iSize, false); } Phpfox::getLib('database')->update(Phpfox::getT('user'), array('user_image' => $sNewImage, 'server_id' => 0), 'user_id = ' . (int) $iUserId); } // Taken from user.process->add $iFriendId = (int) Phpfox::getParam('user.on_signup_new_friend'); if ($iFriendId > 0) { $this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iUserId, 'friend_user_id' => $iFriendId, 'time_stamp' => PHPFOX_TIME)); $this->database()->insert(Phpfox::getT('friend'), array('list_id' => 0, 'user_id' => $iFriendId, 'friend_user_id' => $iUserId, 'time_stamp' => PHPFOX_TIME)); Phpfox::getService('friend.process')->updateFriendCount($iUserId, $iFriendId); Phpfox::getService('friend.process')->updateFriendCount($iFriendId, $iUserId); } return $iUserId; }
/** * This function adds a ban filter, it was not renamed after 2.1 for compatibility * @param array $aVals * @param <type> $aBanFilter * @return true */ public function add($aVals, &$aBanFilter = null) { Phpfox::isAdmin(true); $aForm = array('type_id' => array('type' => 'string:required'), 'find_value' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('ban.filter_value_is_required')), 'reason' => array('type' => 'string'), 'days_banned' => array('type' => 'int'), 'return_user_group' => array('type' => 'int'), 'bShow' => array('type' => 'string'), 'user_groups_affected' => array('type' => 'array')); if ($aBanFilter !== null && isset($aBanFilter['replace'])) { $aForm['replacement'] = array('type' => 'string:required', 'message' => Phpfox::getPhrase('ban.filter_replacement_is_required')); } $aVals = $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } if ($aVals['find_value'] == Phpfox::getIp()) { return Phpfox_Error::set('You cannot ban yourself.'); } $aVals['user_id'] = Phpfox::getUserId(); $aVals['time_stamp'] = PHPFOX_TIME; $aVals['find_value'] = $this->preParse()->convert($aVals['find_value']); if (isset($aVals['bShow']) && $aVals['bShow'] == '0' || !isset($aVals['bShow'])) { unset($aVals['reason']); unset($aVals['days_banned']); unset($aVals['return_user_group']); } else { $aVals['reason'] = !Phpfox_Locale::instance()->isPhrase($aVals['reason']) ? Phpfox::getLib('parse.input')->clean($aVals['reason']) : $aVals['reason']; $aVals['days_banned'] = (int) $aVals['days_banned']; $aVals['return_user_group'] = (int) $aVals['return_user_group']; if (!isset($aVals['user_groups_affected'])) { $aVals['user_groups_affected'] = array(); } $aVals['user_groups_affected'] = serialize($aVals['user_groups_affected']); } unset($aVals['bShow']); if (isset($aVals['replacement'])) { $aVals['replacement'] = $this->preParse()->convert($aVals['replacement']); } if (empty($aVals['user_groups_affected'])) { $aVals['user_groups_affected'] = ''; } $this->database()->insert($this->_sTable, $aVals); $this->cache()->remove('ban', 'substr'); return true; }
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()); } } }
* */ define('PHPFOX_DS', DIRECTORY_SEPARATOR); /** * phpFox Root Directory * */ define('PHPFOX_DIR', dirname(dirname(__FILE__)) . PHPFOX_DS); if (isset($_GET['ajax_page_display'])) { define('PHPFOX_IS_AJAX_PAGE', true); } else { define('PHPFOX_IS_AJAX', true); } // Require phpFox Init require PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php'; if (!Phpfox::getService('ban')->check('ip', Phpfox::getIp())) { exit; } if (isset($_GET['ajax_page_display'])) { $oCache = Phpfox::getLib('cache'); $oAjax = Phpfox::getLib('ajax'); if (Phpfox::getLib('template')->getThemeFolder() == 'nebula') { $oTpl = Phpfox::getLib('template'); $sUserProfileImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => Phpfox::getService('user')->getUserFields(true)), array('path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_50_square', 'max_width' => 50, 'max_height' => 50))); $oTpl->assign(array('sUserProfileImage' => $sUserProfileImage, 'sUserProfileUrl' => Phpfox::getLib('url')->makeUrl('profile', Phpfox::getUserBy('user_name')), 'sCurrentUserName' => Phpfox::getLib('parse.output')->shorten(Phpfox::getLib('parse.output')->clean(Phpfox::getUserBy('full_name')), Phpfox::getParam('user.max_length_for_username'), '...'))); } Phpfox::run(); $aHeaderFiles = Phpfox::getLib('template')->getHeader(true); if (Phpfox::getLib('template')->sDisplayLayout) { Phpfox::getLib('template')->getLayout(Phpfox::getLib('template')->sDisplayLayout); }
/** * This function checks if the hash submitted is valid. * In every case it deletes the hash from the database, if the hash expired it creates a new one and sends an email to the user. * @param String $sHash * @param Boolean $bStrict tells if we should check if the password has expired, added to complement the adminVerify * @return boolean false if the hash is not found on the db or if it has expired | true if the hash matches */ public function verify($sHash, $bStrict = true) { $aVerify = $this->database()->select('uv.user_id, uv.email as newMail, u.password, uv.time_stamp')->join(Phpfox::getT('user'), 'u', 'u.user_id = uv.user_id')->from($this->_sTable, 'uv')->where('uv.hash_code = \'' . Phpfox::getLib('parse.input')->clean($sHash) . '\'')->execute('getSlaveRow'); if (empty($aVerify)) { return false; } /** * @ToDo what do we do if the entry is not found? do we allow the user to log in? */ // Delete the entry from the user_verify table $this->database()->delete($this->_sTable, 'user_id = ' . $aVerify['user_id']); if (Phpfox::getParam('user.verify_email_timeout') == 0 || $aVerify['time_stamp'] + Phpfox::getParam('user.verify_email_timeout') * 60 >= Phpfox::getTime()) { $bValid = true; ($sPlugin = Phpfox_Plugin::get('user.service_verify_process_verify_pass')) ? eval($sPlugin) : false; $this->database()->update(Phpfox::getT('user'), array('status_id' => 0, 'email' => $aVerify['newMail']), 'user_id = ' . $aVerify['user_id']); $this->database()->update(Phpfox::getT('photo'), array('view_id' => '0'), 'view_id = 3 AND user_id = ' . $aVerify['user_id']); // update the friends count when "on signup new friend is enabled if (Phpfox::getParam('user.on_signup_new_friend')) { Phpfox::getService('friend.process')->updateFriendCount($aVerify['user_id'], Phpfox::getParam('user.on_signup_new_friend')); Phpfox::getService('friend.process')->updateFriendCount(Phpfox::getParam('user.on_signup_new_friend'), $aVerify['user_id']); } // Send the welcome email Phpfox::getLib('mail')->to($aVerify['user_id'])->subject(array('core.welcome_email_subject', array('site' => Phpfox::getParam('core.site_title'))))->message(array('core.welcome_email_content'))->send(); return true; } else { $bValid = false; } if ($bStrict === false) { return true; } // Its invalid (timeout) so add the entry to the error log table $aError = array('ip_address' => Phpfox::getIp(), 'hash_code' => Phpfox::getLib('parse.input')->prepare($sHash), 'email' => $aVerify['newMail'], 'time_stamp' => Phpfox::getTime()); $this->database()->insert(Phpfox::getT('user_verify_error'), $aError); return false; }
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()); } }
private function _completed() { if (Phpfox::getLib('file')->isWritable(PHPFOX_DIR_SETTING . 'server.sett.php')) { $sContent = file_get_contents(PHPFOX_DIR_SETTING . 'server.sett.php'); $sContent = preg_replace("/\\\$_CONF\['core.is_installed'\] = (.*?);/i", "\\\$_CONF['core.is_installed'] = true;", $sContent); if ($hServerConf = @fopen(PHPFOX_DIR_SETTING . 'server.sett.php', 'w')) { fwrite($hServerConf, $sContent); fclose($hServerConf); } } if (!defined('PHPFOX_SKIP_INSTALL_KEY')) { $oApi = Phpfox::getLib('phpfox.api'); if ($oApi->send('brandingRemoval')) { Phpfox::getLib('database')->update(Phpfox::getT('setting'), array('value_actual' => '1'), "var_name = 'branding'"); } } $this->_db()->update(Phpfox::getT('setting'), array('value_actual' => Phpfox::getVersion()), 'var_name = \'phpfox_version\''); if ($this->_bUpgrade) { $iCurrentVersion = $this->_getCurrentVersion(); if (!$this->_db()->select('COUNT(*)') ->from(Phpfox::getT('install_log')) ->where('is_upgrade = 1 AND version_id = \'' . $iCurrentVersion . '\' AND upgrade_version_id = \'' . Phpfox::getVersion() . '\'') ->execute('getField') ) { $this->_db()->insert(Phpfox::getT('install_log'), array( 'is_upgrade' => '1', 'version_id' => $this->_getCurrentVersion(), 'upgrade_version_id' => Phpfox::getVersion(), 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp() ) ); } } else { if (!$this->_db()->select('COUNT(*)') ->from(Phpfox::getT('install_log')) ->where('is_upgrade = 0 AND version_id = \'' . Phpfox::getVersion() . '\' AND ' . $this->_db()->isNull('upgrade_version_id') . '') ->execute('getField') ) { $this->_db()->insert(Phpfox::getT('install_log'), array( 'version_id' => Phpfox::getVersion(), 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp() ) ); } } Phpfox::getLib('cache')->remove(); $this->_oTpl->assign(array( 'bIsUpgrade' => $this->_bUpgrade, 'sUpgradeVersion' => Phpfox::getVersion() ) ); }
/** * This function allows a user to log in as another user. * @param array $aUser * @return boolean */ public function snoop($aUser) { Phpfox::isUser(true); if (!Phpfox::getUserParam('user.can_member_snoop')) { return Phpfox_Error::set('Admin lacks permissions'); } $sPasswordHash = Phpfox::getLib('hash')->setRandomHash(Phpfox::getLib('hash')->setHash($aUser['password'], $aUser['password_salt'])); // Set cookie (yummy) $iTime = 0; $this->database()->insert(Phpfox::getT('user_snoop'), array('time_stamp' => PHPFOX_TIME, 'user_id' => Phpfox::getUserId(), 'logging_in_as' => $aUser['user_id'])); Phpfox::setCookie($this->_sNameCookieUserId, $aUser['user_id'], $iTime); Phpfox::setCookie($this->_sNameCookieHash, $sPasswordHash, $iTime); if (!defined('PHPFOX_INSTALLER')) { Phpfox::getLib('session')->remove(Phpfox::getParam('core.theme_session_prefix') . 'theme'); } $this->database()->update($this->_sTable, array('last_login' => PHPFOX_TIME), 'user_id = ' . $aUser['user_id']); $this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => $aUser['user_id'], 'type_id' => 'login', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME)); return true; }
private function _completed() { if (Phpfox_File::instance()->isWritable(PHPFOX_DIR_SETTINGS . 'server.sett.php')) { $sContent = file_get_contents(PHPFOX_DIR_SETTINGS . 'server.sett.php'); $sContent = preg_replace("/\\\$_CONF\\['core.is_installed'\\] = (.*?);/i", "\\\$_CONF['core.is_installed'] = true;", $sContent); if ($hServerConf = @fopen(PHPFOX_DIR_SETTINGS . 'server.sett.php', 'w')) { fwrite($hServerConf, $sContent); fclose($hServerConf); } } $license = file_get_contents(PHPFOX_DIR_SETTINGS . 'license.php'); file_put_contents(PHPFOX_DIR_SETTINGS . 'license.sett.php', $license); unlink(PHPFOX_DIR_SETTINGS . 'license.php'); /* if (!defined('PHPFOX_SKIP_INSTALL_KEY')) { $oApi = Phpfox::getLib('phpfox.api'); if ($oApi->send('brandingRemoval')) { Phpfox_Database::instance()->update(Phpfox::getT('setting'), array('value_actual' => '1'), "var_name = 'branding'"); } } */ $this->_db()->update(Phpfox::getT('setting'), array('value_actual' => Phpfox::getVersion()), 'var_name = \'phpfox_version\''); $this->_db()->update(Phpfox::getT('setting'), array('value_actual' => date('j/n/Y', PHPFOX_TIME)), 'var_name = \'official_launch_of_site\''); $this->_db()->update(Phpfox::getT('module'), array('is_active' => '0'), 'module_id = \'microblog\''); $this->_db()->update(Phpfox::getT('user_group_setting'), array('is_hidden' => '1'), 'name = \'custom_table_name\''); if ($this->_bUpgrade) { $iCurrentVersion = $this->_getCurrentVersion(); if (!$this->_db()->select('COUNT(*)')->from(Phpfox::getT('install_log'))->where('is_upgrade = 1 AND version_id = \'' . $iCurrentVersion . '\' AND upgrade_version_id = \'' . Phpfox::getVersion() . '\'')->execute('getField')) { $this->_db()->insert(Phpfox::getT('install_log'), array('is_upgrade' => '1', 'version_id' => $this->_getCurrentVersion(), 'upgrade_version_id' => Phpfox::getVersion(), 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp())); } } else { // $this->_db()->update(Phpfox::getT('theme_style'), array('is_default' => '0'), 'style_id > 0'); // $this->_db()->update(Phpfox::getT('theme_style'), array('is_default' => '1'), 'folder = \'nebula\''); if (!$this->_db()->select('COUNT(*)')->from(Phpfox::getT('install_log'))->where('is_upgrade = 0 AND version_id = \'' . Phpfox::getVersion() . '\' AND ' . $this->_db()->isNull('upgrade_version_id') . '')->execute('getField')) { $this->_db()->insert(Phpfox::getT('install_log'), array('version_id' => Phpfox::getVersion(), 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp())); } } Phpfox::getLib('cache')->remove(); $this->_oTpl->assign(array('bIsUpgrade' => $this->_bUpgrade, 'sUpgradeVersion' => Phpfox::getVersion())); }
/** * Get an ads redirection URL and update the "click" count for the ad. * * @param int $iId ID# for the ad. * @return string URL of the ad, which can be used to send the user to that page. */ public function getAdRedirect($iId) { ($sPlugin = Phpfox_Plugin::get('ad.service_ad_getadredirect__start')) ? eval($sPlugin) : false; $aAd = $this->database()->select('ad_id, location, url_link, is_cpm, total_click, count_click')->from($this->_sTable)->where('ad_id = ' . (int) $iId)->execute('getSlaveRow'); if (!isset($aAd['ad_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('ad.the_ad_you_are_looking_for_does_not_exist')); } $this->cache()->remove('ad_' . $aAd['location']); if ($aAd['is_cpm'] != 1 && $aAd['count_click'] >= $aAd['total_click']) { $this->database()->update(Phpfox::getT('ad'), array('is_active' => '0'), 'ad_id =' . $aAd['ad_id']); return Phpfox_Error::set(Phpfox::getPhrase('ad.the_ad_you_are_looking_for_does_not_exist')); } $aTrack = $this->database()->select('track_id')->from(Phpfox::getT('ad_track'))->where(Phpfox::isUser() ? 'ad_id = ' . $aAd['ad_id'] . ' AND user_id = ' . Phpfox::getUserId() : 'ad_id = ' . $aAd['ad_id'] . ' AND ip_address = \'' . $this->database()->escape(Phpfox::getIp()) . '\'')->execute('getRow'); if (!isset($aTrack['track_id'])) { $this->database()->updateCounter('ad', 'count_click', 'ad_id', $aAd['ad_id']); $this->database()->insert(Phpfox::getT('ad_track'), array('ad_id' => $aAd['ad_id'], 'user_id' => Phpfox::getUserId(), 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME)); } ($sPlugin = Phpfox_Plugin::get('ad.service_ad_getadredirect__end')) ? eval($sPlugin) : false; return $aAd['url_link']; }
public function login($iPageId) { $aPage = $this->database()->select('p.*, p.user_id AS owner_user_id, u.*')->from(Phpfox::getT('pages'), 'p')->join(Phpfox::getT('user'), 'u', 'u.profile_page_id = p.page_id')->where('p.page_id = ' . (int) $iPageId)->execute('getSlaveRow'); if (!isset($aPage['page_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('pages.unable_to_find_the_page_you_are_trying_to_login_to')); } $iCurrentUserId = Phpfox::getUserId(); $bCanLogin = false; if ($aPage['owner_user_id'] == Phpfox::getUserId()) { $bCanLogin = true; } if (!$bCanLogin) { $iAdmin = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('pages_admin'))->where('page_id = ' . (int) $aPage['page_id'] . ' AND user_id = ' . (int) Phpfox::getUserId())->execute('getSlaveField'); if ($iAdmin) { $bCanLogin = true; } } if (!$bCanLogin) { return Phpfox_Error::set(Phpfox::getPhrase('pages.unable_to_log_in_as_this_page')); } if (Phpfox::getParam('core.auth_user_via_session')) { $this->database()->delete(Phpfox::getT('session'), 'user_id = ' . (int) Phpfox::getUserId()); $this->database()->insert(Phpfox::getT('session'), array('user_id' => $aPage['user_id'], 'last_activity' => PHPFOX_TIME, 'id_hash' => Phpfox_Request::instance()->getIdHash())); } $sPasswordHash = Phpfox::getLib('hash')->setRandomHash(Phpfox::getLib('hash')->setHash($aPage['password'], $aPage['password_salt'])); $iTime = 0; $aUserCookieNames = Phpfox::getService('user.auth')->getCookieNames(); Phpfox::setCookie($aUserCookieNames[0], $aPage['user_id'], $iTime); Phpfox::setCookie($aUserCookieNames[1], $sPasswordHash, $iTime); Phpfox::getLib('session')->remove(Phpfox::getParam('core.theme_session_prefix') . 'theme'); $this->database()->update(Phpfox::getT('user'), array('last_login' => PHPFOX_TIME), 'user_id = ' . $aPage['user_id']); $this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => $aPage['user_id'], 'type_id' => 'login', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME)); $iLoginId = $this->database()->insert(Phpfox::getT('pages_login'), array('page_id' => $aPage['page_id'], 'user_id' => $iCurrentUserId, 'time_stamp' => PHPFOX_TIME)); Phpfox::setCookie('page_login', $iLoginId, $iTime); return true; }
public function getFeed($iId) { $sCacheId = $this->cache()->set('rss_feed_' . $iId); if (!($aFeed = $this->cache()->get($sCacheId))) { $aFeed = $this->database()->select('r.*')->from($this->_sTable, 'r')->where('r.feed_id = ' . (int) $iId . ' AND r.is_active = 1')->order('r.ordering ASC')->execute('getSlaveRow'); if (!isset($aFeed['feed_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('rss.unable_to_find_rss_feed')); } $this->cache()->save($sCacheId, $aFeed); } $sDescription = Phpfox::getPhrase($aFeed['description_var']); eval($aFeed['php_view_code']); if (!isset($aRows) || isset($aRows) && !is_array($aRows)) { return Phpfox_Error::trigger(Phpfox::getPhrase('rss.not_a_valid_rss_feed_php_code_failed'), E_USER_ERROR); } $iLog = $this->database()->select('COUNT(*)')->from(Phpfox::getT('rss_log'))->where('feed_id = ' . $aFeed['feed_id'] . ' AND id_hash = \'' . Phpfox::getLib('request')->getIdHash() . '\'')->execute('getSlaveField'); if (!$iLog) { $this->database()->insert(Phpfox::getT('rss_log'), array('feed_id' => $aFeed['feed_id'], 'id_hash' => Phpfox::getLib('request')->getIdHash(), 'ip_address' => Phpfox::getIp(), 'user_agent' => Phpfox::getLib('request')->getBrowser(), 'time_stamp' => PHPFOX_TIME)); $this->database()->updateCounter('rss', 'total_subscribed', 'feed_id', $aFeed['feed_id']); } $oXmlBuilder = Phpfox::getLib('xml.builder'); $oXmlBuilder->setXml(array('version' => '1.0', 'encoding' => 'UTF-8')); $oXmlBuilder->addGroup('rss', array('version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', 'xmlns:atom' => 'http://www.w3.org/2005/Atom')); $oXmlBuilder->addGroup('channel'); $oXmlBuilder->addTag('atom:link', '', array('href' => Phpfox::getLib('url')->makeUrl('rss', array('id' => $aFeed['feed_id'])), 'rel' => 'self', 'type' => 'application/rss+xml'))->addTag('title', html_entity_decode(Phpfox::getPhrase($aFeed['title_var'])), null, 'UTF-8')->addTag('link', Phpfox::getLib('url')->makeUrl($aFeed['feed_link']))->addTag('description', html_entity_decode($sDescription, null, 'UTF-8')); foreach ($aRows as $aItem) { $aItem['title'] = html_entity_decode($aItem['title'], null, 'UTF-8'); $aItem['title'] = str_replace('"', '"', $aItem['title']); $oXmlBuilder->addGroup('item'); $oXmlBuilder->addTag('title', $aItem['title']); $oXmlBuilder->addTag('link', $aItem['link']); $oXmlBuilder->addTag('description', Phpfox::getLib('parse.output')->shorten($aItem['description'], 150, '...')); $oXmlBuilder->addTag('content:encoded', $aItem['description']); $oXmlBuilder->addTag('guid', $aItem['link']); $oXmlBuilder->addTag('pubDate', date('r', $aItem['time_stamp'])); $oXmlBuilder->addTag('dc:creator', Phpfox::getLib('parse.output')->clean($aItem['creator'])); $oXmlBuilder->closeGroup('item'); // item } $oXmlBuilder->closeGroup(); // channel $oXmlBuilder->closeGroup(); // rss return $oXmlBuilder->output(); }
/** * Starts the phpFox engine. Used to get and display the pages controller. * */ public static function run() { $oTpl = Phpfox::getLib('template'); $aLocale = Phpfox::getLib('locale')->getLang(); $oReq = Phpfox::getLib('request'); $oModule = Phpfox::getLib('module'); $cache_id = Phpfox::getLib('cache')->set('auth_token_' . $_SERVER['REMOTE_ADDR']); if (defined('PHPFOX_FORCE_TOKEN') && !Phpfox::getLib('cache')->get($cache_id, 60)) { require_once PHPFOX_DIR_LIB . 'recaptcha' . PHPFOX_DS . 'recaptchalib.php'; $failed = ''; if (!empty($_POST["recaptcha_challenge_field"])) { $resp = recaptcha_check_answer(PHPFOX_FORCE_PRIVATE, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $failed = '<div class="error">Captcha Failed. Try again!</div>'; } else { Phpfox::getLib('cache')->save($cache_id, true); ob_clean(); header('Location: ' . Phpfox::getParam('core.path')); exit; } } $html = ' <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en"> <head> <title>Human Verification</title> <style type="text/css"> body { background:#e2e2e2; margin:0px; font-size:90%; font:inherit; vertical-align: baseline; font-family: "Helvetica Neue", Arial, sans-serif; font-size:90%; color:#333; line-height:1.5; word-wrap:break-word; } #site_auth { background:#fff; margin-top:200px; text-align:center; padding:50px 0px 50px 0px; } #site_auth form { margin:0px; padding:0px; max-width:500px; margin:auto; } h1 { font-size:2.6em; font-weight:300; letter-spacing:2px; } p { padding:0px 0px 20px 0px; margin:0px; color:#808080; font-size:0.9em; } .submit { margin:20px 0px 0px 0px; padding:10px 30px 10px 30px; background:#71B33D; color:#fff; font-size:1.1em; border:0px; text-transform:uppercase; cursor:pointer; border-radius:3px; } .error { background:#EA5859; color:#fff; padding:20px; margin-bottom:10px; font-size:1.2em; } </style> </head> <body> <div id="site_auth"> <form method="post" action="' . Phpfox::getParam('core.path') . '"> <h1>Human Verification</h1> <p> This site requires you to be a human in order to view the site. Please take a moment to pass the captcha below. Once you have verified you are human you will get a 1 hour token to view the site, thereafter you must renew your token. </p> ' . $failed . ' <div style="margin:auto; display:inline-block;">' . recaptcha_get_html(PHPFOX_FORCE_KEY) . '</div> <div> <input type="submit" value="Submit" class="submit" /> </div> </form> </div> </body> </html> '; echo $html; exit; } ($sPlugin = Phpfox_Plugin::get('run_start')) ? eval($sPlugin) : false; // Load module blocks $oModule->loadBlocks(); if (Phpfox::isMobile() && $oReq->get('req1') == 'go-to-full-site') { Phpfox::getLib('session')->set('mobilestatus', 'true'); Phpfox::getLib('url')->send('phpfox_full_site'); } if (!Phpfox::getParam('core.branding')) { $oTpl->setHeader(array('<meta name="author" content="phpFox" />')); } if (strtolower(Phpfox::getLib('request')->get('req1')) == Phpfox::getParam('admincp.admin_cp')) { self::$_bIsAdminCp = true; } $sImage = Phpfox::getUserBy('user_image'); $bIsAd = false; $oRequest = Phpfox::getLib('request'); if ($oRequest->get('id') && $oRequest->get('req1') == 'ad' && $oRequest->get('req2') == 'iframe') { $bIsAd = true; } if (!Phpfox::getService('ban')->check('ip', Phpfox::getIp())) { $oModule->setController('ban.message'); } else { if (!self::$_bIsAdminCp && Phpfox::getParam('core.site_is_offline') && !Phpfox::getUserParam('core.can_view_site_offline') && $bIsAd != true) { if (Phpfox::getLib('request')->get('req1') == 'user' && (Phpfox::getLib('request')->get('req2') == 'login' || Phpfox::getLib('request')->get('req2') == 'logout') || Phpfox::getLib('request')->get('req1') == 'contact' || Phpfox::getLib('request')->get('req1') == 'captcha') { $oModule->setController(); } else { $oModule->setController('core.offline'); } } else { $oModule->setController(); } } if (!PHPFOX_IS_AJAX_PAGE) { if (Phpfox::isMobile()) { $oTpl->setMobileHeader(array('<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />')); } $oTpl->setImage(array('ajax_small' => 'ajax/small.gif', 'ajax_large' => 'ajax/large.gif', 'loading_animation' => 'misc/loading_animation.gif', 'close' => 'misc/close.gif', 'move' => 'misc/move.png', 'calendar' => 'jquery/calendar.gif')); $oTpl->setHeader(array('<meta http-equiv="Content-Type" content="text/html; charset=' . $aLocale['charset'] . '" />', '<meta http-equiv="cache-control" content="no-cache" />', '<meta http-equiv="expires" content="-1" />', '<meta http-equiv="pragma" content="no-cache" />', '<link rel="shortcut icon" type="image/x-icon" href="' . Phpfox::getParam('core.path') . 'favicon.ico?v=' . $oTpl->getStaticVersion() . '" />'))->setMeta('keywords', Phpfox::getLib('locale')->convert(Phpfox::getParam('core.keywords')))->setMeta('robots', 'index,follow'); if (Phpfox::getParam('core.include_master_files') && Phpfox::isAdminPanel() != true) { $oTpl->setHeader('master', Phpfox::getMasterFiles()); } else { $oTpl->setHeader('cache', Phpfox::getMasterFiles()); } if (!defined('PHPFOX_IS_AD_PREVIEW') && !defined('PHPFOX_IN_DESIGN_MODE') && !defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.site_wide_ajax_browsing')) { $oTpl->setHeader('cache', array('jquery/plugin/jquery.address.js' => 'static_script')); } if (Phpfox::isModule('photo') && Phpfox::getParam('photo.pre_load_header_view')) { $oTpl->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'jquery/plugin/imgnotes/jquery.tag.js' => 'static_script', 'jquery/plugin/imgnotes/jquery.imgareaselect.js' => 'static_script', 'jquery/plugin/imgnotes/jquery.imgnotes.js' => 'static_script', 'imgnotes.css' => 'style_css', 'imgareaselect-default.css' => 'style_css', 'quick_edit.js' => 'static_script', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'view.js' => 'module_photo', 'photo.js' => 'module_photo', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'view.css' => 'module_photo', 'feed.js' => 'module_feed', 'edit.css' => 'module_photo', 'index.js' => 'module_photo')); } if (Phpfox::isModule('friend')) { $oTpl->setPhrase(array('friend.show_more_results_for_search_term')); } if (PHPFOX_DEBUG) { $oTpl->setHeader('cache', array('debug.css' => 'style_css')); } if (!Phpfox::isMobile() && Phpfox::isUser() && Phpfox::getParam('user.enable_user_tooltip')) { $oTpl->setHeader('cache', array('user_info.js' => 'static_script')); } if (Phpfox::isModule('captcha') && Phpfox::getParam('captcha.recaptcha')) { // http://www.phpfox.com/tracker/view/14456/ $sUrl = (Phpfox::getParam('core.force_https_secure_pages') ? 'https' : 'http') . "://www.google.com/recaptcha/api/js/recaptcha_ajax.js"; $oTpl->setHeader('<script type="text/javascript" src="' . $sUrl . '"></script>'); } } if ($sPlugin = Phpfox_Plugin::get('get_controller')) { eval($sPlugin); } $oModule->getController(); Phpfox::getService('admincp.seo')->setHeaders(); if (!defined('PHPFOX_DONT_SAVE_PAGE')) { Phpfox::getLib('session')->set('redirect', Phpfox::getLib('url')->getFullUrl(true)); } if (!defined('PHPFOX_NO_CSRF')) { Phpfox::getService('log.session')->verifyToken(); } ($sPlugin = Phpfox_Plugin::get('run')) ? eval($sPlugin) : false; if (!self::isAdminPanel()) { if (!Phpfox::isMobile() && !PHPFOX_IS_AJAX_PAGE && Phpfox::isModule('rss') && !defined('PHPFOX_IS_USER_PROFILE')) { $aFeeds = Phpfox::getService('rss')->getLinks(); if (is_array($aFeeds) && count($aFeeds)) { foreach ($aFeeds as $sLink => $sPhrase) { $oTpl->setHeader('<link rel="alternate" type="application/rss+xml" title="' . $sPhrase . '" href="' . $sLink . '" />'); } } } $aPageLastLogin = Phpfox::isModule('pages') && Phpfox::getUserBy('profile_page_id') ? Phpfox::getService('pages')->getLastLogin() : false; $oTpl->assign(array('aMainMenus' => $oTpl->getMenu('main'), 'aRightMenus' => $oTpl->getMenu('main_right'), 'aAppMenus' => $oTpl->getMenu('explore'), 'aSubMenus' => $oTpl->getMenu(), 'aFooterMenu' => $oTpl->getMenu('footer'), 'aBlocks1' => $oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(1), 'aBlocks3' => $oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(3), 'aAdBlocks1' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(1, false, false) : null), 'aAdBlocks3' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(3, false, false) : null), 'bIsUsersProfilePage' => defined('PHPFOX_IS_USER_PROFILE') ? true : false, 'sStyleLogo' => $oTpl->getStyleLogo(), 'aStyleInUse' => $oTpl->getStyleInUse(), 'sGlobalUserFullName' => Phpfox::isUser() ? Phpfox::getUserBy('full_name') : null, 'aGlobalUser' => Phpfox::isUser() ? Phpfox::getUserBy(null) : array(), 'sFullControllerName' => str_replace(array('.', '/'), '_', Phpfox::getLib('module')->getFullControllerName()), 'iGlobalProfilePageId' => Phpfox::getUserBy('profile_page_id'), 'aGlobalProfilePageLogin' => $aPageLastLogin, 'aInstalledApps' => Phpfox::isUser() && Phpfox::isModule('apps') ? Phpfox::getService('apps')->getInstalledApps() : array(), 'sSiteTitle' => Phpfox::getParam('core.site_title'))); $oTpl->setEditor(); if (isset($aPageLastLogin['style_id']) && $aPageLastLogin['style_id'] > 0) { Phpfox::getLib('template')->testStyle($aPageLastLogin['style_id']); } if (Phpfox::isModule('captcha')) { $sCaptchaHeader = Phpfox::getParam('captcha.recaptcha_header'); if (strlen(preg_replace('/\\s\\s+/', '', $sCaptchaHeader)) > 0) { $oTpl->setHeader(array($sCaptchaHeader)); } } if (!PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_SKIP_IM')) { if (!defined('PHPFOX_IN_DESIGN_MODE')) { if (Phpfox::isUser() && Phpfox::isModule('subscribe') && Phpfox::getParam('subscribe.subscribe_is_required_on_sign_up') && Phpfox::getUserBy('user_group_id') == '2' && (int) Phpfox::getUserBy('subscribe_id') > 0) { } else { if (Phpfox::isModule('notification') && Phpfox::isUser() && Phpfox::getParam('notification.notify_on_new_request')) { $oTpl->setHeader('cache', array('update.js' => 'module_notification')); } if (!Phpfox::isMobile() && Phpfox::isModule('im') && Phpfox::isUser() && Phpfox::getUserBy('profile_page_id') <= 0 && Phpfox::getParam('im.enable_im_in_footer_bar') && !$oTpl->bIsSample) { $oTpl->setPhrase(array('im.conversations', 'im.more_conversations', 'im.are_you_sure'))->setImage(array('misc_minimize' => 'misc/minimize.gif'))->setHeader('cache', array('im.js' => 'module_im', 'im.css' => 'style_css', 'player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script'))->setHeader(array('<script type="text/javascript">oCore[\'im.is_hidden\'] = \'' . Phpfox::getUserBy('im_hide') . '\';</script>', '<script type="text/javascript">$Behavior.loadMusicPlayer = function() { if (typeof $f == \'undefined\') { $Core.loadStaticFile(\'' . $oTpl->getStyle('static_script', 'player/' . Phpfox::getParam('core.default_music_player') . '/' . Phpfox::getParam('core.default_music_player')) . '.js\'); } else { $Core.player.load({id: \'js_im_player\', type: \'music\'}); } $Behavior.loadMusicPlayer = function() {} }</script>')); } } } } } if (!PHPFOX_IS_AJAX_PAGE && ($sHeaderFile = $oTpl->getHeaderFile())) { ($sPlugin = Phpfox_Plugin::get('run_get_header_file_1')) ? eval($sPlugin) : false; require_once $sHeaderFile; } list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb(); /* Delayed unlink, we now delete all the images */ if (Phpfox::getParam('core.keep_files_in_server') == false) { $oSess = Phpfox::getLib('session'); $aFiles = $oSess->get('deleteFiles'); if (is_array($aFiles)) { foreach ($aFiles as $sFile) { if (file_exists($sFile)) { unlink($sFile); } } } $oSess->remove('deleteFiles'); } $oTpl->assign(array('aErrors' => Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array(), 'sPublicMessage' => Phpfox::getMessage(), 'sLocaleDirection' => $aLocale['direction'], 'sLocaleCode' => $aLocale['language_code'], 'sLocaleFlagId' => $aLocale['image'], 'sLocaleName' => $aLocale['title'], 'aRequests' => Phpfox::getLib('request')->getRequests(), 'aBreadCrumbs' => $aBreadCrumbs, 'aBreadCrumbTitle' => $aBreadCrumbTitle, 'sCopyright' => '© ' . Phpfox::getPhrase('core.copyright') . ' ' . Phpfox::getParam('core.site_copyright'))); Phpfox::clearMessage(); unset($_SESSION['phpfox']['image']); if (Phpfox::getParam('core.cron')) { require_once PHPFOX_DIR_CRON . 'exec.php'; } if (!PHPFOX_IS_AJAX_PAGE && $oTpl->sDisplayLayout) { $oTpl->getLayout($oTpl->sDisplayLayout); } if (Phpfox::getParam('language.cache_phrases')) { Phpfox::getLib('locale')->cache(); } // Use GZIP to output the data if we can if (Phpfox::getParam('core.use_gzip') && !PHPFOX_IS_AJAX_PAGE) { $sContent = ob_get_contents(); ob_clean(); if (function_exists('gzencode')) { $sGzipContent = gzencode($sContent, Phpfox::getParam('core.gzip_level'), FORCE_GZIP); } else { if (function_exists('gzcompress') && function_exists('crc32')) { $iSize = strlen($sContent); $iCrc = crc32($sContent); $sGzipContent = "‹ÿ"; $sGzipContent .= substr(gzcompress($sContent, Phpfox::getParam('core.gzip_level')), 2, -4); $sGzipContent .= pack('V', $iCrc); $sGzipContent .= pack('V', $iSize); } } $sOutputContent = isset($sGzipContent) ? $sGzipContent : $sContent; if (Phpfox::getParam('core.check_body_for_text') && !defined('PHPFOX_INSTALLER') && Phpfox::getLib('request')->get('req1') != 'ad') { if (!preg_match(Phpfox::getParam('core.check_body_regex'), $sContent)) { header(Phpfox::getParam('core.check_body_header')); echo Phpfox::getParam('core.check_body_offline_message'); exit; } } if (isset($sGzipContent)) { header("Content-Encoding: " . (in_array('x-gzip', Phpfox::getParam('core.gzip_encodings')) ? "x-gzip" : "gzip")); } echo $sOutputContent; } }
public function updatePassword($aVals) { Phpfox::isUser(true); if (empty($aVals['old_password'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.missing_old_password')); } if (empty($aVals['new_password'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.missing_new_password')); } if (empty($aVals['confirm_password'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.confirm_your_new_password')); } if ($aVals['confirm_password'] != $aVals['new_password']) { return Phpfox_Error::set(Phpfox::getPhrase('user.your_confirmed_password_does_not_match_your_new_password')); } $aUser = Phpfox::getService('user')->getUser(Phpfox::getUserId()); if (Phpfox::getLib('hash')->setHash($aVals['old_password'], $aUser['password_salt']) != $aUser['password']) { return Phpfox_Error::set(Phpfox::getPhrase('user.your_current_password_does_not_match_your_old_password')); } $sSalt = $this->_getSalt(); $aInsert = array(); $aInsert['password'] = Phpfox::getLib('hash')->setHash($aVals['new_password'], $sSalt); $aInsert['password_salt'] = $sSalt; $this->database()->update($this->_sTable, $aInsert, 'user_id = ' . Phpfox::getUserId()); list($bLogged, $aUser) = Phpfox::getService('user.auth')->login($aUser['email'], $aVals['new_password'], false, 'email'); $this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => Phpfox::getUserId(), 'type_id' => 'update_password', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME)); ($sPlugin = Phpfox_Plugin::get('user.service_process_updatepassword')) ? eval($sPlugin) : false; return $bLogged ? true : false; }
/** * This function checks if the hash submitted is valid. * In every case it deletes the hash from the database, if the hash expired it creates a new one and sends an email to the user. * @param String $sHash * @param Boolean $bStrict tells if we should check if the password has expired, added to complement the adminVerify * @return boolean false if the hash is not found on the db or if it has expired | true if the hash matches */ public function verify($sHash, $bStrict = true) { $aVerify = $this->database() ->select('uv.user_id, uv.email as newMail, u.password, uv.time_stamp') ->join(Phpfox::getT('user'), 'u', 'u.user_id = uv.user_id') ->from($this->_sTable, 'uv') ->where('uv.hash_code = \'' . Phpfox::getLib('parse.input')->clean($sHash) . '\'') ->execute('getSlaveRow'); if (empty($aVerify)) { return false; } /** * @ToDo what do we do if the entry is not found? do we allow the user to log in? */ // Delete the entry from the user_verify table $this->database()->delete($this->_sTable, 'user_id = ' . $aVerify['user_id']); if ((Phpfox::getParam('user.verify_email_timeout') == 0 || ($aVerify['time_stamp'] + (Phpfox::getParam('user.verify_email_timeout') * 60)) >= Phpfox::getTime())) { $bValid = true; // Update the user table where user_id = aVerify[user_id] // (Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->allowGuest()->add('user_joined', $aVerify['user_id'], null, $aVerify['user_id']) : null); (($sPlugin = Phpfox_Plugin::get('user.service_verify_process_verify_pass')) ? eval($sPlugin) : false); $this->database()->update(Phpfox::getT('user'), array( 'status_id' => 0, 'email' => $aVerify['newMail'] ), 'user_id = ' . $aVerify['user_id']); // Send the welcome email Phpfox::getLib('mail') ->to($aVerify['user_id']) ->subject(array('core.welcome_email_subject')) ->message(array('core.welcome_email_content')) ->send(); return true; } else { $bValid = false; } if ($bStrict === false) return true; // Its invalid (timeout) so add the entry to the error log table $aError = array( 'ip_address' => Phpfox::getIp(), 'hash_code' => Phpfox::getLib('parse.input')->prepare($sHash), 'email' => $aVerify['newMail'], // should we add also the email address here ? 'time_stamp' => Phpfox::getTime() ); $this->database()->insert(Phpfox::getT('user_verify_error'), $aError); return false; }
public function addLog($sGateway, $aLogData) { $this->database()->insert(Phpfox::getT('api_gateway_log'), array('gateway_id' => $sGateway, 'log_data' => json_encode($aLogData), 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME)); }
public function addTrack($iId, $iUserId = null) { $this->database()->insert(Phpfox::getT('video_track'), array('item_id' => (int) $iId, 'user_id' => Phpfox::getUserBy('user_id'), 'ip_address' => Phpfox::getIp(true), 'time_stamp' => PHPFOX_TIME)); $this->database()->updateCounter('video', 'total_view', 'video_id', $iId); }
public function getVideo($sVideo, $bUseId = false) { $bUseId = true; if (Phpfox::isModule('track')) { $this->database()->select("video_track.item_id AS video_is_viewed, ")->leftJoin(Phpfox::getT('video_track'), 'video_track', 'video_track.item_id = v.video_id AND video_track.ip_address = \'' . $this->database()->escape(Phpfox::getIp(true)) . '\''); } if (Phpfox::isModule('friend')) { $this->database()->select('f.friend_id AS is_friend, ')->leftJoin(Phpfox::getT('friend'), 'f', "f.user_id = v.user_id AND f.friend_user_id = " . Phpfox::getUserId()); } if (Phpfox::isModule('like')) { $this->database()->select('l.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'video\' AND l.item_id = v.video_id AND l.user_id = ' . Phpfox::getUserId()); } $aVideo = $this->database()->select('v.*, ' . (Phpfox::getParam('core.allow_html') ? 'vt.text_parsed' : 'vt.text') . ' AS text, u.user_name, rate_id AS has_rated, ' . Phpfox::getUserField()) ->from($this->_sTable, 'v') ->join(Phpfox::getT('user'), 'u', 'u.user_id = v.user_id') ->leftJoin(Phpfox::getT('video_text'), 'vt', 'vt.video_id = v.video_id') ->leftJoin(Phpfox::getT('video_rating'), 'vr', 'vr.item_id = v.video_id AND vr.user_id = ' . Phpfox::getUserId()) ->where(($bUseId ? 'v.video_id = ' . (int) $sVideo : 'v.module_id = \'' . ($this->_aCallback !== false ? $this->_aCallback['module'] : 'video') . '\' AND v.item_id = ' . ($this->_aCallback !== false ? (int) $this->_aCallback['item'] : 0) . ' AND v.title_url = \'' . $this->database()->escape($sVideo) . '\'')) ->execute('getSlaveRow'); if (!isset($aVideo['video_id'])) { return false; } if ($aVideo['view_id'] != '0') { if ($aVideo['view_id'] == '2' && ($aVideo['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('video.can_approve_videos'))) { } else { return false; } } $aVideo['breadcrumb'] = Phpfox::getService('video.category')->getCategoriesById($aVideo['video_id']); $aVideo['bookmark'] = ($this->_aCallback !== false ? Phpfox::getLib('url')->makeUrl($this->_aCallback['url'][0], array_merge($this->_aCallback['url'][1], array('video', $aVideo['title']))) : Phpfox::permalink('video', $aVideo['video_id'], $aVideo['title'])); $aVideo['embed'] = ''; if ($aVideo['is_stream']) { $aEmbedVideo = $this->database()->select('video_url, embed_code') ->from(Phpfox::getT('video_embed')) ->where('video_id = ' . $aVideo['video_id']) ->execute('getslaveRow'); if (empty($aEmbedVideo['embed_code'])) { if (!Phpfox::getService('video.grab')->get($aEmbedVideo['video_url'])) { return Phpfox_Error::display(Phpfox::getPhrase('video.not_a_valid_video_to_display')); } $aEmbedVideo['embed_code'] = Phpfox::getService('video.grab')->embed(); $this->database()->update(Phpfox::getT('video_embed'), array('embed_code' => $aEmbedVideo['embed_code']), 'video_id = ' . $aVideo['video_id']); } $aVideo['embed_code'] = $aEmbedVideo['embed_code']; if (preg_match('/youtube/i', $aEmbedVideo['video_url']) || preg_match('/youtu\.be/i', $aEmbedVideo['video_url'])) { preg_match('/value="http:\/\/(.*?)"/i', $aVideo['embed_code'], $aMatches); if (isset($aMatches[1])) { $sTempUrl = trim($aMatches[1]); $aUrlFind = array( '&fs=1', '&fs=0', '&fs=1', '&fs=0', '&rel=1', '&rel=0', '&rel=1', '&rel=0', '&autoplay=1', '&autoplay=0', '&autoplay=1', '&autoplay=0', ); $sNewTempUrl = str_replace($aUrlFind, '', $sTempUrl) . (Phpfox::getParam('video.embed_auto_play') ? '&autoplay=1' : '') . (Phpfox::getParam('video.full_screen_with_youtube') ? '&fs=1' : '') . (Phpfox::getParam('video.disable_youtube_related_videos') ? '&rel=0' : ''); $aVideo['embed_code'] = str_replace($sTempUrl, $sNewTempUrl, $aVideo['embed_code']); } } $aVideo['embed_code'] = preg_replace('/width=\"(.*?)\"/i', 'width="640"', $aVideo['embed_code']); $aVideo['embed_code'] = preg_replace('/height=\"(.*?)\"/i', 'height="390"', $aVideo['embed_code']); $aVideo['embed_code'] = preg_replace_callback('/<object(.*?)>(.*?)<\/object>/is', array($this, '_embedWmode'), $aVideo['embed_code']); $aVideo['embed'] = htmlspecialchars($aEmbedVideo['embed_code']); } if ($this->_aCallback !== false && isset($this->_aCallback['url_home']) && isset($aVideo['breadcrumb']) && is_array($aVideo['breadcrumb']) && count($aVideo['breadcrumb'])) { $sHomeUrl = '/' . $this->_aCallback['url_home'][0] . '/' . implode('/', $this->_aCallback['url_home'][1]) . '/video/'; foreach ($aVideo['breadcrumb'] as $iKey => $aCategory) { $aVideo['breadcrumb'][$iKey][1] = preg_replace('/^http:\/\/(.*?)\/video\/(.*?)$/i', 'http://\\1' . $sHomeUrl . '\\2', $aCategory[1]); } } if (Phpfox::isModule('tag')) { $aTags = Phpfox::getService('tag')->getTagsById('video' . (empty($aVideo['module_id']) ? '' : '_' . $aVideo['module_id']), $aVideo['video_id']); if (isset($aTags[$aVideo['video_id']])) { $aVideo['tag_list'] = $aTags[$aVideo['video_id']]; } } $aVideo['total_user_videos'] = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('in_process = 0 AND view_id = 0 AND item_id = 0 AND user_id = ' . (int) $aVideo['user_id'])->execute('getSlaveField'); if (!isset($aVideo['is_friend'])) { $aVideo['is_friend'] = 1; } (($sPlugin = Phpfox_Plugin::get('video.service_video_getvideo')) ? eval($sPlugin) : null); if (Phpfox::isMobile()) { $aVideo['embed_code'] = preg_replace('/width="([0-9]+)"/', 'width="285"', $aVideo['embed_code']); $aVideo['embed_code'] = preg_replace('/height="([0-9]+)"/', 'height="153"', $aVideo['embed_code']); } return $aVideo; }
/** * Starts the phpFox engine. Used to get and display the pages controller. * */ public static function run() { $oTpl = Phpfox::getLib('template'); $aLocale = Phpfox::getLib('locale')->getLang(); $oReq = Phpfox::getLib('request'); $oModule = Phpfox::getLib('module'); (($sPlugin = Phpfox_Plugin::get('run_start')) ? eval($sPlugin) : false); // Load module blocks $oModule->loadBlocks(); if (Phpfox::isMobile() && $oReq->get('req1') == 'go-to-full-site') { Phpfox::getLib('session')->set('mobilestatus', 'true'); Phpfox::getLib('url')->send('phpfox_full_site'); } if (!Phpfox::getParam('core.branding')) { $oTpl->setHeader(array('<meta name="author" content="phpFox" />')); } if (strtolower(Phpfox::getLib('request')->get('req1')) == Phpfox::getParam('admincp.admin_cp')) { self::$_bIsAdminCp = true; } if (!Phpfox::getService('ban')->check('ip', Phpfox::getIp())) { $oModule->setController('ban.message'); } else { if (!self::$_bIsAdminCp && Phpfox::getParam('core.site_is_offline') && !Phpfox::getUserParam('core.can_view_site_offline') ) { if ((Phpfox::getLib('request')->get('req1') == 'user' && ( Phpfox::getLib('request')->get('req2') == 'login' || Phpfox::getLib('request')->get('req2') == 'logout' )) || Phpfox::getLib('request')->get('req1') == 'contact' || Phpfox::getLib('request')->get('req1') == 'captcha' ) { $oModule->setController(); } else { $oModule->setController('core.offline'); } } else { $oModule->setController(); } } if (!PHPFOX_IS_AJAX_PAGE) { if (Phpfox::isMobile()) { $oTpl->setMobileHeader(array( '<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />' ) ); } $oTpl->setImage(array( 'ajax_small' => 'ajax/small.gif', 'ajax_large' => 'ajax/large.gif', 'loading_animation' => 'misc/loading_animation.gif', 'close' => 'misc/close.gif', 'move' => 'misc/move.png', 'calendar' => 'jquery/calendar.gif' ) ); $oTpl->setHeader(array( '<meta http-equiv="Content-Type" content="text/html; charset=' . $aLocale['charset'] . '" />', '<meta name="keywords" content="' . Phpfox::getLib('locale')->convert(Phpfox::getParam('core.keywords')) . '" />', '<meta name="description" content="' . Phpfox::getLib('locale')->convert(Phpfox::getParam('core.description')) . '" />', '<meta name="robots" content="index,follow" />', '<meta http-equiv="imagetoolbar" content="no" />', '<meta http-equiv="cache-control" content="no-cache" />', '<meta http-equiv="expires" content="-1" />', '<meta http-equiv="pragma" content="no-cache" />', '<link rel="shortcut icon" type="image/x-icon" href="' . Phpfox::getParam('core.path') . 'favicon.ico" />' ) ) ->setHeader('cache', array( 'layout.css' => 'style_css', 'common.css' => 'style_css', 'thickbox.css' => 'style_css', 'jquery.css' => 'style_css', 'pager.css' => 'style_css', 'jquery/jquery.js' => 'static_script' ) ); if (!Phpfox::isMobile()) { $oTpl->setHeader('cache', array('jquery/ui.js' => 'static_script')); } if (!defined('PHPFOX_IS_AD_PREVIEW') && !defined('PHPFOX_IN_DESIGN_MODE') && !defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.site_wide_ajax_browsing')) { $oTpl->setHeader('cache', array('jquery/plugin/jquery.address.js' => 'static_script')); } $oTpl->setHeader('cache', array( 'common.js' => 'static_script', 'main.js' => 'static_script', 'ajax.js' => 'static_script', 'thickbox/thickbox.js' => 'static_script', 'search.js' => 'module_friend' ) ); if (PHPFOX_DEBUG) { $oTpl->setHeader('cache', array('debug.css' => 'style_css')); } if (!Phpfox::isMobile() && Phpfox::isUser() && Phpfox::getParam('user.enable_user_tooltip')) { $oTpl->setHeader('cache', array( 'user_info.js' => 'static_script' ) ); } if ($aLocale['direction'] == 'rtl') { $oTpl->setHeader('cache', array( 'rtl.css' => 'style_css' ) ); } } (($sPlugin = Phpfox_Plugin::get('get_controller')) ? eval($sPlugin) : false); $oModule->getController(); if (!Phpfox::isUser() && !defined('PHPFOX_DONT_SAVE_PAGE')) { Phpfox::getLib('session')->set('redirect', Phpfox::getLib('url')->getFullUrl(true)); } if (!defined('PHPFOX_NO_CSRF')) { Phpfox::getService('log.session')->verifyToken(); } (($sPlugin = Phpfox_Plugin::get('run')) ? eval($sPlugin) : false); if (!self::isAdminPanel()) { if (!Phpfox::isMobile() && !PHPFOX_IS_AJAX_PAGE && Phpfox::isModule('rss') && !defined('PHPFOX_IS_USER_PROFILE')) { $aFeeds = Phpfox::getService('rss')->getLinks(); if (is_array($aFeeds) && count($aFeeds)) { foreach ($aFeeds as $sLink => $sPhrase) { $oTpl->setHeader('<link rel="alternate" type="application/rss+xml" title="' . $sPhrase . '" href="' . $sLink . '" />'); } } } $aPageLastLogin = ((Phpfox::isModule('pages') && Phpfox::getUserBy('profile_page_id')) ? Phpfox::getService('pages')->getLastLogin() : false); $oTpl->assign(array( 'aMenus' => $oTpl->getMenu('main'), 'aRightMenus' => $oTpl->getMenu('main_right'), 'aAppMenus' => $oTpl->getMenu('explore'), 'aSubMenus' => $oTpl->getMenu(), 'aFooterMenu' => $oTpl->getMenu('footer'), 'aBlocks1' => ($oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(1)), 'aBlocks3' => ($oTpl->bIsSample ? true : Phpfox::getLib('module')->getModuleBlocks(3)), 'aAdBlocks1' => ($oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(1) : null)), 'aAdBlocks3' => ($oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Phpfox::getService('ad')->getForBlock(3) : null)), 'bIsUsersProfilePage' => (defined('PHPFOX_IS_USER_PROFILE') ? true : false), 'sStyleLogo' => $oTpl->getStyleLogo(), 'aStyleInUse' => $oTpl->getStyleInUse(), 'sGlobalUserFullName' => (Phpfox::isUser() ? Phpfox::getUserBy('full_name') : null), 'aGlobalUser' => (Phpfox::isUser() ? Phpfox::getUserBy(null) : array()), 'sFullControllerName' => str_replace('.', '_', Phpfox::getLib('module')->getFullControllerName()), 'iGlobalProfilePageId' => Phpfox::getUserBy('profile_page_id'), 'aGlobalProfilePageLogin' => $aPageLastLogin, 'aInstalledApps' => (Phpfox::isUser() ? Phpfox::getService('apps')->getInstalledApps() : array()) ) ); if (isset($aPageLastLogin['style_id']) && $aPageLastLogin['style_id'] > 0) { Phpfox::getLib('template')->testStyle($aPageLastLogin['style_id']); } if (Phpfox::isModule('captcha')) { $sCaptchaHeader = Phpfox::getParam('captcha.recaptcha_header'); if (strlen(preg_replace('/\s\s+/', '', $sCaptchaHeader)) > 0) { $oTpl->setHeader(array($sCaptchaHeader)); } } if (!PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_SKIP_IM')) { if (!defined('PHPFOX_IN_DESIGN_MODE')) { if (Phpfox::isUser() && Phpfox::isModule('subscribe') && Phpfox::getParam('subscribe.subscribe_is_required_on_sign_up') && Phpfox::getUserBy('user_group_id') == '2' && (int) Phpfox::getUserBy('subscribe_id') > 0 ) { } else { if (Phpfox::isModule('notification') && Phpfox::isUser() && Phpfox::getParam('notification.notify_on_new_request')) { $oTpl->setHeader('cache', array('update.js' => 'module_notification')); } if (!Phpfox::isMobile() && Phpfox::isModule('im') && Phpfox::isUser() && Phpfox::getUserBy('profile_page_id') <= 0 && Phpfox::getParam('im.enable_im_in_footer_bar') && !$oTpl->bIsSample) { $oTpl->setPhrase(array( 'im.conversations', 'im.more_conversations', 'im.are_you_sure' ) ) ->setImage(array( 'misc_minimize' => 'misc/minimize.gif' ) ) ->setHeader('cache', array( 'im.js' => 'module_im', 'im.css' => 'style_css', // 'player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script', ) ) ->setHeader(array( '<script type="text/javascript">oCore[\'im.is_hidden\'] = \'' . Phpfox::getUserBy('im_hide') . '\';</script>', // '<script type="text/javascript">$(function() { $Core.player.load({id: \'js_im_player\', type: \'music\'}); });</script>' ) ); } } } } } if (!PHPFOX_IS_AJAX_PAGE && ($sHeaderFile = $oTpl->getHeaderFile())) { require_once($sHeaderFile); } list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb(); $oTpl->assign(array( 'aErrors' => (Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array()), 'sPublicMessage' => Phpfox::getMessage(), 'sLocaleDirection' => $aLocale['direction'], 'sLocaleCode' => $aLocale['language_code'], 'sLocaleFlagId' => $aLocale['image'], 'sLocaleName' => $aLocale['title'], 'aRequests' => Phpfox::getLib('request')->getRequests(), 'aBreadCrumbs' => $aBreadCrumbs, 'aBreadCrumbTitle' => $aBreadCrumbTitle, 'sCopyright' => '© ' . Phpfox::getPhrase('core.copyright') . ' ' . Phpfox::getParam('core.site_copyright') ) ); Phpfox::clearMessage(); unset($_SESSION['phpfox']['image']); if (Phpfox::getParam('core.cron')) { require_once(PHPFOX_DIR_CRON . 'exec.php'); } if (!PHPFOX_IS_AJAX_PAGE && $oTpl->sDisplayLayout) { $oTpl->getLayout($oTpl->sDisplayLayout); } if (Phpfox::getParam('language.cache_phrases')) { Phpfox::getLib('locale')->cache(); } if (!PHPFOX_IS_AJAX_PAGE && Phpfox::getParam('core.phpfox_is_hosted')) { $iTotalMembersOnline = Phpfox::getService('log.session')->getOnlineMembers(); if ($iTotalMembersOnline > Phpfox::getParam('core.phpfox_max_users_online') && $iTotalMembersOnline > (int) Phpfox::getParam('core.phpfox_total_users_online_mark')) { $oDb = Phpfox::getLib('database'); $oDb->update(Phpfox::getT('setting'), array('value_actual' => (int) $iTotalMembersOnline), 'var_name = \'phpfox_total_users_online_mark\''); $sPastHistory = Phpfox::getParam('core.phpfox_total_users_online_history'); $aPastHistory = array(); if (!empty($sPastHistory) && Phpfox::getLib('parse.format')->isSerialized($sPastHistory)) { $aPastHistory = unserialize($sPastHistory); } $oDb->update(Phpfox::getT('setting'), array('value_actual' => serialize(array_merge($aPastHistory, array(array('time_stamp' => PHPFOX_TIME, 'total' => (int) $iTotalMembersOnline))))), 'var_name = \'phpfox_total_users_online_history\''); Phpfox::getLib('cache')->remove('setting'); ob_clean(); } } // Use GZIP to output the data if we can if (Phpfox::getParam('core.use_gzip') && !PHPFOX_IS_AJAX_PAGE) { $sContent = ob_get_contents(); ob_clean(); if (function_exists('gzencode')) { $sGzipContent = gzencode($sContent, Phpfox::getParam('core.gzip_level'), FORCE_GZIP); } else { if (function_exists('gzcompress') && function_exists('crc32')) { $iSize = strlen($sContent); $iCrc = crc32($sContent); $sGzipContent = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff"; $sGzipContent .= substr(gzcompress($sContent, Phpfox::getParam('core.gzip_level')), 2, -4); $sGzipContent .= pack('V', $iCrc); $sGzipContent .= pack('V', $iSize); } } if (isset($sGzipContent)) { header("Content-Encoding: " . (in_array('x-gzip', Phpfox::getParam('core.gzip_encodings')) ? "x-gzip" : "gzip")); } echo (isset($sGzipContent) ? $sGzipContent : $sContent); } }
public function changePassword() { $sCurrentPassword = $this->_oApi->get('current_password'); $sOldPassword = $this->_oApi->get('password'); $sSaltPassword = $this->_oApi->get('password_salt'); $sNewPassword = $this->_oApi->get('new_password'); if (Phpfox::getLib('hash')->setHash($sCurrentPassword, $sSaltPassword) != $sOldPassword) { return array('notice' => Phpfox_Error::set(Phpfox::getPhrase('user.your_current_password_does_not_match_your_old_password'))); } $aVals = array('old_password' => $sOldPassword, 'new_password' => $sNewPassword, 'confirm_password' => $sNewPassword); $sSalt = $this->_getSalt(); $aInsert = array(); $aInsert['password'] = Phpfox::getLib('hash')->setHash($aVals['new_password'], $sSalt); $aInsert['password_salt'] = $sSalt; $this->database()->update(Phpfox::getT('user'), $aInsert, 'user_id = ' . $this->_oApi->getUserId()); $this->database()->insert(Phpfox::getT('user_ip'), array('user_id' => $this->_oApi->getUserId(), 'type_id' => 'update_password', 'ip_address' => Phpfox::getIp(), 'time_stamp' => PHPFOX_TIME)); }