1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339:
<?php
/**
* MvcCore
*
* This source file is subject to the BSD 3 License
* For the full copyright and license information, please view
* the LICENSE.md file that are distributed with this source code.
*
* @copyright Copyright (c) 2016 Tom Flidr (https://github.com/mvccore)
* @license https://mvccore.github.io/docs/mvccore/5.0.0/LICENCE.md
*/
namespace MvcCore\Request;
trait Props {
/**
* List of exceptional two-segment top-level domain like
* `'co.jp', 'co.uk', 'co.kr', 'co.nf' ...` to parse
* domain string correctly.
* @var \string[]
*/
protected static $twoSegmentTlds = ['co.jp'=>1,'ac.uk'=>1,'co.uk'=>1,'co.kr'=>1,'co.nl'=>1,'in.ua'=>1,'co.nf'=>1,'ny.us'=>1,'co.us'=>1];
/**
* Configured router full class name string from core, loaded in `__constructor()`.
* @var string|NULL
*/
protected static $routerClass = NULL;
/**
* Reference to `\MvcCore\Application::GetInstance();`
* @var \MvcCore\Application|NULL
*/
protected static $app = NULL;
/**
* String name or resource for request input stream.
* Example: `'php://input' | STDIN`
* @var string|resource|NULL
*/
protected $inputStream = NULL;
/**
* `TRUE` if PHP `php_sapi_name()` is `cli` and also
* if there is no `$_SERVER['REQUEST_URI']` defined.
* @var bool|NULL
*/
protected $cli = NULL;
/**
* Language international code, lower case, not used by default.
* To use this variable - install `\MvcCore\Router` extension `\MvcCore\Ext\Router\Lang`
* Or use this variable by your own decision.
* Example: `"en" | "de"`
* @var string|NULL
*/
protected $lang = NULL;
/**
* Country/locale code, upper case, not used by default.
* To use this variable - install `\MvcCore\Router` extension `\MvcCore\Ext\Router\Lang`
* Or use this variable by your own decision.
* Example: `"US" | "UK"`
* @var string|NULL
*/
protected $locale = NULL;
/**
* Media site key - `"full" | "tablet" | "mobile"`.
* To use this variable - install `\MvcCore\Router` extension `\MvcCore\Ext\Routers\Media`
* Or use this variable by your own decision.
* Example: `"full" | "tablet" | "mobile"`
* @var string|NULL
*/
protected $mediaSiteVersion = NULL;
/**
* Http scheme: `"http:" | "https:"`
* Example: `"http:"`
* @var string|NULL
*/
protected $scheme = NULL;
/**
* `TRUE` if http scheme is `"https:"`
* @var bool|NULL
*/
protected $secure = NULL;
/**
* Application server name - domain without any port.
* Example: `"localhost"`
* @var string|NULL
*/
protected $hostName = NULL;
/**
* Application host with port if there is any.
* Example: `"localhost:88"`
* @var string|NULL
*/
protected $host = NULL;
/**
* Http port defined in requested URI if any, parsed by `parse_url()`.
* Empty string if there is no port number in requested address.`.
* Example: `"88" | ""`
* @var string|NULL
*/
protected $port = NULL;
/**
* Parsed server name (domain without port) parts.
* Example: `['any.content', 'example', 'co.uk'] | [NULL, NULL, 'localhost']`
* @var \string[]|NULL
*/
protected $domainParts = NULL;
/**
* `TRUE` if http port defined in requested URI (parsed by `parse_url()`).
* @var bool
*/
protected $portDefined = FALSE;
/**
* Requested path in from application root (if `mod_rewrite` enabled), never with query string.
* Example: `"/products/page/2"`
* @var string|NULL
*/
protected $path = NULL;
/**
* Uri query string without question mark.
* Example: `"param-1=value-1¶m-2=value-2¶m-3[]=value-3-a¶m-3[]=value-3-b"`
* @var string|NULL
*/
protected $query = NULL;
/**
* Uri fragment parsed by `parse_url()` including hash.
* Example: `"#any-sublink-path"`
* @var string|NULL
*/
protected $fragment = NULL;
/**
* `TRUE` if request is requested from browser by `XmlHttpRequest` object
* with http header: `X-Requested-With: AnyJavascriptFrameworkName`, `FALSE` otherwise.
* @var bool|null
*/
protected $ajax = NULL;
/**
* Php requested script name path from application root.
* Example: `"/index.php"`
* @var string|NULL
*/
protected $scriptName = NULL;
/**
* Application root path on hard drive.
* Example: `"C:/www/my/development/directory/www"`
* @var string|NULL
*/
protected $appRoot = NULL;
/**
* Base app directory path after domain, if application is placed in domain subdirectory
* Example:
* - full URI: `"http://localhost:88/my/development/directory/www/requested/path/after/domain?with=possible&query=string"`
* - base path: `"/my/development/directory/www"`
* @var string|NULL
*/
protected $basePath = NULL;
/**
* Request path after domain with possible query string
* Example: `"/requested/path/after/app/root?with=possible&query=string"`
* @var string|NULL
*/
protected $requestPath = NULL;
/**
* Url to requested domain and possible port.
* Example: `"https://domain.com" | "http://domain:88"` if any port.
* @var string|NULL
*/
protected $domainUrl = NULL;
/**
* Base URI to application root.
* Example: `"http://domain:88/my/development/directory/www"`
* @var string|NULL
*/
protected $baseUrl = NULL;
/**
* Request URI including scheme, domain, port, path, without any query string
* Example: "`http://localhost:88/my/development/directory/www/requested/path/after/domain"`
* @var string|NULL
*/
protected $requestUrl = NULL;
/**
* Request URI including scheme, domain, port, path and with query string
* Example: `"http://localhost:88/my/development/directory/www/requested/path/after/domain?with=possible&query=string"`
* @var string|NULL
*/
protected $fullUrl = NULL;
/**
* Http method (upper case) - `GET`, `POST`, `PUT`, `HEAD`...
* Example: `"GET"`
* @var string|NULL
*/
protected $method = NULL;
/**
* Referer URI if any, safely read by:
* `filter_var($_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL);`
* Example: `"http://foreing.domain.com/path/where/is/link/to/?my=app"`
* @var string|NULL
*/
protected $referer = NULL;
/**
* Server IP address string.
* Example: `"127.0.0.1" | "111.222.111.222"`
* @var string|NULL
*/
protected $serverIp = NULL;
/**
* Client IP address string.
* Example: `"127.0.0.1" | "222.111.222.111"`
* @var string|NULL
*/
protected $clientIp = NULL;
/**
* Integer value from global `$_SERVER['CONTENT_LENGTH']`,
* `NULL` if no value presented in global `$_SERVER` array.
* Example: `123456 | NULL`
* @var int|NULL
*/
protected $contentLength = NULL;
/**
* Timestamp of the start of the request, with microsecond precision.
* @var float
*/
protected $microtime = NULL;
/**
* All raw http headers without any conversion, initialized by
* `getallheaders()` or from `$_SERVER['HTTP_...']`.
* Headers are `key => value` array, headers keys are
* in standard format like: `"Content-Type" | "Content-Length" | "X-Requested-With" ...`.
* @var array|NULL
*/
protected $headers = NULL;
/**
* Raw request body, usually from `file_get_contents('php://input');`.
* @var string|NULL
*/
protected $body = NULL;
/**
* Raw request params array, with keys defined in route or by query string,
* always with controller and action keys completed by router.
* Do not read this `$params` array directly, read it's values by:
* `\MvcCore\Request::GetParam($paramName, $allowedChars, $defaultValueIfNull, $targetType);`.
* Example:
* `\MvcCore\Request:$params = array(
* "controller" => "default",
* "action" => "default",
* "username" => "' OR 1=1;-- ", // be careful for this content with raw (danger) value!
* );`
* // Do not read `$params` array directly,
* // to get safe param value use:
* `\MvcCore\Request::GetParam("username", "a-zA-Z0-9_");` // return `OR` string without danger chars.
* @var array|NULL
*/
protected $params = NULL;
/**
* Request flag if request targets internal package asset or not,
* - 0 => Means request is `Controller:Asset` call for internal package asset.
* - 1 => Means request is classic application request.
* @var bool|NULL
*/
protected $appRequest = NULL;
/**
* Cleaned input param `"controller"`, containing only chars: `"a-zA-Z0-9\-_/"`.
* @var string
*/
protected $controllerName = NULL;
/**
* Cleaned input param `"action"`, containing only chars: `"a-zA-Z0-9\-_/"`.
* @var string
*/
protected $actionName = NULL;
/**
* Content of referenced `$_SERVER` global variable.
* @var array
*/
protected $globalServer = [];
/**
* Content of referenced `$_GET` global variable.
* @var array
*/
protected $globalGet = [];
/**
* Content of referenced `$_POST` global variable.
* @var array
*/
protected $globalPost = [];
/**
* Content of referenced `$_COOKIE` global variable.
* @var array
*/
protected $globalCookies = [];
/**
* Content of referenced `$_FILES` global variable.
* @var array
*/
protected $globalFiles = [];
}