Esempio n. 1
0
	public function query($sQuery, $iPage, $iTotalShow, $sView = null)
	{
		if ($sView !== null && Phpfox::isModule($sView))
		{
			$aModuleResults = Phpfox::callback($sView . '.globalUnionSearch', $this->preParse()->clean($sQuery));
		}
		else 
		{
			$aModuleResults = Phpfox::massCallback('globalUnionSearch', $this->preParse()->clean($sQuery));
		}
		
		$iOffset = ($iPage * $iTotalShow);
		
		$aRows = $this->database()->select('item.*, ' . Phpfox::getUserField())
				->unionFrom('item')		
				->join(Phpfox::getT('user'), 'u', 'u.user_id = item.item_user_id')
				->limit($iOffset, $iTotalShow)
				->order('item_time_stamp DESC')				
				->execute('getSlaveRows');

		$aResults = array();
		foreach ($aRows as $iKey => $aRow)
		{
			$aResults[] = array_merge($aRow, (array) Phpfox::callback($aRow['item_type_id'] . '.getSearchInfo', $aRow));
		}
		
		return $aResults;
	}
Esempio n. 2
0
 /**
  * Gets the featured members according to Phpfox::getParam('user.how_many_featured_members').
  * Uses cache to save a query (stores a cache if none found)
  * @return array( array of users, int total featured users )
  */
 public function get()
 {
     if ($sPlugin = Phpfox_Plugin::get('user.service_featured_get_1')) {
         eval($sPlugin);
         if (isset($mPluginReturn)) {
             return $mPluginReturn;
         }
     }
     $iTotal = Phpfox::getParam('user.how_many_featured_members');
     // the random will be done with php logic
     $sCacheId = $this->cache()->set('featured_users');
     if (!($aUsers = $this->cache()->get($sCacheId))) {
         $aUsers = $this->database()->select(Phpfox::getUserField() . ', uf.ordering')->from(Phpfox::getT('user'), 'u')->join($this->_sTable, 'uf', 'uf.user_id = u.user_id')->order('ordering DESC')->execute('getSlaveRows');
         if (Phpfox::getParam('user.cache_featured_users')) {
             $this->cache()->save($sCacheId, $aUsers);
         }
     }
     if (!is_array($aUsers)) {
         return array(array(), 0);
     }
     $aOut = array();
     if (Phpfox::getParam('user.randomize_featured_members')) {
         shuffle($aUsers);
     }
     $iCount = count($aUsers);
     // using count instead of $this->database()->limit to measure the real value
     for ($i = 0; $i <= $iTotal; $i++) {
         if (!isset($aUsers[$iCount - $i])) {
             continue;
         }
         // availability check
         $aOut[] = $aUsers[$iCount - $i];
     }
     return array($aOut, count($aUsers));
 }
Esempio n. 3
0
 public function setHash($sCode)
 {
     if (Phpfox::getParam('core.store_only_users_in_session')) {
         $oRequest = Phpfox::getLib('request');
         $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 . "'");
     }
 }
Esempio n. 4
0
 public function export($sProduct, $sModuleId = null)
 {
     $aCond = array();
     $aCond[] = "me.product_id = '" . $this->database()->escape($sProduct) . "'";
     if ($sModuleId !== null) {
         $aCond[] = "AND me.module_id = '" . $sModuleId . "'";
     }
     $aRows = $this->database()->select('me.*, m.module_id AS module_name, p.title AS product_name, pm.var_name as parent_var_name')->from($this->_sTable, 'me')->join(Phpfox::getT('module'), 'm', 'm.module_id = me.module_id')->join(Phpfox::getT('product'), 'p', 'p.product_id = me.product_id')->leftjoin(Phpfox::getT('menu'), 'pm', 'pm.menu_id = me.parent_id')->where($aCond)->execute('getRows');
     if (!count($aRows)) {
         return false;
     }
     $oXmlBuilder = Phpfox::getLib('xml.builder');
     $oXmlBuilder->addGroup('menus');
     foreach ($aRows as $aRow) {
         if (!empty($aRow['disallow_access'])) {
             $aGroups = unserialize($aRow['disallow_access']);
             $aRow['disallow_access'] = array();
             foreach ($aGroups as $iGroup) {
                 if (!in_array($iGroup, array(1, 2, 3, 4))) {
                     continue;
                 }
                 $aRow['disallow_access'][] = $iGroup;
             }
             $aRow['disallow_access'] = serialize($aRow['disallow_access']);
         }
         $aTag = array('module_id' => $aRow['module_id'], 'parent_var_name' => $aRow['parent_var_name'], 'm_connection' => $aRow['m_connection'], 'var_name' => $aRow['var_name'], 'ordering' => $aRow['ordering'], 'url_value' => $aRow['url_value'], 'version_id' => $aRow['version_id'], 'disallow_access' => $aRow['disallow_access'], 'module' => $aRow['module_name']);
         if (!empty($aRow['mobile_icon'])) {
             $aTag['mobile_icon'] = $aRow['mobile_icon'];
         }
         $oXmlBuilder->addTag('menu', '', $aTag);
     }
     $oXmlBuilder->closeGroup();
     return true;
 }
Esempio n. 5
0
 public function get($iContestId, $iPage = 0, $iLimit = 20)
 {
     $where = 'cta.contest_id = ' . $iContestId;
     $iCnt = $this->database()->select('count(*)')->from($this->_sTable, 'cta')->join(Phpfox::getT('user'), 'u', 'u.user_id = cta.user_id')->where($where)->execute('getSlaveField');
     $aRows = $this->database()->select('*')->from($this->_sTable, 'cta')->join(Phpfox::getT('user'), 'u', 'u.user_id = cta.user_id')->where($where)->limit($iPage, $iLimit)->execute('getSlaveRows');
     return array($iCnt, $aRows);
 }
Esempio n. 6
0
 public function getFriends()
 {
     if ((int) $this->_oApi->get('user_id') === 0) {
         $iUserId = $this->_oApi->getUserId();
     } else {
         $iUserId = $this->_oApi->get('user_id');
     }
     if ($this->_oApi->isAllowed('friend.get_friends') == false) {
         return $this->_oApi->error('friend.get_friends', 'User did not to view friends list');
     }
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'f')->join(Phpfox::getT('user'), 'u', 'u.user_id = f.friend_user_id')->where('f.is_page = 0 AND f.user_id = ' . (int) $iUserId)->execute('getSlaveField');
     $this->_oApi->setTotal($iCnt);
     $aRows = $this->database()->select('u.user_id, u.user_name, u.full_name, u.joined, u.user_image, u.country_iso, u.gender')->from($this->_sTable, 'f')->join(Phpfox::getT('user'), 'u', 'u.user_id = f.friend_user_id')->where('f.is_page = 0 AND f.user_id = ' . (int) $iUserId)->limit($this->_oApi->get('page'), 10, $iCnt)->execute('getSlaveRows');
     $aFriends = array();
     foreach ($aRows as $iKey => $aRow) {
         unset($aRows[$iKey]['user_name'], $aRows[$iKey]['country_iso'], $aRows[$iKey]['gender'], $aRows[$iKey]['joined']);
         if (!$this->_oApi->isAllowed('user.get_full_name', null, $aRow['user_id'])) {
             unset($aRows[$iKey]['full_name']);
         } else {
             $aRows[$iKey]['name'] = $aRow['full_name'];
         }
         if (!$this->_oApi->isAllowed('user.get_email', null, $aRow['user_id'])) {
             unset($aRows[$iKey]['email']);
         }
         $sImagePath = $aRow['user_image'];
         $aRows[$iKey]['photo_50px'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'suffix' => '_50', 'return_url' => true));
         $aRows[$iKey]['photo_50px_square'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'suffix' => '_50_square', 'return_url' => true));
         $aRows[$iKey]['photo_120px'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'suffix' => '_120', 'return_url' => true));
         $aRows[$iKey]['permalink'] = Phpfox::getLib('url')->makeUrl($aRow['user_name']);
         unset($aRows[$iKey]['user_image']);
     }
     return $aRows;
 }
Esempio n. 7
0
 /** This function catches all the "actions" (Dislike, and in the future maybe others)
  * */
 public function getNotificationAction($aNotification)
 {
     //d($aNotification);die();
     // get the type of item that was marked ("blog", "photo"...)
     $aAction = $this->database()->select('*')->from(Phpfox::getT('action'))->where('action_id = ' . (int) $aNotification['item_id'])->limit(1)->execute('getSlaveRow');
     if (empty($aAction) || !isset($aAction['item_type_id'])) {
         return false;
         throw new Exception('No type for this action (' . print_r($aAction, true) . ')');
     }
     // Check if the module is a sub module
     if (preg_match('/(?P<module>[a-z]+)[_]?(?P<submodule>[a-z]{0,99})/i', $aAction['item_type_id'], $aMatch) < 1) {
         throw new Exception('Malformed item_type');
     }
     // Call the module and get the title
     if (!Phpfox::isModule($aMatch['module'])) {
         return false;
     }
     $aRow = Phpfox::getService($aMatch['module'])->getInfoForAction($aAction);
     $sUsers = Phpfox::getService('notification')->getUsers($aNotification);
     $sTitle = Phpfox::getLib('parse.output')->shorten($aRow['title'], Phpfox::getParam('notification.total_notification_title_length'), '...');
     $sPhrase = '';
     if ($aNotification['user_id'] == $aRow['user_id']) {
         // {users} disliked {gender} own {item} "{title}"
         $sPhrase = Phpfox::getPhrase('like.users_disliked_gender_own_item_title', array('users' => $sUsers, 'gender' => Phpfox::getService('user')->gender($aRow['gender'], 1), 'title' => $sTitle, 'item' => $aAction['item_type_id']));
     } elseif ($aRow['user_id'] == Phpfox::getUserId()) {
         // {users} liked your blog "{title}"
         $sPhrase = Phpfox::getPhrase('like.users_disliked_your_item_title', array('users' => $sUsers, 'title' => $sTitle, 'item' => $aAction['item_type_id']));
     } else {
         $sPhrase = Phpfox::getPhrase('like.users_disliked_users_item', array('users' => $sUsers, 'row_full_name' => $aRow['full_name'], 'title' => $sTitle, 'item' => $aAction['item_type_id']));
     }
     return array('link' => $aRow['link'], 'message' => $sPhrase, 'icon' => Phpfox_Template::instance()->getStyle('image', 'activity.png', 'blog'));
 }
