elkarte /
Elkarte
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * This, as you have probably guessed, is the crux for all functions. |
||||
| 5 | * Everything should start here, so all the setup and security is done |
||||
| 6 | * properly. |
||||
| 7 | * |
||||
| 8 | * @package ElkArte Forum |
||||
| 9 | * @copyright ElkArte Forum contributors |
||||
| 10 | * @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file) |
||||
| 11 | * |
||||
| 12 | * This file contains code covered by: |
||||
| 13 | * copyright: 2011 Simple Machines (http://www.simplemachines.org) |
||||
| 14 | * |
||||
| 15 | * @version 2.0 dev |
||||
| 16 | * |
||||
| 17 | */ |
||||
| 18 | |||||
| 19 | // Bootstrap the system |
||||
| 20 | require_once(dirname(__FILE__) . '/bootstrap.php'); |
||||
| 21 | new Bootstrap(false); |
||||
| 22 | |||||
| 23 | // Turn on output buffering if it isn't already on (via php.ini for example) |
||||
| 24 | if (!ob_get_level()) |
||||
| 25 | ob_start(); |
||||
| 26 | |||||
| 27 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
||||
| 28 | if (isset($_GET['scheduled'])) |
||||
| 29 | { |
||||
| 30 | // Don't make people wait on us if we can help it. |
||||
| 31 | if (function_exists('fastcgi_finish_request')) |
||||
| 32 | fastcgi_finish_request(); |
||||
| 33 | |||||
| 34 | $controller = new \ElkArte\Controller\ScheduledTasks(new \ElkArte\EventManager()); |
||||
| 35 | $controller->action_autotask(); |
||||
| 36 | } |
||||
| 37 | |||||
| 38 | // Check if compressed output is enabled, supported, and not already being done. |
||||
| 39 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
||||
| 40 | { |
||||
| 41 | // If zlib is being used, turn off output compression. |
||||
| 42 | if (detectServer()->outPutCompressionEnabled()) |
||||
| 43 | $modSettings['enableCompressedOutput'] = 0; |
||||
| 44 | else |
||||
| 45 | { |
||||
| 46 | @ob_end_clean(); |
||||
|
0 ignored issues
–
show
|
|||||
| 47 | ob_start('ob_gzhandler'); |
||||
| 48 | } |
||||
| 49 | } |
||||
| 50 | |||||
| 51 | // Register error & exception handlers. |
||||
| 52 | new ElkArte\Errors\ErrorHandler; |
||||
| 53 | |||||
| 54 | // Start the session. (assuming it hasn't already been.) |
||||
| 55 | loadSession(); |
||||
| 56 | |||||
| 57 | // Restore post data if we are revalidating OpenID. |
||||
| 58 | if (isset($_GET['openid_restore_post']) && !empty($_SESSION['openid']['saved_data'][$_GET['openid_restore_post']]['post']) && empty($_POST)) |
||||
| 59 | { |
||||
| 60 | $_POST = $_SESSION['openid']['saved_data'][$_GET['openid_restore_post']]['post']; |
||||
| 61 | unset($_SESSION['openid']['saved_data'][$_GET['openid_restore_post']]); |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | // Pre-dispatch |
||||
| 65 | elk_main(); |
||||
| 66 | |||||
| 67 | // Call obExit specially; we're coming from the main area ;). |
||||
| 68 | obExit(null, null, true); |
||||
| 69 | |||||
| 70 | /** |
||||
| 71 | * The main dispatcher. |
||||
| 72 | * This delegates to each area. |
||||
| 73 | */ |
||||
| 74 | function elk_main() |
||||
| 75 | { |
||||
| 76 | global $modSettings, $context; |
||||
| 77 | |||||
| 78 | // A safer way to work with our form globals |
||||
| 79 | // @todo Use dependency injection |
||||
| 80 | $_req = \ElkArte\HttpReq::instance(); |
||||
| 81 | |||||
| 82 | // What shall we do? |
||||
| 83 | $dispatcher = new ElkArte\SiteDispatcher($_req); |
||||
| 84 | |||||
| 85 | if ($dispatcher->needSecurity()) |
||||
| 86 | { |
||||
| 87 | // We should set our security headers now. |
||||
| 88 | frameOptionsHeader(); |
||||
| 89 | securityOptionsHeader(); |
||||
| 90 | |||||
| 91 | // Load the user's cookie (or set as guest) and load their settings. |
||||
| 92 | loadUserSettings(); |
||||
|
0 ignored issues
–
show
The function
loadUserSettings() has been deprecated: kept until any trace of $user_info has been completely removed
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. Loading history...
|
|||||
| 93 | $dispatcher->setUser(\ElkArte\User::$info); |
||||
| 94 | |||||
| 95 | // Load the current board's information. |
||||
| 96 | loadBoard(); |
||||
| 97 | |||||
| 98 | // Load the current user's permissions. |
||||
| 99 | loadPermissions(); |
||||
| 100 | |||||
| 101 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
||||
| 102 | if ($dispatcher->needTheme()) |
||||
| 103 | { |
||||
| 104 | new ElkArte\Themes\ThemeLoader(); |
||||
| 105 | |||||
| 106 | // Load BadBehavior before we go much further |
||||
| 107 | loadBadBehavior(); |
||||
| 108 | |||||
| 109 | // The parser is not an object just yet |
||||
| 110 | loadBBCParsers(); |
||||
| 111 | } |
||||
| 112 | // Otherwise don't require the entire theme to be loaded. |
||||
| 113 | else |
||||
| 114 | { |
||||
| 115 | detectBrowser(); |
||||
| 116 | } |
||||
| 117 | |||||
| 118 | // Check if the user should be disallowed access. |
||||
| 119 | is_not_banned(); |
||||
| 120 | |||||
| 121 | // Do some logging, unless this is an attachment, avatar, toggle of editor buttons, theme option, XML feed etc. |
||||
| 122 | if ($dispatcher->trackStats()) |
||||
| 123 | { |
||||
| 124 | // I see you! |
||||
| 125 | writeLog(); |
||||
| 126 | |||||
| 127 | // Track forum statistics and hits...? |
||||
| 128 | if (!empty($modSettings['hitStats'])) |
||||
| 129 | trackStats(array('hits' => '+')); |
||||
| 130 | } |
||||
| 131 | |||||
| 132 | // Show where we came from, and go |
||||
| 133 | $context['site_action'] = $dispatcher->site_action(); |
||||
| 134 | } |
||||
| 135 | |||||
| 136 | $dispatcher->dispatch(); |
||||
| 137 | } |
||||
| 138 |
If you suppress an error, we recommend checking for the error condition explicitly: