Ejemplo n.º 1
0
 /**
  * Get HTML form.
  *
  * @param array $aArgs ARRAY of settings to pass to the form.
  * @return string HTML form.
  */
 public function get($aArgs = array())
 {
     $aVars = Phpfox_Template::instance()->getVar('aForms');
     $sHtml = '';
     $sHtml .= '<input type="text" name="val[' . $aArgs['id'] . '][]" id="js_inline_input_' . $aArgs['id'] . '" style="width:' . $aArgs['width'] . ';" size="' . $aArgs['size'] . '"';
     $sHtml .= " autocomplete=\"off\"";
     if (isset($aArgs['edit']) && $aArgs['edit'] != '') {
         $sHtml .= " value=\"" . $aArgs['edit'] . "\" ";
     } elseif (isset($aArgs['display'])) {
         $sHtml .= " value=\"" . $aArgs['display'] . "\" onfocus=\"if (this.value == '" . $aArgs['display'] . "') { this.value=''; }\"";
     }
     $sHtml .= " onkeyup=\"if (this.value != '') { oInlineSearch.call('" . $aArgs['id'] . "', '" . $aArgs['call'] . "', '" . Phpfox_Template::instance()->getVar('sTagType') . "'); }\" ";
     $sHtml .= ' />';
     if (isset($aArgs['type']) && $aArgs['type'] == 'comma') {
         $sHtml .= ' <input type="button" value="Add" class="button" onclick="return oInlineSearch.addWithComma(\'' . $aArgs['id'] . '\');" />';
     }
     $sHtml .= '<div style="position:relative; width:' . $aArgs['width'] . '; z-index:100;"><div class="drop_layer" id="js_inline_hidden_' . $aArgs['id'] . '" style="position:absolute;"></div></div>';
     $sHtml .= '<div class="inline_search_box" id="js_inline_search_box_' . $aArgs['id'] . '" style="width:' . $aArgs['width'] . ';"><div style="overflow:scroll; height:60px;"><div id="js_inline_search_content_' . $aArgs['id'] . '" style="padding:5px;"></div></div></div>';
     if (isset($aArgs['info'])) {
         $sHtml .= '<div class="p_4">' . $aArgs['info'] . '</div>';
     }
     if (isset($aVars[$aArgs['id']]) && is_array($aVars[$aArgs['id']])) {
         $sHtml .= '<script type="text/javascript">';
         foreach ($aVars[$aArgs['id']] as $mKey => $mValue) {
             $sHtml .= "oInlineSearch.add('" . $aArgs['id'] . "', 'val[" . $aArgs['id'] . "]', '{$mKey}', '{$mValue}');";
         }
         $sHtml .= '</script>';
     }
     return $sHtml;
 }
Ejemplo n.º 2
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'));
 }
Ejemplo n.º 3
0
 public function addCategory()
 {
     if (!Phpfox::getService('blog.category')->canAdd()) {
         return $this->alert(Phpfox::getPhrase('blog.you_have_reached_your_limit'));
     }
     $aVals = $this->get('val');
     $oBlogCategoryProcess = Phpfox::getService('blog.category.process');
     $sCleanUrl = Phpfox::getLib('parse.input')->clean($aVals['add']);
     if (Phpfox::getService('blog.category')->isPrivateCategory($sCleanUrl, Phpfox::getUserId())) {
         $this->call('alert("' . Phpfox::getPhrase('blog.already_a_category') . '"); $("#js_add_category").val(""); $("#js_add_category").focus();');
         return false;
     }
     $aCategories = explode(',', $aVals['add']);
     $aRows = array();
     foreach ($aCategories as $sCategory) {
         $sCategory = trim($sCategory);
         $iId = $oBlogCategoryProcess->add($sCategory);
         $aRows[] = array('category_id' => $iId, 'name' => Phpfox::getLib('parse.input')->clean($sCategory, 255));
     }
     rsort($aRows);
     foreach ($aRows as $aRow) {
         Phpfox_Template::instance()->assign(array('aItem' => array('category_id' => $aRow['category_id'], 'name' => $aRow['name'], 'user_id' => Phpfox::getUserId())));
         Phpfox_Template::instance()->getTemplate('blog.block.category-form');
     }
     $this->call('$("#js_add_new_category").prepend("' . $this->getContent() . '"); $("#js_category_info").html("' . Phpfox::getPhrase('blog.added') . '").highlightFade().fadeOut(5000); $("#js_add_category").val(""); $Core.loadInit();');
 }
Ejemplo n.º 4
0
 /**
  * Controller
  */
 public function process()
 {
     // $this->request()->cache('text/html', strtotime('-2 days'), 7);
     if ($sPlugin = Phpfox_Plugin::get('core.component_controller_index_member_start')) {
         eval($sPlugin);
     }
     if ($this->request()->segment(1) != 'hashtag') {
         Phpfox::isUser(true);
     }
     if ($this->request()->get('req3') == 'customize') {
         define('PHPFOX_IN_DESIGN_MODE', true);
         define('PHPFOX_CAN_MOVE_BLOCKS', true);
         if ($iTestStyle = $this->request()->get('test_style_id')) {
             if (Phpfox_Template::instance()->testStyle($iTestStyle)) {
             }
         }
         $aDesigner = array('current_style_id' => Phpfox::getUserBy('style_id'), 'design_header' => Phpfox::getPhrase('core.customize_dashboard'), 'current_page' => $this->url()->makeUrl(''), 'design_page' => $this->url()->makeUrl('core.index-member', 'customize'), 'block' => 'core.index-member', 'item_id' => Phpfox::getUserId(), 'type_id' => 'user');
         $this->setParam('aDesigner', $aDesigner);
         $this->template()->setPhrase(array('theme.are_you_sure'))->setHeader('cache', array('style.css' => 'style_css', 'video.css' => 'module_video', 'design.js' => 'module_theme', 'select.js' => 'module_theme'));
         if (Phpfox::getParam('profile.can_drag_drop_blocks_on_profile')) {
             $this->template()->setHeader('cache', array('jquery/ui.js' => 'static_script', 'sort.js' => 'module_theme'))->setHeader(array('<script type="text/javascript">$Behavior.core_controller_member_designonupdate = function() { function designOnUpdate() { $Core.design.updateSorting(); } };</script>', '<script type="text/javascript">$Behavior.core_controller_init = function() { $Core.design.init({type_id: \'user\'}); };</script>'));
         }
     } else {
         // $this->template()->setHeader('jquery/ui.js', 'static_script');
         $this->template()->setHeader('cache', array('sort.js' => 'module_theme', 'design.js' => 'module_theme', 'video.css' => 'module_video'))->setHeader(array());
     }
     if (Phpfox::getParam('video.convert_servers_enable')) {
         $this->template()->setHeader('<script type="text/javascript">document.domain = "' . Phpfox::getParam('video.convert_js_parent') . '";</script>');
     }
     Phpfox_Module::instance()->setCacheBlockData(array('table' => 'user_dashboard', 'field' => 'user_id', 'item_id' => Phpfox::getUserId(), 'controller' => 'core.index-member'));
     $this->template()->setHeader('cache', array('feed.js' => 'module_feed', 'welcome.css' => 'style_css', 'announcement.css' => 'style_css', 'comment.css' => 'style_css', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script'))->setEditor(array('load' => 'simple'));
 }
Ejemplo n.º 5
0
 public function getDashboardLinks()
 {
     $aMenus = array();
     $aModules = Phpfox::massCallback('getDashboardLinks');
     foreach ($aModules as $aModule) {
         if ($aModule === false) {
             continue;
         }
         if (isset($aModule['submit']['link'])) {
             $aMenus['submit'][] = $aModule['submit'];
         } else {
             foreach ($aModule['submit'] as $aSubModule) {
                 $aMenus['submit'][] = $aSubModule;
             }
         }
         $aMenus['edit'][] = $aModule['edit'];
     }
     $aProfileMenus = Phpfox_Template::instance()->getMenu('profile');
     foreach ($aProfileMenus as $aProfileMenu) {
         if ($aProfileMenu['url'] == 'profile') {
             continue;
         }
         $aMenus['profile'][] = array('module' => $aProfileMenu['module'], 'var_name' => $aProfileMenu['var_name'], 'url' => $aProfileMenu['url']);
     }
     // $this->cache()->save($sCacheId, $aMenus);
     return $aMenus;
 }
Ejemplo n.º 6
0
 public function getRequestLink()
 {
     ($sPlugin = Phpfox_Plugin::get('comment.component_service_callback_getrequestlink__start')) ? eval($sPlugin) : false;
     $iTotalApproveCount = $this->database()->select('COUNT(*)')->from(Phpfox::getT('comment'))->where('owner_user_id = ' . Phpfox::getUserId() . ' AND view_id = 1')->execute('getSlaveField');
     if (!Phpfox::getParam('request.display_request_box_on_empty') && !$iTotalApproveCount) {
         return null;
     }
     return '<li><a href="' . Phpfox_Url::instance()->makeUrl('request', '#comment') . '"' . (!$iTotalApproveCount ? ' onclick="alert(\'' . Phpfox::getPhrase('comment.nothing_new_to_approve') . '\'); return false;"' : '') . '><img src="' . Phpfox_Template::instance()->getStyle('image', 'misc/comment.png') . '" alt="" class="v_middle" /> ' . Phpfox::getPhrase('comment.comments_pending_approval_total', array('total' => $iTotalApproveCount)) . '</a></li>';
 }
Ejemplo n.º 7
0
 public function getContent()
 {
     $Template = \Phpfox_Template::instance();
     if (!$this->_render) {
         /*
         if (PHPFOX_IS_AJAX_PAGE) {
         	\Phpfox_Module::instance()->getControllerTemplate();
         	$content = ob_get_contents(); ob_clean();
         	$content = (string) new View\Functions('content', $content);
         	return $content;
         }
         else {
         	\Phpfox_Module::instance()->getControllerTemplate();
         	$content = ob_get_contents(); ob_clean();
         
         	$this->_render['name'] = '@Base/Layout.html';
         	$this->_render['params']['content'] = $content;
         }
         */
         \Phpfox_Module::instance()->getControllerTemplate();
         $content = ob_get_contents();
         ob_clean();
         $this->_render['name'] = '@Base/' . self::$template . '.html';
         $this->_render['params']['content'] = $content;
     }
     $params = $this->_render['params'];
     $params['content'] = $this->_env->render($this->_render['name'], $params);
     if (PHPFOX_IS_AJAX_PAGE) {
         $content = (string) new View\Functions('content', $params['content']);
         return $content;
     }
     // $params['content'] = '<div class="_block_content">' . $params['content'] . '</div>';
     $params['content'] = new View\Functions('content', $params['content']);
     $params['header'] = $Template->getHeader();
     $params['title'] = $Template->getTitle();
     $params['js'] = $Template->getFooter();
     $params['nav'] = new View\Functions('nav');
     $params['menu'] = new View\Functions('menu');
     $params['share'] = new View\Functions('share');
     $params['notify'] = new View\Functions('notify');
     $params['search'] = new View\Functions('search');
     $params['footer'] = new View\Functions('footer');
     $params['errors'] = new View\Functions('errors');
     $params['top'] = new View\Functions('top');
     $params['left'] = new View\Functions('left');
     $params['right'] = new View\Functions('right');
     $params['h1'] = new View\Functions('h1');
     $params['breadcrumb'] = new View\Functions('breadcrumb');
     $params['notification'] = new View\Functions('notification');
     $params['logo'] = new View\Functions('logo');
     $params['body'] = 'id="page_' . \Phpfox_Module::instance()->getPageId() . '" class="' . \Phpfox_Module::instance()->getPageClass() . '"';
     // d($params['active']); exit;
     $locale = \Phpfox_Locale::instance()->getLang();
     $params['html'] = 'xmlns="http://www.w3.org/1999/xhtml" dir="' . $locale['direction'] . '" lang="' . $locale['language_code'] . '"';
     // return $this->_env->render($this->_render['name'], $params);
     return $this->_env->render('@Theme/' . self::$template . '.html', $params);
 }
Ejemplo n.º 8
0
 public function getNotificationLink($mId, $mTotal = null)
 {
     $sImage = '<img src="' . Phpfox_Template::instance()->getStyle('image', 'misc/email.png') . '" alt="" class="v_middle" />';
     if (is_array($mId) && $mTotal === null) {
         return Phpfox::getPhrase('mail.li_a_href_link_email_image_new_messages_messages_number_a_li', array('link' => Phpfox_Url::instance()->makeUrl('mail'), 'email_image' => $sImage, 'messages_number' => isset($mId['mail']) ? $mId['mail'] : '0'));
     } else {
         return '<li><a href="' . Phpfox_Url::instance()->makeUrl('mail') . '" class="js_nofitication_' . $mId . '">' . $sImage . ' ' . ($mTotal > 1 ? Phpfox::getPhrase('mail.total_new_messages', array('total' => $mTotal)) : Phpfox::getPhrase('mail.1_new_message')) . '</a></li>';
     }
 }
Ejemplo n.º 9
0
 public function getSource($name)
 {
     if ($name == '@Theme/layout.html') {
         $Theme = \Phpfox_Template::instance()->theme()->get();
         $Service = new \Core\Theme\Service($Theme);
         return $Service->html()->get();
     }
     return parent::getSource($name);
 }
Ejemplo n.º 10
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     if (!Phpfox::getParam('mail.threaded_mail_conversation')) {
         $this->url()->send('mail');
     }
     $aVals = $this->request()->get('val');
     if ($aVals && ($iNewId = Mail_Service_Process::instance()->add($aVals))) {
         list($aCon, $aMessages) = Mail_Service_Mail::instance()->getThreadedMail($iNewId);
         $aMessages = array_reverse($aMessages);
         Phpfox_Template::instance()->assign(array('aMail' => $aMessages[0], 'aCon' => $aCon, 'bIsLastMessage' => true))->getTemplate('mail.block.entry');
         $content = ob_get_contents();
         ob_clean();
         return ['append' => ['to' => '#mail_threaded_new_message', 'with' => $content]];
     }
     $iThreadId = $this->request()->getInt('id');
     list($aThread, $aMessages) = Mail_Service_Mail::instance()->getThreadedMail($iThreadId);
     if ($aThread === false) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_find_a_conversation_history_with_this_user'));
     }
     $aValidation = array('message' => Phpfox::getPhrase('mail.add_reply'));
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if ($aThread['user_is_archive']) {
         $this->request()->set('view', 'trash');
     }
     Mail_Service_Mail::instance()->buildMenu();
     Mail_Service_Process::instance()->threadIsRead($aThread['thread_id']);
     $iUserCnt = 0;
     $sUsers = '';
     $bCanViewThread = false;
     foreach ($aThread['users'] as $aUser) {
         if ($aUser['user_id'] == Phpfox::getUserId()) {
             $bCanViewThread = true;
         }
         if ($aUser['user_id'] == Phpfox::getUserId()) {
             continue;
         }
         $iUserCnt++;
         if ($iUserCnt == count($aThread['users']) - 1 && count($aThread['users']) - 1 > 1) {
             $sUsers .= ' &amp; ';
         } else {
             if ($iUserCnt != '1') {
                 $sUsers .= ', ';
             }
         }
         $sUsers .= $aUser['full_name'];
     }
     if (!$bCanViewThread) {
         return Phpfox_Error::display('Unable to view this thread.');
     } else {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'))->setBreadcrumb($sUsers, $this->url()->makeUrl('mail.thread', array('id' => $iThreadId)), true);
     }
     $this->template()->setTitle($sUsers)->setTitle(Phpfox::getPhrase('mail.mail'))->setHeader('cache', array('mail.js' => 'module_mail', 'jquery/plugin/jquery.scrollTo.js' => 'static_script'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(false), 'aMessages' => $aMessages, 'aThread' => $aThread, 'sCurrentPageCnt' => $this->request()->getInt('page', 0) + 1));
     $this->setParam('attachment_share', array('type' => 'mail', 'id' => 'js_form_mail'));
     $this->setParam('global_moderation', array('name' => 'mail', 'ajax' => 'mail.mailThreadAction', 'custom_fields' => '<div><input type="hidden" name="forward_thread_id" value="' . $aThread['thread_id'] . '" id="js_forward_thread_id" /></div>', 'menu' => array(array('phrase' => Phpfox::getPhrase('mail.forward'), 'action' => 'forward'))));
 }
Ejemplo n.º 11
0
 public function __construct($assets)
 {
     if (!is_array($assets)) {
         $assets = [$assets];
     }
     foreach ($assets as $asset) {
         if (substr($asset, 0, 7) == '@static') {
             \Phpfox_Template::instance()->delayedHeaders[] = [str_replace('@static/', '', $asset) => 'static_script'];
         }
     }
 }
Ejemplo n.º 12
0
 public function __construct($path = null)
 {
     $this->request = new Request();
     $this->url = new Url();
     $this->active = (new \Api\User())->get(\Phpfox::getUserId());
     $this->_template = \Phpfox_Template::instance();
     $this->_view = new View();
     if ($path !== null && is_dir($path)) {
         $this->_view->loader()->addPath($path);
     }
 }
Ejemplo n.º 13
0
 public function addThreadMail()
 {
     $aVals = $this->get('val');
     if ($iNewId = Mail_Service_Process::instance()->add($aVals)) {
         list($aCon, $aMessages) = Mail_Service_Mail::instance()->getThreadedMail($iNewId);
         $aMessages = array_reverse($aMessages);
         Phpfox_Template::instance()->assign(array('aMail' => $aMessages[0], 'aCon' => $aCon, 'bIsLastMessage' => true))->getTemplate('mail.block.entry');
         $this->call('$(\'.mail_thread_holder\').removeClass(\'is_last_message\');');
         $this->append('#mail_threaded_new_message', $this->getContent(false));
         $this->call("\$.scrollTo('.is_last_message:first');");
         $this->call("\$('.mail_thread_form_holder').addClass('not_fixed');");
     }
 }
Ejemplo n.º 14
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;
 }
Ejemplo n.º 15
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();');
 }
Ejemplo n.º 16
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'));
 }
Ejemplo n.º 17
0
 public function getNotificationComment($aNotification)
 {
     $aRow = $this->database()->select('b.poke_id, u.user_id, u.gender, u.user_name, u.full_name, u2.full_name AS to_full_name')->from(Phpfox::getT('poke_data'), 'b')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->join(Phpfox::getT('user'), 'u2', 'u2.user_id = b.to_user_id')->where('b.poke_id = ' . (int) $aNotification['item_id'])->execute('getSlaveRow');
     if (!isset($aRow['poke_id'])) {
         return false;
     }
     $sUsers = Phpfox::getService('notification')->getUsers($aNotification);
     $sTitle = Phpfox::getLib('parse.output')->shorten($aRow['to_full_name'], Phpfox::getParam('notification.total_notification_title_length'), '...');
     $sPhrase = '';
     if ($aNotification['user_id'] == $aRow['user_id'] && !isset($aNotification['extra_users'])) {
         $sPhrase = Phpfox::getPhrase('poke.users_commented_on_gender_poke_for_title', array('users' => $sUsers, 'gender' => Phpfox::getService('user')->gender($aRow['gender'], 1), 'title' => $sTitle));
     } elseif ($aRow['user_id'] == Phpfox::getUserId()) {
         $sPhrase = Phpfox::getPhrase('poke.users_commented_on_your_poke_for_title', array('users' => $sUsers, 'title' => $sTitle));
     } else {
         $sPhrase = Phpfox::getPhrase('poke.users_commented_on_span_class_drop_data_user_row_full_name_s_span_for_title', array('users' => $sUsers, 'row_full_name' => $aRow['full_name'], 'title' => $sTitle));
     }
     return array('link' => Phpfox_Url::instance()->makeUrl($aRow['user_name'], array('poke-id' => $aRow['poke_id'])), 'message' => $sPhrase, 'icon' => Phpfox_Template::instance()->getStyle('image', 'activity.png', 'blog'));
 }