Esempio n. 8
0
 public function newUploadComplete()
 {
     Phpfox::isUser(true);
     $bCanAddVideo = false;
     $aServer = $this->get('_v');
     $aVideoServers = Phpfox::getParam('video.convert_servers');
     foreach ($aVideoServers as $sServer) {
         if (md5($sServer) == $aServer['url']) {
             $mReturn = json_decode(Phpfox::getLib('request')->send($sServer, array('action' => 'check', '_v_id' => $aServer['id'], '_v_secret' => Phpfox::getParam('video.convert_servers_secret'))));
             if (!$mReturn->error) {
                 $bCanAddVideo = true;
                 break;
             }
         }
     }
     if ($bCanAddVideo) {
         $aVals = $this->get('val');
         $aVideo = $this->get('video');
         if (($iId = Phpfox::getService('video.process')->add($aVals, $aVideo)) !== false) {
             $aVideo = Phpfox::getService('video')->getForEdit($iId, true);
             Phpfox::getLib('database')->update(Phpfox::getT('video'), array('custom_v_id' => $aServer['id']), 'video_id = ' . (int) $aVideo['video_id']);
             $this->call('window.location.href = \'' . Phpfox::permalink('video', $aVideo['video_id'], $aVideo['title']) . '\';');
         }
     }
 }
Esempio n. 9
0
 public function process()
 {
     $aUser = $this->getParam('aUser');
     #
     # Check User Privacy Settings
     if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'megapoke.who_can_poke')) {
         return false;
     }
     # Check for User Group Permission
     if (!Phpfox::getUserParam('megapoke.canmegapoke')) {
         return false;
     }
     # User can't Poke themself
     if ($aUser['user_id'] == Phpfox::getUserId()) {
         return false;
     }
     # User must be logged in to Poke
     if (!Phpfox::getUserId()) {
         return false;
     }
     #GET POKES
     $aPokes = phpfox::getLib('phpfox.database')->select('*')->from(Phpfox::getT('megapoke'))->where("poke_active = '0' ")->order('poke_text')->execute('getSlaveRows');
     $this->template()->assign(array('sHeader' => Phpfox::getPhrase('megapoke.profilepoketitle'), 'aPokes' => $aPokes, 'sSendText' => Phpfox::getPhrase('megapoke.poke_send', array('user_name' => $aUser['full_name'])), 'pokeFormUrl' => Phpfox::getLib('url')->makeUrl('megapoke')));
     return 'block';
 }
Esempio n. 10
0
 public function export($sProductId, $sModuleId = null)
 {
     $aWhere = array();
     $aWhere[] = "block.product_id = '" . $sProductId . "'";
     if ($sModuleId !== null) {
         $aWhere[] = " AND block.module_id = '" . $sModuleId . "'";
     }
     $aRows = $this->database()->select('block.*, product.title AS product_name, m.module_id AS module_name, bs.source_code, bs.source_parsed')->from($this->_sTable, 'block')->leftJoin(Phpfox::getT('block_source'), 'bs', 'bs.block_id = block.block_id')->leftJoin(Phpfox::getT('product'), 'product', 'product.product_id = block.product_id')->leftJoin(Phpfox::getT('module'), 'm', "m.module_id = block.module_id")->where($aWhere)->execute('getRows');
     if (!isset($aRows[0]['product_name'])) {
         return Phpfox_Error::set(Phpfox::getPhrase('admincp.product_does_not_have_any_settings'));
     }
     if (!count($aRows)) {
         return false;
     }
     $oXmlBuilder = Phpfox::getLib('xml.builder');
     $oXmlBuilder->addGroup('blocks');
     foreach ($aRows as $aRow) {
         $oXmlBuilder->addGroup('block', array('type_id' => $aRow['type_id'], 'm_connection' => $aRow['m_connection'], 'module_id' => $aRow['module_name'], 'component' => $aRow['component'], 'location' => $aRow['location'], 'is_active' => $aRow['is_active'], 'ordering' => $aRow['ordering'], 'disallow_access' => $aRow['disallow_access'], 'can_move' => $aRow['can_move']));
         $oXmlBuilder->addTag('title', $aRow['title']);
         $oXmlBuilder->addTag('source_code', empty($aRow['source_code']) ? '' : $aRow['source_code']);
         $oXmlBuilder->addTag('source_parsed', empty($aRow['source_parsed']) ? '' : $aRow['source_parsed']);
         $oXmlBuilder->closeGroup();
     }
     $oXmlBuilder->closeGroup();
     return true;
 }
