/** * Fetch the topic participants * * @access public * @param int Topic ID * @param boolean Load and parse member data (TRUE for yes, FALSE for no) * @return array Array of member data indexed by member ID */ public function fetchTopicParticipants($topicID, $parseThem = FALSE) { //----------------------------------------- // INIT //----------------------------------------- $memberData = array(); $remapData = array(); //----------------------------------------- // Grab 'em //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'message_topic_user_map', 'where' => 'map_topic_id=' . intval($topicID))); $this->DB->execute(); while ($row = $this->DB->fetch()) { $remapData[$row['map_user_id']] = $row; } if (!count($remapData)) { return array(); } /* Parse 'em? */ if ($parseThem === TRUE) { /* Grab member data */ $memberData = IPSMember::load(array_keys($remapData), 'all'); foreach ($memberData as $id => $data) { $data['_canBeBlocked'] = IPSMember::isIgnorable($data['member_group_id'], $data['mgroup_others']); $memberData[$id] = IPSMember::buildDisplayData($data, array('__all__' => 1)); $memberData[$id] = array_merge($memberData[$id], $remapData[$id]); } $remapData = $memberData; } return $remapData; }
/** * Build the in-memory information tiers * * @access protected * @return @e void */ protected function _buildTiers() { if (!count($this->_itemCache)) { //----------------------------------------- // See if there is a specialized function // for this first //----------------------------------------- if (method_exists($this, $this->_customBuildMethod)) { $method = $this->_customBuildMethod; $this->{$method}(); return; } //----------------------------------------- // Get pages from db //----------------------------------------- $this->_sqlOrder = $this->_sqlOrder ? $this->_sqlOrder : $this->_sqlTitle; $this->DB->build(array('select' => $this->_sqlSelect, 'where' => $this->_sqlWhere, 'from' => $this->_sqlTable, 'order' => $this->_sqlOrder)); $this->DB->execute(); while ($item = $this->DB->fetch()) { if ($item[$this->_sqlParentID] < 1) { $item[$this->_sqlParentID] = 'root'; } $this->_itemCache[$item[$this->_sqlParentID]][$item[$this->_sqlPrimaryID]] = $item; $this->_itemByID[$item[$this->_sqlPrimaryID]] = $item[$this->_sqlParentID]; } } }
/** * This function grabs the actual results for display * * @param array $ids * @return query result **/ public function getResultsForSphinx($ids) { if (ipsRegistry::$request['content_title_only'] == 1) { $this->DB->build(array('select' => "t.*", 'from' => array('topics' => 't'), 'where' => 't.tid IN( ' . implode(',', $ids) . ')', 'order' => 't.last_post DESC', 'add_join' => array(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => 'p.pid=t.topic_firstpost', 'type' => 'left'), array('from' => array('forums' => 'f'), 'where' => 'f.id=t.forum_id', 'type' => 'left'), array('select' => 'm.member_id, m.members_display_name, m.members_seo_name', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left')))); } else { $this->DB->build(array('select' => "p.*", 'from' => array('posts' => 'p'), 'where' => 'p.pid IN( ' . implode(',', $ids) . ')', 'order' => 'p.post_date DESC', 'add_join' => array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'), array('from' => array('forums' => 'f'), 'where' => 'f.id=t.forum_id', 'type' => 'left'), array('select' => 'm.member_id, m.members_display_name, m.members_seo_name', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left')))); } return $this->DB->execute(); }
/** * Builds query based on the current query elements established * * @param string $type The type of query to build * @return string * @since 2.0.0 **/ private function buildQuery($type = 'select') { $pieces = array(); // Loop through query elements foreach ($this->{$type} as $piece) { // If we have one of these elements, get its string value if ($element = $this->syntax->build($piece)) { $pieces[] = $element; } } return implode("\n", $pieces); }
/** * Returns the total number of results the search will return * * @access public * @param string $search_term Search term * @param string $group_by Column to group by * @param bool $content_title_only Only search title records * @return integer */ public function getSearchCount($search_term, $group_by = '', $content_title_only = false) { /* Query the count */ $this->DB->build($this->_buildSearchQueryArray($search_term, array(), '', $group_by, true, $content_title_only)); $this->DB->execute(); /* Return the count */ if ($group_by) { return $this->DB->getTotalRows(); } else { $r = $this->DB->fetch(); return $r['total_results']; } }
/** * Process links data * * Array will be $key => array( log_data_app =>, log_data_type =>, log_data_primary_id =>, ) * * MUST be returned: * $key => array( 'title' => 'My Great Topic', * 'url' => URL, SEO where appropriate, * 'published' => unix time stamp, * 'icon' => icon relative to /style_images/master (16x16 icon) * * @param array * @return array */ public function processData($array) { $topics = array(); $final = array(); $return = array(); /* Ensure forums class is loaded */ if (!$this->registry->isClassLoaded('class_forums')) { try { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums'); $this->registry->setClass('class_forums', new $classToLoad($this->registry)); $this->registry->getClass('class_forums')->strip_invisible = 1; $this->registry->getClass('class_forums')->forumsInit(); } catch (Exception $error) { IPS_exception_error($error); } } /* Here we go again */ if (is_array($array) and count($array)) { foreach ($array as $key => $data) { if ($data['log_data_type'] == 'topic') { $topics[] = intval($data['log_data_primary_id']); } } if (count($topics)) { $this->DB->build(array('select' => 'tid, title, title_seo, start_date, forum_id', 'from' => 'topics', 'where' => 'tid IN (' . implode(',', $topics) . ')')); $this->DB->execute(); while ($row = $this->DB->fetch()) { /* Quick permission check */ if (!$this->registry->getClass('class_forums')->forumsCheckAccess($row['forum_id'], 0, 'forum', $row, true)) { $url = $this->registry->output->buildUrl('showtopic=' . $row['tid'], 'publicNoSession'); $title = 'Protected Topic'; } else { $url = $this->registry->output->buildSEOUrl('showtopic=' . $row['tid'], 'publicNoSession', $row['title_seo'], 'showtopic'); $title = $row['title']; } $final[$row['tid']] = array('title' => $title, 'url' => $url, 'published' => $row['start_date'], 'icon' => 'page_topic.png'); } } /* Sigh */ if (is_array($final)) { foreach ($array as $key => $data) { $return[$key] = isset($final[$data['log_data_primary_id']]) ? $final[$data['log_data_primary_id']] : array(); } return $return; } return array(); } return array(); }
/** * Recaches member's friends * * @access public * @param array $member Member array to recache * @return boolean */ public function recacheFriends($member) { /* INIT */ $friends = array(); /* Check the member id */ if (!$member['member_id']) { return FALSE; } /* Get our friends */ $this->DB->build(array('select' => '*', 'from' => 'profile_friends', 'where' => 'friends_member_id=' . $member['member_id'])); $this->DB->execute(); while ($row = $this->DB->fetch()) { $friends[$row['friends_friend_id']] = $row['friends_approved']; } /* Update the cache */ IPSMember::packMemberCache($member['member_id'], array('friends' => $friends)); return TRUE; }
/** * Build the in-memory information tiers * * @access private * @return void */ private function _buildTiers() { if (!count($this->_itemCache)) { //----------------------------------------- // Get pages from db //----------------------------------------- $this->_sqlOrder = $this->_sqlOrder ? $this->_sqlOrder : $this->_sqlTitle; $this->DB->build(array('select' => '*', 'where' => $this->_sqlWhere, 'from' => $this->_sqlTable, 'order' => $this->_sqlOrder)); $this->DB->execute(); while ($item = $this->DB->fetch()) { if ($item[$this->_sqlParentID] < 1) { $item[$this->_sqlParentID] = 'root'; } $this->_itemCache[$item[$this->_sqlParentID]][$item[$this->_sqlPrimaryID]] = $item; $this->_itemByID[$item[$this->_sqlPrimaryID]] = $item[$this->_sqlParentID]; } } }
/** * Add a widget to the dashboard. * * If a widget with the same $widgetIdent already exists, it will be overridden. * * @param string $widgetIdent The widget identifier. * @param UiItemInterface|array $widget The widget object or structure. * @throws InvalidArgumentException If the widget is invalid. * @return DashboardInterface Chainable */ public function addWidget($widgetIdent, $widget) { if (!is_string($widgetIdent)) { throw new InvalidArgumentException('Widget identifier needs to be a string'); } if ($widget instanceof UiItemInterface) { $this->widgets[$widgetIdent] = $widget; } elseif (is_array($widget)) { if (!isset($widget['ident'])) { $widget['ident'] = $widgetIdent; } $w = $this->widgetBuilder->build($widget); $this->widgets[$widgetIdent] = $w; } else { throw new InvalidArgumentException('Can not add widget: Invalid Widget.'); } return $this; }
/** * Builds comments * * @access public * @param array Member information * @param boolean Use a new id * @param string Message to display * @return string Comment HTML * @since IPB 2.2.0.2006-08-02 */ public function buildComments($member, $new_id = 0, $return_msg = '') { //----------------------------------------- // INIT //----------------------------------------- $comments = array(); $member_id = intval($member['member_id']); $comment_perpage = 15; //intval( $member['pp_setting_count_comments'] ); $comment_html = 0; $comment_start = intval($this->request['st']); $comment_approved = ($this->memberData['member_id'] == $member['member_id'] or $this->memberData['g_is_supmod']) ? '' : ' AND ( pc.comment_approved=1 OR ( pc.comment_approved=0 AND pc.comment_by_member_id=' . $member_id . ') )'; //----------------------------------------- // Not showing comments? //----------------------------------------- if ($comment_perpage < 1) { return ''; } //----------------------------------------- // Regenerate comments... //----------------------------------------- $this->DB->build(array('select' => 'pc.*', 'from' => array('profile_comments' => 'pc'), 'where' => 'pc.comment_for_member_id=' . $member_id . $comment_approved, 'order' => 'pc.comment_date DESC', 'limit' => array($comment_start, $comment_perpage), 'calcRows' => TRUE, 'add_join' => array(array('select' => 'm.members_display_name, m.members_seo_name, m.posts, m.last_activity, m.member_group_id, m.member_id, m.last_visit, m.warn_level', 'from' => array('members' => 'm'), 'where' => 'm.member_id=pc.comment_by_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left')))); $o = $this->DB->execute(); $max = $this->DB->fetchCalculatedRows(); while ($row = $this->DB->fetch($o)) { $row['_comment_date'] = ipsRegistry::getClass('class_localization')->getDate($row['comment_date'], 'TINY'); $row = IPSMember::buildDisplayData($row); if (!$row['members_display_name_short']) { $row = array_merge($row, IPSMember::setUpGuest()); } $comments[] = $row; } //----------------------------------------- // Pagination //----------------------------------------- $links = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $comment_perpage, 'currentStartValue' => $comment_start, 'baseUrl' => "showuser={$member_id}", 'seoTitle' => $member['members_seo_name'])); $comment_html = $this->registry->getClass('output')->getTemplate('profile')->showComments($member, $comments, $new_id, $return_msg, $links); //----------------------------------------- // Return it... //----------------------------------------- return $comment_html; }
/** * Initializes cache, loads kernel class, and formats data for kernel class * * @param string $type Set to view for displaying the field normally or edit for displaying in a form * @param bool $mlist Whether this is the memberlist or not * @return @e void */ public function initData($type = 'view', $mlist = 0, $attributes = array()) { /* Store Type */ $this->type = $type; /* Get Member */ if (!count($this->member_data) and $this->mem_data_id && !$mlist) { $this->member_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'pfields_content', 'where' => 'member_id=' . intval($this->mem_data_id))); } if (count($this->member_data)) { $this->mem_data_id = isset($this->member_data['member_id']) ? $this->member_data['member_id'] : 0; } if (!$this->init) { /* Cache data... */ if (!is_array($this->cache_data)) { $this->DB->build(array('select' => '*', 'from' => 'pfields_data', 'order' => 'pf_group_id,pf_position')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $this->cache_data[$r['pf_id']] = $r; } } } /* Get names... */ if (is_array($this->cache_data) and count($this->cache_data)) { foreach ($this->cache_data as $id => $data) { /* Field names and descriptions */ $this->field_names[$id] = $data['pf_title']; $this->field_desc[$id] = $data['pf_desc']; /* In Fields */ foreach ($this->cache_data as $id => $data) { $data['pf_key'] = !empty($data['pf_key']) ? $data['pf_key'] : '_key_' . $data['pf_id']; $data['pf_group_key'] = $data['pf_group_key'] ? $data['pf_group_key'] : '_other'; if ($mlist) { $this->in_fields[$id] = ''; if (!empty(ipsRegistry::$request['field_' . $id])) { if (is_string(ipsRegistry::$request['field_' . $id])) { $this->in_fields[$id] = urldecode(ipsRegistry::$request['field_' . $id]); } else { if (is_array(ipsRegistry::$request['field_' . $id])) { foreach (ipsRegistry::$request['field_' . $id] as $k => $v) { $this->in_fields[$id][$k] = urldecode($v); } } } } } else { $_val = ''; if (is_string(ipsRegistry::$request['field_' . $id])) { $_val = urldecode(ipsRegistry::$request['field_' . $id]); } else { if (is_array(ipsRegistry::$request['field_' . $id])) { foreach (ipsRegistry::$request['field_' . $id] as $k => $v) { $_val[$k] = urldecode($v); } } } $this->in_fields[$id] = isset($this->member_data['field_' . $id]) ? $this->member_data['field_' . $id] : $_val; } } } } /* Clean up on aisle #4 */ $this->out_fields = array(); $this->out_chosen = array(); /* Format data for kernel class */ foreach ($this->cache_data as $k => $v) { /* Add any option to dropdown */ if ($v['pf_type'] == 'drop' && $mlist) { $v['pf_content'] = '0=|' . $v['pf_content']; } /* Field Info */ $this->cache_data[$k]['id'] = $v['pf_id']; $this->cache_data[$k]['type'] = $v['pf_type']; $this->cache_data[$k]['data'] = $v['pf_content']; $this->cache_data[$k]['value'] = $this->in_fields[$k]; /* Field Restrictions */ $this->cache_data[$k]['restrictions'] = array('max_size' => isset($v['pf_max_input']) ? $v['pf_max_input'] : '', 'min_size' => isset($v['pf_min_input']) ? $v['pf_min_input'] : '', 'not_null' => isset($v['pf_not_null']) ? $v['pf_not_null'] : '', 'format' => isset($v['pf_input_format']) ? $v['pf_input_format'] : '', 'urlfilter' => isset($v['pf_filtering']) ? $v['pf_filtering'] : ''); if (!empty($attributes)) { if (!isset($this->cache_data[$k]['attributes'])) { $this->cache_data[$k]['attributes'] = $attributes; } else { $this->cache_data[$k]['attributes'] = array_merge($this->cache_data[$k]['attributes'], $attributes); } } } /* Kernel profile field class */ $_NOW = IPSDebug::getMemoryDebugFlag(); $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classCustomFields.php', 'classCustomFields'); IPSDebug::setMemoryDebugFlag("Get CustomFields Kernel Class", $_NOW); $this->cfields_obj = new $classToLoad($this->cache_data, $type, $attributes); $this->cfields = $this->cfields_obj->cfields; $this->init = 1; }
/** * Build the children * * @param array $sDates array containing Calendar objects to select (optional) * * @return boolean * @access public * @abstract */ function build($sDates = array()) { $this->calendar->build($sDates); }
/** * Processes the source code tokens * * Gets all the source code tokens. Determines the source code EOL. * Determines the file PHP version. Initializes the Page-level tags. * Parses the file tokens and creates their DocBlocks. * Re-assembles all the tokens with their DocBlocks. * * @param string $data the source code * @param array $param the tags/parameters values * @return boolean true on success, false on failure * @access public */ public function process($data, $param) { // get all the tokens if ($result = $this->getAll($data)) { // determines the source code EOL $this->getEOL($data); // extracts all the tokens $allTokens = $this->slice(); // initializes the Page-level tags $this->block->init($param); $this->hasBlock = 0; $this->id = array(); $this->inClass = null; $inFunct = null; $openTagID = null; $isPageBlock = false; foreach ($this->tokens as $id => $token) { $value = $token['value']; switch ($type = $token['type']) { case '{': // class or function opening curly brace // note: none matching open and close curly braces will cause issues // class or function opening curly brace // note: none matching open and close curly braces will cause issues case T_CURLY_OPEN: case T_DOLLAR_OPEN_CURLY_BRACES: // ${ // counting braces within the function, and the class is_null($inFunct) or $inFunct++; is_null($this->inClass) or $this->inClass++; break; case '}': // class or function closing curly brace // reached end of the function or class is_null($inFunct) or --$inFunct or $inFunct = null; is_null($this->inClass) or --$this->inClass or $this->inClass = null; break; case T_CLASS: // class classes and objects $this->inClass = 0; $this->block->setClass($id); break; case T_CONST: // const // sets the const DocBlock is_null($this->inClass) or $this->block->setConst($id); break; case T_CONSTANT_ENCAPSED_STRING: // "foo" or 'bar' string syntax // sets the include DocBlock isset($this->id[T_INCLUDE]) and $this->block->build($this->id[T_INCLUDE]); break; case T_DOC_COMMENT: // /** */ PHPDoc style comments (PHP 5 only) // spots the page block, realigns the DocBlock tags $this->hasBlock = true; $isPageBlock or $isPageBlock = strpos($value, '@package') !== false; $this->block->realign($id, $value); break; case T_FUNCTION: // function or cfunction functions $inFunct = 0; $this->block->setFunction($id); // sets function DocBlock break; case T_INCLUDE: // include() include() // include() include() case T_INCLUDE_ONCE: // include_once() include_once() // include_once() include_once() case T_REQUIRE: // require() require() // require() require() case T_REQUIRE_ONCE: // require_once() require_once() $type = T_INCLUDE; case T_GLOBAL: // global variable scope // only capturing includes and globals outside of classes and functions is_null($this->inClass) and is_null($inFunct) and $this->id[$type] = $id; break; case T_OPEN_TAG: // <?php, <? or <% $openTagID = $id; break; case T_PRIVATE: // private classes and objects. PHP 5 only. // private classes and objects. PHP 5 only. case T_PROTECTED: // protected classes and objects. PHP 5 only. // protected classes and objects. PHP 5 only. case T_PUBLIC: // public classes and objects. PHP 5 only. // captures the class visibilty is_null($this->inClass) or $this->id['access'] = array($id, $value); break; case T_STATIC: // static variable scope if (!is_null($this->inClass) and is_null($inFunct)) { // captures the static property within a class and outside of a function // defaults the access to public isset($this->id['access']) or $this->id['access'] = array($id, 'public'); // captures the static property inside a class and outside of a function $this->id[$type] = $id; } break; case T_VAR: // var classes and objects // captures the class property is_null($this->inClass) or $this->id[$type] = $id; break; case T_STRING: // sets define DocBlock $value == 'define' and $this->block->setDefine($id); break; case T_VARIABLE: // $foo variables if (isset($this->id[T_INCLUDE])) { // including a variable instead of a string, sets the include DocBlock $this->block->build($this->id[T_INCLUDE]); } else { if (isset($this->id[T_GLOBAL])) { // a global variable, sets the global DocBlock, e.g. global $var $this->block->setGlobal($this->id[T_GLOBAL], $token, $allTokens); } else { if (is_null($this->inClass) and is_null($inFunct) and $value == '$GLOBALS') { // a GLOBALS variable outside of a class and function // sets the global variable DocBlock, e.g. $GLOBALS['foo'] $this->block->setGLOBALS($id, $allTokens); } else { if (isset($this->id['access']) or isset($this->id[T_VAR])) { // a class property, sets the class variable $this->block->setVar($token); } } } } break; } } if (!$isPageBlock) { // no Page-level DocBlock, determines the PHP version, sets the Page-level DocBlock $info = $this->info->parseString($data); list($this->phpVersion) = explode('.', $info['version']); $this->block->setPage($openTagID); } // re-assembles all the tokens $result = $this->putAll(); } return $result; }
/** * Kill sessions * * @access protected * @param string Any extra WHERE stuff * @return void */ protected function _destroySessions($where = '') { $where .= $where ? ' OR ' : ''; $where .= 'running_time < ' . (IPS_UNIX_TIME_NOW - $this->settings['session_expiration']); //----------------------------------------- // Grab session data to delete on destruct //----------------------------------------- if ($this->_deleteNow) { $this->DB->delete('sessions', $where); } else { $this->DB->build(array('select' => '*', 'from' => 'sessions', 'where' => $where)); $this->DB->execute(); while ($row = $this->DB->fetch()) { $this->_sessionsToKill[$row['id']] = $row; } IPSDebug::addLogMessage("_destroySessions: {$where}", 'sessions-' . $this->_memberData['member_id']); } }
/** * This function grabs the actual results for display * * @param array $ids * @return query result **/ public function getResultsForSphinx($ids) { $this->DB->build(array('select' => "*", 'from' => 'ccs_pages', 'where' => 'page_id IN(' . implode(',', $ids) . ')', 'order' => "page_last_edited DESC")); return $this->DB->execute(); }
/** * This function grabs the actual results for display * * @param array $ids * @return query result **/ public function getResultsForSphinx($ids) { $this->DB->build(array('select' => "h.*", 'from' => array('faq' => 'h'), 'where' => 'h.id IN( ' . implode(',', $ids) . ')', 'add_join' => array(array('select' => 'i.*', 'from' => array('permission_index' => 'i'), 'where' => "i.perm_type='help' AND i.perm_type_id=1", 'type' => 'left')))); return $this->DB->execute(); }
/** * 数据查询操作 * @param object $query 查询query对象 * @return array 数据数组 */ public function findAll($query) { $this->url = ApiCloudDb::API_CLOUD_URL . '/mcm/api/' . $query->getForm(); $filter = $query->build(); if ($filter) { $this->url .= '?filter=' . json_encode($filter); } $this->method = 'GET'; $res = $this->execute(); if ($res && ($data = json_decode($res, true))) { return $data; } return null; }
/** * Initialize class * * @access public * @return void */ public function init() { //----------------------------------------- // INIT //----------------------------------------- require_once IPS_PATH_CUSTOM_LOGIN . '/login_core.php'; require_once IPS_PATH_CUSTOM_LOGIN . '/login_interface.php'; $classes = array(); $configs = array(); $methods = array(); //----------------------------------------- // Do we have cache? //----------------------------------------- $cache = $this->registry->cache()->getCache('login_methods'); if (is_array($cache) and count($cache)) { foreach ($cache as $login_method) { if ($login_method['login_enabled']) { if (file_exists(IPS_PATH_CUSTOM_LOGIN . '/' . $login_method['login_folder_name'] . '/auth.php')) { $classes[$login_method['login_order']] = IPS_PATH_CUSTOM_LOGIN . '/' . $login_method['login_folder_name'] . '/auth.php'; $configs[$login_method['login_order']] = IPS_PATH_CUSTOM_LOGIN . '/' . $login_method['login_folder_name'] . '/conf.php'; $this->login_methods[$login_method['login_order']] = $login_method; $this->login_confs[$login_method['login_order']] = array(); if (file_exists($configs[$login_method['login_order']])) { $LOGIN_CONF = array(); require $configs[$login_method['login_order']]; $this->login_confs[$login_method['login_order']] = $LOGIN_CONF; } $classname = "login_" . $login_method['login_folder_name']; require_once $classes[$login_method['login_order']]; $this->modules[$login_method['login_order']] = new $classname($this->registry, $login_method, $this->login_confs[$login_method['login_order']]); } } } } else { $this->DB->build(array('select' => '*', 'from' => 'login_methods', 'where' => 'login_enabled=1')); $this->DB->execute(); while ($login_method = $this->DB->fetch()) { if (file_exists(IPS_PATH_CUSTOM_LOGIN . '/' . $login_method['login_folder_name'] . '/auth.php')) { $classes[$login_method['login_order']] = IPS_PATH_CUSTOM_LOGIN . '/' . $login_method['login_folder_name'] . '/auth.php'; $configs[$login_method['login_order']] = IPS_PATH_CUSTOM_LOGIN . '/' . $login_method['login_folder_name'] . '/conf.php'; $this->login_methods[$login_method['login_order']] = $login_method; if (file_exists($configs[$login_method['login_order']])) { $LOGIN_CONF = array(); require $configs[$login_method['login_order']]; $this->login_confs[$login_method['login_order']] = $LOGIN_CONF; } $classname = "login_" . $login_method['login_folder_name']; require_once $classes[$login_method['login_order']]; $this->modules[$login_method['login_order']] = new $classname($this->registry, $login_method, $this->login_confs[$login_method['login_order']]); } } } //----------------------------------------- // Got nothing? //----------------------------------------- if (!count($classes)) { $login_method = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'login_methods', 'where' => "login_folder_name='internal'")); if ($login_method['login_id']) { $classes[0] = IPS_PATH_CUSTOM_LOGIN . '/internal/auth.php'; $this->login_methods[0] = $login_method; $this->login_confs[0] = array(); $classname = "login_internal"; require_once $classes[0]; $this->modules[0] = new $classname($this->registry, $login_method, array()); } } //----------------------------------------- // If we're here, there is no enabled login // handler and internal was deleted //----------------------------------------- if (!count($this->modules)) { $this->registry->output->showError($this->lang->words['no_login_methods'], 4000); } //----------------------------------------- // Pass of some data //----------------------------------------- foreach ($this->modules as $k => $obj_reference) { $obj_reference->is_admin_auth = $this->is_admin_auth; $obj_reference->login_method = $this->login_methods[$k]; $obj_reference->login_conf = $this->login_confs[$k]; } }
/** * Build a RSS import query * * @access public * @param mixed False on error/no entries, or an array of imported entries */ public function build($data) { /* Reset stuff */ $this->_imported = array(); $this->__usedGuids = array(); $this->__pointer = 0; $this->__map = array(); $this->errors = array(); /* Prep vars */ $final_guids = array(); $final_items = array(); if (isset($data['title'])) { $this->_titleMatch = $data['title']; } if (isset($data['content'])) { $this->_contentMatch = $data['content']; } if (isset($data['limit'])) { $this->_limit = intval($data['limit']); } /* Ensure we got stuff */ if (!$this->_limit) { $this->_limit = 50; } /* Loop through the channels */ foreach ($this->_rssClass->rss_channels as $channel_id => $channel_data) { if (is_array($this->_rssClass->rss_items[$channel_id]) and count($this->_rssClass->rss_items[$channel_id])) { /* Loop through the items in this channel */ foreach ($this->_rssClass->rss_items[$channel_id] as $item_data) { /* Item Data */ $item_data['content'] = $item_data['content'] ? $item_data['content'] : $item_data['description']; $item_data['guid'] = md5($this->_key . ($item_data['guid'] ? $item_data['guid'] : preg_replace("#\\s|\r|\n#is", "", $item_data['title'] . $item_data['link'] . $item_data['description']))); $item_data['unixdate'] = intval($item_data['unixdate']) ? intval($item_data['unixdate']) : time(); /* Convert char set? */ if ($this->_rssClass->orig_doc_type != $this->_rssClass->doc_type) { $item_data['title'] = IPSText::convertCharsets($item_data['title'], "UTF-8", IPS_DOC_CHAR_SET); $item_data['content'] = IPSText::convertCharsets($item_data['content'], "UTF-8", IPS_DOC_CHAR_SET); } /* Dates */ if ($item_data['unixdate'] < 1 or $item_data['unixdate'] > time()) { $item_data['unixdate'] = time(); } /* Error check */ if (!$item_data['title'] or !$item_data['content']) { $this->errors[] = $this->registry->getClass('class_localization')->words['_rssimportnotoc']; continue; } /* Content check? */ if ($this->_contentMatch) { if (!stristr($item_data['content'], $this->_contentMatch)) { continue; } } /* Title check? */ if ($this->_titleMatch) { if (!stristr($item_data['title'], $this->_titleMatch)) { continue; } } /* Add to array */ $items[$item_data['guid']] = $item_data; $check_guids[] = $item_data['guid']; } } } /* Check GUIDs */ if (!count($check_guids)) { $rss_error[] = $this->lang->words['im_noitems']; return false; } $this->DB->build(array('select' => 'rss_guid', 'from' => 'core_rss_imported', 'where' => "rss_foreign_key='" . $this->_key . "' AND rss_guid IN ('" . implode("','", $check_guids) . "')")); $i = $this->DB->execute(); while ($guid = $this->DB->fetch($i)) { $final_guids[$guid['rss_guid']] = $guid['rss_guid']; } /* Compare GUIDs */ $item_count = 0; foreach ($items as $guid => $data) { if (in_array($guid, $final_guids)) { continue; } else { $item_count++; /* Make sure each item has a unique date */ $final_items[$data['unixdate'] . '.' . $item_count] = $data; } } /* Sort Array */ krsort($final_items); /* Pick off last X */ $count = 1; $tmp_final_items = $final_items; $final_items = array(); foreach ($tmp_final_items as $date => $data) { $this->_imported[$date] = $data; if ($count >= $this->_limit) { break; } } /* now sort it oldest first */ ksort($this->_imported); /* add in map */ foreach ($this->_imported as $date => $data) { $this->__map[$count - 1] = $date; $count++; } reset($this->_imported); }
/** * Does search * * @access private * @param string $search_term * @param array $limit_clause The erray should be array( begin, end ) * @param string $sort_by Either relevance or date * @param string [$group_by] Field to group on * @param bool [$count_only] Set to true for a count(*) query * @param bool [$content_title_only] Only search titles * @return array **/ private function _searchQuery($search_term, $limit_clause, $sort_by, $group_by = '', $count_only = false, $content_title_only = false) { /* Do we only need to count results? */ if (!$count_only) { if ($limit_clause[1]) { /* Limit Results */ $this->sphinxClient->SetLimits(intval($limit_clause[0]), intval($limit_clause[1])); } else { if ($limit_clause[0]) { $this->sphinxClient->SetLimits(0, intval($limit_clause[0])); } } /* Sort By */ if (isset($sort_by) && in_array($sort_by, array('date', 'relevance'))) { if ($sort_by == 'date') { if ($this->request['search_sort_order'] == 0) { $this->sphinxClient->SetSortMode(SPH_SORT_ATTR_DESC, $this->appSearchPlugin->getDateField()); } else { $this->sphinxClient->SetSortMode(SPH_SORT_ATTR_ASC, $this->appSearchPlugin->getDateField()); } } else { $this->sphinxClient->SetSortMode(SPH_SORT_RELEVANCE); } } else { $this->sphinxClient->SetSortMode(SPH_SORT_RELEVANCE); } } /* Exclude Apps */ if (count($this->exclude_apps)) { $app_id_exclude = array(); foreach ($this->exclude_apps as $app_dir) { $app_id_exclude[] = ipsRegistry::$applications[$app_dir]['app_id']; } $this->sphinxClient->SetFilter('app', $app_id_exclude, TRUE); } /* Permissions */ $perm_array = $this->member->perm_id_array; $perm_array[] = 0; /* Need to remove empty values... */ $final_perms = array(); foreach ($perm_array as $perm_id) { if (is_numeric($perm_id)) { $final_perms[] = $perm_id; } } $this->sphinxClient->SetFilter('perm_view', $final_perms); /* Exclude some items */ if (!$this->memberData['g_is_supmod']) { /* Owner only */ $this->sphinxClient->SetFilter('owner_only', array(0, $this->memberData['member_id'])); /* Friend only */ $this->DB->build(array('select' => 'friends_member_id', 'from' => 'profile_friends', 'where' => "friends_friend_id={$this->memberData['member_id']}")); $this->DB->execute(); $friends_ids = array(0); while ($r = $this->DB->fetch()) { $friends_ids[] = $r['friends_member_id']; } $this->sphinxClient->SetFilter('friend_only', $friends_ids); /* Authorized users only */ $this->sphinxClient->SetFilter('authorized_users', array(0, $this->memberData['member_id'])); } /* Loop through all the search plugins and let them modify the search query */ foreach (ipsRegistry::$applications as $app) { if (IPSSearchIndex::appisSearchable($app['app_directory'])) { if (!isset($this->display_plugins[$app['app_directory']]) || !$this->display_plugins[$app['app_directory']]) { require_once IPSLib::getAppDir($app['app_directory']) . '/extensions/searchDisplay.php'; $_class = $app['app_directory'] . 'SearchDisplay'; $this->display_plugins[$app['app_directory']] = new $_class(); } $this->display_plugins[$app['app_directory']]->search_plugin = $this->appSearchPlugin; if (method_exists($this->display_plugins[$app['app_directory']], 'modifySearchQuery')) { /* Get the modified query */ $this->display_plugins[$app['app_directory']]->modifySearchQuery($this->sphinxClient, $count_only); } } } $groupby = $this->request['show_as_titles'] ? true : false; /* Perform the search */ if (method_exists($this->display_plugins[$this->request['search_app']], 'runSearchQuery')) { $result = $this->display_plugins[$this->request['search_app']]->runSearchQuery($this->sphinxClient, $search_term, $groupby); } else { if ($groupby) { $this->sphinxClient->SetGroupBy('search_id', SPH_GROUPBY_ATTR, '@group DESC'); } $result = $this->sphinxClient->Query($search_term, $this->request['search_app'] . '_search_main,' . $this->request['search_app'] . '_search_delta'); } /* Return the total number of results */ if ($count_only) { return $result['total']; } else { $search_ids = array(); if (is_array($result['matches']) && count($result['matches'])) { foreach ($result['matches'] as $res) { $search_ids[] = $res['attrs']['search_id']; } } return $search_ids; } }
/** * This function grabs the actual results for display * * @param array $ids * @return query result **/ public function getResultsForSphinx($ids) { $this->DB->build(array('select' => "c.*", 'from' => array('cal_events' => 'c'), 'where' => 'c.event_id IN( ' . implode(',', $ids) . ')', 'order' => 'c.event_unix_from DESC', 'add_join' => array(array('select' => 'mem.members_display_name, mem.member_group_id, mem.mgroup_others', 'from' => array('members' => 'mem'), 'where' => "mem.member_id=c.event_member_id", 'type' => 'left')))); return $this->DB->execute(); }
/** * This function grabs the actual results for display * * @param array $ids * @return query result **/ public function getResultsForSphinx($ids) { $this->DB->build(array('select' => "m.*", 'from' => array('members' => 'm'), 'where' => 'm.member_id IN( ' . implode(',', $ids) . ')', 'order' => 'm.member_id DESC', 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => "p.pp_member_id=m.member_id", 'type' => 'left')))); return $this->DB->execute(); }