public function get($sCategory = null) { $sSelect = 'p.photo_id, p.server_id, p.destination, p.time_stamp, ' . Phpfox::getUserField(); $aConds = array(); $aConds[] = 'AND p.privacy = 0 AND p.allow_rate = 1'; if ($sCategory !== null) { $sCategoryIds = Phpfox::getService('photo.category')->getAllCategories($sCategory); if (!empty($sCategoryIds)) { $aConds[] = ' AND pcd.category_id IN (' . $sCategoryIds . ')'; $this->database()->innerJoin(Phpfox::getT('photo_category_data'), 'pcd', 'pcd.photo_id = p.photo_id'); } } $aRows = $this->database()->select($sSelect)->from($this->_sTable, 'p')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->where($aConds)->order('RAND()')->limit(2)->execute('getSlaveRows'); if (!count($aRows)) { return false; } if (count($aRows) < 2) { return false; } $sMode = Phpfox_Request::instance()->get('mode') == 'full' ? 'full' : ''; $aPhotos = array(); foreach ($aRows as $iKey => $aRow) { if ($iKey === 0) { $aRow['link'] = Phpfox_Url::instance()->makeUrl('photo.battle', array('w' => $aRow['photo_id'], 'l' => $aRows[1]['photo_id'], 'mode' => $sMode)); } else { $aRow['link'] = Phpfox_Url::instance()->makeUrl('photo.battle', array('w' => $aRow['photo_id'], 'l' => $aRows[0]['photo_id'], 'mode' => $sMode)); } $aPhotos[$iKey === 0 ? 'one' : 'two'] = $aRow; } return $aPhotos; }
public function setHash($sCode) { if (Phpfox::getParam('core.store_only_users_in_session')) { $oRequest = Phpfox_Request::instance(); $oSession = Phpfox::getLib('session'); $sSessionHash = $oSession->get('sessionhash'); $bCreate = true; if (!empty($sSessionHash)) { $bCreate = false; $aRow = $this->database()->select('*')->from(Phpfox::getT('log_session'))->where('session_hash = \'' . $this->database()->escape($sSessionHash) . '\'')->execute('getSlaveRow'); if (isset($aRow['session_hash'])) { $this->database()->update(Phpfox::getT('log_session'), array('captcha_hash' => $this->_getHash($sCode, $sSessionHash)), "session_hash = '" . $sSessionHash . "'"); } else { $bCreate = true; } } if ($bCreate) { $sSessionHash = $oRequest->getSessionHash(); $this->database()->insert(Phpfox::getT('log_session'), array('session_hash' => $sSessionHash, 'id_hash' => $oRequest->getIdHash(), 'captcha_hash' => $this->_getHash($sCode, $sSessionHash), 'user_id' => Phpfox::getUserId(), 'last_activity' => PHPFOX_TIME, 'location' => '', 'is_forum' => '0', 'forum_id' => 0, 'im_hide' => 0, 'ip_address' => '', 'user_agent' => '')); $oSession->set('sessionhash', $sSessionHash); } } else { $iId = $this->_oSession->getSessionId(); $this->database()->update(Phpfox::getT('log_session'), array('captcha_hash' => $this->_getHash($sCode, $iId)), "session_hash = '" . $iId . "'"); } }
/** * Gets the $_POST form value based on the ID passed. * * @param string $iId ID of the <textarea> form * @return string Returns the value if we can find it, if not the value is blank. */ public function getValue($iId, $sDefaultValue = null) { if (!($aParams = Phpfox_Request::instance()->getArray('val'))) { $aParams = Phpfox_Template::instance()->getVar('aForms'); } return isset($aParams[$iId]) ? Phpfox::getLib('parse.output')->clean($aParams[$iId]) : ($sDefaultValue === null ? '' : $sDefaultValue); }
/** * Controller */ public function process() { if (!defined('PHPFOX_IS_USER_PROFILE') && !defined('PHPFOX_IS_PAGES_VIEW')) { return false; } if (defined('PHPFOX_IS_PAGES_VIEW')) { $aUser = $this->getParam('aPage'); $aUser['user_image'] = $aUser['image_path']; $aUser['profile_page_id'] = $aUser['page_id']; $aUser['server_id'] = $aUser['image_server_id']; } else { $aUser = $this->getParam('aUser'); } $aUserInfo = array('title' => $aUser['full_name'], 'path' => 'core.url_user', 'file' => $aUser['user_image'], 'suffix' => '_50_square', 'max_width' => 75, 'max_height' => 75, 'no_default' => Phpfox::getUserId() == $aUser['user_id'] ? false : true, 'thickbox' => true, 'class' => 'profile_user_image'); if (defined('PHPFOX_IS_PAGES_VIEW')) { $sImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => $aUser), $aUserInfo)); } else { $sImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => Phpfox::getService('user')->getUserFields(true, $aUser)), $aUserInfo)); } $bIsInfo = false; if (isset($aUser['landing_page']) && $aUser['landing_page'] == 'info' && Phpfox_Request::instance()->get('req2') != 'wall' || Phpfox_Request::instance()->get('req2') == 'info') { $bIsInfo = true; } if (defined('PHPFOX_IS_PAGES_VIEW') && empty($aUser['vanity_url'])) { if (isset($aUser['landing_page']) && $aUser['landing_page'] == 'info' && Phpfox_Request::instance()->get('req3') != 'wall' || Phpfox_Request::instance()->get('req3') == 'info') { $bIsInfo = true; } } $this->template()->assign(array('aUser' => $aUser, 'sProfileImage' => $sImage, 'bIsInfo' => $bIsInfo, 'bCanPoke' => Phpfox::isModule('poke') && Phpfox::getService('poke')->canSendPoke($aUser['user_id']))); }
public function add($sMethod, $sAction, $aExtra = array()) { $aInsert = array('user_id' => Phpfox::getUserId(), 'type_id' => $this->_aActions[$sAction], 'call_name' => $sMethod, 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox_Request::instance()->getIp()); if ($aExtra) { $aInsert['extra'] = serialize($aExtra); } $this->database()->insert($this->_sTable, $aInsert); }
public function add($iReportId, $sType, $iItemId, $sFeedback = '') { if (empty($iReportId)) { return Phpfox_Error::set(Phpfox::getPhrase('report.provide_a_category_name')); } $this->database()->insert($this->_sTable, array('report_id' => (int) $iReportId, 'item_id' => $sType . '_' . (int) $iItemId, 'user_id' => Phpfox::getUserId(), 'added' => PHPFOX_TIME, 'ip_address' => Phpfox_Request::instance()->getServer('REMOTE_ADDR'), 'feedback' => $sFeedback != '' ? Phpfox::getLib('parse.input')->clean($sFeedback) : '')); return true; }
public function add($aVals) { $aVals = array_merge($aVals, array('server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID'))); $aInsert = array('category_id' => $aVals['category'], 'link_id' => isset($aVals['link_id']) ? (int) $aVals['link_id'] : 0, 'user_id' => Phpfox::getUserId(), 'time_stamp' => PHPFOX_TIME, 'file_name' => empty($aVals['file_name']) ? null : $aVals['file_name'], 'extension' => empty($aVals['extension']) ? null : $aVals['extension'], 'is_image' => isset($aVals['is_image']) && $aVals['is_image'] ? 1 : 0, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID')); $iId = $this->database()->insert(Phpfox::getT('attachment'), $aInsert); // Update user activity Phpfox::getService('user.activity')->update(Phpfox::getUserId(), 'attachment'); ($sPlugin = Phpfox_Plugin::get('attachment.service_process_add')) ? eval($sPlugin) : false; return $iId; }
public function add() { /* @title @info Create a page. On success it will return information about the new page. @method POST @extra title=#{Title of the page|string|yes}&info=#{Information about the page|string|yes}&type_id=#{Parent category ID#. Use [action]page.categories[/action]|int|yes}&category_id=#{Sub-category ID#. Use [action]page.categories[/action]|int|yes}&image=#{Default avatar/logo for the page. Must be an HTTP path to an image|string|no} @return page_id=#{Page ID#|int}&profile_user_id=#{This is the profile user ID# for the page|int}&title=#{Title of the page|string}&likes=#{Total number of likes|int}&permalink=#{Link to the page|string}&info=#{Information about the page|string}&created_by=#{Person who created the page|string}&created_by_url=#{Profile link of the person who created the page|string}&photo_100px=#{Photo of the page. 100px|string}&photo_100px_square=#{Square photo of the page. 100px|string} */ if ($this->_oApi->isAllowed('pages.add_page') == false) { return $this->_oApi->error('pages.add_page', 'Unable to create a page for this user.'); } $aInsert = array('title' => $this->_oApi->get('title'), 'info' => $this->_oApi->get('info'), 'type_id' => $this->_oApi->get('type_id'), 'category_id' => $this->_oApi->get('category_id')); $iId = Phpfox::getService('pages.process')->add($aInsert); if (!$iId) { return $this->_oApi->error('pages.unable_to_add_page', implode('', Phpfox_Error::get())); } $aPages = $this->get($iId); if ($this->_oApi->get('image') != '') { $sType = $this->_oApi->get('image_type'); $sImageContent = file_get_contents($this->_oApi->get('image')); $sImagePath = Phpfox::getParam('pages.dir_image') . $aPages[0]['page_id'] . '.' . $sType; $hFile = fopen($sImagePath, 'w'); fwrite($hFile, $sImageContent); fclose($hFile); $_FILES['photo']['error'] = ''; $_FILES['photo']['tmp_name'] = $sImagePath; $_FILES['photo']['name'] = $this->_oApi->get('photo_name'); $oFile = Phpfox_File::instance(); $oImage = Phpfox_Image::instance(); $aImage = $oFile->load('photo', array('jpg', 'gif', 'png'), Phpfox::getUserParam('pages.max_upload_size_pages') === 0 ? null : Phpfox::getUserParam('pages.max_upload_size_pages') / 1024); $sFileName = $oFile->upload('photo', Phpfox::getParam('pages.dir_image'), $iId); $sPath = Phpfox::getParam('pages.dir_image'); $iFileSizes = filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '')); $aUpdate['image_path'] = $sFileName; $aUpdate['image_server_id'] = Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID'); $iSize = 50; $oImage->createThumbnail(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $iFileSizes += filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize)); $iSize = 120; $oImage->createThumbnail(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $iFileSizes += filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize)); $iSize = 200; $oImage->createThumbnail(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $iFileSizes += filesize(Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '_' . $iSize)); define('PHPFOX_PAGES_IS_IN_UPDATE', true); Phpfox::getService('user.process')->uploadImage($aPages[0]['profile_user_id'], true, Phpfox::getParam('pages.dir_image') . sprintf($sFileName, '')); // Update user space usage Phpfox::getService('user.space')->update(Phpfox::getUserId(), 'pages', $iFileSizes); $this->database()->update($this->_sTable, $aUpdate, 'page_id = ' . (int) $iId); $aPages = $this->get($iId); } return $aPages[0]; }
public function check($sActualTitle, $sReq = 'req3') { return; if (PHPFOX_IS_AJAX) { return; } $sTitle = urldecode(Phpfox_Request::instance()->get($sReq)); if (empty($sTitle)) { $aParts = explode('/', trim(Phpfox_Request::instance()->get(PHPFOX_GET_METHOD), '/')); $iCnt = 0; foreach ($aParts as $sPart) { if (Phpfox::isMobile() && $sPart == 'mobile') { continue; } $iCnt++; if ((int) str_replace('req', '', $sReq) == $iCnt) { $sTitle = $sPart; break; } } } $sActualTitle = Phpfox_Url::instance()->cleanTitle($sActualTitle); if (empty($sActualTitle)) { return; } if ($sTitle != $sActualTitle) { $sPath = ''; $aRequests = (array) Phpfox_Request::instance()->getRequests(); if (defined('PHPFOX_IS_AJAX_PAGE') && PHPFOX_IS_AJAX_PAGE) { $aSubRequests = explode('/', trim(Phpfox_Request::instance()->get(PHPFOX_GET_METHOD), '/')); $aRequests = array(); foreach ($aSubRequests as $iKey => $sSubRequest) { $sCurrentCnt = 'req' . ($iKey + 1); $aRequests[$sCurrentCnt] = $sSubRequest; } } if (empty($sTitle)) { $aRequests[$sReq] = $sActualTitle; } foreach ($aRequests as $sKey => $sValue) { if ($sKey == PHPFOX_GET_METHOD) { continue; } if ($sKey == $sReq) { $sValue = $sActualTitle; } $sPath .= $sValue . '.'; } $sPath = rtrim($sPath, '.'); if (!empty($sActualTitle)) { Phpfox_Url::instance()->send($sPath, array(), null, 301); } } }
/** * Send a request to our API server. * * @param string $sCmd Command. * @param array $aVals POST values. * @return string Returns what our API server has returned for us. */ public function send($sCmd, $aVals = array()) { $aVals['domain'] = $this->_getDomain(); $mReturn = Phpfox_Request::instance()->send(PHPFOX::PHPFOX_API, array('request' => base64_encode(serialize(array_merge(array('cmd' => $sCmd), $aVals)))), 'POST'); $mReturn = unserialize($mReturn); $this->_sError = $mReturn['error'] == 'fatal' ? $mReturn['error_message'] : $mReturn['error']; if ($mReturn['error'] === 'fatal') { Phpfox_Error::set($mReturn['error_message']); } return $mReturn['return']; }
public function add($aVals, $iUpdateId = null) { $aForms = array('title' => array('message' => Phpfox::getPhrase('subscribe.provide_a_message_for_the_package'), 'type' => array('string:required')), 'description' => array('message' => Phpfox::getPhrase('subscribe.provide_a_description_for_the_package'), 'type' => 'string:required'), 'user_group_id' => array('message' => Phpfox::getPhrase('subscribe.provide_a_user_group_on_success'), 'type' => 'int:required'), 'fail_user_group' => array('message' => Phpfox::getPhrase('subscribe.provide_a_user_group_on_cancellation'), 'type' => 'int:required'), 'is_registration' => array('message' => Phpfox::getPhrase('subscribe.provide_if_the_package_should_be_added_to_the_registration_form'), 'type' => 'int:required'), 'is_active' => array('message' => Phpfox::getPhrase('subscribe.select_if_the_package_is_active_or_not'), 'type' => 'int:required'), 'cost' => array('message' => Phpfox::getPhrase('subscribe.provide_a_price_for_the_package'), 'type' => 'currency:required'), 'show_price' => array('type' => 'int:required'), 'background_color' => array('type' => 'string')); $bIsRecurring = false; if (isset($aVals['is_recurring']) && $aVals['is_recurring']) { $aForms['recurring_cost'] = array('message' => Phpfox::getPhrase('subscribe.provide_a_recurring_cost'), 'type' => 'currency:required'); $aForms['recurring_period'] = array('message' => Phpfox::getPhrase('subscribe.provide_a_recurring_period'), 'type' => 'int:required'); $bIsRecurring = true; } if ($iUpdateId !== null) { if (isset($aVals['is_recurring']) && !$aVals['is_recurring']) { $aCacheForm = $aVals; } } $aVals = $this->validator()->process($aForms, $aVals); if (!Phpfox_Error::isPassed()) { return false; } if ($iUpdateId !== null) { if (isset($aCacheForm['is_recurring']) && !$aCacheForm['is_recurring']) { $aVals['recurring_period'] = 0; $aVals['recurring_cost'] = null; } } $aVals['cost'] = serialize($aVals['cost']); if ($bIsRecurring) { $aVals['recurring_cost'] = serialize($aVals['recurring_cost']); } if (!empty($_FILES['image']['name'])) { $aImage = Phpfox_File::instance()->load('image', array('jpg', 'gif', 'png')); if ($aImage === false) { return false; } } $aVals['title'] = $this->preParse()->convert($aVals['title']); $aVals['description'] = $this->preParse()->convert($aVals['description']); $aVals['background_color'] = Phpfox::getLib('parse.input')->clean($aVals['background_color']); if ($iUpdateId !== null) { $iId = $iUpdateId; $this->database()->update($this->_sTable, $aVals, 'package_id = ' . (int) $iUpdateId); } else { $iLastOrderId = $this->database()->select('ordering')->from($this->_sTable)->order('ordering DESC')->execute('getSlaveField'); $aVals['ordering'] = $iLastOrderId + 1; $iId = $this->database()->insert($this->_sTable, $aVals); } if (!empty($_FILES['image']['name']) && ($sFileName = Phpfox_File::instance()->upload('image', Phpfox::getParam('subscribe.dir_image'), $iId))) { $this->database()->update($this->_sTable, array('image_path' => $sFileName, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID')), 'package_id = ' . (int) $iId); Phpfox_Image::instance()->createThumbnail(Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, '_120'), 120, 120); unlink(Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, '')); } return $iId; }
public function add() { /* @title @info @method POST @extra title=#{Title of the listing|string|yes}¤cy_id=#{Currency ID. Use [action]core.getCurrencies[/action] to get a list of valid currencies|string|yes}&price=#{Price|decimal|no}&country_iso=#{Country ISO ID. Use [action]core.getCurrencies[/action]|string|no}&country_child_id=#{State/Province ID#. Use [action]core.getCurrencies[/action]|int|no}&postal_code=#{Postal code|string|no}&city=#{City|string|no}&mini_description=#{Mini description|string|yes}&description=#{Description|string|yes}&category=#{Comma separated category ID#'s. Use [action]marketplace.categories[/action]|string|yes}&images=#{Comma separated URL to images|string|no} @return id=#{Item ID#|int}&title=#{Title of the item|string}&description=#{Description of the item|string}&likes=#{Total number of likes|int}&permalink=#{Link to the item|string}&mini_description=#{Mini description of the listing|string}¤cy_id=#{Currency ID|string}&price=#{Price|decimal}&country_iso=#{Country ISO|string}&postal_code=#{Postal code|string}&city=#{City|string}&images=#{Array of images|array} */ $aCategories = array(); if ($this->_oApi->get('category')) { $aCategories = explode(',', $this->_oApi->get('category')); } $aVals = array('title' => $this->_oApi->get('title'), 'currency_id' => $this->_oApi->get('currency_id'), 'price' => $this->_oApi->get('price'), 'country_iso' => $this->_oApi->get('country_iso'), 'country_child_id' => $this->_oApi->get('country_child_id'), 'postal_code' => $this->_oApi->get('postal_code'), 'city' => $this->_oApi->get('city'), 'mini_description' => $this->_oApi->get('mini_description'), 'description' => $this->_oApi->get('description'), 'category' => (array) $aCategories); if (($iId = Phpfox::getService('marketplace.process')->add($aVals)) !== false) { if ($this->_oApi->get('images') != '') { $oImage = Phpfox_Image::instance(); $oFile = Phpfox_File::instance(); $aSizes = array(50, 120, 200, 400); $iFileSizes = 0; foreach (explode(',', $this->_oApi->get('images')) as $sImage) { $sType = $oFile->getFileExt($sImage); $sImageContent = file_get_contents($sImage); $sImagePath = Phpfox::getParam('marketplace.dir_image') . $iId . '.' . $sType; $hFile = fopen($sImagePath, 'w'); fwrite($hFile, $sImageContent); fclose($hFile); $_FILES['photo']['error'] = ''; $_FILES['photo']['tmp_name'] = $sImagePath; $_FILES['photo']['name'] = basename($sImagePath); if ($aImage = $oFile->load('photo', array('jpg', 'gif', 'png'), Phpfox::getUserParam('marketplace.max_upload_size_listing') === 0 ? null : Phpfox::getUserParam('marketplace.max_upload_size_listing') / 1024)) { $sFileName = Phpfox_File::instance()->upload('photo', Phpfox::getParam('marketplace.dir_image'), $iId); $iFileSizes += filesize(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '')); $this->database()->insert(Phpfox::getT('marketplace_image'), array('listing_id' => $iId, 'image_path' => $sFileName, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID'))); foreach ($aSizes as $iSize) { $oImage->createThumbnail(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '_' . $iSize), $iSize, $iSize); $oImage->createThumbnail(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '_' . $iSize . '_square'), $iSize, $iSize, false); $iFileSizes += filesize(Phpfox::getParam('marketplace.dir_image') . sprintf($sFileName, '_' . $iSize)); } } } if ($iFileSizes === 0) { return false; } $this->database()->update($this->_sTable, array('image_path' => $sFileName, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID')), 'listing_id = ' . $iId); Phpfox::getService('user.space')->update(Phpfox::getUserId(), 'marketplace', $iFileSizes); } $aReturn = $this->get($iId); return $aReturn[0]; } }
/** * Controller */ public function process() { Phpfox::getUserParam('feed.can_view_feed', true); $sFeedDisplay = 'feed.display'; ($sPlugin = Phpfox_Plugin::get('feed.component_controller_index_feeddisplay')) ? eval($sPlugin) : false; /* Load the picup files if needed*/ if (Phpfox::isMobile() && (($sBrowser = Phpfox_Request::instance()->getBrowser()) && strpos($sBrowser, 'Safari') !== false)) { $sMethod = 'simple'; $this->template()->setHeader(array('<script type="text/javascript"> var flash_user_id = ' . Phpfox::getUserId() . '; var sHash = "' . Phpfox::getService('core')->getHashForUpload() . '";</script>', 'mobile.js' => 'module_photo'))->assign(array('bRawFileInput' => true)); } $this->template()->setEditor()->setHeader('cache', array('feed.js' => 'module_feed', 'comment.css' => 'style_css', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script'))->assign(array('sFeedDisplay' => $sFeedDisplay)); }
public function checkProductVersions() { $aProduct = $this->database()->select('product_id, url_version_check')->from(Phpfox::getT('product'))->order('last_check ASC')->execute('getRow'); $iVersion = null; if (!empty($aProduct['url_version_check'])) { $mData = Phpfox_Request::instance()->send($aProduct['url_version_check']); if (is_string($mData) && preg_match('/<phpfox>(.*?)<\\/phpfox>/is', $mData)) { $aXml = Phpfox::getLib('xml.parser')->parse($mData); if (isset($aXml['product_version'])) { $iVersion = $aXml['product_version']; } } } $this->database()->update(Phpfox::getT('product'), array('last_check' => PHPFOX_TIME, 'latest_version' => $iVersion), 'product_id = \'' . $this->database()->escape($aProduct['product_id']) . '\''); }
public function getList() { $sCacheId = $this->cache()->set('music_genre'); if (!($aRows = $this->cache()->get($sCacheId))) { $aRows = $this->database()->select('genre_id, name, name_url')->from($this->_sTable)->order('name ASC')->execute('getRows'); $this->cache()->save($sCacheId, $aRows); } foreach ($aRows as $iKey => $aRow) { if ($sView = Phpfox_Request::instance()->get('view')) { $aRows[$iKey]['link'] = Phpfox::permalink('music.genre', $aRow['genre_id'], $aRow['name'], false, null, array('view' => $sView)); } else { $aRows[$iKey]['link'] = Phpfox::permalink('music.genre', $aRow['genre_id'], $aRow['name']); } } return $aRows; }
public function __construct() { header('Cache-Control: no-cache'); header('Pragma: no-cache'); session_start(); $this->_oTpl = Phpfox_Template::instance(); $this->_oReq = Phpfox_Request::instance(); $this->_oUrl = Phpfox_Url::instance(); $this->_sTempDir = Phpfox_File::instance()->getTempDir(); $this->_sPage = $this->_oReq->get('page'); $this->_sUrl = $this->_oReq->get('req1') == 'upgrade' ? 'upgrade' : 'install'; self::$_sSessionId = $this->_oReq->get('sessionid') ? $this->_oReq->get('sessionid') : uniqid(); if (defined('PHPFOX_IS_UPGRADE')) { $this->_oTpl->assign('bIsUprade', true); $this->_bUpgrade = true; if (file_exists(PHPFOX_DIR . 'include' . PHPFOX_DS . 'settings' . PHPFOX_DS . 'server.sett.php')) { $_CONF = []; require_once PHPFOX_DIR . 'include' . PHPFOX_DS . 'settings' . PHPFOX_DS . 'server.sett.php'; $this->_aOldConfig = $_CONF; } } if (!Phpfox_File::instance()->isWritable($this->_sTempDir)) { if (PHPFOX_SAFE_MODE) { $this->_sTempDir = PHPFOX_DIR_FILE . 'log' . PHPFOX_DS; if (!Phpfox_File::instance()->isWritable($this->_sTempDir)) { exit('Unable to write to temporary folder: ' . $this->_sTempDir); } } else { exit('Unable to write to temporary folder: ' . $this->_sTempDir); } } $this->_sSessionFile = $this->_sTempDir . 'installer_' . ($this->_bUpgrade ? 'upgrade_' : '') . '_' . self::$_sSessionId . '_' . 'phpfox.log'; $this->_hFile = fopen($this->_sSessionFile, 'a'); if ($this->_sUrl == 'install' && $this->_oReq->get('req2') == '') { if (file_exists(PHPFOX_DIR_SETTING . 'server.sett.php')) { require PHPFOX_DIR_SETTING . 'server.sett.php'; if (isset($_CONF['core.is_installed']) && $_CONF['core.is_installed'] === true) { $this->_oUrl->forward('../install/index.php?' . PHPFOX_GET_METHOD . '=/upgrade/'); } } if (file_exists(PHPFOX_DIR . 'include' . PHPFOX_DS . 'settings' . PHPFOX_DS . 'server.sett.php')) { $this->_oUrl->forward('../install/index.php?' . PHPFOX_GET_METHOD . '=/upgrade/'); } } // Define some needed params Phpfox::getLib('setting')->setParam(array('core.path' => self::getHostPath(), 'core.url_static_script' => self::getHostPath() . 'static/jscript/', 'core.url_static_css' => self::getHostPath() . 'static/style/', 'core.url_static_image' => self::getHostPath() . 'static/image/', 'sCookiePath' => '/', 'sCookieDomain' => '', 'sWysiwyg' => false, 'bAllowHtml' => false, 'core.url_rewrite' => '2')); }
public function make() { $Request = new Request(); if (!$Request->isPost()) { return false; } $return = \Phpfox_Request::instance()->get('val'); if (!$return) { return false; } $gump = new Gump(); $gump->validation_rules(Validator\Rules::get()); if (!$gump->run($return)) { throw Error($gump->get_errors_array()); } return true; }
public function get($sAction, $sUrl) { if (empty($_REQUEST['code'])) { return Phpfox_Error::trigger('Missing request code.', E_USER_ERROR); } $mReturn = Phpfox_Request::instance()->send('https://graph.facebook.com/oauth/access_token', array('client_id' => '' . Phpfox::getParam('facebook.facebook_app_id') . '', 'redirect_uri' => $sUrl, 'client_secret' => '' . Phpfox::getParam('facebook.facebook_secret') . '', 'code' => $_REQUEST['code'])); $aParts = explode('access_token=', $mReturn); if (!isset($aParts[1])) { return Phpfox_Error::set('Unable to find security token.', E_USER_ERROR); } $aParts = explode('&expires', $aParts[1]); $this->_sToken = $aParts[0]; $mReturn = file_get_contents('https://graph.facebook.com/' . $sAction . '?access_token=' . $this->_sToken); if (!function_exists('json_decode')) { return Phpfox_Error::set('Server is missing the PHP function json_decode().', E_USER_ERROR); } return json_decode($mReturn); }
public function processRows(&$aRows) { $oReq = Phpfox_Request::instance(); foreach ($aRows as $iKey => $aRow) { $aRows[$iKey]['link'] = Phpfox::permalink('photo', $aRow['photo_id'], $aRow['title']); if (Phpfox::getUserId() && defined('PHPFOX_IS_USER_PROFILE') || $oReq->get('req1') == 'photo' && $oReq->get('view') == 'my') { $aRows[$iKey]['link'] .= 'userid_' . $aRow['user_id'] . '/'; } $aRows[$iKey]['destination'] = Phpfox::getService('photo')->getPhotoUrl($aRow); if (Phpfox_Request::instance()->get('mode') == 'edit') { $sCategoryList = ''; $aCategories = (array) $this->database()->select('category_id')->from(Phpfox::getT('photo_category_data'))->where('photo_id = ' . (int) $aRow['photo_id'])->execute('getSlaveRows'); foreach ($aCategories as $aCategory) { $sCategoryList .= $aCategory['category_id'] . ','; } $aRows[$iKey]['category_list'] = rtrim($sCategoryList, ','); } } }
public function getActivityFeed($aFeed) { $aCore = Phpfox_Request::instance()->get('core'); $bForceUser = false; if (defined('PHPFOX_CURRENT_USER_PROFILE') || isset($aCore['profile_user_id'])) { $aUser = (array) (isset($aCore['profile_user_id']) ? Phpfox::getService('user')->get($aCore['profile_user_id']) : Phpfox::getService('user')->getUserObject(PHPFOX_CURRENT_USER_PROFILE)); if (isset($aUser['user_id'])) { if ($aUser['user_id'] == $aFeed['item_id']) { $aFeed['item_id'] = $aFeed['user_id']; $bForceUser = true; } } } // http://www.phpfox.com/tracker/view/14915/ $iDestinationUserId = 0; if (isset($aUser['user_id']) && $aFeed['parent_user_id'] == $aUser['user_id']) { $iDestinationUserId = $aFeed['user_id']; // http://www.phpfox.com/tracker/view/15149/ // http://www.phpfox.com/tracker/view/15311/ $bForceUser = true; } else { $iDestinationUserId = $aFeed['parent_user_id']; } $aRow = $this->database()->select(Phpfox::getUserField())->from(Phpfox::getT('user'), 'u')->where('u.user_id = ' . (int) $iDestinationUserId)->execute('getSlaveRow'); // http://www.phpfox.com/tracker/view/14671/ $iTotalLikes = $this->database()->select('COUNT(*)')->from(Phpfox::getT('like'))->where('item_id = ' . $aFeed['item_id'] . " AND type_id = 'friend'")->execute('getSlaveField'); // http://www.phpfox.com/tracker/view/14671/ $iIsLiked = $this->database()->select('COUNT(*)')->from(Phpfox::getT('like'))->where('item_id = ' . $aFeed['item_id'] . ' AND user_id = ' . Phpfox::getUserId())->execute('getSlaveField'); if (!isset($aRow['user_id'])) { return false; } $aParams = array('user' => $aRow, 'suffix' => '_50_square', 'max_width' => '50', 'max_height' => '50'); $sImage = Phpfox::getLib('image.helper')->display($aParams); $aReturn = array('feed_title' => $aRow['full_name'], 'feed_title_sub' => $aRow['user_name'], 'feed_info' => Phpfox::getPhrase('feed.is_now_friends_with'), 'feed_link' => Phpfox_Url::instance()->makeUrl($aRow['user_name']), 'feed_icon' => Phpfox::getLib('image.helper')->display(array('theme' => 'misc/friend_added.png', 'return_url' => true)), 'feed_total_like' => $iTotalLikes, 'feed_is_liked' => (int) $iIsLiked > 0 ? true : false, 'time_stamp' => $aFeed['time_stamp'], 'enable_like' => false, 'feed_image' => $sImage); if ($bForceUser) { $aReturn['force_user'] = $aUser; $aReturn['gender'] = $aUser['gender']; // bug report 13368 } ($sPlugin = Phpfox_Plugin::get('friend.component_service_callback_getactivityfeed__1')) ? eval($sPlugin) : false; return $aReturn; }
public function execute__() { if ($this->_sCategory !== null) { $sCategories = Phpfox::getService('marketplace.category')->getAllCategories($this->_sCategory); $this->database()->innerJoin(Phpfox::getT('marketplace_category_data'), 'mcd', 'mcd.listing_id = m.listing_id'); $this->_aConditions[] = ' AND mcd.category_id IN(' . $sCategories . ')'; } if ($this->_bIsSeen !== false) { $this->database()->join(Phpfox::getT('marketplace_invite'), 'mi', 'mi.listing_id = m.listing_id AND mi.visited_id = 0 AND mi.invited_user_id = ' . Phpfox::getUserId()); } if (Phpfox_Request::instance()->get('view') == 'purchased') { $this->database()->join(Phpfox::getT('marketplace_invoice'), 'minvoice', 'minvoice.listing_id = m.listing_id AND minvoice.user_id = ' . Phpfox::getUserId() . ' AND minvoice.status = \'completed\''); } if (Phpfox_Request::instance()->get('view') == 'sold') { $this->database()->join(Phpfox::getT('marketplace_invoice'), 'minvoice', 'minvoice.listing_id = m.listing_id AND minvoice.status = \'completed\''); } ($sPlugin = Phpfox_Plugin::get('marketplace.service_browse_execute_query')) ? eval($sPlugin) : false; $this->_iCnt = $this->database()->select($this->_sCategory !== null || (Phpfox_Request::instance()->get('view') == 'sold' || Phpfox_Request::instance()->get('view') == 'purchased') ? 'COUNT(DISTINCT m.listing_id)' : 'COUNT(*)')->from($this->_sTable, 'm')->where($this->_aConditions)->execute('getSlaveField'); if ($this->_iCnt) { if ($this->_sCategory !== null) { $this->database()->innerJoin(Phpfox::getT('marketplace_category_data'), 'mcd', 'mcd.listing_id = m.listing_id')->group('m.listing_id'); } if ($this->_bIsSeen !== false) { $this->database()->join(Phpfox::getT('marketplace_invite'), 'mi', 'mi.listing_id = m.listing_id AND mi.visited_id = 0 AND mi.invited_user_id = ' . Phpfox::getUserId()); } if (Phpfox_Request::instance()->get('view') == 'purchased') { $this->database()->join(Phpfox::getT('marketplace_invoice'), 'minvoice', 'minvoice.listing_id = m.listing_id AND minvoice.user_id = ' . Phpfox::getUserId() . ' AND minvoice.status = \'completed\''); } if (Phpfox_Request::instance()->get('view') == 'sold') { $this->database()->join(Phpfox::getT('marketplace_invoice'), 'minvoice', 'minvoice.listing_id = m.listing_id AND minvoice.status = \'completed\'')->group('m.listing_id'); } ($sPlugin = Phpfox_Plugin::get('marketplace.service_browse_execute')) ? eval($sPlugin) : false; $this->_aListings = $this->database()->select('m.*, ' . Phpfox::getUserField())->from($this->_sTable, 'm')->join(Phpfox::getT('user'), 'u', 'u.user_id = m.user_id')->where($this->_aConditions)->order($this->_sOrder)->limit($this->_iPage, $this->_iPageSize, $this->_iCnt)->execute('getSlaveRows'); if (Phpfox_Request::instance()->get('view') == 'sold') { foreach ($this->_aListings as $iKey => $aListing) { list($iSoldCount, $aSoldItems) = Phpfox::getService('marketplace')->getInvoices('mi.listing_id = ' . $aListing['listing_id'] . ' AND mi.status = \'completed\'', true); $this->_aListings[$iKey]['invoices'] = $aSoldItems; } } } }
/** * Controller */ public function process() { if (defined('PHPFOX_IS_USER_PROFILE')) { return false; } $iCategoryId = $this->getParam('iCategory', 0); $aCategories = Phpfox::getService('pages.category')->getForBrowse($iCategoryId); if (!is_array($aCategories)) { return false; } if (!count($aCategories)) { return false; } if ($sView = Phpfox_Request::instance()->get('view')) { foreach ($aCategories as $iKey => $aCategory) { $aCategories[$iKey]['link'] = $aCategory['link'] . 'view_' . $sView . '/'; } } $this->template()->assign(array('sHeader' => $iCategoryId ? Phpfox::getPhrase('pages.sub_categories') : Phpfox::getPhrase('pages.categories'), 'aCategories' => $aCategories)); return 'block'; }
public function __construct() { $this->db = \Phpfox_Database::instance(); $this->request = \Phpfox_Request::instance(); if ($this->request->segment(1) == 'api') { \Core\Route\Controller::$isApi = true; if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { throw new \Exception('Missing authentication key and pass.'); } foreach ((new App())->all() as $App) { if ($App->auth->id == $_SERVER['PHP_AUTH_USER']) { $this->active = $App; break; } } if (!$this->active) { throw new \Exception('Unable to find this app.'); } if ($_SERVER['PHP_AUTH_PW'] != $App->auth->key) { throw new \Exception('Authentication failed. Key is not valid: ' . $App->auth->key); } } }
public function requestPassword($sEmail) { $aUser = $this->database()->select('user_id, profile_page_id, email, full_name')->from($this->_sTable)->where('email = \'' . $this->database()->escape($sEmail) . '\'')->execute('getRow'); if (!isset($aUser['user_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.not_a_valid_email')); } $aVals = Phpfox_Request::instance()->getArray('val'); if (empty($aUser['email']) || $aUser['profile_page_id'] > 0) { return Phpfox_Error::set('Unable to attain a password for this account.'); } if (empty($aVals['image_verification']) && Phpfox::isModule('captcha') && !Phpfox::getParam('captcha.recaptcha')) { return Phpfox_Error::set(Phpfox::getPhrase('captcha.captcha_failed_please_try_again')); } if (Phpfox::isModule('captcha') && !Phpfox::getService('captcha')->checkHash(isset($aVals['image_verification']) ? $aVals['image_verification'] : null)) { return Phpfox_Error::set(Phpfox::getPhrase('captcha.captcha_failed_please_try_again')); } // Send the user an email $sHash = md5($aUser['user_id'] . $aUser['email'] . Phpfox::getParam('core.salt')); $sLink = Phpfox_Url::instance()->makeUrl('user.password.verify', array('id' => $sHash)); Phpfox::getLib('mail')->to($aUser['user_id'])->subject(array('user.password_request_for_site_title', array('site_title' => Phpfox::getParam('core.site_title'))))->message(array('user.you_have_requested_for_us_to_send_you_a_new_password_for_site_title', array('site_title' => Phpfox::getParam('core.site_title'), 'link' => $sLink)))->send(); $this->database()->delete(Phpfox::getT('password_request'), 'user_id = ' . $aUser['user_id']); $this->database()->insert(Phpfox::getT('password_request'), array('user_id' => $aUser['user_id'], 'request_id' => $sHash, 'time_stamp' => PHPFOX_TIME)); return true; }
/** * Gets the polls given the conditions in $aCond which can be an array or just a string, * orders by date as in newest first * * @deprecated * @since 3.0.0beta1 * @param mixed $aCond * @param integer $iUser user id to check if this user has already voted * @param integer $iPage Page to show * @param integer $iPageSize How many items per page * @return array */ public function getPolls($aCond = array(), $iPage = false, $iPageSize = false, $sOrder = null) { ($sPlugin = Phpfox_Plugin::get('poll.service_poll_getpolls_start')) ? eval($sPlugin) : false; $aCond = array(); foreach ($this->search()->getConditions() as $sCond) { switch (Phpfox_Request::instance()->get('view')) { case 'friend': $aCond[] = str_replace('%PRIVACY%', '0,1,2', $sCond); break; case 'my': $aCond[] = str_replace('%PRIVACY%', '0,1,2,3,4', $sCond); break; default: $aCond[] = str_replace('%PRIVACY%', '0', $sCond); break; } } if (Phpfox::getParam('core.section_privacy_item_browsing')) { Privacy_Service_Privacy::instance()->buildPrivacy(array('module_id' => 'poll', 'alias' => 'poll', 'field' => 'poll_id', 'count' => true, 'table' => Phpfox::getT('poll'), 'service' => 'poll')); $iCnt = $this->database()->joinCount('total_item')->execute('getSlaveField'); } else { $iCnt = $this->database()->select("COUNT(*)")->from($this->_sTable, 'poll')->where($aCond)->execute('getSlaveField'); } // quick check if (empty($iCnt) || $iCnt == 0) { return array(0, array()); } if (Phpfox::getParam('core.section_privacy_item_browsing')) { Privacy_Service_Privacy::instance()->buildPrivacy(array('module_id' => 'poll', 'alias' => 'poll', 'field' => 'poll_id', 'table' => Phpfox::getT('poll'), 'service' => 'poll')); $this->database()->unionFrom('poll'); } else { $this->database()->from($this->_sTable, 'poll')->where($aCond); } $aPolls = $this->database()->select('poll.*, pd.background, pd.percentage, pd.border, pr.answer_id, pr.user_id as voted, friends.friend_id AS is_friend, ' . Phpfox::getUserField())->join(Phpfox::getT('user'), 'u', 'u.user_id = poll.user_id')->leftjoin(Phpfox::getT('poll_design'), 'pd', 'pd.poll_id = poll.poll_id')->leftjoin(Phpfox::getT('poll_result'), 'pr', 'pr.poll_id = poll.poll_id AND pr.user_id = ' . Phpfox::getUserId())->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'poll\' AND l.item_id = poll.poll_id AND l.user_id = ' . Phpfox::getUserId())->leftJoin(Phpfox::getT('friend'), 'friends', 'friends.user_id = poll.user_id AND friends.friend_user_id = ' . Phpfox::getUserId())->limit($iPage, $iPageSize, $iCnt)->order('poll.time_stamp DESC')->execute('getSlaveRows'); // we "implode" the poll_ids to run only one query on the DB to get the // answers $sPolls = ''; foreach ($aPolls as $aPoll) { $sPolls .= $aPoll['poll_id'] . ','; } $sPolls = rtrim($sPolls, ','); $aAnswers = $this->database()->select('pa.*, pr.user_id as voted')->from(Phpfox::getT('poll_answer'), 'pa')->where('pa.poll_id IN(' . $sPolls . ')')->leftjoin(Phpfox::getT('poll_result'), 'pr', 'pr.answer_id = pa.answer_id AND pr.user_id = ' . Phpfox::getUserId())->order('pa.ordering ASC')->execute('getSlaveRows'); // now merge both arrays by their poll_id and add the count for the total votes $aPolls2 = array(); $iTotalVotes = 0; $aTotalVotes = array(); foreach ($aAnswers as $aAnswer) { if ($aAnswer['total_votes'] > 0) { if (isset($aTotalVotes[$aAnswer['poll_id']])) { $aTotalVotes[$aAnswer['poll_id']] += $aAnswer['total_votes']; //$aTotalVotes[$aAnswer['poll_id']]+1; } else { $aTotalVotes[$aAnswer['poll_id']] = $aAnswer['total_votes']; } } } foreach ($aPolls as $iKey => $aPoll) { $aPoll['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'poll', 'privacy' => $aPoll['privacy'], 'comment_privacy' => $aPoll['privacy_comment'], 'like_type_id' => 'poll', 'feed_is_liked' => isset($aPoll['is_liked']) ? $aPoll['is_liked'] : false, 'feed_is_friend' => isset($aPoll['is_friend']) ? $aPoll['is_friend'] : false, 'item_id' => $aPoll['poll_id'], 'user_id' => $aPoll['user_id'], 'total_comment' => $aPoll['total_comment'], 'feed_total_like' => $aPoll['total_like'], 'total_like' => $aPoll['total_like'], 'feed_link' => Phpfox::permalink('poll', $aPoll['poll_id'], $aPoll['question']), 'feed_title' => $aPoll['question']); $aPolls2[$aPoll['poll_id']] = $aPoll; if ($aPoll['poll_id']['user_id'] == Phpfox::getUserId()) { $aPolls2[$aPoll['poll_id']]['user_voted_this_poll'] = 'true'; } else { $aPolls2[$aPoll['poll_id']]['user_voted_this_poll'] = 'false'; // this could be tricky, test and see if it works everywhere } if (!isset($aPolls2[$aPoll['poll_id']]['total_votes'])) { $aPolls2[$aPoll['poll_id']]['total_votes'] = 0; } foreach ($aAnswers as &$aAnswer) { // we add the total votes for the poll if (!isset($aAnswer['vote_percentage'])) { $aAnswer['vote_percentage'] = 0; } if (!isset($aAnswer['total_votes'])) { $aAnswer['total_votes'] = 0; } // Normalize if user voted this answer or not if (isset($aAnswer['voted']) && $aAnswer['voted'] == Phpfox::getUserId()) { $aAnswer['user_voted_this_answer'] = 1; } else { $aAnswer['user_voted_this_answer'] = 2; } if ($aPoll['poll_id'] == $aAnswer['poll_id']) { if (isset($aTotalVotes[$aAnswer['poll_id']]) && $aTotalVotes[$aAnswer['poll_id']] > 0) { $aAnswer['vote_percentage'] = round($aAnswer['total_votes'] / $aTotalVotes[$aAnswer['poll_id']] * 100); } else { $aAnswer['vote_percentage'] = 0; } $aPolls2[$aPoll['poll_id']]['answer'][$aAnswer['answer_id']] = $aAnswer; $aPolls2[$aPoll['poll_id']]['total_votes'] += $aAnswer['total_votes']; } } if ($aPoll['randomize'] == 1 && !empty($aPolls2[$aPoll['poll_id']]['answer'])) { shuffle($aPolls2[$aPoll['poll_id']]['answer']); } } ($sPlugin = Phpfox_Plugin::get('poll.service_poll_getpolls_end')) ? eval($sPlugin) : false; return array($iCnt, $aPolls2); }
public function resetBlock($sType) { Phpfox::isUser(true); if ($sType == 'profile') { $this->database()->delete(Phpfox::getT('user_design_order'), 'user_id = ' . Phpfox::getUserId()); if (Phpfox::getParam('profile.cache_blocks_design')) { $sCacheId = $this->cache()->set(array('user_design', Phpfox::getUserId())); $this->cache()->remove($sCacheId); } } elseif ($sType == 'pages') { if (Phpfox::getService('pages')->isAdmin(Phpfox_Request::instance()->get('req2'))) { $this->database()->delete(Phpfox::getT('pages_design_order'), 'page_id = ' . (int) Phpfox_Request::instance()->get('req2')); $sCacheId = $this->cache()->set(array('pages_design', Phpfox::getUserId())); $this->cache()->remove($sCacheId); } } else { $this->database()->delete(Phpfox::getT('user_dashboard'), 'user_id = ' . Phpfox::getUserId()); $sCacheId = $this->cache()->set(array('user_dashboard', Phpfox::getUserId())); $this->cache()->remove($sCacheId); } return true; }
public function _hashSearch() { if (Phpfox_Request::instance()->get('req1') != 'hashtag' && Phpfox_Request::instance()->get('hashtagsearch') == '') { return; } $sRequest = isset($_GET[PHPFOX_GET_METHOD]) ? $_GET[PHPFOX_GET_METHOD] : ''; $sReq2 = ''; if (!empty($sRequest)) { $aParts = explode('/', trim($sRequest, '/')); $iCnt = 0; // http://www.phpfox.com/tracker/view/15000/ // We have to count the "mobile" part as a req1 // add one to the count $iCntTotal = Phpfox::isMobile() ? 3 : 2; foreach ($aParts as $sPart) { $iCnt++; if ($iCnt === $iCntTotal) { $sReq2 = $sPart; break; } } } $sTag = Phpfox_Request::instance()->get('hashtagsearch') ? Phpfox_Request::instance()->get('hashtagsearch') : $sReq2; $sTag = \Phpfox_Parse_Output::instance()->parse($sTag); //https://github.com/moxi9/phpfox/issues/595 $sTag = urldecode($sTag); if (empty($sTag)) { return; } $sTag = Phpfox::getLib('parse.input')->clean($sTag, 255); $sTag = mb_convert_case($sTag, MB_CASE_LOWER, "UTF-8"); $this->database()->join(Phpfox::getT('tag'), 'hashtag', 'hashtag.item_id = feed.item_id AND hashtag.category_id = feed.type_id AND (tag_text = \'' . Phpfox_Database::instance()->escape($sTag) . '\' OR tag_url = \'' . Phpfox_Database::instance()->escape($sTag) . '\')'); }
/** * Returns paging info: 'totalPages', 'totalRows', 'current', 'fromRow','toRow', 'firstUrl', 'prevUrl', 'nextUrl', 'lastUrl', 'urls' (url=>page) * * @param Url $oUrl page url * @return array paging info */ private function _getInfo() { /* if($this->getTotalPages() == 0) { return false; } $sParams = ''; if (count($this->_aParams)) { foreach ($this->_aParams as $iKey => $sValue) { if (in_array($iKey, array( 'phpfox', Phpfox::getTokenName(), 'page', PHPFOX_GET_METHOD, 'ajax_page_display' ) ) ) { continue; } if (is_array($sValue)) { foreach ($sValue as $sKey => $sNewValue) { if (is_numeric($sKey)) { continue; } $sParams .= '&' . $iKey . '[' . $sKey . ']=' . $sNewValue; } } else { if (PHPFOX_IS_AJAX && $iKey == 'feed' && Phpfox::isModule('comment') && Phpfox::getParam('comment.load_delayed_comments_items')) { continue; } $sParams .= '&' . $iKey . '=' . $sValue; } } } $aInfo = array( 'totalPages' => $this->_iPagesCount, 'totalRows' => $this->_iCnt, 'current' => $this->_iPage, 'fromRow' => $this->_iFirstRow+1, 'toRow' => $this->_iLastRow, 'displaying' => ($this->_iCnt <= ($this->_iPageSize * $this->_iPage) ? $this->_iCnt : ($this->_iPageSize * $this->_iPage)), 'sParams' => $sParams, 'phrase' => $this->_sPhrase, 'icon' => $this->_sIcon ); list($nStart, $nEnd) = $this->_getPos(); $oUrl = Phpfox_Url::instance(); $oUrl->clearParam('page'); if ($this->_iPage != 1) { $oUrl->setParam($this->_sUrlKey, 1); $aInfo['firstAjaxUrl'] = 1; $aInfo['firstUrl'] = $oUrl->getFullUrl(); $oUrl->setParam($this->_sUrlKey, $this->_iPage-1); $aInfo['prevAjaxUrl'] = ($this->_iPage-1); $aInfo['prevUrl'] = $oUrl->getFullUrl(); Phpfox_Template::instance()->setHeader('<link rel="prev" href="' . $aInfo['prevUrl'] . '" />'); } for ($i = $nStart; $i <= $nEnd; $i++) { if ($this->_iPage == $i) { $oUrl->setParam($this->_sUrlKey, $i); $aInfo['urls'][$oUrl->getFullUrl()] = $i; } else { $oUrl->setParam($this->_sUrlKey, $i); $aInfo['urls'][$oUrl->getFullUrl()] = $i; } } $oUrl->setParam($this->_sUrlKey, ($this->_iPage + 1)); $aInfo['nextAjaxUrlPager'] = $oUrl->getFullUrl(); if ($this->_iPagesCount != $this->_iPage) { $oUrl->setParam($this->_sUrlKey, ($this->_iPage + 1)); $aInfo['nextAjaxUrl'] = ($this->_iPage + 1); $aInfo['nextUrl'] = $oUrl->getFullUrl(); Phpfox_Template::instance()->setHeader('<link rel="next" href="' . $aInfo['nextUrl'] . '" />'); $oUrl->setParam($this->_sUrlKey, $this->_iPagesCount); $aInfo['lastUrl']= $oUrl->getFullUrl(); $aInfo['lastAjaxUrl'] = $this->_iPagesCount; } $aInfo['sParamsAjax'] = str_replace("'", "\\'", $aInfo['sParams']); */ $sNextPage = (int) Phpfox_Request::instance()->get('page', 1) + 1; Phpfox_Url::instance()->clearParam('page'); $_GET['page'] = $sNextPage; Phpfox_Template::instance()->assign(array('sCurrentUrl' => Phpfox_Url::instance()->makeUrl('current'), 'sNextIteration' => $sNextPage)); }
/** * Extends the request class and returns its class object. * * @see Phpfox_Request * @return Phpfox_Request */ protected function request() { return Phpfox_Request::instance(); }
public function addLike($iItemId, $bDoNotSendEmail = false) { $aRow = $this->database()->select('field_id, phrase_var_name')->from(Phpfox::getT('custom_field'))->where('field_id = ' . (int) $iItemId)->execute('getSlaveRow'); if (!isset($aRow['field_id'])) { return false; } $aFeed = $this->database()->select('f.*, u.user_name')->from(Phpfox::getT('feed'), 'f')->where('feed_id = ' . (int) Phpfox_Request::instance()->get('parent_id'))->join(Phpfox::getT('user'), 'u', 'u.user_id = f.user_id')->execute('getSlaveRow'); /* Check if the field exists for the total_like*/ $iExists = $this->database()->select('field_id')->from(Phpfox::getT('user_custom_data'))->where('field_id = ' . $iItemId . ' AND user_id = ' . $aFeed['user_id'])->execute('getSlaveField'); if ($iExists > 0) { $this->database()->updateCount('like', 'type_id = \'custom\' AND item_id = ' . (int) $iItemId . '', 'total_like', 'user_custom_data', 'field_id = ' . (int) $iItemId . ' AND user_id = ' . $aFeed['user_id']); } else { $this->database()->insert(Phpfox::getT('user_custom_data'), array('user_id' => $aFeed['user_id'], 'field_id' => $iItemId, 'total_like' => 1)); } if (!$bDoNotSendEmail) { $sLink = Phpfox_Url::instance()->makeUrl($aFeed['user_name'], array('feed-id' => $aFeed['feed_id'])); Phpfox::getLib('mail')->to($aFeed['user_id'])->subject(array('custom.full_name_liked_your_change_on_phrase_var_name', array('full_name' => Phpfox::getUserBy('full_name'), 'phrase_var_name' => Phpfox::getPhrase($aRow['phrase_var_name']))))->message(array('custom.full_name_liked_your_change_on_message', array('full_name' => Phpfox::getUserBy('full_name'), 'link' => $sLink, 'phrase_var_name' => Phpfox::getPhrase($aRow['phrase_var_name']))))->notification('like.new_like')->send(); Phpfox::getService('notification.process')->add('custom_like', $aFeed['feed_id'], $aFeed['user_id']); } }