Esempio n. 11
0
 public function removeCacheUrl()
 {
     $iUrlId = (int) $this->get('iUrlId');
     $sUrl = $aCache = Phpfox::getLib('database')->select('u.url')->from(Phpfox::getT('ko_generator_cache_url'), 'u')->where('u.url_id =' . $iUrlId)->execute('getField');
     Phpfox::getService('generator.image.process')->ignore($sUrl);
     Phpfox::getService('generator.cache.process')->removeCacheUrl($iUrlId);
 }
Esempio n. 12
0
 public function updateOrdering($aVal)
 {
     foreach ($aVal as $iId => $iPosition) {
         $this->database()->update(Phpfox::getT('contact_category'), array('ordering' => (int) $iPosition), 'category_id = ' . (int) $iId);
     }
     $this->renewCache();
 }
Esempio n. 13
0
 public function add($aVals)
 {
     if (!isset($aVals['agree'])) {
         Phpfox_Error::set('Check our agreement in order to join our site.');
         return false;
     }
     if (!filter_var($aVals['organization_email'], FILTER_VALIDATE_EMAIL)) {
         Phpfox_Error::set('Provide a valid email address.');
         return false;
     }
     if (strlen($aVals['organization_password']) < 6) {
         Phpfox_Error::set('Not a valid password.');
         return false;
     }
     $aInsert = array('view_id' => 0, 'type_id' => isset($aVals['type_id']) ? (int) $aVals['type_id'] : 2, 'app_id' => isset($aVals['app_id']) ? (int) $aVals['app_id'] : 0, 'category_id' => isset($aVals['category_id']) ? (int) $aVals['category_id'] : 2, 'user_id' => 0, 'title' => $this->preParse()->clean($aVals['organization_name']), 'founder' => $aVals['organization_founder'], 'mission_statement' => $aVals['organization_mission'], 'phone' => $aVals['organization_phone'], 'website' => $aVals['organization_website'], 'time_stamp' => PHPFOX_TIME);
     $iId = $this->database()->insert(Phpfox::getT('organization'), $aInsert);
     $aInsertText = array('organization_id' => $iId);
     if (isset($aVals['info'])) {
         $aInsertText['text'] = $this->preParse()->clean($aVals['info']);
         $aInsertText['text_parsed'] = $this->preParse()->prepare($aVals['info']);
     }
     $this->database()->insert(Phpfox::getT('organization_text'), $aInsertText);
     $sSalt = $this->_getSalt();
     $iUserId = $this->database()->insert(Phpfox::getT('user'), array('profile_organization_id' => $iId, 'user_group_id' => NORMAL_USER_ID, 'view_id' => '7', 'full_name' => $this->preParse()->clean($aVals['organization_name']), 'joined' => PHPFOX_TIME, 'email' => $aVals['organization_email'], 'password' => Phpfox::getLib('hash')->setHash($aVals['organization_password'], $sSalt), 'password_salt' => $sSalt));
     $this->database()->update(Phpfox::getT('user'), array('user_name' => 'profile-' . $iUserId), 'user_id=' . $iUserId);
     $this->database()->update(Phpfox::getT('organization'), array('user_id' => $iUserId), 'organization_id=' . $iId);
     $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);
     Phpfox::getService('user.activity')->update(Phpfox::getUserId(), 'organization');
     Phpfox::getService('like.process')->add('organization', $iId);
     return $iId;
 }
