Esempio n. 1
0
 /**
  * gets the caching flag
  * @return boolean
  */
 public function getIgnoreCache()
 {
     if (vB_Api_Search::getCacheTTL() == 0) {
         return true;
     }
     return $this->ignoreCache;
 }
Esempio n. 2
0
 /**
  * breaks up the text into words
  * @param string $text
  * @return string
  */
 protected static function break_words($text)
 {
     $text = strip_tags($text);
     $text = strip_bbcode($text, true, false, false, true);
     // multibyte
     $is_mb = preg_match('/[^\\x00-\\x7F]/', $text);
     if (!$is_mb) {
         $is_mb = strlen($text) != vB_String::vbStrlen($text);
     }
     if ($is_mb) {
         $text = vB_String::toUtf8($text, vB_String::getCharSet());
         if (preg_match('/&#([0-9]+);|[^\\x00-\\x7F]/esiU', $text) and function_exists('mb_decode_numericentity')) {
             $text = mb_decode_numericentity($text, array(0x0, 0x2ffff, 0, 0xffff), 'UTF-8');
         }
         $pattern = '/[\\s,.!?@#$%^&*\\(\\)\\/<>"\';:\\[\\]\\{\\}\\+|-]/';
     } else {
         $pattern = '/[^a-z0-9_]+/i';
     }
     $words = preg_split($pattern, vB_String::vBStrToLower($text), -1, PREG_SPLIT_NO_EMPTY);
     foreach ($words as $index => $word) {
         if (!vB_Api_Search::is_index_word($word, true)) {
             unset($words[$index]);
             continue;
         }
         //$words[$index] = $is_mb ? vB_String::toUtf8($word) : $word;
         if (empty($words[$index])) {
             unset($words[$index]);
             continue;
         }
     }
     return $words;
 }
