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;
    }
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;
    }
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 ; }
If we are quoting a message
If we are quoting a message