Esempio n. 14
0
 /**
  * Get the latest shoutouts.
  *
  * @param int $iLimit Define the limit so we don't return all the shoutouts.
  * @return array Array of shoutouts.
  */
 public function getMessages($iLimit = 5)
 {
     if (isset($this->_aCallback['module'])) {
         if (Phpfox::hasCallback($this->_aCallback['module'], 'getShoutboxData')) {
             $aCallback = Phpfox::callback($this->_aCallback['module'] . '.getShoutboxData');
             if (isset($aCallback['table'])) {
                 $this->_sTable = Phpfox::getT($aCallback['table']);
                 $this->database()->where('item_id = ' . (int) $this->_aCallback['item']);
             }
         }
     }
     $aMessages = $this->database()->select('s.shout_id, s.text, s.time_stamp, ' . Phpfox::getUserField())->from($this->_sTable, 's')->join(Phpfox::getT('user'), 'u', 'u.user_id = s.user_id')->limit($iLimit)->order('s.time_stamp DESC')->execute('getSlaveRows');
     foreach ($aMessages as $iKey => $aMessage) {
         $aMessage['text'] = Phpfox::getLib('parse.output')->replaceHashTags(Phpfox::getLib('parse.output')->split(Phpfox::getLib('parse.output')->clean($aMessage['text']), Phpfox::getParam('shoutbox.shoutbox_wordwrap')));
         if (Phpfox::isModule('emoticon')) {
             $aMessages[$iKey]['text'] = Phpfox::getService('emoticon')->parse($aMessage['text']);
         }
         $aMessages[$iKey]['module'] = isset($this->_aCallback['module']) ? $this->_aCallback['module'] : '';
     }
     // FUDGE Lovinity January 5, 2016: Filter shouts by users who have been blocked or are blocking
     $bIsBlocked = Phpfox::getService('user.block')->isBlocked($aMessages[$iKey]['user_id'], Phpfox::getUserId());
     $bIsBlocked2 = Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $aMessages[$iKey]['user_id']);
     if ($bIsBlocked || $bIsBlocked2) {
         $aMessages[$iKey]['text'] = '<img src="file/public/blocked.png">';
     }
     // END FUDGE
     return $aMessages;
 }
Esempio n. 15
0
 /**
  * Deletes a category
  * @param int $iId 
  * @return bool
  */
 public function deleteCategory($iId)
 {
     Phpfox::isAdmin(true);
     $this->database()->delete(Phpfox::getT('app_category'), 'category_id = ' . (int) $iId);
     $this->database()->delete(Phpfox::getT('app_category_data'), 'category_id = ' . (int) $iId);
     return true;
 }
Esempio n. 16
0
 private function deleteAllContestTable()
 {
     $aRows = Phpfox::getLib('phpfox.database')->select("concat('DROP TABLE ', TABLE_NAME, ';') as drop_query")->from('INFORMATION_SCHEMA.TABLES')->where('TABLE_NAME like \'' . Phpfox::getT('contest') . '%\' AND table_schema = \'' . Phpfox::getParam(array('db', 'name')) . '\'')->execute('getSlaveRows');
     foreach ($aRows as $aRow) {
         Phpfox::getLib('phpfox.database')->query($aRow['drop_query']);
     }
 }
Esempio n. 17
0
 public function getSiteStats()
 {
     $sCacheQueryId = $this->cache()->set('stat_query');
     if (!($aStats = $this->cache()->get($sCacheQueryId))) {
         $aStats = $this->database()->select('ss.*')->from($this->_sTable, 'ss')->where('ss.is_active = 1')->join(Phpfox::getT('module'), 'm', 'm.module_id = ss.module_id AND m.is_active = 1')->join(Phpfox::getT('product'), 'p', 'p.product_id = ss.product_id AND p.is_active = 1')->order('ss.ordering ASC')->execute('getRows');
         $this->cache()->save($sCacheQueryId, $aStats);
     }
     $aCached = array();
     $bRun = true;
     if (Phpfox::getParam('core.cache_site_stats')) {
         $sCacheCountId = $this->cache()->set('stat_count');
         if ($aCached = $this->cache()->get($sCacheCountId, Phpfox::getParam('core.site_stat_update_time'))) {
             $bRun = false;
         }
     }
     if ($bRun === true) {
         foreach ($aStats as $aStat) {
             eval('$aStat[\'count\'] = ' . $aStat['php_code'] . '');
             unset($aStat['php_code']);
             $aCached[] = $aStat;
         }
         if (Phpfox::getParam('core.cache_site_stats')) {
             $this->cache()->save($sCacheCountId, $aCached);
         }
     }
     return $aCached;
 }
Esempio n. 18
0
	/**
	 * Get the latest shoutouts.
	 *
	 * @param int $iLimit Define the limit so we don't return all the shoutouts.
	 * @return array Array of shoutouts.
	 */
	public function getMessages($iLimit = 5)
	{
		if (isset($this->_aCallback['module']))
		{
			if (Phpfox::hasCallback($this->_aCallback['module'], 'getShoutboxData'))
			{
				$aCallback = Phpfox::callback($this->_aCallback['module'] . '.getShoutboxData');		
				if (isset($aCallback['table']))
				{
					$this->_sTable = Phpfox::getT($aCallback['table']);
					
					$this->database()->where('item_id = ' . (int) $this->_aCallback['item']);
				}
			}
		}				
		
		$aMessages = $this->database()->select('s.shout_id, s.text, s.time_stamp, ' . Phpfox::getUserField())
			->from($this->_sTable, 's')
			->join(Phpfox::getT('user'), 'u', 'u.user_id = s.user_id')
			->limit($iLimit)
			->order('s.time_stamp DESC')
			->execute('getSlaveRows');

		foreach ($aMessages as $iKey => $aMessage)
		{
			$aMessage['text'] = Phpfox::getLib('parse.output')->split(Phpfox::getLib('parse.output')->clean($aMessage['text']), Phpfox::getParam('shoutbox.shoutbox_wordwrap'));
			
			$aMessages[$iKey]['text'] = Phpfox::getService('emoticon')->parse($aMessage['text']);
			$aMessages[$iKey]['module'] = (isset($this->_aCallback['module']) ? $this->_aCallback['module'] : '');
		}
			
		return $aMessages;
	}