Esempio n. 3
0
 public static function get_bad_words()
 {
     if (!isset(self::$badwords)) {
         $badwords = array('&amp', '&quot', 'a', 'able', 'about', 'above', 'according', 'accordingly', 'across', 'actually', 'after', 'afterwards', 'again', 'against', 'aint', 'all', 'allow', 'allows', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'an', 'and', 'another', 'any', 'anybody', 'anyhow', 'anyone', 'anything', 'anyway', 'anyways', 'anywhere', 'apart', 'appear', 'appreciate', 'appropriate', 'are', 'arent', 'around', 'as', 'aside', 'ask', 'asking', 'associated', 'at', 'available', 'away', 'awfully', 'b', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'believe', 'below', 'beside', 'besides', 'best', 'better', 'between', 'beyond', 'both', 'brief', 'but', 'by', 'c', 'came', 'can', 'cannot', 'cant', 'cause', 'causes', 'certain', 'certainly', 'changes', 'clearly', 'cmon', 'co', 'com', 'come', 'comes', 'concerning', 'consequently', 'consider', 'considering', 'contain', 'containing', 'contains', 'corresponding', 'could', 'couldnt', 'course', 'cs', 'currently', 'd', 'definitely', 'described', 'despite', 'did', 'didnt', 'different', 'do', 'does', 'doesnt', 'doing', 'done', 'dont', 'down', 'downwards', 'during', 'e', 'each', 'edu', 'eg', 'eight', 'either', 'else', 'elsewhere', 'enough', 'entirely', 'especially', 'et', 'etc', 'even', 'ever', 'every', 'everybody', 'everyone', 'everything', 'everywhere', 'ex', 'exactly', 'example', 'except', 'f', 'far', 'few', 'fifth', 'first', 'five', 'followed', 'following', 'follows', 'for', 'former', 'formerly', 'forth', 'four', 'from', 'further', 'furthermore', 'g', 'get', 'gets', 'getting', 'given', 'gives', 'go', 'goes', 'going', 'gone', 'got', 'gotten', 'greetings', 'h', 'had', 'hadnt', 'happens', 'hardly', 'has', 'hasnt', 'have', 'havent', 'having', 'he', 'hello', 'help', 'hence', 'her', 'here', 'heres', 'hereafter', 'hereby', 'herein', 'hereupon', 'hers', 'herself', 'hes', 'hi', 'him', 'himself', 'his', 'hither', 'hopefully', 'how', 'howbeit', 'however', 'i', 'id', 'ie', 'if', 'ignored', 'ill', 'im', 'immediate', 'in', 'inasmuch', 'inc', 'indeed', 'indicate', 'indicated', 'indicates', 'inner', 'insofar', 'instead', 'into', 'inward', 'is', 'isnt', 'ist', 'it', 'itd', 'itll', 'its', 'itself', 'ive', 'j', 'just', 'k', 'keep', 'keeps', 'kept', 'know', 'knows', 'known', 'l', 'last', 'lately', 'later', 'latter', 'latterly', 'least', 'less', 'lest', 'let', 'lets', 'like', 'liked', 'likely', 'little', 'look', 'looking', 'looks', 'ltd', 'm', 'mainly', 'many', 'may', 'maybe', 'me', 'mean', 'meanwhile', 'merely', 'might', 'more', 'moreover', 'most', 'mostly', 'much', 'must', 'my', 'myself', 'n', 'name', 'namely', 'nd', 'near', 'nearly', 'necessary', 'need', 'needs', 'neither', 'never', 'nevertheless', 'new', 'next', 'nine', 'no', 'nobody', 'non', 'none', 'noone', 'nor', 'normally', 'not', 'nothing', 'novel', 'now', 'nowhere', 'o', 'obviously', 'of', 'off', 'often', 'oh', 'ok', 'okay', 'old', 'on', 'once', 'one', 'ones', 'only', 'onto', 'or', 'originally', 'other', 'others', 'otherwise', 'ought', 'our', 'ours', 'ourselves', 'out', 'outside', 'over', 'overall', 'own', 'p', 'particular', 'particularly', 'per', 'perhaps', 'placed', 'please', 'plus', 'possible', 'posted', 'presumably', 'probably', 'provides', 'q', 'que', 'quite', 'quote', 'qv', 'r', 'rather', 'rd', 're', 'really', 'reasonably', 'regarding', 'regardless', 'regards', 'relatively', 'respectively', 'right', 's', 'said', 'same', 'saw', 'say', 'saying', 'says', 'second', 'secondly', 'see', 'seeing', 'seem', 'seemed', 'seeming', 'seems', 'seen', 'self', 'selves', 'sensible', 'sent', 'seriously', 'seven', 'several', 'shall', 'she', 'should', 'shouldnt', 'since', 'six', 'so', 'some', 'somebody', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhat', 'somewhere', 'soon', 'sorry', 'specified', 'specify', 'specifying', 'still', 'sub', 'such', 'sup', 'sure', 't', 'take', 'taken', 'tell', 'tends', 'th', 'than', 'thank', 'thanks', 'thanx', 'that', 'thats', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'thence', 'there', 'theres', 'thereafter', 'thereby', 'therefore', 'therein', 'theres', 'thereupon', 'these', 'they', 'theyd', 'theyll', 'theyre', 'theyve', 'think', 'third', 'this', 'thorough', 'thoroughly', 'those', 'though', 'three', 'through', 'throughout', 'thru', 'thus', 'to', 'together', 'too', 'took', 'toward', 'towards', 'tried', 'tries', 'truly', 'try', 'trying', 'ts', 'twice', 'two', 'u', 'un', 'under', 'unfortunately', 'unless', 'unlikely', 'until', 'unto', 'up', 'upon', 'us', 'use', 'used', 'useful', 'uses', 'using', 'usually', 'v', 'value', 'various', 'very', 'via', 'viz', 'vs', 'w', 'want', 'wants', 'was', 'wasnt', 'way', 'we', 'wed', 'welcome', 'well', 'went', 'were', 'weve', 'werent', 'what', 'whats', 'whatever', 'when', 'whence', 'whenever', 'where', 'whereafter', 'whereas', 'whereby', 'wherein', 'whereupon', 'wherever', 'wheres', 'whether', 'which', 'while', 'whither', 'who', 'whoever', 'whole', 'whom', 'whos', 'whose', 'why', 'will', 'willing', 'wish', 'with', 'within', 'without', 'wonder', 'wont', 'would', 'would', 'wouldnt', 'x', 'y', 'yes', 'yet', 'you', 'youd', 'youll', 'your', 'youre', 'yours', 'yourself', 'yourselves', 'youve', 'z', 'zero');
         // Legacy Hook 'search_stopwords' Removed //
         self::$badwords = $badwords;
     }
     return self::$badwords;
 }
Esempio n. 4
0
 /**
  * Generate a cache key for the first pass of getSearchResults. Build key based on:
  * usergroupids, infractiongroupids, search json, search sort order, search sort by,
  * moderated channels
  *
  * @param vB_Search_Criteria
  *
  * @staticvar array	$hashResult	Array to build hash from
  * @return string
  */
 public static function getTwoPassCacheKey(vB_Search_Criteria $criteria)
 {
     $cacheTTL = vB_Api_Search::getCacheTTL();
     if ($cacheTTL < 1) {
         return false;
     }
     $channelAccess = vB::getUserContext()->getAllChannelAccess();
     $currentUserId = vB::getCurrentSession()->get('userid');
     // Don't use cache if we have a GIT record
     if (!empty($channelAccess['member'])) {
         return false;
     }
     // Not 100% set on this but it seems adding further nodes to the result set
     // could introduce nodes that were grabbed based on nodes that might
     // end up removed on the second pass
     if ($criteria->get_post_processors()) {
         return false;
     }
     $json = $criteria->getJSON();
     //$json['disable_two_pass'] = true;
     if (!empty($json['disable_two_pass']) or !empty($json['my_following']) and !empty($currentUserId) or !empty($json[vB_Api_Search::FILTER_FOLLOW]) or !empty($json['private_messages_only']) or !empty($json['include_private_messages']) or !empty($json['date']) and $json['date'] == vB_Api_Search::FILTER_LASTVISIT or !empty($json['unread_only']) or !empty($json['author']) and !empty($json['exactname']) and ($json['author'] == 'myFriends' or $json['author'] == 'iFollow')) {
         return false;
     }
     // Don't cache for globally ignored users
     if (!empty($currentUserId)) {
         $globalignore = trim(vB::getDatastore()->getOption('globalignore'));
         if (!empty($globalignore)) {
             $blocked = preg_split('#\\s+#s', $globalignore, -1, PREG_SPLIT_NO_EMPTY);
             $bbuserkey = array_search($currentUserId, $blocked);
             if ($bbuserkey !== FALSE and $bbuserkey !== NULL) {
                 return false;
             }
         }
     }
     if (isset($json['ignored_words'])) {
         unset($json['ignored_words']);
     }
     if (isset($json['original_keywords'])) {
         unset($json['original_keywords']);
     }
     // Make sure ugids and ifids are in a consistent order
     $ugids = $ifids = $mod = '';
     $userinfo = vB_User::fetchUserinfo();
     if (!empty($userinfo['membergroupids']) and trim($userinfo['membergroupids']) != '' and $ugids = explode(',', str_replace(' ', '', $userinfo['membergroupids']))) {
         $ugids[] = $userinfo['usergroupid'];
         sort($ugids, SORT_NUMERIC);
         $ugids = array_unique($ugids, SORT_NUMERIC);
         $ugids = implode(',', $ugids);
     } else {
         $ugids = $userinfo['usergroupid'];
     }
     $ifid = !empty($userinfo['infractiongroupid']) ? intval($userinfo['infractiongroupid']) : 0;
     if (!empty($userinfo['infractiongroupids']) and trim($userinfo['infractiongroupids']) != '' and $ifids = explode(',', str_replace(' ', '', $userinfo['infractiongroupids']))) {
         if ($ifid) {
             $ifids[] = $ifid;
         }
         sort($ifids, SORT_NUMERIC);
         $ifids = array_unique($ifids, SORT_NUMERIC);
         $ifids = implode(',', $ifids);
     } else {
         if ($ifid) {
             $ifids = $ifid;
         }
     }
     if (!empty($channelAccess['canmoderate'])) {
         $mod = $channelAccess['canmoderate'];
         sort($mod, SORT_NUMERIC);
         $mod = array_unique($mod, SORT_NUMERIC);
         $mod = implode(',', $mod);
     }
     $hashResult = array('json' => $json, 'so' => $criteria->get_sort_field(), 'sb' => $criteria->get_sort_direction(), 'ul' => vB::getUserContext()->getUserLevel(), 'ug' => $ugids);
     if (!empty($ifids)) {
         $hashResult['if'] = $ifids;
     }
     if (!empty($mod)) {
         $hashResult['mod'] = $mod;
     }
     return 'getSearchResults_' . md5(serialize($hashResult));
 }