Ejemplo n.º 18
0
 public function setHeaders()
 {
     $sCacheId = $this->cache()->set('seo_nofollow_build');
     if (!($aNoFollows = $this->cache()->get($sCacheId))) {
         $aRows = $this->database()->select('*')->from(Phpfox::getT('seo_nofollow'))->execute('getSlaveRows');
         $aNoFollows = array();
         foreach ($aRows as $aRow) {
             $aNoFollows[$aRow['url']] = true;
         }
         $this->cache()->save($sCacheId, $aNoFollows);
     }
     if (count($aNoFollows)) {
         $sUrl = trim(Phpfox_Url::instance()->getFullUrl(true), '/');
         if (isset($aNoFollows[$sUrl])) {
             Phpfox_Template::instance()->setHeader('<meta name="robots" content="nofollow" />');
         }
     }
     $sCacheId = $this->cache()->set('seo_meta_build');
     if (!($aMetas = $this->cache()->get($sCacheId))) {
         $aRows = $this->database()->select('*')->from(Phpfox::getT('seo_meta'))->execute('getSlaveRows');
         $aMetas = array();
         foreach ($aRows as $aRow) {
             if (!isset($aMetas[$aRow['url']])) {
                 $aMetas[$aRow['url']] = array();
             }
             $aMetas[$aRow['url']][] = $aRow;
         }
         $this->cache()->save($sCacheId, $aMetas);
     }
     if (count($aMetas)) {
         $sUrl = trim(Phpfox_Url::instance()->getFullUrl(true), '/');
         if (isset($aMetas[$sUrl])) {
             foreach ($aMetas[$sUrl] as $aMeta) {
                 if ($aMeta['type_id'] == '2') {
                     Phpfox_Template::instance()->setTitle(Phpfox_Locale::instance()->convert($aMeta['content']));
                     continue;
                 }
                 Phpfox_Template::instance()->setMeta(!$aMeta['type_id'] ? 'keywords' : 'description', $aMeta['content']);
             }
         }
     }
 }
Ejemplo n.º 19
0
 public function getSource($name)
 {
     if ($name == '@Theme/layout.html') {
         $Theme = \Phpfox_Template::instance()->theme()->get();
         $Service = new \Core\Theme\Service($Theme);
         return $Service->html()->get();
     } else {
         if (substr($name, 0, 7) == '@Theme/') {
             $Theme = \Phpfox_Template::instance()->theme()->get();
             $name = str_replace('@Theme/', '', $name);
             $file = $Theme->getPath() . $name;
             if (!file_exists($file)) {
                 $file = PHPFOX_DIR . 'theme/default/html/' . $name;
             }
             $html = file_get_contents($file);
             return $html;
         }
     }
     return parent::getSource($name);
 }
Ejemplo n.º 20
0
 public function searchUsersTags()
 {
     $aParams = $this->get('val');
     $aParams['tag_list'] = $aParams['tag_list'][0];
     if (strstr($aParams['tag_list'], ',')) {
         $aParts = explode(',', $aParams['tag_list']);
         $aWords = array_reverse($aParts);
         if (isset($aWords[0])) {
             $aParams['tag_list'] = trim($aWords[0]);
         }
     }
     if (empty($aParams['tag_list'])) {
         $this->call("oInlineSearch.close('" . $this->get('id') . "');");
         return false;
     }
     $aRows = Tag_Service_Tag::instance()->getInlineSearchForUser(Phpfox::getUserId(), $aParams['tag_list'], $this->get('category_id'));
     if (count($aRows)) {
         Phpfox_Template::instance()->assign(array('aRows' => $aRows, 'sJsId' => $this->get('id'), 'sSearch' => $aParams['tag_list']));
         Phpfox_Template::instance()->getLayout('inline-search');
         $this->call("oInlineSearch.display('" . $this->get('id') . "', '" . $this->getContent() . "');");
     } else {
         $this->call("oInlineSearch.close('" . $this->get('id') . "');");
     }
 }
Ejemplo n.º 21
0
 /**
  * Cache all module blocks.
  *
  */
 private function _cacheModuleBlocks()
 {
     $oCache = Phpfox::getLib('cache');
     $aStyleInUse = Phpfox_Template::instance()->getStyleInUse();
     if (!isset($aStyleInUse['style_id'])) {
         $aStyleInUse['style_id'] = 0;
     }
     $iBlockCacheId = $oCache->set(array('block', 'all_' . Phpfox::getUserBy('user_group_id')));
     $sLocationCacheId = $oCache->set(array('block', 'location_' . Phpfox::getUserBy('user_group_id')));
     $sMoveBlockId = $oCache->set(array('block', 'move_' . Phpfox::getUserBy('user_group_id')));
     $sSourceCodeBlockId = $oCache->set(array('block', 'source_code_' . Phpfox::getUserBy('user_group_id')));
     if (!($this->_aModuleBlocks = $oCache->get($iBlockCacheId)) || !($this->_aBlockLocations = $oCache->get($sLocationCacheId)) || !($this->_aMoveBlocks = $oCache->get($sMoveBlockId)) || !($this->_aBlockWithSource = $oCache->get($sSourceCodeBlockId))) {
         $aRows = Phpfox_Database::instance()->select('b.block_id, b.type_id, b.ordering, b.m_connection, b.component, b.location, b.disallow_access, b.can_move, m.module_id, bs.source_parsed')->from(Phpfox::getT('block'), 'b')->leftJoin(Phpfox::getT('block_source'), 'bs', 'bs.block_id = b.block_id')->join(Phpfox::getT('module'), 'm', 'b.module_id = m.module_id AND m.is_active = 1')->join(Phpfox::getT('product'), 'p', 'b.product_id = p.product_id AND p.is_active = 1')->where('b.is_active = 1')->order('b.ordering ASC')->execute('getRows');
         foreach ($aRows as $aRow) {
             if (!empty($aRow['disallow_access'])) {
                 if (in_array(Phpfox::getUserBy('user_group_id'), unserialize($aRow['disallow_access']))) {
                     continue;
                 }
             }
             if (Phpfox::getLib('parse.format')->isSerialized($aRow['location'])) {
                 $aLocations = unserialize($aRow['location']);
                 $aRow['location'] = $aLocations['g'];
                 if (isset($aLocations['s'][$aStyleInUse['style_id']])) {
                     $aRow['location'] = $aLocations['s'][$aStyleInUse['style_id']];
                 }
             }
             if ($aRow['type_id'] > 0) {
                 $this->_aBlockWithSource[$aRow['m_connection']][$aRow['location']][$aRow['block_id']] = true;
                 $sArrayName = $aRow['block_id'];
             } else {
                 $sArrayName = $aRow['module_id'] . '.' . $aRow['component'];
             }
             $this->_aModuleBlocks[$aRow['m_connection']][$aRow['location']][$sArrayName] = $aRow['disallow_access'];
             $this->_aBlockLocations[$aRow['m_connection']][$sArrayName] = $aRow['location'];
             if ($aRow['can_move']) {
                 $this->_aMoveBlocks[$aRow['m_connection']][$sArrayName] = true;
             } else {
                 $this->_aMoveBlocks[$aRow['m_connection']][$sArrayName] = false;
             }
             $iCacheId = $oCache->set(array('block', 'file_' . $aRow['block_id']));
             $oCache->save($iCacheId, $aRow);
             $oCache->close($iCacheId);
         }
         $oCache->save($iBlockCacheId, $this->_aModuleBlocks);
         $oCache->save($sLocationCacheId, $this->_aBlockLocations);
         $oCache->save($sMoveBlockId, $this->_aMoveBlocks);
         $oCache->save($sSourceCodeBlockId, $this->_aBlockWithSource);
     }
 }
Ejemplo n.º 22
0
 private function _get($iParentId, $iActive = null)
 {
     $aCategories = $this->database()->select('*')->from($this->_sTable)->where('parent_id = ' . (int) $iParentId . ' AND is_active = ' . (int) $iActive . '')->order('ordering ASC')->execute('getRows');
     if (count($aCategories)) {
         $aCache = array();
         if ($iParentId != 0) {
             $this->_iCnt++;
         }
         if ($this->_sDisplay == 'option') {
         } elseif ($this->_sDisplay == 'admincp') {
             $sOutput = '<ul>';
         } else {
             $this->_sOutput .= '<div class="js_mp_parent_holder" id="js_mp_holder_' . $iParentId . '" ' . ($iParentId > 0 ? ' style="display:none; padding:5px 0px 0px 0px;"' : '') . '>';
             $this->_sOutput .= '<select name="val[category][]" class="js_mp_category_list" id="js_mp_id_' . $iParentId . '">' . "\n";
             $this->_sOutput .= '<option value="">' . ($iParentId === 0 ? Phpfox::getPhrase('marketplace.select') : Phpfox::getPhrase('marketplace.select_a_sub_category')) . ':</option>' . "\n";
         }
         foreach ($aCategories as $iKey => $aCategory) {
             $aCache[] = $aCategory['category_id'];
             if ($this->_sDisplay == 'option') {
                 $this->_sOutput .= '<option value="' . $aCategory['category_id'] . '" id="js_mp_category_item_' . $aCategory['category_id'] . '">' . ($this->_iCnt > 0 ? str_repeat('&nbsp;', $this->_iCnt * 2) . ' ' : '') . Phpfox_Locale::instance()->convert($aCategory['name']) . '</option>' . "\n";
                 $this->_sOutput .= $this->_get($aCategory['category_id'], $iActive);
             } elseif ($this->_sDisplay == 'admincp') {
                 $sOutput .= '<li><img src="' . Phpfox_Template::instance()->getStyle('image', 'misc/draggable.png') . '" alt="" /> <input type="hidden" name="order[' . $aCategory['category_id'] . ']" value="' . $aCategory['ordering'] . '" class="js_mp_order" /><a href="#?id=' . $aCategory['category_id'] . '" class="js_drop_down">' . Phpfox_Locale::instance()->convert($aCategory['name']) . '</a>' . $this->_get($aCategory['category_id'], $iActive) . '</li>' . "\n";
             } else {
                 $this->_sOutput .= '<option value="' . $aCategory['category_id'] . '" id="js_mp_category_item_' . $aCategory['category_id'] . '">' . Phpfox_Locale::instance()->convert($aCategory['name']) . '</option>' . "\n";
             }
         }
         if ($this->_sDisplay == 'option') {
         } elseif ($this->_sDisplay == 'admincp') {
             $sOutput .= '</ul>';
             return $sOutput;
         } else {
             $this->_sOutput .= '</select>' . "\n";
             $this->_sOutput .= '</div>';
             foreach ($aCache as $iCateoryId) {
                 $this->_get($iCateoryId, $iActive);
             }
         }
         $this->_iCnt = 0;
     }
 }
Ejemplo n.º 23
0
 public function resetCss($sTypeId, $aCss)
 {
     $aCallback = Phpfox::callback($sTypeId . '.getDetailOnCssUpdate');
     if ($aCallback === false) {
         return false;
     }
     foreach ($aCss as $sSelector => $aProperties) {
         foreach ($aProperties as $sProperty => $sValue) {
             ($sCmd = Phpfox_Template::instance()->getXml('reset_css')) ? eval($sCmd) : null;
             switch ($sProperty) {
                 case 'font-color':
                     $sProperty = 'color';
                     break;
             }
             $this->database()->delete(Phpfox::getT($aCallback['table']), $aCallback['field'] . ' = ' . $aCallback['value'] . ' AND css_selector = \'' . $this->database()->escape($sSelector) . '\' AND css_property = \'' . $this->database()->escape($sProperty) . '\'');
         }
     }
     $sHash = $this->database()->select($aCallback['table_hash_field'])->from(Phpfox::getT($aCallback['table_hash']))->where($aCallback['field'] . ' = ' . $aCallback['value'])->execute('getField');
     $sCacheFile = Phpfox::getParam('css.dir_cache') . $sHash . '.css';
     if (file_exists($sCacheFile)) {
         unlink($sCacheFile);
     }
     return true;
 }
Ejemplo n.º 24
0
 public function processAjax($iId)
 {
     $oAjax = Phpfox_Ajax::instance();
     $aFeeds = Feed_Service_Feed::instance()->get(Phpfox::getUserId(), $iId);
     if (!isset($aFeeds[0])) {
         $oAjax->alert(Phpfox::getPhrase('feed.this_item_has_successfully_been_submitted'));
         $oAjax->call('$Core.resetActivityFeedForm();');
         return;
     }
     if (isset($aFeeds[0]['type_id'])) {
         Phpfox_Template::instance()->assign(array('aFeed' => $aFeeds[0], 'aFeedCallback' => array('module' => str_replace('_comment', '', $aFeeds[0]['type_id']), 'item_id' => $aFeeds[0]['item_id'])))->getTemplate(Profile_Service_Profile::instance()->timeline() ? 'feed.block.timeline' : 'feed.block.entry');
     } else {
         Phpfox_Template::instance()->assign(array('aFeed' => $aFeeds[0]))->getTemplate('feed.block.entry');
     }
     $sId = 'js_tmp_comment_' . md5('feed_' . uniqid() . Phpfox::getUserId()) . '';
     $sNewContent = '<div id="' . $sId . '" class="js_temp_new_feed_entry js_feed_view_more_entry_holder">' . $oAjax->getContent(false) . '</div>';
     if (Profile_Service_Profile::instance()->timeline()) {
         $oAjax->prepend('.timeline_left_new', '<div class="timeline_feed_row"><div class="timeline_arrow_left">0</div><div class="timeline_float_left">0</div>' . $sNewContent . '</div>');
     } else {
         $oAjax->prepend('#js_new_feed_comment', $sNewContent);
     }
     // $oAjax->call('$(\'#' . $sId . '\').highlightFade();');
     $oAjax->removeClass('.js_user_feed', 'row_first');
     $oAjax->call("iCnt = 0; \$('.js_user_feed').each(function(){ iCnt++; if (iCnt == 1) { \$(this).addClass('row_first'); } });");
     if ($oAjax->get('force_form')) {
         $oAjax->call('tb_remove();');
         $oAjax->show('#js_main_feed_holder');
         $oAjax->call('$Core.resetActivityFeedForm();');
     } else {
         $oAjax->call('$Core.resetActivityFeedForm();');
     }
     $oAjax->call('$Core.loadInit();');
 }
Ejemplo n.º 25
0
 /** 
  * 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 .= '&amp;' . $iKey . '[' . $sKey . ']=' . $sNewValue;
     					}
     				}
         	else
     				{
     					if (PHPFOX_IS_AJAX && $iKey == 'feed' && Phpfox::isModule('comment') && Phpfox::getParam('comment.load_delayed_comments_items'))
     					{
     						continue;
     					}
     					$sParams .= '&amp;' . $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));
 }
Ejemplo n.º 26
0
 /**
  * Extends the template class and returns its class object.
  *
  * @see Phpfox_Template
  * @return Phpfox_Template
  */
 protected function template()
 {
     return Phpfox_Template::instance();
 }
Ejemplo n.º 27
0
 public function getCommentNotification($aNotification)
 {
     $aRow = $this->database()->select('cf.field_id, cf.phrase_var_name, f.feed_id, u.user_id, u.gender, u.user_name, u.full_name')->from(Phpfox::getT('custom_field'), 'cf')->join(Phpfox::getT('feed'), 'f', 'f.item_id = cf.field_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = f.user_id')->where('cf.field_id = ' . (int) $aNotification['item_id'])->execute('getSlaveRow');
     $sUsers = Phpfox::getService('notification')->getUsers($aNotification);
     $sGender = Phpfox::getService('user')->gender($aRow['gender'], 1);
     $sTitle = Phpfox::getLib('parse.output')->shorten(Phpfox::getPhrase($aRow['phrase_var_name']), Phpfox::getParam('notification.total_notification_title_length'), '...');
     $sPhrase = '';
     if ($aNotification['user_id'] == $aRow['user_id'] && !isset($aNotification['extra_users'])) {
         $sPhrase = Phpfox::getPhrase('custom.users_commented_on_gender_profile_update_title', array('users' => $sUsers, 'gender' => $sGender, 'title' => $sTitle));
     } elseif ($aRow['user_id'] == Phpfox::getUserId()) {
         $sPhrase = Phpfox::getPhrase('custom.users_commented_on_your_profile_update_title', array('users' => $sUsers, 'title' => $sTitle));
     } else {
         $sPhrase = Phpfox::getPhrase('custom.users_commented_on_span_class_drop_data_user_row_full_name_s_span_profile_update_title', array('users' => $sUsers, 'row_full_name' => $aRow['full_name'], 'title' => $sTitle));
     }
     return array('link' => Phpfox_Url::instance()->makeUrl($aRow['user_name'], array('feed-id' => $aRow['feed_id'])), 'message' => $sPhrase, 'icon' => Phpfox_Template::instance()->getStyle('image', 'activity.png', 'blog'));
 }