Esempio n. 19
0
	public function getQueryJoins($bIsCount = false, $bNoQueryFriend = false)
	{
		if (Phpfox::isModule('friend') && Phpfox::getService('friend')->queryJoin($bNoQueryFriend))
		{
			$this->database()->join(Phpfox::getT('friend'), 'friends', 'friends.user_id = q.user_id AND friends.friend_user_id = ' . Phpfox::getUserId());	
		}			
	}
Esempio n. 20
0
 public function get($iUserId = null)
 {
     if ($iUserId === null) {
         $iUserId = Phpfox::getUserId();
     }
     return $this->database()->select('ub.block_user_id, ' . Phpfox::getUserField())->from($this->_sTable, 'ub')->join(Phpfox::getT('user'), 'u', 'u.user_id = ub.block_user_id')->where('ub.user_id = ' . (int) $iUserId)->execute('getSlaveRows');
 }
Esempio n. 21
0
 public function update($sTable, $iId, $iUserId = null)
 {
     if (Phpfox::getParam('track.cache_allow_recurrent_visit') > 0) {
         // Get the cache!
         $sType = '';
         switch ($sTable) {
             case 'user_track':
                 // This type is defined in the service track->getLatestUsers. It is also used in track.callback->addTrack
                 $sType = 'profile';
                 break;
         }
         $sCacheId = $this->cache()->set(array('track', $sType . '_' . $iId));
         if (!($aTracks = $this->cache()->get($sCacheId))) {
         } else {
             // Check every track record in cache
             foreach ($aTracks as $aTrack) {
                 // If its the user visiting this profile and it was added recently we dont add it anymore.
                 if ($aTrack['user_id'] == Phpfox::getUserId() && $aTrack['time_stamp'] >= PHPFOX_TIME - Phpfox::getParam('track.cache_allow_recurrent_visit') * 60) {
                     return true;
                 }
             }
         }
     }
     $this->database()->update(Phpfox::getT($sTable), array('time_stamp' => PHPFOX_TIME), 'item_id = ' . (int) $iId . ' AND user_id = ' . Phpfox::getUserId());
 }
Esempio n. 22
0
 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::getLib('request')->get('mode') == 'full' ? 'full' : '';
     $aPhotos = array();
     foreach ($aRows as $iKey => $aRow) {
         if ($iKey === 0) {
             $aRow['link'] = Phpfox::getLib('url')->makeUrl('photo.battle', array('w' => $aRow['photo_id'], 'l' => $aRows[1]['photo_id'], 'mode' => $sMode));
         } else {
             $aRow['link'] = Phpfox::getLib('url')->makeUrl('photo.battle', array('w' => $aRow['photo_id'], 'l' => $aRows[0]['photo_id'], 'mode' => $sMode));
         }
         $aPhotos[$iKey === 0 ? 'one' : 'two'] = $aRow;
     }
     return $aPhotos;
 }
 protected function getRandomLink($sType)
 {
     $sField = $sType . '_id';
     $sTable = Phpfox::getT($sType);
     $sLink = $sType;
     switch ($sType) {
         case 'pages':
             $sField = 'page_id';
             break;
         case 'music_song':
             $sField = 'song_id';
             $sLink = 'music';
             break;
         case 'mail':
             $this->database()->where('owner_user_id = ' . Phpfox::getUserId() . ' OR ' . 'viewer_user_id = ' . Phpfox::getUserId());
             $sLink = 'mail.view';
             break;
         case 'forum_thread':
             $sField = 'thread_id';
             $sLink = 'forum.thread';
             break;
     }
     $id = $this->database()->select($sField)->from($sTable)->order('RAND()')->execute('getField');
     if (!$id) {
         return false;
     }
     $sUrl = Phpfox::getLib('url')->makeUrl($sLink, array($id));
     return $sUrl;
 }
Esempio n. 24
0
	public function update($sTable, $iId, $iUserId = null)
	{
		$this->database()->update(Phpfox::getT($sTable), array(
				'time_stamp' => PHPFOX_TIME
			), 'item_id = ' . (int) $iId . ' AND user_id = ' . Phpfox::getUserId()
		);
	}
