示例#1
0
 /**
  * Controller
  */
 public function process()
 {
     ($sPlugin = Phpfox_Plugin::get('ad.component_controller_admincp_process__start')) ? eval($sPlugin) : false;
     $iPage = $this->request()->getInt('page');
     if ($iId = $this->request()->getInt('approve')) {
         if (Phpfox::getService('ad.process')->approve($iId)) {
             $this->url()->send('admincp.ad', null, Phpfox::getPhrase('ad.ad_successfully_approved'));
         }
     }
     if ($iId = $this->request()->getInt('deny')) {
         if (Phpfox::getService('ad.process')->deny($iId)) {
             $this->url()->send('admincp.ad', null, Phpfox::getPhrase('ad.ad_successfully_denied'));
         }
     }
     if ($iId = $this->request()->getInt('delete')) {
         if (Phpfox::getService('ad.process')->delete($iId)) {
             $this->url()->send('admincp.ad', null, Phpfox::getPhrase('ad.ad_successfully_deleted'));
         }
     }
     if ($aVals = $this->request()->getArray('val')) {
         if (Phpfox::getService('ad.process')->updateActivity($aVals)) {
             $this->url()->send('admincp.ad', null, Phpfox::getPhrase('ad.ad_s_successfully_updated'));
         }
     }
     $aPages = array(5, 10, 15, 20);
     $aDisplays = array();
     foreach ($aPages as $iPageCnt) {
         $aDisplays[$iPageCnt] = Phpfox::getPhrase('core.per_page', array('total' => $iPageCnt));
     }
     $aSorts = array('ad_id' => Phpfox::getPhrase('ad.recently_added'));
     $aFilters = array('status' => array('type' => 'select', 'options' => array('1' => Phpfox::getPhrase('ad.pending_approval'), '2' => Phpfox::getPhrase('ad.pending_payment'), '4' => Phpfox::getPhrase('ad.denied')), 'add_any' => true), 'display' => array('type' => 'select', 'options' => $aDisplays, 'default' => '10'), 'sort' => array('type' => 'select', 'options' => $aSorts, 'default' => 'ad_id'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'DESC'));
     $oSearch = Phpfox_Search::instance()->set(array('type' => 'campaigns', 'filters' => $aFilters, 'search' => 'search'));
     $sStatus = $oSearch->get('status');
     $sView = $this->request()->get('view');
     $iLocation = $this->request()->getInt('location');
     if ($sStatus == '1') {
         $oSearch->setCondition('is_custom = 2');
     } elseif ($sStatus == '2') {
         $oSearch->setCondition('is_custom = 1');
     } elseif ($sStatus == '4') {
         $oSearch->setCondition('is_custom = 4');
     } else {
         switch ($sView) {
             case 'pending':
                 $oSearch->setCondition('is_custom = 2');
                 break;
             default:
                 // $oSearch->setCondition('is_custom IN(0,2,3)');
                 break;
         }
     }
     if ($iLocation > 0) {
         $oSearch->setCondition('AND location = ' . (int) $iLocation);
     }
     $iLimit = $oSearch->getDisplay();
     list($iCnt, $aAds) = Ad_Service_Ad::instance()->get($oSearch->getConditions(), $oSearch->getSort(), $oSearch->getPage(), $iLimit);
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iLimit, 'count' => $oSearch->getSearchTotal($iCnt)));
     $this->template()->setTitle(Phpfox::getPhrase('ad.manage_ad_campaigns'))->setBreadcrumb(Phpfox::getPhrase('ad.manage_ad_campaigns'), $this->url()->makeUrl('admincp.ad'))->assign(array('aAds' => $aAds, 'iPendingCount' => (int) Ad_Service_Ad::instance()->getPendingCount(), 'sPendingLink' => Phpfox_Url::instance()->makeUrl('admincp.ad', array('view' => 'pending')), 'bIsSearch' => $this->request()->get('search-id') ? true : false, 'sView' => $sView));
     ($sPlugin = Phpfox_Plugin::get('ad.component_controller_admincp_process__end')) ? eval($sPlugin) : false;
 }
示例#2
0
 public function add($aVals, $bIsCustom = false, $aCallback = null)
 {
     if (!defined('PHPFOX_FORCE_IFRAME')) {
         define('PHPFOX_FORCE_IFRAME', true);
     }
     if (empty($aVals['privacy_comment'])) {
         $aVals['privacy_comment'] = 0;
     }
     if (empty($aVals['privacy'])) {
         $aVals['privacy'] = 0;
     }
     // d($aVals); exit;
     if (trim($aVals['link']['url']) == trim($aVals['status_info']) && (!empty($aVals['link']['title']) || !empty($aVals['link']['description']))) {
         $aVals['status_info'] = null;
     }
     $iId = $this->database()->insert($this->_sTable, array('user_id' => Phpfox::getUserId(), 'is_custom' => $bIsCustom ? '1' : '0', 'module_id' => $aCallback === null ? null : $aCallback['module'], 'item_id' => $aCallback === null ? 0 : $aCallback['item_id'], 'parent_user_id' => isset($aVals['parent_user_id']) ? (int) $aVals['parent_user_id'] : 0, 'link' => $this->preParse()->clean($aVals['link']['url'], 255), 'image' => isset($aVals['link']['image_hide']) && $aVals['link']['image_hide'] == '1' || !isset($aVals['link']['image']) ? null : $this->preParse()->clean($aVals['link']['image'], 255), 'title' => isset($aVals['link']['title']) ? $this->preParse()->clean($aVals['link']['title'], 255) : '', 'description' => isset($aVals['link']['description']) ? $this->preParse()->clean($aVals['link']['description'], 200) : '', 'status_info' => empty($aVals['status_info']) ? null : $this->preParse()->prepare($aVals['status_info']), 'privacy' => (int) $aVals['privacy'], 'privacy_comment' => (int) $aVals['privacy_comment'], 'time_stamp' => PHPFOX_TIME, 'has_embed' => empty($aVals['link']['embed_code']) ? '0' : '1'));
     if (!empty($aVals['link']['embed_code'])) {
         $this->database()->insert(Phpfox::getT('link_embed'), array('link_id' => $iId, 'embed_code' => $this->preParse()->prepare($aVals['link']['embed_code'])));
     }
     if ($aCallback === null && isset($aVals['parent_user_id']) && $aVals['parent_user_id'] != Phpfox::getUserId()) {
         $aUser = $this->database()->select('user_name')->from(Phpfox::getT('user'))->where('user_id = ' . (int) $aVals['parent_user_id'])->execute('getRow');
         $sLink = Phpfox_Url::instance()->makeUrl($aUser['user_name'], array('plink-id' => $iId));
         Phpfox::getLib('mail')->to($aVals['parent_user_id'])->subject(array('link.full_name_posted_a_link_on_your_wall', array('full_name' => Phpfox::getUserBy('full_name'))))->message(array('link.full_name_posted_a_link_on_your_wall_message', array('full_name' => Phpfox::getUserBy('full_name'), 'link' => $sLink)))->notification('comment.add_new_comment')->send();
         if (Phpfox::isModule('notification')) {
             Phpfox::getService('notification.process')->add('feed_comment_link', $iId, $aVals['parent_user_id']);
         }
     }
     $this->_iLinkId = $iId;
     return $bIsCustom ? $iId : Phpfox::getService('feed.process')->callback($aCallback)->add('link', $iId, $aVals['privacy'], $aVals['privacy_comment'], isset($aVals['parent_user_id']) ? (int) $aVals['parent_user_id'] : 0);
 }
