/**
  * Returns possible matches for the string input
  *
  * @return	@e void		Outputs to screen
  */
 protected function _getMembers()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $name = IPSText::convertUnicode($this->convertAndMakeSafe($this->request['name'], 0), true);
     $name = IPSText::convertCharsets($name, 'utf-8', IPS_DOC_CHAR_SET);
     //-----------------------------------------
     // Check length
     //-----------------------------------------
     if (IPSText::mbstrlen($name) < 3) {
         $this->returnJsonError('requestTooShort');
     }
     //-----------------------------------------
     // Try query...
     //-----------------------------------------
     $this->DB->build(array('select' => 'm.members_display_name, m.member_id, m.members_seo_name, m.member_group_id', 'from' => array('members' => 'm'), 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes(strtolower($name)) . "%'", 'order' => $this->DB->buildLength('m.members_display_name') . ' ASC', 'limit' => array(0, 15), 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'p.pp_member_id=m.member_id', 'type' => 'left'))));
     $this->DB->execute();
     //-----------------------------------------
     // Got any results?
     //-----------------------------------------
     if (!$this->DB->getTotalRows()) {
         $this->returnJsonArray(array());
     }
     $return = array();
     while ($r = $this->DB->fetch()) {
         $url = $this->registry->output->buildSEOUrl("app=core&amp;module=modcp&amp;do=editmember&amp;mid={$r['member_id']}", 'public');
         $photo = IPSMember::buildProfilePhoto($r);
         $group = IPSMember::makeNameFormatted('', $r['member_group_id']);
         $return[$r['member_id']] = array('name' => $r['members_display_name'], 'showas' => '<strong>' . $r['members_display_name'] . '</strong> (' . $group . ')', 'img' => $photo['pp_thumb_photo'], 'img_w' => $photo['pp_mini_width'], 'img_h' => $photo['pp_mini_height'], 'url' => $url);
     }
     $this->returnJsonArray($return);
 }
 /**
  * Formats the URL (.htaccess SEO, etc)
  *
  * @access	public
  * @param	string	Raw URL
  * @param	string	Any special SEO title passed
  * @param	string	Any special SEO template to use. If none is passed but SEO is enabled, IPB will search all templates for a match
  * @return	string	Formatted  URL
  */
 public function formatUrl($url, $seoTitle = '', $seoTemplate = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if (!ipsRegistry::$settings['use_friendly_urls']) {
         return $url;
     }
     $_template = FALSE;
     $seoTitle = !empty($seoTitle) && !is_array($seoTitle) ? array($seoTitle) : $seoTitle;
     $_seoTitleForCache = is_array($seoTitle) ? implode(';', $seoTitle) : '';
     $_md5 = md5($url . $_seoTitleForCache . $seoTemplate);
     $_s = '';
     $cached = $this->getCachedFurl($_md5);
     if (!is_null($cached)) {
         return $cached;
     }
     //-----------------------------------------
     // If using URL sessions, fix the URL...
     //-----------------------------------------
     if (!IN_ACP and strstr($url, 's=')) {
         preg_match("/s=([a-zA-Z0-9]{32})(.*?)\$/", $url, $matches);
         if (!empty($matches[2])) {
             $url = preg_replace("/s=([a-zA-Z0-9]{32})(&amp;|&)/", '', $url);
             $_s = $matches[1];
         }
         if (strstr($url, 's=0')) {
             $url = preg_replace("/(\\?|&|;)s=0(&amp;|&)/", '', $url);
             $_s = '';
         }
     }
     if ($this->settings['use_friendly_urls'] and is_array($seoTitle) && count($seoTitle)) {
         /* SEO Tweak - if default app is forums then don't bother with act=idx nonsense */
         if (IPS_DEFAULT_APP == 'forums' and !$this->settings['actidx_override']) {
             if (stristr($url, 'act=idx')) {
                 $url = str_ireplace(array(IPS_PUBLIC_SCRIPT . '?act=idx', '?act=idx', 'act=idx'), '', $url);
             }
         }
         if ($seoTemplate and isset($this->seoTemplates[$seoTemplate])) {
             $_template = $seoTemplate;
         }
         /* Need to search for one - fast? */
         if ($_template === FALSE) {
             /* Search for one, then. Possibly a bit slower than we'd like! */
             foreach ($this->seoTemplates as $key => $data) {
                 if (stristr(str_replace($this->settings['board_url'], '', $url), $key)) {
                     $_template = $key;
                     break;
                 }
             }
         }
         /* Got one to work with? */
         if ($_template !== FALSE) {
             if (count($seoTitle) == 1 && (substr($seoTitle[0], 0, 2) == '%%' and substr($seoTitle[0], -2) == '%%')) {
                 $seoTitle[0] = IPSText::makeSeoTitle(substr($seoTitle[0], 2, -2));
             }
             /* Do we need to encode? */
             if (IPS_DOC_CHAR_SET != 'UTF-8') {
                 foreach ($seoTitle as $id => $item) {
                     $seoTitle[$id] = urlencode($item);
                 }
             }
             if (count($seoTitle) == 1) {
                 $replace = str_replace('#{__title__}', IPSText::convertUnicode($seoTitle[0]), $this->seoTemplates[$_template]['out'][1]);
                 // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/transliteration-r37146
             } else {
                 $replace = $this->seoTemplates[$_template]['out'][1];
                 foreach ($seoTitle as $id => $item) {
                     $replace = str_replace('#{__title-' . $id . '__}', IPSText::convertUnicode($item), $replace);
                     // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/transliteration-r37146
                 }
             }
             $url = preg_replace($this->seoTemplates[$_template]['out'][0], $replace, $url);
             $_anchor = '';
             $__url = $url;
             /* Protect html entities */
             $url = preg_replace('/&#(\\d)/', "~|~\\1", $url);
             if (strstr($url, '&')) {
                 $restUrl = substr($url, strpos($url, '&'));
                 $url = substr($url, 0, strpos($url, '&'));
             } else {
                 $restUrl = '';
             }
             /* Anchor */
             if (strstr($restUrl, '#')) {
                 $_anchor = substr($restUrl, strpos($restUrl, '#'));
                 $restUrl = substr($restUrl, 0, strpos($restUrl, '#'));
             }
             switch ($this->settings['url_type']) {
                 case 'path_info':
                     if ($this->settings['htaccess_mod_rewrite']) {
                         $url = str_replace(IPS_PUBLIC_SCRIPT . '?', '', $url);
                     } else {
                         $url = str_replace(IPS_PUBLIC_SCRIPT . '?', IPS_PUBLIC_SCRIPT . '/', $url);
                     }
                     break;
                 default:
                 case 'query_string':
                     $url = str_replace(IPS_PUBLIC_SCRIPT . '?', IPS_PUBLIC_SCRIPT . '?/', $url);
                     break;
             }
             /* Ensure that if the seoTitle is missing there is no double slash */
             # http://localhost/invisionboard3/user/1//
             # http://localhost/invisionboard3/user/1/mattm/
             if (substr($url, -2) == '//') {
                 $url = substr($url, 0, -1);
             }
             /* Others... */
             if ($restUrl) {
                 $_url = str_replace('&amp;', '&', str_replace('?', '', $restUrl));
                 $_data = explode("&", $_url);
                 $_add = array();
                 $_page = '';
                 foreach ($_data as $k) {
                     if (strstr($k, '=')) {
                         list($kk, $vv) = explode('=', $k);
                         /* Catch page */
                         if ($this->seoTemplates[$_template]['isPagesMode'] && $kk == 'page') {
                             $_page .= $this->seoTemplates['__data__']['varPage'] . $vv;
                         } else {
                             if ($kk and $vv) {
                                 $_add[] = $kk . $this->seoTemplates['__data__']['varJoin'] . $vv;
                             }
                         }
                     }
                 }
                 /* Got anything to add?... */
                 if (count($_add) or $_page) {
                     if ($_page) {
                         if (strrpos($url, $this->seoTemplates['__data__']['end']) + strlen($this->seoTemplates['__data__']['end']) == strlen($url)) {
                             $url = substr($url, 0, -1);
                         }
                         $url .= $this->seoTemplates['__data__']['end'] . $_page;
                     }
                     if (count($_add)) {
                         $url .= $this->seoTemplates['__data__']['varBlock'] . implode($this->seoTemplates['__data__']['varSep'], $_add);
                     }
                 }
             }
             /* Session ID? */
             $this->_appendSession($url, $_s);
             /* anchor? */
             if ($_anchor) {
                 $url .= $_anchor;
             }
             /* Protect html entities */
             $url = str_replace('~|~', '&#', $url);
             $this->setCachedFurl($_md5, $url);
             return $url;
         } else {
             /* Session ID? */
             $this->_appendSession($url, $_s);
             $this->setCachedFurl($_md5, $url);
             return $url;
         }
     } else {
         /* Session ID? */
         $this->_appendSession($url, $_s);
         $this->setCachedFurl($_md5, $url);
         return $url;
     }
 }
Beispiel #3
0
 /**
  * Callback to convert unicode and charset for AJAX requests
  * 
  * @param	mixed		Value
  * @param	string		Key
  * @return	@e void
  */
 public function arrayWalkConvert(&$value, $key)
 {
     if (is_string($value)) {
         $value = IPSText::convertCharsets(IPSText::convertUnicode($value), "utf-8", IPS_DOC_CHAR_SET);
     }
 }