Esempio n. 25
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     if ($aVals = $this->request()->getArray('val')) {
         Phpfox::isUser(true);
         Phpfox::getUserParam('comment.can_post_comments', true);
         if (($iFlood = Phpfox::getUserParam('comment.comment_post_flood_control')) !== 0) {
             $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('comment'), 'condition' => 'type_id = \'' . Phpfox::getLib('database')->escape($aVals['type']) . '\' AND user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
             // actually check if flooding
             if (Phpfox::getLib('spam')->check($aFlood)) {
                 Phpfox_Error::set(Phpfox::getPhrase('comment.posting_a_comment_a_little_too_soon_total_time', array('total_time' => Phpfox::getLib('spam')->getWaitTime())));
             }
         }
         if (Phpfox::getLib('parse.format')->isEmpty($aVals['text'])) {
             Phpfox_Error::set(Phpfox::getPhrase('feed.add_some_text_to_your_comment'));
         }
         if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('comment.process')->add($aVals))) {
             $this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), Phpfox::getPhrase('feed.successfully_added_your_comment'));
         }
     }
     if ($iLikeType = $this->request()->getInt('liketype')) {
         if (Phpfox::getService('feed.process')->like($this->request()->getInt('id'), $iLikeType)) {
             $this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), $iLikeType == '1' ? Phpfox::getPhrase('feed.successfully_liked_this_feed') : Phpfox::getPhrase('feed.successfully_unliked_this_feed'));
         }
     }
     list($iFeedCount, $aFeeds) = Phpfox::getService('feed')->get(null, $this->request()->getInt('id'), 1);
     $iCommentCnt = 0;
     $aComments = array();
     if (Phpfox::getParam('feed.allow_comments_on_feeds')) {
         list($iCommentCnt, $aComments) = Phpfox::getService('comment')->get('cmt.*', array("AND cmt.type_id = 'feed'", 'AND cmt.item_id = ' . (int) $aFeeds[0]['feed_id'], 'AND cmt.view_id = 0'), 'cmt.time_stamp ASC');
     }
     if (!count($aFeeds)) {
         return Phpfox_Error::display(Phpfox::getPhrase('feed.not_a_valid_feed'));
     }
     $this->template()->setMobileHeader(array('feed.css' => 'module_feed'))->assign(array('iFeedId' => $aFeeds[0]['feed_id'], 'aFeeds' => $aFeeds, 'aComments' => $aComments));
 }
Esempio n. 26
0
 public function check()
 {
     if (!Phpfox::getParam('user.check_promotion_system')) {
         return false;
     }
     if (!Phpfox::isUser()) {
         return false;
     }
     $sCacheId = $this->cache()->set('promotion_' . Phpfox::getUserBy('user_group_id'));
     $aPromotion = array();
     if (!($aPromotion = $this->cache()->get($sCacheId))) {
         $aPromotion = $this->database()->select('*')->from($this->_sTable)->where('user_group_id = ' . Phpfox::getUserBy('user_group_id'))->execute('getSlaveRow');
         $this->cache()->save($sCacheId, $aPromotion);
     }
     if (isset($aPromotion['promotion_id'])) {
         if ((int) Phpfox::getUserBy('activity_points') >= (int) $aPromotion['total_activity'] && (int) $aPromotion['total_activity']) {
             $this->database()->update(Phpfox::getT('user'), array('user_group_id' => $aPromotion['upgrade_user_group_id']), 'user_id = ' . Phpfox::getUserId());
             Phpfox_Url::instance()->send('user.promotion');
         } else {
             if ((int) $aPromotion['total_day'] > 0) {
                 if (str_replace('-', '', Phpfox::getUserBy('joined') - PHPFOX_TIME) >= $aPromotion['total_day'] * 86400) {
                     $this->database()->update(Phpfox::getT('user'), array('user_group_id' => $aPromotion['upgrade_user_group_id']), 'user_id = ' . Phpfox::getUserId());
                     Phpfox_Url::instance()->send('user.promotion');
                 }
             }
         }
     }
 }