Ejemplo n.º 28
0
 /**
  * Starts the phpFox engine. Used to get and display the pages controller.
  *
  */
 public static function run()
 {
     if (isset($_REQUEST['m9callback'])) {
         header('Content-type: application/json');
         try {
             $Home = new Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY);
             $callback = $_REQUEST['m9callback'];
             unset($_GET['m9callback'], $_GET['do']);
             if (!$_GET) {
                 $_GET = [];
             }
             echo json_encode(call_user_func([$Home, $callback], $_GET));
         } catch (\Exception $e) {
             // throw new \Exception($e->getMessage(), 0, $e);
             echo json_encode(['error' => $e->getMessage()]);
         }
         exit;
     }
     $oTpl = Phpfox_Template::instance();
     $aLocale = Phpfox_Locale::instance()->getLang();
     $oReq = Phpfox_Request::instance();
     $oModule = Phpfox_Module::instance();
     if ($oReq->segment(1) == 'favicon.ico') {
         header('Content-type: image/x-icon');
         echo file_get_contents('http://www.phpfox.com/favicon.ico');
         exit;
     }
     $aStaticFolders = ['file', 'static', 'module', 'apps', 'Apps', 'themes'];
     if (in_array($oReq->segment(1), $aStaticFolders) || $oReq->segment(1) == 'theme' && $oReq->segment(2) != 'demo' && $oReq->segment(1) == 'theme' && $oReq->segment(2) != 'sample') {
         $sUri = Phpfox_Url::instance()->getUri();
         if ($sUri == '/static/ajax.php') {
             $oAjax = Phpfox_Ajax::instance();
             $oAjax->process();
             echo $oAjax->getData();
             exit;
         }
         if (Phpfox::getParam('core.url_rewrite') == '1') {
             header("HTTP/1.0 404 Not Found");
             header('Content-type: application/json');
             echo json_encode(['error' => 404]);
             exit;
         }
         $HTTPCache = new Core\HTTP\Cache();
         $HTTPCache->checkCache();
         $sDir = PHPFOX_DIR;
         if ($oReq->segment(1) == 'Apps' || $oReq->segment(1) == 'apps' || $oReq->segment(1) == 'themes') {
             $sDir = PHPFOX_DIR_SITE;
         }
         $sPath = $sDir . ltrim($sUri, '/');
         if ($oReq->segment(1) == 'themes' && $oReq->segment(2) == 'default') {
             $sPath = PHPFOX_DIR . str_replace('themes/default', 'theme/default', $sUri);
         }
         if ($oReq->segment(3) == 'emoticon') {
             $sPath = str_replace('/file/pic/emoticon/default/', PHPFOX_DIR . 'static/image/emoticon/', $sUri);
         }
         $sType = Phpfox_File::instance()->mime($sUri);
         $sExt = Phpfox_File::instance()->extension($sUri);
         if (!file_exists($sPath)) {
             $sPath = str_replace('PF.Base', 'PF.Base/..', $sPath);
             // header('Content-type: ' . $sType);
             if (!file_exists($sPath)) {
                 header("HTTP/1.0 404 Not Found");
                 header('Content-type: application/json');
                 echo json_encode(['error' => 404]);
                 exit;
             }
         }
         // header('Content-type: ' . $sType);
         $HTTPCache->cache($sType, filemtime($sPath), 7);
         if ($oReq->segment(1) == 'themes') {
             $Theme = $oTpl->theme()->get();
             $Service = new Core\Theme\Service($Theme);
             if ($sType == 'text/css') {
                 echo $Service->css()->getParsed();
             } else {
                 echo $Service->js()->get();
             }
         } else {
             echo @file_get_contents($sPath);
         }
         exit;
     }
     ($sPlugin = Phpfox_Plugin::get('run_start')) ? eval($sPlugin) : false;
     // Load module blocks
     $oModule->loadBlocks();
     if (!Phpfox::getParam('core.branding')) {
         $oTpl->setHeader(array('<meta name="author" content="PHPfox" />'));
     }
     if (strtolower(Phpfox_Request::instance()->get('req1')) == Phpfox::getParam('admincp.admin_cp')) {
         self::$_bIsAdminCp = true;
     }
     $View = $oModule->setController();
     if ($View instanceof Core\View) {
     } else {
         if (!self::$_bIsAdminCp) {
             $View = new Core\View();
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE) {
         $oTpl->setImage(array('ajax_small' => 'ajax/small.gif', 'ajax_large' => 'ajax/large.gif', 'loading_animation' => 'misc/loading_animation.gif', 'close' => 'misc/close.gif', 'move' => 'misc/move.png', 'calendar' => 'jquery/calendar.gif'));
         $oTpl->setHeader(array('<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />', '<meta http-equiv="Content-Type" content="text/html; charset=' . $aLocale['charset'] . '" />', '<meta http-equiv="cache-control" content="no-cache" />', '<meta http-equiv="expires" content="-1" />', '<meta http-equiv="pragma" content="no-cache" />', '<link rel="shortcut icon" type="image/x-icon" href="' . Phpfox::getParam('core.path') . 'favicon.ico?v=' . $oTpl->getStaticVersion() . '" />'))->setMeta('keywords', Phpfox_Locale::instance()->convert(Phpfox::getParam('core.keywords')))->setMeta('robots', 'index,follow');
         $oTpl->setHeader('cache', Phpfox::getMasterFiles());
         if (Phpfox::isModule('friend')) {
             $oTpl->setPhrase(array('friend.show_more_results_for_search_term'));
         }
         if (PHPFOX_DEBUG) {
             $oTpl->setHeader('cache', array('debug.css' => 'style_css'));
         }
         if (!Phpfox::isMobile() && Phpfox::isUser() && Phpfox::getParam('user.enable_user_tooltip')) {
             $oTpl->setHeader('cache', array('user_info.js' => 'static_script'));
         }
         if (Phpfox::isModule('captcha') && Phpfox::getParam('captcha.recaptcha')) {
             // http://www.phpfox.com/tracker/view/14456/
             $sUrl = (Phpfox::getParam('core.force_https_secure_pages') ? 'https' : 'http') . "://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
             $oTpl->setHeader('<script type="text/javascript" src="' . $sUrl . '"></script>');
         }
     }
     if ($sPlugin = Phpfox_Plugin::get('get_controller')) {
         eval($sPlugin);
     }
     $oTpl->assign(['aGlobalUser' => Phpfox::isUser() ? Phpfox::getUserBy(null) : array()]);
     $oModule->getController();
     Phpfox::getService('admincp.seo')->setHeaders();
     if (!defined('PHPFOX_DONT_SAVE_PAGE')) {
         Phpfox::getLib('session')->set('redirect', Phpfox_Url::instance()->getFullUrl(true));
     }
     if (!defined('PHPFOX_NO_CSRF')) {
         Phpfox::getService('log.session')->verifyToken();
     }
     ($sPlugin = Phpfox_Plugin::get('run')) ? eval($sPlugin) : false;
     if (!self::isAdminPanel()) {
         if (!Phpfox::isMobile() && !PHPFOX_IS_AJAX_PAGE && Phpfox::isModule('rss') && !defined('PHPFOX_IS_USER_PROFILE')) {
             $aFeeds = Phpfox::getService('rss')->getLinks();
             if (is_array($aFeeds) && count($aFeeds)) {
                 foreach ($aFeeds as $sLink => $sPhrase) {
                     $oTpl->setHeader('<link rel="alternate" type="application/rss+xml" title="' . $sPhrase . '" href="' . $sLink . '" />');
                 }
             }
         }
         $aPageLastLogin = Phpfox::isModule('pages') && Phpfox::getUserBy('profile_page_id') ? Phpfox::getService('pages')->getLastLogin() : false;
         $oTpl->assign(array('aMainMenus' => $oTpl->getMenu('main'), 'aSubMenus' => $oTpl->getMenu(), 'bIsUsersProfilePage' => defined('PHPFOX_IS_USER_PROFILE') ? true : false, 'sGlobalUserFullName' => Phpfox::isUser() ? Phpfox::getUserBy('full_name') : null, 'sFullControllerName' => str_replace(array('.', '/'), '_', Phpfox_Module::instance()->getFullControllerName()), 'iGlobalProfilePageId' => Phpfox::getUserBy('profile_page_id'), 'aGlobalProfilePageLogin' => $aPageLastLogin));
         $oTpl->setEditor();
         if (Phpfox::isModule('captcha')) {
             $sCaptchaHeader = Phpfox::getParam('captcha.recaptcha_header');
             if (strlen(preg_replace('/\\s\\s+/', '', $sCaptchaHeader)) > 0) {
                 $oTpl->setHeader(array($sCaptchaHeader));
             }
         }
         if (Phpfox::isModule('notification') && Phpfox::isUser() && Phpfox::getParam('notification.notify_on_new_request')) {
             $oTpl->setHeader('cache', array('update.js' => 'module_notification'));
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE && ($sHeaderFile = $oTpl->getHeaderFile())) {
         ($sPlugin = Phpfox_Plugin::get('run_get_header_file_1')) ? eval($sPlugin) : false;
         require_once $sHeaderFile;
     }
     list($aBreadCrumbs, $aBreadCrumbTitle) = $oTpl->getBreadCrumb();
     $oTpl->assign(array('aErrors' => Phpfox_Error::getDisplay() ? Phpfox_Error::get() : array(), 'sPublicMessage' => Phpfox::getMessage(), 'sLocaleDirection' => $aLocale['direction'], 'sLocaleCode' => $aLocale['language_code'], 'sLocaleFlagId' => $aLocale['image'], 'sLocaleName' => $aLocale['title'], 'aBreadCrumbs' => $aBreadCrumbs, 'aBreadCrumbTitle' => $aBreadCrumbTitle, 'sCopyright' => '&copy; ' . Phpfox::getPhrase('core.copyright') . ' ' . Phpfox::getParam('core.site_copyright')));
     Phpfox::clearMessage();
     unset($_SESSION['phpfox']['image']);
     if (Phpfox::getParam('core.cron')) {
         require_once PHPFOX_DIR_CRON . 'exec.php';
     }
     if ($oReq->isPost()) {
         header('X-Is-Posted: true');
         exit;
     }
     if ($oReq->get('is_ajax_get')) {
         header('X-Is-Get: true');
         exit;
     }
     if (defined('PHPFOX_SITE_IS_OFFLINE')) {
         $oTpl->sDisplayLayout = 'blank';
         unset($View);
     }
     if (!PHPFOX_IS_AJAX_PAGE && $oTpl->sDisplayLayout && !isset($View) || !PHPFOX_IS_AJAX_PAGE && self::isAdminPanel()) {
         $oTpl->getLayout($oTpl->sDisplayLayout);
     }
     if (PHPFOX_IS_AJAX_PAGE) {
         header('Content-type: application/json; charset=utf-8');
         /*
         if (isset($View) && $View instanceof \Core\View) {
         	$content = $View->getContent();
         }
         else {
         	Phpfox_Module::instance()->getControllerTemplate();
         	$content = ob_get_contents(); ob_clean();
         }
         */
         if ($View instanceof \Core\View) {
             $content = $View->getContent();
         } else {
             Phpfox_Module::instance()->getControllerTemplate();
             $content = ob_get_contents();
             ob_clean();
         }
         $oTpl->getLayout('breadcrumb');
         $breadcrumb = ob_get_contents();
         ob_clean();
         $aHeaderFiles = Phpfox_Template::instance()->getHeader(true);
         $aCss = [];
         $aLoadFiles = [];
         foreach ($aHeaderFiles as $sHeaderFile) {
             if (!is_string($sHeaderFile)) {
                 continue;
             }
             if (preg_match('/<style(.*)>(.*)<\\/style>/i', $sHeaderFile)) {
                 $aCss[] = strip_tags($sHeaderFile);
                 continue;
             }
             if (preg_match('/href=(["\']?([^"\'>]+)["\']?)/', $sHeaderFile, $aMatches) > 0 && strpos($aMatches[1], '.css') !== false) {
                 $sHeaderFile = str_replace(array('"', "'"), '', $aMatches[1]);
                 $sHeaderFile = substr($sHeaderFile, 0, strpos($sHeaderFile, '?'));
             }
             $sHeaderFile = strip_tags($sHeaderFile);
             $sNew = preg_replace('/\\s+/', '', $sHeaderFile);
             if (empty($sNew)) {
                 continue;
             }
             $aLoadFiles[] = $sHeaderFile;
         }
         $blocks = [];
         foreach (range(1, 12) as $location) {
             if ($location == 3) {
                 echo \Phpfox_Template::instance()->getSubMenu();
             }
             $aBlocks = Phpfox_Module::instance()->getModuleBlocks($location);
             $blocks[$location] = [];
             foreach ($aBlocks as $sBlock) {
                 Phpfox::getBlock($sBlock);
                 $blocks[$location][] = ob_get_contents();
                 ob_clean();
             }
         }
         $oTpl->getLayout('search');
         $search = ob_get_contents();
         ob_clean();
         Phpfox::getBlock('core.template-menusub');
         $menuSub = ob_get_contents();
         ob_clean();
         $h1 = '';
         if (isset($aBreadCrumbTitle[1])) {
             $h1 .= '<h1><a href="' . $aBreadCrumbTitle[1] . '">' . Phpfox_Parse_Output::instance()->clean($aBreadCrumbTitle[0]) . '</a></h1>';
         }
         $oTpl->getLayout('error');
         $error = ob_get_contents();
         ob_clean();
         $controller = Phpfox_Module::instance()->getFullControllerName();
         $data = json_encode(['content' => str_replace(['&#039;'], ["'"], Phpfox_Parse_Input::instance()->convert($content)), 'title' => html_entity_decode($oTpl->instance()->getTitle()), 'phrases' => Phpfox_Template::instance()->getPhrases(), 'files' => $aLoadFiles, 'css' => $aCss, 'breadcrumb' => $breadcrumb, 'blocks' => $blocks, 'search' => $search, 'menuSub' => $menuSub, 'id' => Phpfox_Module::instance()->getPageId(), 'class' => Phpfox_Module::instance()->getPageClass(), 'h1' => $h1, 'h1_clean' => strip_tags($h1), 'error' => $error, 'controller_e' => Phpfox::isAdmin() ? Phpfox_Url::instance()->makeUrl('admincp.element.edit', ['controller' => base64_encode(Phpfox_Module::instance()->getFullControllerName())]) : null, 'meta' => Phpfox_Template::instance()->getPageMeta(), 'keep_body' => Phpfox_Template::instance()->keepBody()]);
         // header("Content-length: " . strlen($data));
         echo $data;
         // sleep(4);
     } else {
         if (isset($View)) {
             echo $View->getContent();
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * Get JavaScript code used to verify the validity of a CSS property value.
  *
  * @return string JavaScript code used to validate CSS property values.
  */
 public function getJavaScript()
 {
     $sJs = '<script type="text/javascript">';
     $sJs .= 'var oValidateCss = {';
     ($sCmd = Phpfox_Template::instance()->getXml('design_css')) ? eval($sCmd) : null;
     $aWidths = array();
     if (isset($aAdvanced)) {
         foreach ($aAdvanced as $aCss) {
             if (isset($aCss['design']['width']) && isset($aCss['id']) && ($aCss['id'] = 'page_width')) {
                 $aWidths = array_values($aCss['design']['width']);
                 break;
             }
         }
     }
     $sJs .= '\'width\': ' . $this->_build($aWidths) . ',';
     $sJs .= '\'font-family\': ' . $this->_build($this->getFonts()) . ',';
     $sJs .= '\'font-size\': ' . $this->_build($this->getFontSizes()) . ',';
     $sJs .= '\'font-style\': ' . $this->_build($this->getFontStyles()) . ',';
     $sJs .= '\'font-weight\': ' . $this->_build($this->getFontWeights()) . ',';
     $sJs .= '\'text-align\': ' . $this->_build($this->getTextAlign()) . ',';
     $sJs .= '\'text-transform\': ' . $this->_build($this->getTextTransforms()) . ',';
     $sJs .= '\'text-decoration\': ' . $this->_build($this->getTextDecorations()) . ',';
     $sJs .= '\'background-position\': ' . $this->_build($this->getPositions()) . ',';
     $sJs .= '\'background-attachment\': ' . $this->_build($this->_aAttachment) . ',';
     $sJs .= '\'background-repeat\': ' . $this->_build($this->_aRepeat) . ',';
     foreach ($this->getBorders() as $sBorder) {
         $sJs .= '\'' . $sBorder . 'style\': ' . $this->_build($this->getBorderStyles()) . ',';
         $sJs .= '\'' . $sBorder . 'width\': ' . $this->_build($this->getBorderWidths()) . ',';
     }
     foreach ($this->getPaddings() as $sPadding) {
         $sJs .= '\'' . $sPadding . '\': ' . $this->_build($this->getPaddingSizes()) . ',';
     }
     $sJs .= 'isHex: function(sHex) { if (sHex == \'#transparent\') { return true; } if (sHex.search(' . $this->_aRegex['hex'] . ') == -1) { return false; } return true;},';
     $sJs .= 'isImageLink: function(sLink) { if (sLink.search(' . $this->_aRegex['link'] . ') == -1) { return false; } return true;}';
     $sJs .= '};';
     $sJs .= '</script>';
     return $sJs;
 }
Ejemplo n.º 30
0
 private function _loadLikeBlock($iPage)
 {
     $aPage = Phpfox::getService('pages')->getForView($iPage);
     $oAjax = Phpfox_Ajax::instance();
     Phpfox_Template::instance()->assign('aPage', $aPage);
     Phpfox_Component::setPublicParam('aPage', $aPage);
     Phpfox::getBlock('pages.like');
     $oAjax->html('#js_pages_like_join_holder', $oAjax->getContent(false));
 }