public function _hashSearch() { if (Phpfox_Request::instance()->get('req1') != 'hashtag' && Phpfox_Request::instance()->get('hashtagsearch') == '') { return; } $sRequest = isset($_GET[PHPFOX_GET_METHOD]) ? $_GET[PHPFOX_GET_METHOD] : ''; $sReq2 = ''; if (!empty($sRequest)) { $aParts = explode('/', trim($sRequest, '/')); $iCnt = 0; // http://www.phpfox.com/tracker/view/15000/ // We have to count the "mobile" part as a req1 // add one to the count $iCntTotal = Phpfox::isMobile() ? 3 : 2; foreach ($aParts as $sPart) { $iCnt++; if ($iCnt === $iCntTotal) { $sReq2 = $sPart; break; } } } $sTag = Phpfox_Request::instance()->get('hashtagsearch') ? Phpfox_Request::instance()->get('hashtagsearch') : $sReq2; $sTag = \Phpfox_Parse_Output::instance()->parse($sTag); //https://github.com/moxi9/phpfox/issues/595 $sTag = urldecode($sTag); if (empty($sTag)) { return; } $sTag = Phpfox::getLib('parse.input')->clean($sTag, 255); $sTag = mb_convert_case($sTag, MB_CASE_LOWER, "UTF-8"); $this->database()->join(Phpfox::getT('tag'), 'hashtag', 'hashtag.item_id = feed.item_id AND hashtag.category_id = feed.type_id AND (tag_text = \'' . Phpfox_Database::instance()->escape($sTag) . '\' OR tag_url = \'' . Phpfox_Database::instance()->escape($sTag) . '\')'); }
/** * Prepare text strings. Used to prepare all data that can contain HTML. Not only does * it protect against harmful HTML and CSS, it also has support for emoticon and BBCode conversion. * * @param string $sTxt Text to parse. * @return string Parsed string. */ public function prepare($sTxt, $bNoClean = false) { /* // Parse Emoticons if (Phpfox::isModule('emoticon')) { $sTxt = Phpfox::getService('emoticon')->parse($sTxt); } $sTxt = str_replace('\\', '\', $sTxt); $sTxt = str_replace(array('<', '>'), array('<', '>'), $sTxt); $sTxt = str_replace('[*]', '<li>', $sTxt); $oFilterBbcode = Phpfox::getLib('parse.bbcode'); $sTxt = $oFilterBbcode->preParse($sTxt); // Parse for language package $sTxt = $this->_utf8ToUnicode($sTxt); $sTxt = str_replace('\\', '\', $sTxt); // Clean out the HTML if (!$bNoClean) { $sTxt = $this->_cleanHtml($sTxt); } // Parse BBCode $sTxt = $oFilterBbcode->parse($sTxt); $sTxt = str_replace('<br /><li>', '<li>', $sTxt); $sTxt = str_replace('<br /></ul>', '</ul>', $sTxt); $sTxt = str_replace('<br /><tr>', '<tr>', $sTxt); $sTxt = str_replace('<br /><td>', '<td>', $sTxt); $sTxt = str_replace('<br /></tr>', '</tr>', $sTxt); $sTxt = str_replace('<br /></table>', '</table>', $sTxt); $sTxt = str_replace('<br /></ol>', '</ol>', $sTxt); */ return Phpfox_Parse_Output::instance()->htmlspecialchars($sTxt); }
/** * 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' => '© ' . 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(['''], ["'"], 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(); } } }
public function __toString() { try { $Template = \Phpfox_Template::instance(); switch ($this->_method) { case 'search': \Phpfox::getBlock('search.panel'); break; case 'footer': \Phpfox::getBlock('core.template-menufooter'); break; case 'share': \Phpfox::getBlock('feed.form2', ['menu' => true]); break; case 'notify': \Phpfox::getBlock('core.template-notification'); break; case 'menu': \Phpfox::getBlock('core.template-menu'); break; case 'sticky_bar': \Phpfox::getBlock('core.template-notification'); break; case 'menu_sub': \Phpfox::getBlock('core.template-menusub'); break; case 'breadcrumb_menu': \Phpfox::getBlock('core.template-breadcrumbmenu'); break; case 'nav': \Phpfox::getBlock('feed.form2', ['menu' => true]); \Phpfox::getBlock('core.template-notification'); \Phpfox::getBlock('core.template-menu'); break; case 'content': $isSearch = \Phpfox_Request::instance()->get('page') ? true : false; if ($isSearch && PHPFOX_IS_AJAX_PAGE) { \Phpfox_Module::instance()->getControllerTemplate(); $content = ob_get_contents(); ob_clean(); return $content; } if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_' . $this->_method . '">'; } $this->_loadBlocks(2); if ($this->_extra) { echo $this->_extra; } else { try { \Phpfox_Module::instance()->getControllerTemplate(); } catch (\Exception $e) { exit($e->getMessage()); } } $this->_loadBlocks(4); if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } if (PHPFOX_IS_AJAX_PAGE) { $content = ob_get_contents(); ob_clean(); return $content; } break; case 'location_1': $this->_loadBlocks(1); break; case 'location_2': $this->_loadBlocks(2); break; case 'location_3': $this->_loadBlocks(3); break; case 'location_4': $this->_loadBlocks(4); break; case 'location_5': $this->_loadBlocks(5); break; case 'location_6': $this->_loadBlocks(6); break; case 'location_7': $this->_loadBlocks(7); break; case 'location_8': $this->_loadBlocks(8); break; case 'location_9': $this->_loadBlocks(9); break; case 'location_10': $this->_loadBlocks(10); break; case 'location_11': $this->_loadBlocks(11); break; case 'location_12': $this->_loadBlocks(12); break; case 'main_top': if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_top">'; } $Template->getLayout('search'); if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } $this->_loadBlocks(7); break; case 'top': $this->_loadBlocks(11); if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_top">'; } $Template->getLayout('search'); if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } $this->_loadBlocks(7); break; case 'errors': $Template->getLayout('error'); break; case 'left': $this->_loadBlocks(1); break; case 'right': $this->_loadBlocks(3); break; case 'logo': \Phpfox::getBlock('core.template-logo'); break; case 'breadcrumb': if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_' . $this->_method . '">'; } $Template->getLayout('breadcrumb'); if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } break; case 'title': echo $Template->getTitle(); break; case 'h1': if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_' . $this->_method . '">'; } list($breadcrumbs, $title) = $Template->getBreadCrumb(); if (count($title)) { echo '<h1><a href="' . $title[1] . '">' . \Phpfox_Parse_Output::instance()->clean($title[0]) . '</a></h1>'; } if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } break; } } catch (\Exception $e) { register_shutdown_function(function () use($e) { ob_clean(); throw new \Exception($e->getMessage(), $e->getCode(), $e); }); } return ''; }
public function __toString() { try { $Template = \Phpfox_Template::instance(); switch ($this->_method) { case 'footer': \Phpfox::getBlock('core.template-menufooter'); break; case 'nav': \Phpfox::getBlock('feed.form2', ['menu' => true]); \Phpfox::getBlock('core.template-notification'); \Phpfox::getBlock('core.template-menu'); break; case 'content': if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_' . $this->_method . '">'; } $this->_loadBlocks(2); if ($this->_extra) { echo $this->_extra; } else { try { \Phpfox_Module::instance()->getControllerTemplate(); } catch (\Exception $e) { exit($e->getMessage()); } } $this->_loadBlocks(4); if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } if (PHPFOX_IS_AJAX_PAGE) { $content = ob_get_contents(); ob_clean(); return $content; } break; case 'top': $this->_loadBlocks(11); if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_' . $this->_method . '">'; } $Template->getLayout('search'); if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } $this->_loadBlocks(7); break; case 'errors': $Template->getLayout('error'); break; case 'left': $this->_loadBlocks(1); break; case 'right': $this->_loadBlocks(3); break; case 'logo': \Phpfox::getBlock('core.template-logo'); break; case 'breadcrumb': if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_' . $this->_method . '">'; } $Template->getLayout('breadcrumb'); if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } break; case 'title': echo $Template->getTitle(); break; case 'h1': if (!PHPFOX_IS_AJAX_PAGE) { echo '<div class="_block_' . $this->_method . '">'; } list($breadcrumbs, $title) = $Template->getBreadCrumb(); if (count($title)) { echo '<h1><a href="' . $title[1] . '">' . \Phpfox_Parse_Output::instance()->clean($title[0]) . '</a></h1>'; } if (!PHPFOX_IS_AJAX_PAGE) { echo '</div>'; } break; } } catch (\Exception $e) { // throw new \Exception($e->getMessage(), $e->getCode(), $e); ob_clean(); echo $e->getMessage(); exit; } return ''; }
/** * Prepare text strings. Used to prepare all data that can contain HTML. Not only does * it protect against harmful HTML and CSS, it also has support for emoticon and BBCode conversion. * * @param string $sTxt Text to parse. * @return string Parsed string. */ public function prepare($sTxt, $bNoClean = false) { ($sPlugin = Phpfox_Plugin::get('parse_input_prepare')) ? eval($sPlugin) : null; if (isset($override) && is_callable($override)) { return call_user_func($override, $sTxt); } return Phpfox_Parse_Output::instance()->htmlspecialchars($sTxt); }
public function get($aConds = array(), $sSort = 'm.time_updated DESC', $iPage = '', $iLimit = '', $bIsSentbox = false, $bIsTrash = false) { $aRows = array(); $aInputs = array('unread', 'read'); if (Phpfox::getParam('mail.threaded_mail_conversation')) { $iArchiveId = $bIsTrash ? 1 : 0; } $bIsTextSearch = false; if (Phpfox::getParam('mail.threaded_mail_conversation')) { if (!defined('PHPFOX_IS_PRIVATE_MAIL')) { $this->database()->select('COUNT(*)'); if ($bIsSentbox) { $this->database()->where('th.user_id = ' . (int) Phpfox::getUserId() . ' AND th.is_archive = 0 AND th.is_sent = 1'); } else { $this->database()->where('th.user_id = ' . (int) Phpfox::getUserId() . ' AND th.is_archive = ' . (int) $iArchiveId . ''); } } else { $this->database()->select('COUNT(DISTINCT t.thread_id)'); $aNewCond = array(); if (count($aConds)) { foreach ($aConds as $sCond) { if (preg_match('/AND mt.text LIKE \'%(.*)%\'/i', $sCond, $aTextMatch)) { $bIsTextSearch = true; $aNewCond[] = $sCond; } } } } if ($bIsTextSearch) { $iCnt = $this->database()->from(Phpfox::getT('mail_thread_text'), 'mt')->join(Phpfox::getT('mail_thread'), 't', 't.thread_id = mt.thread_id')->where($aNewCond)->execute('getSlaveField'); } else { $iCnt = $this->database()->from(Phpfox::getT('mail_thread_user'), 'th')->join(Phpfox::getT('mail_thread'), 't', 't.thread_id = th.thread_id')->execute('getSlaveField'); } } else { $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'm')->join(Phpfox::getT('mail_text'), 'mt', 'mt.mail_id = m.mail_id')->leftjoin(Phpfox::getT('user'), 'u', 'u.user_id ' . (!$bIsSentbox ? '= m.owner_user_id' : '= m.viewer_user_id'))->where($aConds)->execute('getSlaveField'); } if ($iCnt) { ($sPlugin = Phpfox_Plugin::get('mail.service_mail_get')) ? eval($sPlugin) : false; if (Phpfox::getParam('mail.threaded_mail_conversation')) { if (!defined('PHPFOX_IS_PRIVATE_MAIL')) { if ($bIsSentbox) { $this->database()->where('th.user_id = ' . (int) Phpfox::getUserId() . ' AND th.is_archive = 0 AND th.is_sent = 1'); } else { $this->database()->where('th.user_id = ' . (int) Phpfox::getUserId() . ' AND th.is_archive = ' . (int) $iArchiveId . ''); } } else { $this->database()->where($aConds); $this->database()->group('th.thread_id'); } if ($bIsTextSearch) { $aRows = $this->database()->select('th.*, mt.text AS preview, mt.time_stamp, mt.user_id AS last_user_id')->from(Phpfox::getT('mail_thread_text'), 'mt')->join(Phpfox::getT('mail_thread_user'), 'th', 'th.user_id = mt.user_id')->join(Phpfox::getT('mail_thread'), 't', 't.thread_id = mt.thread_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = mt.user_id')->limit($iPage, $iLimit, $iCnt)->order('t.time_stamp DESC')->execute('getSlaveRows'); } else { $aRows = $this->database()->select('th.*, tt.text AS preview, tt.time_stamp, tt.user_id AS last_user_id')->from(Phpfox::getT('mail_thread_user'), 'th')->join(Phpfox::getT('mail_thread'), 't', 't.thread_id = th.thread_id')->join(Phpfox::getT('mail_thread_text'), 'tt', 'tt.message_id = t.last_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = tt.user_id')->limit($iPage, $iLimit, $iCnt)->order('t.time_stamp DESC')->execute('getSlaveRows'); } $aFields = Phpfox::getService('user')->getUserFields(); foreach ($aRows as $iKey => $aRow) { if (Phpfox::getParam('mail.threaded_mail_conversation')) { $aRows[$iKey]['preview'] = strip_tags($aRow['preview']); } $aRows[$iKey]['viewer_is_new'] = $aRow['is_read'] ? false : true; $aRows[$iKey]['users'] = $this->database()->select('th.is_read, ' . Phpfox::getUserField())->from(Phpfox::getT('mail_thread_user'), 'th')->join(Phpfox::getT('user'), 'u', 'u.user_id = th.user_id')->where('th.thread_id = ' . (int) $aRow['thread_id'])->execute('getSlaveRows'); $iUserCnt = 0; foreach ($aRows[$iKey]['users'] as $iUserKey => $aUser) { if (!\Core\Route\Controller::$isApi && !defined('PHPFOX_IS_PRIVATE_MAIL') && $aUser['user_id'] == Phpfox::getUserId()) { unset($aRows[$iKey]['users'][$iUserKey]); continue; } $iUserCnt++; if ($iUserCnt == 1) { foreach ($aFields as $sField) { if ($sField == 'server_id') { $sField = 'user_server_id'; } $aRows[$iKey][$sField] = $aUser[$sField]; } } if (!isset($aRows[$iKey]['users_is_read'])) { $aRows[$iKey]['users_is_read'] = array(); } if ($aUser['is_read']) { $aRows[$iKey]['users_is_read'][] = $aUser; } } if (!$iUserCnt) { unset($aRows[$iKey]); } } } else { if ($bIsTrash) { $this->database()->select(Phpfox::getUserField('u2', 'other_') . ', ')->join(Phpfox::getT('user'), 'u2', 'u2.user_id = m.viewer_user_id'); } $aRows = $this->database()->select('m.*, ' . Phpfox::getUserField())->from($this->_sTable, 'm')->join(Phpfox::getT('mail_text'), 'mt', 'mt.mail_id = m.mail_id')->leftjoin(Phpfox::getT('user'), 'u', 'u.user_id ' . (!$bIsSentbox ? '= m.owner_user_id' : '= m.viewer_user_id'))->where($aConds)->limit($iPage, $iLimit, $iCnt)->order($sSort)->execute('getSlaveRows'); if (!$bIsSentbox) { foreach ($aRows as $iKey => $aRow) { if ($aRow['viewer_is_new']) { $aInputs['unread'][] = $aRow['mail_id']; } else { $aInputs['read'][] = $aRow['mail_id']; } } } } } //thread name if (Phpfox::getParam('mail.threaded_mail_conversation')) { foreach ($aRows as $iKey => $aRow) { $iCntUser = 0; $sThreadName = ''; $iCut = 0; foreach ($aRow['users'] as $aUser) { $sMore = \Phpfox_Parse_Output::instance()->shorten($aUser['full_name'], 30, '...'); if (strlen($sThreadName . $sMore) < 45) { $sThreadName .= $sMore; $iCut++; } $iCntUser++; if ($iCntUser == $iCut && count($aRow['users']) > 1) { $sThreadName .= ', '; } } if ($iCntUser > $iCut) { if (Phpfox::isPhrase('mail.and_number_other')) { $sThreadName .= ' ' . Phpfox::getPhrase('mail.and_number_other', array('number' => $iCntUser - $iCut)) . ($iCntUser - $iCut > 1 ? 's' : ''); } else { $sThreadName .= ' and ' . ($iCntUser - $iCut) . ' other' . ($iCntUser - $iCut > 1 ? 's' : ''); } } $aRows[$iKey]['thread_name'] = $sThreadName; } } return array($iCnt, $aRows, $aInputs); }
/** * Prepare text strings. Used to prepare all data that can contain HTML. Not only does * it protect against harmful HTML and CSS, it also has support for emoticon and BBCode conversion. * * @param string $sTxt Text to parse. * @return string Parsed string. */ public function prepare($sTxt, $bNoClean = false, $extra = []) { ($sPlugin = Phpfox_Plugin::get('parse_input_prepare')) ? eval($sPlugin) : null; if (isset($extra['comment'])) { $mentions = Phpfox_Parse_Output::instance()->mentionsRegex($sTxt); $link = Phpfox_Url::instance()->makeUrl('comment.view.' . $extra['comment']); foreach ($mentions as $user) { Phpfox_Mail::instance()->to(Phpfox::getUserBy('email'))->subject($user->name . ' mentioned you in a post.')->message($user->name . ' mentioned you in a post. <a href="' . $link . '">Check it out</a>')->send(); } } if (isset($override) && is_callable($override)) { return call_user_func($override, $sTxt); } return Phpfox_Parse_Output::instance()->htmlspecialchars($sTxt); }