Esempio n. 27
0
 public function getJavascript($iPhotoId)
 {
     $aTags = $this->database()->select('p.user_id AS photo_owner_id, pt.tag_id, pt.user_id AS post_user_id, pt.content, pt.position_x, pt.position_y, pt.width, pt.height, ' . Phpfox::getUserField())->from($this->_sTable, 'pt')->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = pt.tag_user_id')->join(Phpfox::getT('photo'), 'p', 'p.photo_id = pt.photo_id')->where('pt.photo_id = ' . (int) $iPhotoId)->execute('getSlaveRows');
     if (!count($aTags)) {
         return false;
     }
     $sNotes = '[';
     foreach ($aTags as $aTag) {
         $sNotes .= '{';
         $sNotes .= 'note_id: ' . $aTag['tag_id'] . ', ';
         $sNotes .= 'x1: ' . $aTag['position_x'] . ', ';
         $sNotes .= 'y1: ' . $aTag['position_y'] . ', ';
         $sNotes .= 'width: ' . $aTag['width'] . ', ';
         $sNotes .= 'height: ' . $aTag['height'] . ', ';
         $sRemove = $aTag['post_user_id'] == Phpfox::getUserId() || $aTag['photo_owner_id'] == Phpfox::getUserId() || $aTag['user_id'] == Phpfox::getUserId() ? ' <a href="#" onclick="if (confirm(\\\'' . Phpfox::getPhrase('photo.are_you_sure') . '\\\')) { $(\\\'#noteform\\\').hide(); $(\\\'#js_photo_view_image\\\').imgAreaSelect({ hide: true }); $(this).parent(\\\'span:first\\\').remove();$(\\\'.notep#notep_' . $aTag['tag_id'] . '\\\').remove();$.ajaxCall(\\\'photo.removePhotoTag\\\', \\\'tag_id=' . $aTag['tag_id'] . '\\\'); } return false;"><i class="fa fa-remove"></i></a>' : '';
         if (!empty($aTag['user_id'])) {
             $sNotes .= 'note: \'<a href="' . Phpfox_Url::instance()->makeUrl($aTag['user_name']) . '" id="js_photo_tag_user_id_' . $aTag['user_id'] . '">' . $aTag['full_name'] . '</a>' . $sRemove . '\'';
         } else {
             $sNotes .= 'note: \'' . str_replace("'", "\\'", Phpfox::getLib('parse.output')->clean($aTag['content'])) . $sRemove . '\'';
         }
         $sNotes .= '},';
     }
     $sNotes = rtrim($sNotes, ',');
     $sNotes .= ']';
     return $sNotes;
 }
 public function isPhotoShare()
 {
     $aLinks = $this->database()->select('COUNT(*)')->from(Phpfox::getT('feed_share'), 'fs')->where('module_id = "photo"')->execute('getField');
     if ($aLinks > 0) {
         return true;
     }
 }
Esempio n. 29
0
 /**
  * Class process method wnich is used to execute this component.
  */
 public function process()
 {
     if ($this->request()->get('update')) {
         $aModules = Phpfox::massCallback('getSqlTitleField');
         $aParseTables = array();
         if (is_array($aModules) && count($aModules)) {
             foreach ($aModules as $aModule) {
                 if (isset($aModule['table'])) {
                     $aModule = array($aModule);
                 }
                 foreach ($aModule as $aInfo) {
                     $aParseTables[] = $aInfo;
                 }
             }
         }
         $oDb = Phpfox::getLib('database');
         foreach ($aParseTables as $aParseTable) {
             if (isset($aParseTable['has_index'])) {
                 $aIndexes = Phpfox::getLib('database.support')->getIndexes(Phpfox::getT($aParseTable['table']), null, $oDb, true);
                 foreach ($aIndexes as $aIndex) {
                     if ($aIndex['Column_name'] == $aParseTable['has_index']) {
                         $oDb->query('ALTER TABLE ' . Phpfox::getT($aParseTable['table']) . ' DROP INDEX ' . $aIndex['Key_name']);
                     }
                 }
             }
             Phpfox::getLib('database')->query('ALTER TABLE ' . Phpfox::getT($aParseTable['table']) . ' CHANGE ' . $aParseTable['field'] . ' ' . $aParseTable['field'] . ' text');
         }
         $this->url()->send('admincp.sql.title', null, Phpfox::getPhrase('admincp.database_tables_updated'));
     }
     $this->template()->setTitle(Phpfox::getPhrase('admincp.alter_title_fields'))->setBreadcrumb(Phpfox::getPhrase('admincp.alter_title_fields'))->assign(array());
 }
Esempio n. 30
0
	public function getOnlineGuests($aConds, $sSort = '', $iPage = '', $iLimit = '')
	{		
		$iCnt = $this->database()->select('COUNT(*)')
			->from(Phpfox::getT('log_session'), 'ls')			
			->where($aConds)
			->order($sSort)
			->execute('getSlaveField');	
			
		$aItems = array();
		if ($iCnt)
		{		
			$aItems = $this->database()->select('ls.*, b.ban_id')
				->from(Phpfox::getT('log_session'), 'ls')
				->leftJoin(Phpfox::getT('ban'), 'b', 'b.type_id = \'ip\' AND b.find_value = ls.ip_address')
				->where($aConds)
				->order($sSort)
				->limit($iPage, $iLimit, $iCnt)
				->execute('getSlaveRows');	
				
			foreach ($aItems as $iKey => $aItem)
			{
				$aItems[$iKey]['ip_address_search'] = str_replace('.', '-', $aItem['ip_address']);
			}
		}
							
		return array($iCnt, $aItems);
	}