示例#3
0
 public function get()
 {
     /*
     @title Get Feeds
     @info Get an activity feed for a specific user.
     @method GET
     @extra user_id=#{User ID#|int|yes}
     @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}&content=#{Additional text some feeds might have|string}&image=#{Some feeds include an image|string}
     */
     define('PHPFOX_SKIP_LOOP_MAX_COUNT', true);
     $aFeeds = array();
     $aFeedRows = Feed_Service_Feed::instance()->get($this->_oApi->get('user_id'), null, $this->_oApi->get('page'));
     foreach ($aFeedRows as $iKey => $aFeedRow) {
         foreach ($aFeedRow as $sKey => $mValue) {
             if (substr($sKey, 0, 5) == 'feed_') {
                 if (in_array($sKey, array('feed_reference', 'feed_time_stamp', 'feed_icon', 'feed_month_year', 'feed_image_onclick', 'feed_is_liked'))) {
                     continue;
                 }
                 $sKey = str_replace('feed_', '', $sKey);
                 switch ($sKey) {
                     case 'total_like':
                         $sKey = 'likes';
                         break;
                     case 'info':
                         $mValue = '<a href="' . Phpfox_Url::instance()->makeUrl($aFeedRow['user_name']) . '">' . $aFeedRow['full_name'] . '</a> ' . $mValue;
                         break;
                 }
                 $aFeeds[$iKey][$sKey] = $mValue;
             }
         }
     }
     return $aFeeds;
 }
示例#4
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');
                 }
             }
         }
     }
 }
示例#5
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_Url::instance()->makeUrl($aRow['user_name']);
         unset($aRows[$iKey]['user_image']);
     }
     return $aRows;
 }
示例#6
0
 public function processRows(&$aRows)
 {
     foreach ($aRows as $iKey => $aSong) {
         $aRows[$iKey]['song_path'] = Phpfox::getService('music')->getSongPath($aSong['song_path'], $aSong['server_id']);
         $aRows[$iKey]['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'music_song', 'privacy' => $aSong['privacy'], 'comment_privacy' => $aSong['privacy_comment'], 'like_type_id' => 'music_song', 'feed_is_liked' => isset($aSong['is_liked']) ? $aSong['is_liked'] : false, 'feed_is_friend' => isset($aSong['is_friend']) ? $aSong['is_friend'] : false, 'item_id' => $aSong['song_id'], 'user_id' => $aSong['user_id'], 'total_comment' => $aSong['total_comment'], 'feed_total_like' => $aSong['total_like'], 'total_like' => $aSong['total_like'], 'feed_link' => Phpfox_Url::instance()->permalink('music', $aSong['song_id'], $aSong['title']), 'feed_title' => $aSong['title'], 'type_id' => 'music_song');
     }
 }
示例#7
0
 public function process()
 {
     if (Phpfox::getService('language.process')->useLanguage($this->get('id'))) {
         Phpfox::addMessage(Phpfox::getPhrase('language.successfully_updated_your_language_preferences'));
         $sReturn = Phpfox::getLib('session')->get('redirect');
         if (is_bool($sReturn)) {
             $sReturn = '';
         }
         if ($sReturn) {
             $aParts = explode('/', trim($sReturn, '/'));
             if (isset($aParts[0])) {
                 $aParts[0] = Phpfox_Url::instance()->reverseRewrite($aParts[0]);
             }
             if (isset($aParts[0]) && !Phpfox::isModule($aParts[0])) {
                 $aUserCheck = Phpfox::getService('user')->getByUserName($aParts[0]);
                 if (isset($aUserCheck['user_id'])) {
                     if (isset($aParts[1]) && !Phpfox::isModule($aParts[1])) {
                         $sReturn = '';
                     }
                 } else {
                     $sReturn = '';
                 }
             }
         }
         $sReturn = trim($sReturn, '/');
         $this->call('window.location.href = window.location.href;');
         // . Phpfox_Url::instance()->makeUrl($sReturn) . '\';');
     }
 }
示例#8
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;
 }
示例#9
0
 public function reload()
 {
     $sUrl = Phpfox_Url::instance()->makeUrl('captcha.image', array('id' => md5(rand(100, 1000))));
     $sId = htmlspecialchars($this->get('sId'));
     $sInput = htmlspecialchars($this->get('sInput'));
     $this->call('$("#' . $sId . '").attr("src", "' . $sUrl . '"); $("#' . $sInput . '").val(""); $("#' . $sInput . '").focus(); $("#js_captcha_process").html("");');
 }
