Returns the message headers as string

@param int    $uid  Message UID
@param string $part Optional message part ID

@return string Message headers string
969972
public function get_raw_headers($uid, $part = null)
    {
        if (!$this->check_connection()) {
            return null;
        }

        return $this->conn->fetchPartHeader($this->folder, $uid, true, $part);
    }
606980
public function getBody( $uid = '' )
	{
		$view = $this->getView();

		try
		{
			if( !isset( $this->view ) ) {
				$view = $this->view = $this->getObject()->addData( $view );
			}

			$html = '';
			foreach( $this->getSubClients() as $subclient ) {
				$html .= $subclient->setView( $view )->getBody( $uid );
			}
			$view->stockBody = $html;

			/** client/html/catalog/stock/standard/template-body
			 * Relative path to the HTML body template of the catalog stock client.
			 *
			 * The template file contains the HTML code and processing instructions
			 * to generate the result shown in the body of the frontend. The
			 * configuration string is the path to the template file relative
			 * to the templates directory (usually in client/html/templates).
			 *
			 * You can overwrite the template file configuration in extensions and
			 * provide alternative templates. These alternative templates should be
			 * named like the default one but with the string "standard" replaced by
			 * an unique name. You may use the name of your project for this. If
			 * you've implemented an alternative client class as well, "standard"
			 * should be replaced by the name of the new class.
			 *
			 * @param string Relative path to the template creating code for the HTML page body
			 * @since 2014.03
			 * @category Developer
			 * @see client/html/catalog/stock/standard/template-header
			 */
			$tplconf = 'client/html/catalog/stock/standard/template-body';
			$default = 'catalog/stock/body-standard';

			return $view->render( $view->config( $tplconf, $default ) );
		}
		catch( \Exception $e )
		{
			$this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
		}
	}
202691
protected function getUrlPartsFromMessage($requestUrl, array $parts)
    {
        // Parse the URL information from the message
        $urlParts = array(
            'path'   => $requestUrl,
            'scheme' => 'http'
        );

        // Check for the Host header
        if (isset($parts['headers']['Host'])) {
            $urlParts['host'] = $parts['headers']['Host'];
        } elseif (isset($parts['headers']['host'])) {
            $urlParts['host'] = $parts['headers']['host'];
        } else {
            $urlParts['host'] = null;
        }

        if (false === strpos($urlParts['host'], ':')) {
            $urlParts['port'] = '';
        } else {
            $hostParts = explode(':', $urlParts['host']);
            $urlParts['host'] = trim($hostParts[0]);
            $urlParts['port'] = (int) trim($hostParts[1]);
            if ($urlParts['port'] == 443) {
                $urlParts['scheme'] = 'https';
            }
        }

        // Check if a query is present
        $path = $urlParts['path'];
        $qpos = strpos($path, '?');
        if ($qpos) {
            $urlParts['query'] = substr($path, $qpos + 1);
            $urlParts['path'] = substr($path, 0, $qpos);
        } else {
            $urlParts['query'] = '';
        }

        return $urlParts;
    }
191644
public function getUidInfo($uid)
    {
        $fd = $this->getFdFromUid($uid);
        if (empty($fd)) {
            if (!$this->isCluster()) {
                return [];
            } else {
                $fdInfo = ProcessManager::getInstance()->getRpcCall(ClusterProcess::class)->my_getUidInfo($uid);

                return $fdInfo;
            }
        } else {
            $fdInfo = $this->getFdInfo($fd);
            $fdInfo['node'] = getNodeName();

            return $fdInfo;
        }
    }
308808
protected function getPartBodyFromText(&$part)
    {
        $start = $part['starting-pos-body'];
        $end = $part['ending-pos-body'];

        return substr($this->data, $start, $end - $start);
    }
920171
public function show($uid)
    {
        $options = $this->getParams('includes');

        $user = Subbly::api('subbly.user')->find($uid, $options);

        return $this->jsonResponse(array(
            'user' => $this->presenter->single($user),
        ));
    }
110137
public function getHeader( $uid = '' )
	{
		$view = $this->getView();

		try
		{
			if( !isset( $this->view ) ) {
				$view = $this->view = $this->getObject()->addData( $view, $this->tags, $this->expire );
			}

			$html = '';
			foreach( $this->getSubClients() as $subclient ) {
				$html .= $subclient->setView( $view )->getHeader( $uid );
			}
			$view->selectHeader = $html;

			/** client/html/locale/select/standard/template-header
			 * Relative path to the HTML header template of the locale select client.
			 *
			 * The template file contains the HTML code and processing instructions
			 * to generate the HTML code that is inserted into the HTML page header
			 * of the rendered page in the frontend. The configuration string is the
			 * path to the template file relative to the templates directory (usually
			 * in client/html/templates).
			 *
			 * You can overwrite the template file configuration in extensions and
			 * provide alternative templates. These alternative templates should be
			 * named like the default one but with the string "standard" replaced by
			 * an unique name. You may use the name of your project for this. If
			 * you've implemented an alternative client class as well, "standard"
			 * should be replaced by the name of the new class.
			 *
			 * @param string Relative path to the template creating code for the HTML page head
			 * @since 2014.09
			 * @category Developer
			 * @see client/html/locale/select/standard/template-body
			 */
			$tplconf = 'client/html/locale/select/standard/template-header';
			$default = 'locale/select/header-standard';

			return $view->render( $view->config( $tplconf, $default ) );
		}
		catch( \Exception $e )
		{
			$this->logException( $e );
		}
	}
920686
public static function getTagGroupByUid(string $uid): TagGroup
    {
        $query = TagGroup::find();
        $query->andWhere(['uid' => $uid]);
        return $query->one() ?? new TagGroup();
    }
220721
public function clientGetByUid($uid)
  {
    foreach($this->clientList() as $client)
    {
      if($client["client_unique_identifier"] == $uid) return $client;
    }

    throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
  }
162192
public function getUniqueEmails($uid, $body = false)
    {
        Argument::i()
            ->test(1, 'int', 'string', 'array')
            ->test(2, 'bool');

        //if not connected
        if (!$this->socket) {
            //then connect
            $this->connect();
        }

        //if the total in this mailbox is 0
        //it means they probably didn't select a mailbox
        //or the mailbox selected is empty
        if ($this->total == 0) {
            //we might as well return an empty array
            return array();
        }

        //if uid is an array
        if (is_array($uid)) {
            $uid = implode(',', $uid);
        }

        //lets call it
        $items = array('UID', 'FLAGS', 'BODY[HEADER]');

        if ($body) {
            $items = array('UID', 'FLAGS', 'BODY[]');
        }

        $first = is_numeric($uid) ? true : false;

        return $this->getEmailResponse('UID FETCH', array($uid, $this->getList($items)), $first);
    }
12943
public function getHeader( $uid = '' )
	{
		$context = $this->getContext();
		$site = $context->getLocale()->getSiteId();
		$view = $this->getView();

		$config = $context->getConfig()->get( 'client/html/basket/mini', [] );
		$key = $this->getParamHash( [], $uid . $site . ':basket:mini-header', $config );

		if( ( $html = $this->getBasketCached( $key ) ) === null )
		{
			try
			{
				if( !isset( $this->view ) ) {
					$view = $this->view = $this->getObject()->addData( $view );
				}

				$output = '';
				foreach( $this->getSubClients() as $subclient ) {
					$output .= $subclient->setView( $view )->getHeader( $uid );
				}
				$view->miniHeader = $output;

				/** client/html/basket/mini/standard/template-header
				 * Relative path to the HTML header template of the basket mini client.
				 *
				 * The template file contains the HTML code and processing instructions
				 * to generate the HTML code that is inserted into the HTML page header
				 * of the rendered page in the frontend. The configuration string is the
				 * path to the template file relative to the templates directory (usually
				 * in client/html/templates).
				 *
				 * You can overwrite the template file configuration in extensions and
				 * provide alternative templates. These alternative templates should be
				 * named like the default one but with the string "standard" replaced by
				 * an unique name. You may use the name of your project for this. If
				 * you've implemented an alternative client class as well, "standard"
				 * should be replaced by the name of the new class.
				 *
				 * @param string Relative path to the template creating code for the HTML page head
				 * @since 2014.03
				 * @category Developer
				 * @see client/html/basket/mini/standard/template-body
				 */
				$tplconf = 'client/html/basket/mini/standard/template-header';
				$default = 'basket/mini/header-standard';

				$html = $view->render( $view->config( $tplconf, $default ) );
				$this->setBasketCached( $key, $html );
			}
			catch( \Exception $e )
			{
				$this->logException( $e );
			}
		}
		else
		{
			$html = $this->modifyHeader( $html, $uid );
		}

		return $html;
	}
1374493
public function getQuoteMessage($qid, $tid)
    {
        $retVal = '';
        // fire hook
        $retVal = Container::get('hooks')->fire('model.post.begin_quote_message', $retVal, $qid, $tid);

        $quote = DB::forTable('posts')->select_many(['poster', 'message'])
                     ->where('id', $qid)
                     ->where('topic_id', $tid);
        $quote = Container::get('hooks')->fireDB('model.post.get_quote_message_query', $quote);
        $quote = $quote->find_one();

        if (!$quote) {
            throw new  RunBBException(__('Bad request'), 404);
        }

        // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched)
//        if (strpos($quote->message, '[code]') !== false && strpos($quote->message, '[/code]') !== false) {
//            list($inside, $outside) = split_text($quote->message, '[code]', '[/code]');
//
//            $quote->message = implode("\1", $outside);
//        }

        // Remove [img] tags from quoted message
        $quote->message = preg_replace(
            '%\[img(?:=(?:[^\[]*?))?\]((ht|f)tps?://)([^\s<"]*?)\[/img\]%U',
            '\1\3',
            $quote->message
        );

        // If we split up the message before we have to concatenate it together again (code tags)
//        if (isset($inside)) {
//            $outside = explode("\1", $quote->message);
//            $quote->message = '';
//
//            $num_tokens = count($outside);
//            for ($i = 0; $i < $num_tokens; ++$i) {
//                $quote->message .= $outside[$i];
//                if (isset($inside[$i])) {
//                    $quote->message .= '[code]'.$inside[$i].'[/code]';
//                }
//            }
//
//            unset($inside);
//        }

        if (ForumSettings::get('o_censoring') == '1') {
            $quote->message = Utils::censor($quote->message);
        }

        $quote->message = Utils::escape($quote->message);

        if (ForumSettings::get('p_message_bbcode') == '1') {    // Sanitize username for inclusion within QUOTE
            // BBCode attribute.
                //   This is a bit tricky because a username can have any "special"
                //   characters such as backslash \ square brackets [] and quotes '".
//                if (preg_match('/[[\]\'"]/S', $quote->poster)) {
//                    // Check if we need to quote it.
//                    // Post has special chars. Escape escapes and quotes then wrap in quotes.
//                    if (strpos($quote->poster, '"') !== false && strpos($quote->poster, '\'') === false)
//                    { // If there are double quotes but no single quotes, use single quotes,
//                        $quote->poster = Utils::escape(str_replace('\\', '\\\\', $quote->poster));
//                        $quote->poster = '\''. $quote->poster .'#'. $qid .'\'';
//                    } else { // otherwise use double quotes.
//                        $quote->poster = Utils::escape(str_replace(array('\\', '"'), array('\\\\', '\\"'),
//                            $quote->poster));
//                        $quote->poster = '"'. $quote->poster .'#'. $qid .'"';
//                    }
//                } else {
//                    $quote->poster = $quote->poster .'#'. $qid;
//                }
//            $retVal = '[quote='. $quote->poster .']'.$quote->message.'[/quote]'."\n";

            $retVal .= '> --- **'.$quote->poster.'** *['.__('wrote').']('.
                Router::pathFor('viewPost', ['pid' => $qid]).'#p'.$qid.')*'."\n";

            // ^ - beginning of a string. m - multiline.
            $retVal .= preg_replace('/^/m', '>', $quote->message);
        } else {
            $quote->message .= preg_replace('/^/m', '>', $quote->message);
            $retVal = '> --- '.$quote->poster.' '.__('wrote')."\n".$quote->message."\n";
        }

        $retVal = Container::get('hooks')->fire('model.post.finish_quote_message', $retVal);

        return $retVal;
    }
