Documentation

QueryString
in package

Handles the query string, request variables, and session management.

Table of Contents

Properties

$route_parsers  : array<string|int, mixed>

Methods

buildRoute()  : string
Builds a routing path based on URL query parameters.
cleanRequest()  : void
Clean the request variables - add html entities to GET and slashes if magic_quotes_gpc is Off.
isFilteredRequest()  : bool
Checks whether a $_REQUEST variable contains an expected value.
ob_sessrewrite()  : string
Rewrite URLs to include the session ID, if the user is not accepting cookies and is using a standard web browser.
parseRoute()  : array<string|int, mixed>
Updates an array of URL parameters based on a routing path.
rewriteAsQueryless()  : string
Rewrites URLs for the queryless URLs option.
fixUrl()  : void
If the user got here using an unexpected but valid URL, fix it.
redirectFromMsg()  : void
Handles redirecting 'index.php?msg=123' links to the canonical URL.
sslRedirect()  : void
Checks to see if we're forcing SSL, and redirects if necessary.
wwwRedirect()  : void
Checks if $_SERVER['REQUEST_URL'] is incorrect due to an added/removed 'www.', and redirects if necessary.

Properties

$route_parsers

public static array<string|int, mixed> $route_parsers = ['about:unknown' => \SMF\Actions\Like::class, 'acceptagreement' => \SMF\Actions\AgreementAccept::class, 'activate' => \SMF\Actions\Activate::class, 'admin' => \SMF\Actions\Admin\Main::class, 'agreement' => \SMF\Actions\Agreement::class, 'announce' => \SMF\Actions\Announce::class, 'attachapprove' => \SMF\Actions\AttachmentApprove::class, 'board' => \SMF\Board::class, 'boardindex' => \SMF\Actions\BoardIndex::class, 'boards' => \SMF\Board::class, 'buddy' => \SMF\Actions\BuddyListToggle::class, 'calendar' => \SMF\Actions\Calendar::class, 'clock' => \SMF\Actions\Calendar::class, 'coppa' => \SMF\Actions\CoppaForm::class, 'credits' => \SMF\Actions\Credits::class, 'deletemsg' => \SMF\Actions\MsgDelete::class, 'display' => \SMF\Actions\Display::class, 'dlattach' => \SMF\Actions\AttachmentDownload::class, 'editpoll' => \SMF\Actions\PollEdit::class, 'editpoll2' => \SMF\Actions\PollEdit2::class, 'feed' => \SMF\Actions\Feed::class, 'groups' => \SMF\Actions\Groups::class, 'help' => \SMF\Actions\Help::class, 'helpadmin' => \SMF\Actions\HelpAdmin::class, 'jsmodify' => \SMF\Actions\JavaScriptModify::class, 'jsoption' => \SMF\Actions\ThemeSetOption::class, 'likes' => \SMF\Actions\Like::class, 'lock' => \SMF\Actions\TopicLock::class, 'lockvoting' => \SMF\Actions\PollLock::class, 'login' => \SMF\Actions\Login::class, 'login2' => \SMF\Actions\Login2::class, 'logintfa' => \SMF\Actions\LoginTFA::class, 'logout' => \SMF\Actions\Logout::class, 'markasread' => \SMF\Actions\MarkRead::class, 'mergetopics' => \SMF\Actions\TopicMerge::class, 'messageindex' => \SMF\Actions\MessageIndex::class, 'mlist' => \SMF\Actions\Memberlist::class, 'members' => \SMF\Actions\Profile\Main::class, 'member' => \SMF\Actions\Profile\Main::class, 'moderate' => \SMF\Actions\Moderation\Main::class, 'modifycat' => \SMF\Actions\Admin\Main::class, 'movetopic' => \SMF\Actions\TopicMove::class, 'movetopic2' => \SMF\Actions\TopicMove2::class, 'msg' => \SMF\Msg::class, 'msgs' => \SMF\Msg::class, 'notifyannouncements' => \SMF\Actions\NotifyAnnouncements::class, 'notifyboard' => \SMF\Actions\NotifyBoard::class, 'notifytopic' => \SMF\Actions\NotifyTopic::class, 'pm' => \SMF\Actions\PersonalMessage::class, 'post' => \SMF\Actions\Post::class, 'post2' => \SMF\Actions\Post2::class, 'printpage' => \SMF\Actions\TopicPrint::class, 'profile' => \SMF\Actions\Profile\Main::class, 'quickmod' => \SMF\Actions\QuickModeration::class, 'quickmod2' => \SMF\Actions\QuickModerationInTopic::class, 'quotefast' => \SMF\Actions\QuoteFast::class, 'recent' => \SMF\Actions\Recent::class, 'reminder' => \SMF\Actions\Reminder::class, 'removepoll' => \SMF\Actions\PollRemove::class, 'removetopic2' => \SMF\Actions\TopicRemove::class, 'reporttm' => \SMF\Actions\ReportToMod::class, 'restoretopic' => \SMF\Actions\TopicRestore::class, 'search' => \SMF\Actions\Search::class, 'search2' => \SMF\Actions\Search2::class, 'sendactivation' => \SMF\Actions\SendActivation::class, 'signup' => \SMF\Actions\Register::class, 'signup2' => \SMF\Actions\Register2::class, 'smstats' => \SMF\Actions\SmStats::class, 'splittopics' => \SMF\Actions\TopicSplit::class, 'stats' => \SMF\Actions\Stats::class, 'sticky' => \SMF\Actions\TopicSticky::class, 'suggest' => \SMF\Actions\AutoSuggest::class, 'termsofservice' => \SMF\Actions\Agreement::class, 'themechooser' => \SMF\Actions\ThemeChooser::class, 'topic' => \SMF\Topic::class, 'topics' => \SMF\Topic::class, 'trackip' => \SMF\Actions\TrackIP::class, 'unread' => \SMF\Actions\Unread::class, 'unreadreplies' => \SMF\Actions\UnreadReplies::class, 'uploadAttach' => \SMF\Actions\AttachmentUpload::class, 'users' => \SMF\Actions\Profile\Main::class, 'user' => \SMF\Actions\Profile\Main::class, 'verificationcode' => \SMF\Actions\VerificationCode::class, 'viewprofile' => \SMF\Actions\Profile\Main::class, 'viewquery' => \SMF\Actions\ViewQuery::class, 'viewsmfile' => \SMF\Actions\DisplayAdminFile::class, 'vote' => \SMF\Actions\PollVote::class, 'who' => \SMF\Actions\Who::class, 'xmlhttp' => \SMF\Actions\XmlHttp::class]

Maps elements that could appear at the start of a virtual route path to the names of classes that can fully parse the route.

Classes listed in this array must implement the Routable interface.

MOD AUTHORS: To add a new route parser to this list for a custom action or content type, use the integrate_route_parsers hook.

Methods

buildRoute()

Builds a routing path based on URL query parameters.

public static buildRoute(array<string|int, mixed>|string $params) : string
Parameters
$params : array<string|int, mixed>|string

URL query, as a string or array of parameters.

Return values
string

A routing path plus any remaining URL query string.

cleanRequest()

Clean the request variables - add html entities to GET and slashes if magic_quotes_gpc is Off.

public static cleanRequest() : void

What it does:

  • cleans the request variables (ENV, GET, POST, COOKIE, SERVER) and
  • makes sure the query string was parsed correctly.
  • handles the URLs passed by the queryless URLs option.
  • makes sure, regardless of php.ini, everything has slashes.
  • sets up Board::$board_id, Topic::$topic_id, and $_REQUEST['start'].
  • determines, or rather tries to determine, the client's IP.

isFilteredRequest()

Checks whether a $_REQUEST variable contains an expected value.

public static isFilteredRequest(array<string|int, mixed> $value_list, string $var) : bool

The second parameter, $var, gives the name of the $_REQUEST variable to check. For example, if $var == 'action', then $_REQUEST['action'] will be tested.

The first parameter, $value_list, is an associative array whose keys denote accepted values in $_REQUEST[$var], and whose values can be:

  • Null, in which case the existence of $_REQUEST[$var] causes the test to fail.

  • A non-null scalar value, in which case the existence of $_REQUEST[$var] is all that is necessary to pass the test.

  • Another associative array indicating additional $_REQUEST variables and acceptable values that must also be present.

For example, if $var == 'action' and $value_list contains this:

  'logout' => true,
  'pm' => array('sa' => array('popup')),

... then the test will pass (a) if $_REQUEST['action'] == 'logout' or (b) if $_REQUEST['action'] == 'pm' and $_REQUEST['sa'] == 'popup'.

Parameters
$value_list : array<string|int, mixed>

A list of acceptable values.

$var : string

Name of a $_REQUEST variable.

Return values
bool

Whether any of the criteria were satisfied.

ob_sessrewrite()

Rewrite URLs to include the session ID, if the user is not accepting cookies and is using a standard web browser.

public static ob_sessrewrite(string $buffer) : string
Parameters
$buffer : string

The unmodified output buffer.

Return values
string

The modified buffer.

parseRoute()

Updates an array of URL parameters based on a routing path.

public static parseRoute(string $path, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$path : string

A virtual path. Typically $_SERVER['PATH_INFO'].

$params : array<string|int, mixed>

Existing URL query parameters. Typically $_GET.

Return values
array<string|int, mixed>

Updated copy of $params.

rewriteAsQueryless()

Rewrites URLs for the queryless URLs option.

public static rewriteAsQueryless(string $buffer) : string

MOD AUTHORS: If your mod implements an alternative form of pretty URLs, the 'integrate_rewrite_as_queryless' hook inside this method will be of interest to you.

Parameters
$buffer : string

A string that might contain URLs.

Return values
string

Modified version of $buffer.

fixUrl()

If the user got here using an unexpected but valid URL, fix it.

protected static fixUrl() : void

redirectFromMsg()

Handles redirecting 'index.php?msg=123' links to the canonical URL.

protected static redirectFromMsg() : void

sslRedirect()

Checks to see if we're forcing SSL, and redirects if necessary.

protected static sslRedirect() : void

wwwRedirect()

Checks if $_SERVER['REQUEST_URL'] is incorrect due to an added/removed 'www.', and redirects if necessary.

protected static wwwRedirect() : void

        
On this page

Search results