示例#10
0
 public function processActivityPayment()
 {
     $aParts = explode('|', $this->get('item_number'));
     if (Phpfox::getService('user.process')->purchaseWithPoints($aParts[0], $aParts[1], $this->get('amount'), $this->get('currency_code'))) {
         Phpfox::addMessage('Purchase successfully completed.');
         $this->call('window.location.href = \'' . Phpfox_Url::instance()->makeUrl('') . '\'');
     }
 }
示例#11
0
 public function add($aVals)
 {
     Phpfox::isUser(true);
     $aPhoto = $this->database()->select('p.photo_id, p.user_id, p.title, u.full_name')->from(Phpfox::getT('photo'), 'p')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->where('p.photo_id = ' . (int) $aVals['item_id'])->execute('getSlaveRow');
     if (!isset($aPhoto['photo_id'])) {
         return Phpfox_Error::set(Phpfox::getPhrase('photo.unable_to_find_the_photo'));
     }
     if (Phpfox::getUserParam('photo.can_tag_own_photo') && $aPhoto['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('photo.can_tag_other_photos')) {
         $sReturn = '';
         $iIsTagged = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('photo_id = ' . (int) $aVals['item_id'] . ' AND position_x = ' . (int) $aVals['x1'] . ' AND position_y = ' . (int) $aVals['y1'] . ' AND width = ' . (int) $aVals['width'] . ' AND height = ' . (int) $aVals['height'] . '')->execute('getSlaveField');
         if ($iIsTagged) {
             return Phpfox_Error::set(Phpfox::getPhrase('photo.this_photo_is_already_tagged_in_the_same_position'));
         }
         $iTotalTags = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('photo_id = ' . (int) $aVals['item_id'] . ' AND user_id = ' . Phpfox::getUserId())->execute('getSlaveField');
         if ($aPhoto['user_id'] == Phpfox::getUserId() && $iTotalTags >= Phpfox::getUserParam('photo.how_many_tags_on_own_photo') || $aPhoto['user_id'] != Phpfox::getUserId() && $iTotalTags >= Phpfox::getUserParam('photo.how_many_tags_on_other_photo')) {
             return Phpfox_Error::set(Phpfox::getPhrase('photo.no_more_tags_for_this_photo_can_be_added'));
         }
         $iTotalTags = 0;
         $iTotalTags = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('photo_id = ' . (int) $aVals['item_id'])->execute('getSlaveField');
         if ($iTotalTags > Phpfox::getParam('photo.total_tags_on_photos')) {
         }
         if (!empty($aVals['note'])) {
             if (Phpfox::getLib('parse.format')->isEmpty($aVals['note'])) {
                 return Phpfox_Error::set(Phpfox::getPhrase('photo.provide_a_photo_tag'));
             }
             $aVals['note'] = Phpfox::getLib('parse.input')->clean($aVals['note'], 255);
             $sReturn = Phpfox::getLib('parse.output')->clean($aVals['note']);
         }
         Phpfox::getService('ban')->checkAutomaticBan($aVals['note']);
         $iTagUserId = 0;
         if (!empty($aVals['tag_user_id'])) {
             $aUser = Phpfox::getService('user')->getUser($aVals['tag_user_id'], 'u.user_id, u.user_name, u.full_name');
             if (isset($aUser['user_id'])) {
                 $iTagUserId = $aUser['user_id'];
                 $iIsUserTagged = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('photo_id = ' . (int) $aVals['item_id'] . ' AND tag_user_id = ' . (int) $iTagUserId . '')->execute('getSlaveField');
                 if ($iIsUserTagged) {
                     return Phpfox_Error::set(Phpfox::getPhrase('photo.full_name_has_already_been_tagged_in_this_photo', array('full_name' => $aUser['full_name'])));
                 }
                 $sReturn = '<a href="' . Phpfox_Url::instance()->makeUrl($aUser['user_name']) . '">' . $aUser['full_name'] . '</a>';
                 unset($aVals['note']);
             }
         }
         if (empty($aVals['note']) && $iTagUserId < 1) {
             return;
         }
         $iTagId = $this->database()->insert($this->_sTable, array('photo_id' => (int) $aVals['item_id'], 'user_id' => Phpfox::getUserId(), 'tag_user_id' => $iTagUserId, 'content' => empty($aVals['note']) ? null : $aVals['note'], 'time_stamp' => PHPFOX_TIME, 'position_x' => (int) $aVals['x1'], 'position_y' => (int) $aVals['y1'], 'width' => (int) $aVals['width'], 'height' => (int) $aVals['height']));
         ($sPlugin = Phpfox_Plugin::get('photo.service_tag_process_add__1')) ? eval($sPlugin) : false;
         Phpfox::getService('feed.process')->add('photo_tag', $iTagId, 0, 0, $iTagUserId);
         $sLink = Phpfox_Url::instance()->permalink('photo', $aPhoto['photo_id'], $aPhoto['title']);
         Phpfox::getLib('mail')->to($iTagUserId)->subject(array('photo.full_name_tagged_you_in_a_photo', array('full_name' => Phpfox::getUserBy('full_name'), 'user_id' => Phpfox::getUserId())))->message(Phpfox::getUserId() == $aPhoto['user_id'] ? Phpfox::getPhrase('photo.full_name_tagged_you_on_gender_photo', array('full_name' => Phpfox::getUserBy('full_name'), 'gender' => Phpfox::getService('user')->gender(Phpfox::getUserBy('gender'), 1), 'link' => $sLink, 'title' => $aPhoto['title'])) : Phpfox::getPhrase('photo.full_name_tagged_you_on_user_photo', array('full_name' => Phpfox::getUserBy('full_name'), 'other_full_name' => $aPhoto['full_name'], 'link' => $sLink, 'title' => $aPhoto['title'])))->send();
         Phpfox::getService('notification.process')->add('photo_tag', $aPhoto['photo_id'], $iTagUserId);
         // }
         return $sReturn;
     }
     return Phpfox_Error::set(Phpfox::getPhrase('photo.not_allowed_to_tag_this_photo'));
 }
示例#12
0
文件: View.php 项目: lev1976g/core
    public function __construct()
    {
        $Template = \Phpfox_Template::instance();
        $this->_loader = new View\Loader();
        $dir = $Template->theme()->get()->getPath() . 'html';
        if (is_dir($dir)) {
            $this->_loader->addPath($dir, 'Theme');
        }
        $this->_loader->addPath(PHPFOX_DIR . 'theme/default/html', 'Theme');
        $this->_loader->addPath(PHPFOX_DIR . 'views', 'Base');
        $this->_env = new View\Environment($this->_loader, array('cache' => defined('PHPFOX_IS_TECHIE') && PHPFOX_IS_TECHIE || defined('PHPFOX_NO_TEMPLATE_CACHE') ? false : PHPFOX_DIR_FILE . 'cache/twig/', 'autoescape' => false));
        $this->_env->setBaseTemplateClass('Core\\View\\Base');
        $this->_env->addFunction(new \Twig_SimpleFunction('url', function ($url, $params = []) {
            return \Phpfox_Url::instance()->makeUrl($url, $params);
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('setting', function () {
            return call_user_func_array('setting', func_get_args());
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('user', function () {
            return call_user_func_array('user', func_get_args());
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('phrase', function () {
            return call_user_func_array('phrase', func_get_args());
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('comments', function () {
            \Phpfox::getBlock('feed.comment');
            return '';
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('payment', function ($params) {
            $params = new \Core\Object($params);
            \Phpfox::getBlock('api.gateway.form', ['gateway_data' => ['item_number' => '@App/' . $params->callback . '|' . $params->id, 'currency_code' => 'USD', 'amount' => $params->amount, 'item_name' => $params->name, 'return' => $params->return, 'recurring' => '', 'recurring_cost' => '', 'alternative_cost' => '', 'alternative_recurring_cost' => '']]);
            return '';
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('pager', function () {
            $u = \Phpfox_Url::instance();
            if (!isset($_GET['page'])) {
                $_GET['page'] = 1;
            }
            $_GET['page']++;
            $u->setParam('page', $_GET['page']);
            $url = $u->current();
            $html = '
				<div class="js_pager_view_more_link">
					<a href="' . $url . '" class="next_page">
						<i class="fa fa-spin fa-circle-o-notch"></i>
						<span>View More</span>
					</a>
				</div>
			';
            return $html;
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('_p', function () {
            return call_user_func_array('_p', func_get_args());
        }));
    }
示例#13
0
 public function email($sEmail)
 {
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable)->where("email = '" . $this->database()->escape($sEmail) . "'")->execute('getField');
     if ($iCnt) {
         Phpfox_Error::set(Phpfox::getPhrase('user.email_is_in_use_and_user_can_login', array('email' => trim(strip_tags($sEmail)), 'link' => Phpfox_Url::instance()->makeUrl('user.login', array('email' => base64_encode($sEmail))))));
     }
     if (!Phpfox::getService('ban')->check('email', $sEmail)) {
         Phpfox_Error::set(Phpfox::getPhrase('user.this_email_is_not_allowed_to_be_used'));
     }
     return $this;
 }
示例#14
0
 public function sendEmails($iThreadId, $iPostId = null)
 {
     $aUsers = $this->database()->select('fs.user_id, ft.forum_id, ft.thread_id, ft.group_id, ft.title, f.name AS forum_name')->from($this->_sTable, 'fs')->join(Phpfox::getT('forum_thread'), 'ft', 'ft.thread_id = fs.thread_id')->leftJoin(Phpfox::getT('forum'), 'f', 'f.forum_id = ft.forum_id')->where('fs.thread_id = ' . (int) $iThreadId)->execute('getSlaveRows');
     if (count($aUsers)) {
         foreach ($aUsers as $aUser) {
             $sLink = Phpfox_Url::instance()->permalink('forum.thread', $aUser['thread_id'], $aUser['title']) . 'view_' . $iPostId . '/';
             Phpfox::getService('notification.process')->add('forum_subscribed_post', $iPostId, $aUser['user_id']);
             Phpfox::getLib('mail')->to($aUser['user_id'])->subject(array('forum.reply_to_thread_title', array('title' => $aUser['title'])))->message(array('forum.full_name_has_just_replied_to_the_thread_title', array('full_name' => Phpfox::getUserBy('full_name'), 'title' => $aUser['title'], 'link' => $sLink)))->notification('forum.subscribe_new_post')->send();
         }
     }
 }
示例#15
0
 public function processRows(&$aRows)
 {
     foreach ($aRows as $iKey => $aListing) {
         $aRows[$iKey]['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'marketplace', 'privacy' => $aListing['privacy'], 'comment_privacy' => $aListing['privacy_comment'], 'like_type_id' => 'marketplace', 'feed_is_liked' => isset($aListing['is_liked']) ? $aListing['is_liked'] : false, 'feed_is_friend' => isset($aListing['is_friend']) ? $aListing['is_friend'] : false, 'item_id' => $aListing['listing_id'], 'user_id' => $aListing['user_id'], 'total_comment' => $aListing['total_comment'], 'feed_total_like' => $aListing['total_like'], 'total_like' => $aListing['total_like'], 'feed_link' => Phpfox_Url::instance()->permalink('marketplace', $aListing['listing_id'], $aListing['title']), 'feed_title' => $aListing['title'], 'type_id' => 'marketplace');
         // Mark expired items here so its easier to display them in the template
         if (Phpfox::getParam('marketplace.days_to_expire_listing') > 0 && $aListing['time_stamp'] < PHPFOX_TIME - Phpfox::getParam('marketplace.days_to_expire_listing') * 86400) {
             $aRows[$iKey]['is_expired'] = true;
         }
         $aRows[$iKey]['url'] = Phpfox_Url::instance()->permalink('marketplace', $aListing['listing_id'], $aListing['title']);
     }
 }
示例#16
0
 /**
  * Controller
  */
 public function process()
 {
     if (!$this->request()->get('user') && !$this->request()->get('id')) {
         Phpfox::isUser(true);
     }
     list($bIsRegistration, $sNextUrl) = $this->url()->isRegistration(2);
     ($sPlugin = Phpfox_Plugin::get('invite.component_controller_index_process_start')) ? eval($sPlugin) : false;
     // is a user sending an invite
     if ($aVals = $this->request()->getArray('val')) {
         // we may have a bunch of emails separated by commas, lets array them
         $aMails = explode(',', $aVals['emails']);
         list($aMails, $aInvalid, $aCacheUsers) = Phpfox::getService('invite')->getValid($aMails, Phpfox::getUserId());
         // failed emails
         $sFailed = '';
         $bSent = true;
         if (!empty($aMails)) {
             foreach ($aMails as $sMail) {
                 $sMail = trim($sMail);
                 // we insert the invite id and send the reference, so we can track which users
                 // have signed up
                 $iInvite = Phpfox::getService('invite.process')->addInvite($sMail, Phpfox::getUserId());
                 ($sPlugin = Phpfox_Plugin::get('invite.component_controller_index_process_send')) ? eval($sPlugin) : false;
                 $sFromEmail = Phpfox::getParam('core.email_from_email');
                 // check if we could send the mail
                 $sLink = Phpfox_Url::instance()->makeUrl('invite', array('id' => $iInvite));
                 $bSent = Phpfox::getLib('mail')->to($sMail)->fromEmail(empty($sFromEmail) ? Phpfox::getUserBy('email') : Phpfox::getParam('core.email_from_email'))->fromName(Phpfox::getUserBy('full_name'))->subject(array('invite.full_name_invites_you_to_site_title', array('full_name' => Phpfox::getUserBy('full_name'), 'site_title' => Phpfox::getParam('core.site_title'))))->message(array('invite.full_name_invites_you_to_site_title_link', array('full_name' => Phpfox::getUserBy('full_name'), 'site_title' => Phpfox::getParam('core.site_title'), 'link' => $sLink)))->send();
             }
         }
         if ($bIsRegistration === true) {
             $this->url()->send($sNextUrl, null, Phpfox::getPhrase('invite.your_friends_have_successfully_been_invited'));
         }
         $this->template()->assign(array('aValid' => $aMails, 'aInValid' => $aInvalid, 'aUsers' => $aCacheUsers));
     }
     // check if someone is visiting a link sent by email
     if ($iId = $this->request()->getInt('id')) {
         if (Phpfox::isUser() == true) {
             $this->url()->send('core.index-member');
         }
         // we update the entry to be seen:
         if (Phpfox::getService('invite.process')->updateInvite($iId, true)) {
             $this->url()->send('user.register');
         } else {
             Phpfox_Error::set('Your invitation has expired or it was not valid');
             return Phpfox_Module::instance()->setController('core.index-visitor');
         }
     } elseif ($iId = $this->request()->getInt('user')) {
         if (Phpfox::getService('invite.process')->updateInvite($iId, false)) {
             $this->url()->send('user.register');
         }
     }
     $this->template()->setTitle(Phpfox::getPhrase('invite.invite_your_friends'))->setBreadcrumb(Phpfox::getPhrase('invite.invite_your_friends'))->assign(array('sFullName' => Phpfox::getUserBy('full_name'), 'sSiteEmail' => Phpfox::getUserBy('email'), 'sSiteTitle' => Phpfox::getParam('core.site_title'), 'sIniviteLink' => Phpfox_Url::instance()->makeUrl('invite', array('user' => Phpfox::getUserId())), 'bIsRegistration' => $bIsRegistration, 'sNextUrl' => $this->url()->makeUrl($sNextUrl)));
     ($sPlugin = Phpfox_Plugin::get('invite.component_controller_index_process_end')) ? eval($sPlugin) : false;
 }
示例#17
0
 public function getAlbum($iAlbum)
 {
     if (Phpfox::isModule('like')) {
         $this->database()->select('lik.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'lik', 'lik.type_id = \'music_album\' AND lik.item_id = ma.album_id AND lik.user_id = ' . Phpfox::getUserId());
     }
     $this->database()->select('f.friend_id AS is_friend, ')->leftJoin(Phpfox::getT('friend'), 'f', "f.user_id = ma.user_id AND f.friend_user_id = " . Phpfox::getUserId());
     $aAlbum = $this->database()->select('ma.*, ' . (Phpfox::getParam('core.allow_html') ? 'mat.text_parsed' : 'mat.text') . ' AS text, u.user_name, vr.rate_id AS has_rated, ' . Phpfox::getUserField())->from($this->_sTable, 'ma')->join(Phpfox::getT('music_album_text'), 'mat', 'mat.album_id = ma.album_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = ma.user_id')->leftJoin(Phpfox::getT('music_album_rating'), 'vr', 'vr.item_id = ma.album_id AND vr.user_id = ' . Phpfox::getUserId())->where('ma.album_id = ' . (int) $iAlbum)->execute('getSlaveRow');
     if (!isset($aAlbum['album_id'])) {
         return false;
     }
     $aAlbum['bookmark'] = Phpfox_Url::instance()->permalink('music.album', $aAlbum['album_id'], $aAlbum['name']);
     return $aAlbum;
 }
示例#18
0
 /**
  * Sanity check, this function checks for users pending their newsletter and newsletters still incomplete (in process)
  * sets Phpfox_Error
  */
 public function checkPending()
 {
     $aUsers = $this->database()->select('user_id')->from(Phpfox::getT('user_field'))->where('newsletter_state != 0')->execute('getSlaveRows');
     if (!empty($aUsers)) {
         Phpfox_Error::set(Phpfox::getPhrase('newsletter.there_are_users_still_missing_their_newsletter_total', array('total' => count($aUsers))));
         return Phpfox_Url::instance()->makeUrl('admincp.newsletter.manage', array('task' => 'pending-users'));
     }
     $aNewsletters = $this->database()->select('newsletter_id')->from($this->_sTable)->where('state = 1')->execute('getSlaveRows');
     if (!empty($aNewsletters)) {
         Phpfox_Error::set(Phpfox::getPhrase('newsletter.there_are_newsletters_in_process_total', array('total' => count($aNewsletters))));
         return Phpfox_Url::instance()->makeUrl('admincp.newsletter.manage', array('task' => 'pending-tasks'));
     }
 }
示例#19
0
 /**
  * Controller
  */
 public function process()
 {
     if ($aVals = $this->request()->getArray('val')) {
         if ($this->request()->get('widget_id') ? Phpfox::getService('pages.process')->updateWidget($this->request()->get('widget_id'), $this->request()->get('val')) : Phpfox::getService('pages.process')->addWidget($this->request()->get('val'))) {
             $aVals = $this->request()->get('val');
             echo '<script type="text/javascript">window.parent.location.href = \'' . Phpfox_Url::instance()->makeUrl('pages.add.widget', array('id' => $aVals['page_id'])) . '\';</script>';
         } else {
             echo '<script type="text/javascript">';
             echo 'window.parent.$(\'#js_pages_widget_error\').html(\'<div class="error_message">' . implode('', Phpfox_Error::get()) . '</div>\');';
             echo '</script>';
         }
     }
     exit;
 }
示例#20
0
 public function loadProfileBlock()
 {
     exit;
     $sProfileUrl = str_replace('profile_', '', $this->get('url'));
     if ($this->get('url') == 'profile_info') {
         $sProfileUrl = 'profile';
     }
     if (!Phpfox::isModule($sProfileUrl)) {
         Phpfox_Error::set('Trying to load an invalid module.');
     } else {
         if (!Phpfox::hasCallback($sProfileUrl, 'getAjaxProfileController')) {
             Phpfox_Error::set('Unable to load the section you are looking for.');
         }
     }
     if (Phpfox_Error::isPassed()) {
         $oModule = Phpfox_Module::instance();
         $oTpl = Phpfox_Template::instance();
         $oTpl->assign(array('bIsAjaxLoader' => true));
         $aStyleInUse = $oTpl->getStyleInUse();
         $oModule->loadBlocks();
         $aUrlParams = array($this->get('user_name'));
         if ($this->get('url') != 'profile') {
             $aUrlParams[] = str_replace('profile_', '', $this->get('url'));
         }
         Phpfox_Url::instance()->setParam($aUrlParams);
         $oModule->setController(Phpfox::callback($sProfileUrl . '.getAjaxProfileController'));
         if ($aStyleInUse['total_column'] == '3') {
             $oTpl->assign(array('aBlocks1' => $oTpl->bIsSample ? true : Phpfox_Module::instance()->getModuleBlocks(1), 'aBlocks3' => $oTpl->bIsSample ? true : Phpfox_Module::instance()->getModuleBlocks(3), 'aAdBlocks1' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Ad_Service_Ad::instance()->getForBlock(1) : null), 'aAdBlocks3' => $oTpl->bIsSample ? true : (Phpfox::isModule('ad') ? Ad_Service_Ad::instance()->getForBlock(3) : null)));
         } else {
             $oTpl->assign(array('aBlocks1' => array(), 'aBlocks3' => array(), 'aAdBlocks1' => array(), 'aAdBlocks3' => array()));
         }
         $oTpl->assign(array('sPublicMessage' => Phpfox::getMessage(), 'aErrors' => Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array(), 'aStyleInUse' => $aStyleInUse));
         list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb();
         $this->remove('#js_temp_breadcrumb');
         if (count($aBreadCrumbs)) {
             foreach ($aBreadCrumbs as $sLink => $sPhrase) {
                 $this->append('h1', '<span id="js_temp_breadcrumb"><span class="profile_breadcrumb">&#187;</span><a href="' . $sLink . '">' . $sPhrase . '</a></span>');
                 break;
             }
         }
         $oTpl->getLayout($oTpl->sDisplayLayout);
         $this->html($aStyleInUse['total_column'] == '3' ? '#content_load_data' : '#content', $this->getContent(false));
         if ($this->get('url') == 'profile_info') {
             $this->call('$Core.loadProfileInfo();');
         }
     } else {
         $this->html('#js_profile_block_view_data_' . $this->get('url'), implode('', Phpfox_Error::get()));
     }
     $this->call('$Core.loadInit();');
 }
示例#21
0
 /**
  * Displays the error message and directly creates a variable for the template engine
  *
  * @static 
  * @param string $sMsg Error message you want to display on the current page the user is on.
  */
 public static function display($sMsg, $iErrCode = null)
 {
     if (PHPFOX_IS_AJAX) {
         echo $sMsg;
     } else {
         Phpfox_Module::instance()->setController('error.display');
         Phpfox_Template::instance()->assign(array('sErrorMessage' => $sMsg));
     }
     if ($iErrCode !== null) {
         $oUrl = Phpfox_Url::instance();
         header($oUrl->getHeaderCode($iErrCode));
     }
     return false;
 }
示例#22
0
 public function get($aConds, $sSort = 'c.name ASC', $iPage = '', $iLimit = '')
 {
     ($sPlugin = Phpfox_Plugin::get('blog.service_category_category_get_start')) ? eval($sPlugin) : false;
     $iCnt = $this->database()->select('COUNT(*)')->from(Phpfox::getT('blog_category'), 'c')->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = c.user_id')->where($aConds)->order($sSort)->execute('getSlaveField');
     $aItems = array();
     if ($iCnt) {
         $aItems = $this->database()->select('c.*, ' . Phpfox::getUserField())->from(Phpfox::getT('blog_category'), 'c')->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = c.user_id')->where($aConds)->order($sSort)->limit($iPage, $iLimit, $iCnt)->execute('getSlaveRows');
         foreach ($aItems as $iKey => $aItem) {
             $aItems[$iKey]['link'] = $aItem['user_id'] ? Phpfox_Url::instance()->permalink($aItem['user_name'] . '.blog.category', $aItem['category_id'], $aItem['name']) : Phpfox_Url::instance()->permalink('blog.category', $aItem['category_id'], $aItem['name']);
         }
     }
     ($sPlugin = Phpfox_Plugin::get('blog.service_category_category_get_end')) ? eval($sPlugin) : false;
     return array($iCnt, $aItems);
 }
示例#23
0
 /**
  * Cleans the values and calls the sending function
  *
  * @param array $aValues
  * @return unknown
  */
 public function sendContactMessage($aValues)
 {
     $sSiteEmail = Phpfox::getParam('contact.contact_staff_emails');
     if (empty($sSiteEmail)) {
         $sSiteEmail = Phpfox::getParam('core.email_from_email');
     }
     if (empty($sSiteEmail)) {
         return false;
     }
     // its better if we instantiate here instead of dynamic calling the lib every time
     $oParser = Phpfox::getLib('parse.input');
     // Remove all tags to make it plain text
     $sText = '';
     if (Phpfox::getUserId()) {
         $sText .= Phpfox::getPhrase('contact.full_name') . ': ' . Phpfox::getUserBy('full_name') . '<br />';
         $sText .= Phpfox::getPhrase('contact.user_id') . ': ' . Phpfox::getUserId() . '<br />';
         $sText .= Phpfox::getPhrase('contact.profile') . ': ' . Phpfox_Url::instance()->makeUrl(Phpfox::getUserBy('user_name')) . '<br />';
     }
     $sText .= Phpfox::getPhrase('contact.email') . ': ' . $aValues['email'] . '<br />';
     $sText .= '------------------------------------------------------------<br />';
     if (!empty($aValues['category_id']) && $aValues['category_id'] == 'phpfox_sales_ticket') {
         $sText = $oParser->clean($aValues['text']);
     } else {
         $sText .= Phpfox::getParam('contact.allow_html_in_contact') == true ? $oParser->prepare($aValues['text']) : $oParser->clean($aValues['text']);
     }
     // check if the user is logged in to include
     if (Phpfox::getUserId() > 0) {
         $aValues['full_name'] .= ' (user id:' . Phpfox::getUserId() . ')';
     }
     // send the mail
     $aMails = explode(',', $sSiteEmail);
     if (!empty($aValues['category_id']) && $aValues['category_id'] == 'phpfox_sales_ticket') {
         $aValues['category_id'] = '';
     }
     $bResult = true;
     foreach ($aMails as $sMail) {
         $sMail = trim($sMail);
         $bSend = Phpfox::getLib('mail')->to($sMail)->messageHeader(false)->subject((!empty($aValues['category_id']) ? Phpfox_Locale::instance()->convert($aValues['category_id']) . ': ' : '') . $aValues['subject'])->message($sText)->fromName($aValues['full_name'])->fromEmail(Phpfox::getParam('core.email_from_email'))->send();
         $bResult = $bResult && $bSend;
     }
     if (isset($aValues['copy'])) {
         Phpfox::getLib('mail')->to($aValues['email'])->messageHeader(false)->subject((!empty($aValues['category_id']) ? Phpfox_Locale::instance()->convert($aValues['category_id']) . ': ' : '') . $aValues['subject'])->message($sText)->fromName(Phpfox::getParam('core.mail_from_name'))->fromEmail(Phpfox::getParam('core.email_from_email'))->send();
     }
     if (Phpfox::getParam('contact.enable_auto_responder')) {
         Phpfox::getLib('mail')->to($aValues['email'])->messageHeader(false)->subject(Phpfox::getParam('contact.auto_responder_subject'))->message(Phpfox::getParam('contact.auto_responder_message'))->fromEmail(Phpfox::getParam('core.email_from_email'))->fromName(Phpfox::getParam('core.site_title'))->send();
     }
     return $bResult;
 }
示例#24
0
 public function getAll()
 {
     if (!Phpfox::isUser()) {
         $this->call('<script type="text/javascript">window.location.href = \'' . Phpfox_Url::instance()->makeUrl('user.login') . '\';</script>');
     } else {
         // This function caches into a static so it shouldn't be an extra load
         /*
         $aNotifications = Phpfox::getService('notification')->get();
         if (count($aNotifications) < 1)
         {
         	$this->call('<script type="text/javascript">$("#js_total_new_notifications").hide();</script>');
         }
         */
         Phpfox::getBlock('notification.link');
     }
 }
示例#25
0
 /**
  * Controller
  */
 public function process()
 {
     $iLinkId = (int) $this->getParam('link_id');
     if (!($aLink = Link_Service_Link::instance()->getLinkById($iLinkId))) {
         return false;
     }
     if (Phpfox::getParam('core.warn_on_external_links')) {
         if (!preg_match('/' . preg_quote(Phpfox::getParam('core.host')) . '/i', $aLink['link'])) {
             $aLink['link'] = Phpfox_Url::instance()->makeUrl('core.redirect', array('url' => Phpfox_Url::instance()->encode($aLink['link'])));
         }
     }
     if (substr($aLink['link'], 0, 7) != 'http://' && substr($aLink['link'], 0, 8) != 'https://') {
         $aLink['link'] = 'http://' . $aLink['link'];
     }
     $this->template()->assign(array('aLink' => $aLink, 'bIsAttachment' => $this->getParam('attachment') ? true : false));
 }
示例#26
0
 private function _build($aPhoto)
 {
     $sJs = '';
     foreach ($aPhoto as $sKey => $sValue) {
         if ($sKey == 'destination') {
             $sValue = Phpfox::getLib('image.helper')->display(array('server_id' => $aPhoto['server_id'], 'path' => 'photo.url_photo', 'file' => $aPhoto['destination'], 'suffix' => '_500', 'max_width' => 400, 'max_height' => 400));
         } elseif ($sKey == 'full_name') {
             $sValue = '<a href="' . Phpfox_Url::instance()->makeUrl($aPhoto['user_name']) . '">' . $aPhoto['full_name'] . '</a>';
         } elseif ($sKey == 'time_stamp') {
             $sValue = Phpfox::getTime(Phpfox::getParam('photo.photo_image_details_time_stamp'), $aPhoto['time_stamp']);
         }
         $sJs .= $sKey . ': \'' . str_replace("'", "\\'", $sValue) . '\',';
     }
     $sJs = rtrim($sJs, ',');
     return $sJs;
 }
示例#27
0
 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'));
 }
示例#28
0
文件: View.php 项目: pH7s/phpfox
    public function __construct()
    {
        $this->_loader = new View\Loader();
        $this->_loader->addPath(PHPFOX_DIR . 'theme/default/html', 'Theme');
        $this->_loader->addPath(PHPFOX_DIR . 'views', 'Base');
        /*
        $this->_env = new \Twig_Environment($this->_loader, array(
        	'cache' => false,
        	'autoescape' => false
        ));
        */
        $this->_env = new View\Environment($this->_loader, array('cache' => false, 'autoescape' => false));
        $this->_env->setBaseTemplateClass('Core\\View\\Base');
        $this->_env->addFunction(new \Twig_SimpleFunction('url', function ($url, $params = []) {
            return \Phpfox_Url::instance()->makeUrl($url, $params);
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('phrase', function () {
            return call_user_func_array('phrase', func_get_args());
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('comments', function () {
            \Phpfox::getBlock('feed.comment');
            return '';
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('pager', function () {
            $u = \Phpfox_Url::instance();
            if (!isset($_GET['page'])) {
                $_GET['page'] = 1;
            }
            $_GET['page']++;
            $u->setParam('page', $_GET['page']);
            $url = $u->current();
            $html = '
				<div class="js_pager_view_more_link">
					<a href="' . $url . '" class="next_page">
						<i class="fa fa-spin fa-circle-o-notch"></i>
						<span>View More</span>
					</a>
				</div>
			';
            return $html;
        }));
        $this->_env->addFunction(new \Twig_SimpleFunction('_p', function () {
            return call_user_func_array('_p', func_get_args());
        }));
    }
示例#29
0
 /**
  * Controller
  */
 public function process()
 {
     $aModules = Phpfox::massCallback('reparserList');
     foreach ($aModules as $iKey => $aModule) {
         if (!isset($aModule['name'])) {
             unset($aModules[$iKey]);
             $iCnt = 0;
             foreach ($aModule as $iModuleKey => $aCacheModule) {
                 $iCnt++;
                 $aModules = array_merge($aModules, array('custom' . $iCnt => $aCacheModule));
             }
         }
     }
     foreach ($aModules as $iKey => $aModule) {
         if (!isset($aModule['name'])) {
             foreach ($aModule as $iSubKey => $aSub) {
                 $aModules[$iKey . '_' . $iSubKey] = $aSub;
             }
             unset($aModules[$iKey]);
         }
         if (is_array($aModule['table'])) {
             $aModule['table'] = $aModule['table'][0];
         }
         $aModules[$iKey]['total_record'] = Phpfox_Database::instance()->select('COUNT(*)')->from(Phpfox::getT($aModule['table']))->execute('getSlaveField');
         if ($aModules[$iKey]['total_record'] == 0) {
             unset($aModules[$iKey]);
         }
     }
     $iPage = $this->request()->get('page');
     $iLimit = 200;
     if (($sModule = $this->request()->get('module')) && isset($aModules[$sModule])) {
         $iCnt = Phpfox::getService('admincp.maintain')->reParseText($aModules[$sModule], $iPage, $iLimit);
         Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iLimit, 'count' => $iCnt));
         $iTotalPages = (int) Phpfox_Pager::instance()->getTotalPages();
         $iCurrentPage = (int) Phpfox_Pager::instance()->getCurrentPage();
         $iPage = (int) Phpfox_Pager::instance()->getNextPage();
         if ($iTotalPages === $iCurrentPage || $iTotalPages === 0) {
             $this->url()->send('admincp.maintain.reparser', null, Phpfox::getPhrase('admincp.parsing_completed'));
         } else {
             $this->template()->assign(array('bInProcess' => true, 'iCurrentPage' => $iCurrentPage, 'iTotalPages' => $iTotalPages))->setHeader(array('<meta http-equiv="refresh" content="2;url=' . Phpfox_Url::instance()->makeUrl('admincp.maintain.reparser', array('module' => $sModule, 'page' => $iPage)) . '" />'));
         }
     }
     $this->template()->setTitle(Phpfox::getPhrase('admincp.text_reparser'))->setSectionTitle('Content Re-Parser')->assign(array('aReparserLists' => $aModules));
 }
示例#30
0
 public function getCategoriesById($iId = null, &$aCategories = null)
 {
     $oUrl = Phpfox_Url::instance();
     if ($aCategories === null) {
         $aCategories = $this->database()->select('pc.parent_id, pc.category_id, pc.name')->from(Phpfox::getT('marketplace_category_data'), 'pcd')->join($this->_sTable, 'pc', 'pc.category_id = pcd.category_id')->where('pcd.listing_id = ' . (int) $iId)->order('pc.parent_id ASC, pc.ordering ASC')->execute('getSlaveRows');
     }
     if (!count($aCategories)) {
         return null;
     }
     $aBreadcrumb = array();
     if (count($aCategories) > 1) {
         foreach ($aCategories as $aCategory) {
             $aBreadcrumb[] = array(Phpfox_Locale::instance()->convert($aCategory['name']), Phpfox::permalink('marketplace.category', $aCategory['category_id'], $aCategory['name']));
         }
     } else {
         $aBreadcrumb[] = array(Phpfox_Locale::instance()->convert($aCategories[0]['name']), Phpfox::permalink('marketplace.category', $aCategories[0]['category_id'], $aCategories[0]['name']));
     }
     return $aBreadcrumb;
 }