1121671
public function userIdToFid($uid) {
        $value = Cache::redis()->hGet('user_id_#_fid', $uid);
        Cache::release();
        return $value;
    }
455546
public function getBody( $uid = '' )
	{
		$view = $this->getView();

		$html = '';
		foreach( $this->getSubClients() as $subclient ) {
			$html .= $subclient->setView( $view )->getBody( $uid );
		}
		$view->itemsBody = $html;

		/** client/html/catalog/lists/items/standard/template-body
		 * Relative path to the HTML body template of the catalog list items client.
		 *
		 * The template file contains the HTML code and processing instructions
		 * to generate the result shown in the body of the frontend. The
		 * configuration string is the path to the template file relative
		 * to the templates directory (usually in client/html/templates).
		 *
		 * You can overwrite the template file configuration in extensions and
		 * provide alternative templates. These alternative templates should be
		 * named like the default one but with the string "standard" replaced by
		 * an unique name. You may use the name of your project for this. If
		 * you've implemented an alternative client class as well, "standard"
		 * should be replaced by the name of the new class.
		 *
		 * It's also possible to create a specific template for each type, e.g.
		 * for the grid, list or whatever view you want to offer your users. In
		 * that case, you can configure the template by adding "-<type>" to the
		 * configuration key. To configure an alternative list view template for
		 * example, use the key
		 *
		 * client/html/catalog/lists/items/standard/template-body-list = catalog/lists/items-body-list.php
		 *
		 * The argument is the relative path to the new template file. The type of
		 * the view is determined by the "l_type" parameter (allowed characters for
		 * the types are a-z and 0-9), which is also stored in the session so users
		 * will keep the view during their visit. The catalog list type subpart
		 * contains the template for switching between list types.
		 *
		 * @param string Relative path to the template creating code for the HTML page body
		 * @since 2014.03
		 * @category Developer
		 * @see client/html/catalog/lists/items/standard/template-header
		 * @see client/html/catalog/lists/type/standard/template-body
		 */
		$tplconf = 'client/html/catalog/lists/items/standard/template-body';
		$default = 'catalog/lists/items-body-standard';

		return $view->render( $this->getTemplatePath( $tplconf, $default ) );
	}
616367
public function getBody( $uid = '' )
	{
		$view = $this->getView();
		$context = $this->getContext();
		$session = $context->getSession();

		/** client/html/catalog/session/pinned
		 * All parameters defined for the catalog session pinned subpart
		 *
		 * This returns all settings related to the catalog session pinned subpart.
		 * Please refer to the single settings for details.
		 *
		 * @param array Associative list of name/value settings
		 * @category Developer
		 * @see client/html/catalog/session#pinned
		 */
		$config = $context->getConfig()->get( 'client/html/catalog/session/pinned', [] );
		$key = $this->getParamHash( [], $uid . ':catalog:session-pinned-body', $config );

		if( ( $html = $session->get( $key ) ) === null )
		{
			$output = '';
			foreach( $this->getSubClients() as $subclient ) {
				$output .= $subclient->setView( $view )->getBody( $uid );
			}
			$view->pinnedBody = $output;

			/** client/html/catalog/session/pinned/standard/template-body
			 * Relative path to the HTML body template of the catalog session pinned client.
			 *
			 * The template file contains the HTML code and processing instructions
			 * to generate the result shown in the body of the frontend. The
			 * configuration string is the path to the template file relative
			 * to the templates directory (usually in client/html/templates).
			 *
			 * You can overwrite the template file configuration in extensions and
			 * provide alternative templates. These alternative templates should be
			 * named like the default one but with the string "standard" replaced by
			 * an unique name. You may use the name of your project for this. If
			 * you've implemented an alternative client class as well, "standard"
			 * should be replaced by the name of the new class.
			 *
			 * @param string Relative path to the template creating code for the HTML page body
			 * @since 2014.03
			 * @category Developer
			 * @see client/html/catalog/session/pinned/standard/template-header
			 */
			$tplconf = 'client/html/catalog/session/pinned/standard/template-body';
			$default = 'catalog/session/pinned-body-standard';

			$html = $view->render( $view->config( $tplconf, $default ) );

			$cached = $session->get( 'aimeos/catalog/session/pinned/cache', [] ) + array( $key => true );
			$session->set( 'aimeos/catalog/session/pinned/cache', $cached );
			$session->set( $key, $html );
		}

		$view->block()->set( 'catalog/session/pinned', $html );

		return $html;
	}
616887
public function get_message($uid, $folder = null)
    {
        if (!strlen($folder)) {
            $folder = $this->folder;
        }

        // decode combined UID-folder identifier
        if (preg_match('/^\d+-.+/', $uid)) {
            list($uid, $folder) = explode('-', $uid, 2);
        }

        // Check internal cache
        if (!empty($this->icache['message'])) {
            if (($headers = $this->icache['message']) && $headers->uid == $uid) {
                return $headers;
            }
        }

        $headers = $this->get_message_headers($uid, $folder);

        // message doesn't exist?
        if (empty($headers)) {
            return null;
        }

        // structure might be cached
        if (!empty($headers->structure)) {
            return $headers;
        }

        $this->msg_uid = $uid;

        if (!$this->check_connection()) {
            return $headers;
        }

        if (empty($headers->bodystructure)) {
            $headers->bodystructure = $this->conn->getStructure($folder, $uid, true);
        }

        $structure = $headers->bodystructure;

        if (empty($structure)) {
            return $headers;
        }

        // set message charset from message headers
        if ($headers->charset) {
            $this->struct_charset = $headers->charset;
        }
        else {
            $this->struct_charset = $this->structure_charset($structure);
        }

        $headers->ctype = @strtolower($headers->ctype);

        // Here we can recognize malformed BODYSTRUCTURE and
        // 1. [@TODO] parse the message in other way to create our own message structure
        // 2. or just show the raw message body.
        // Example of structure for malformed MIME message:
        // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
        if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain'
            && strtolower($structure[0].'/'.$structure[1]) == 'text/plain'
        ) {
            // A special known case "Content-type: text" (#1488968)
            if ($headers->ctype == 'text') {
                $structure[1]   = 'plain';
                $headers->ctype = 'text/plain';
            }
            // we can handle single-part messages, by simple fix in structure (#1486898)
            else if (preg_match('/^(text|application)\/(.*)/', $headers->ctype, $m)) {
                $structure[0] = $m[1];
                $structure[1] = $m[2];
            }
            else {
                // Try to parse the message using rcube_mime_decode.
                // We need a better solution, it parses message
                // in memory, which wouldn't work for very big messages,
                // (it uses up to 10x more memory than the message size)
                // it's also buggy and not actively developed
                if ($headers->size && rcube_utils::mem_check($headers->size * 10)) {
                    $raw_msg = $this->get_raw_body($uid);
                    $struct = rcube_mime::parse_message($raw_msg);
                }
                else {
                    return $headers;
                }
            }
        }

        if (empty($struct)) {
            $struct = $this->structure_part($structure, 0, '', $headers);
        }

        // some workarounds on simple messages...
        if (empty($struct->parts)) {
            // ...don't trust given content-type
            if (!empty($headers->ctype)) {
                $struct->mime_id  = '1';
                $struct->mimetype = strtolower($headers->ctype);
                list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
            }

            // ...and charset (there's a case described in #1488968 where invalid content-type
            // results in invalid charset in BODYSTRUCTURE)
            if (!empty($headers->charset) && $headers->charset != $struct->ctype_parameters['charset']) {
                $struct->charset                     = $headers->charset;
                $struct->ctype_parameters['charset'] = $headers->charset;
            }
        }

        $headers->structure = $struct;

        return $this->icache['message'] = $headers;
    }
540359
protected function parsePart($stream, $uid, $part, $partNo = 1)
    {
        if (!in_array($part->type, [TYPETEXT, TYPEMULTIPART])) {
            return null;
        }

        $body = imap_fetchbody($stream, $uid, $partNo, static::$bodyFlags);

        $body = static::decode($body, $part->encoding);
        if ('' !== ($charset = $this->findCharset($part))) {
            $body = static::convertBodyEncoding($body, $charset, $part->encoding);
        }

        return (object) [
            'body' => $body,
            'mime_type' => strtolower($part->subtype)
        ];
    }