MediaWiki  1.23.3
WebRequest.php
Go to the documentation of this file.
1 <?php
38 class WebRequest {
39  protected $data, $headers = array();
40 
45  private $response;
46 
51  private $ip;
52 
57  protected $protocol;
58 
59  public function __construct() {
63  $this->checkMagicQuotes();
64 
65  // POST overrides GET data
66  // We don't use $_REQUEST here to avoid interference from cookies...
67  $this->data = $_POST + $_GET;
68  }
69 
85  public static function getPathInfo( $want = 'all' ) {
86  global $wgUsePathInfo;
87  // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892
88  // And also by Apache 2.x, double slashes are converted to single slashes.
89  // So we will use REQUEST_URI if possible.
90  $matches = array();
91  if ( !empty( $_SERVER['REQUEST_URI'] ) ) {
92  // Slurp out the path portion to examine...
93  $url = $_SERVER['REQUEST_URI'];
94  if ( !preg_match( '!^https?://!', $url ) ) {
95  $url = 'http://unused' . $url;
96  }
98  $a = parse_url( $url );
100  if ( $a ) {
101  $path = isset( $a['path'] ) ? $a['path'] : '';
102 
103  global $wgScript;
104  if ( $path == $wgScript && $want !== 'all' ) {
105  // Script inside a rewrite path?
106  // Abort to keep from breaking...
107  return $matches;
108  }
109 
110  $router = new PathRouter;
111 
112  // Raw PATH_INFO style
113  $router->add( "$wgScript/$1" );
114 
115  if ( isset( $_SERVER['SCRIPT_NAME'] )
116  && preg_match( '/\.php5?/', $_SERVER['SCRIPT_NAME'] )
117  ) {
118  # Check for SCRIPT_NAME, we handle index.php explicitly
119  # But we do have some other .php files such as img_auth.php
120  # Don't let root article paths clober the parsing for them
121  $router->add( $_SERVER['SCRIPT_NAME'] . "/$1" );
122  }
123 
125  if ( $wgArticlePath ) {
126  $router->add( $wgArticlePath );
127  }
128 
130  if ( $wgActionPaths ) {
131  $router->add( $wgActionPaths, array( 'action' => '$key' ) );
132  }
133 
134  global $wgVariantArticlePath, $wgContLang;
135  if ( $wgVariantArticlePath ) {
136  $router->add( $wgVariantArticlePath,
137  array( 'variant' => '$2' ),
138  array( '$2' => $wgContLang->getVariants() )
139  );
140  }
141 
142  wfRunHooks( 'WebRequestPathInfoRouter', array( $router ) );
143 
144  $matches = $router->parse( $path );
145  }
146  } elseif ( $wgUsePathInfo ) {
147  if ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) {
148  // Mangled PATH_INFO
149  // http://bugs.php.net/bug.php?id=31892
150  // Also reported when ini_get('cgi.fix_pathinfo')==false
151  $matches['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 );
152 
153  } elseif ( isset( $_SERVER['PATH_INFO'] ) && $_SERVER['PATH_INFO'] != '' ) {
154  // Regular old PATH_INFO yay
155  $matches['title'] = substr( $_SERVER['PATH_INFO'], 1 );
156  }
157  }
158 
159  return $matches;
160  }
161 
168  public static function detectServer() {
169  $proto = self::detectProtocol();
170  $stdPort = $proto === 'https' ? 443 : 80;
171 
172  $varNames = array( 'HTTP_HOST', 'SERVER_NAME', 'HOSTNAME', 'SERVER_ADDR' );
173  $host = 'localhost';
174  $port = $stdPort;
175  foreach ( $varNames as $varName ) {
176  if ( !isset( $_SERVER[$varName] ) ) {
177  continue;
178  }
179  $parts = IP::splitHostAndPort( $_SERVER[$varName] );
180  if ( !$parts ) {
181  // Invalid, do not use
182  continue;
183  }
184  $host = $parts[0];
185  if ( $parts[1] === false ) {
186  if ( isset( $_SERVER['SERVER_PORT'] ) ) {
187  $port = $_SERVER['SERVER_PORT'];
188  } // else leave it as $stdPort
189  } else {
190  $port = $parts[1];
191  }
192  break;
193  }
194 
195  return $proto . '://' . IP::combineHostAndPort( $host, $port, $stdPort );
196  }
197 
205  public static function detectProtocol() {
206  if ( ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ||
207  ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
208  $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ) {
209  return 'https';
210  } else {
211  return 'http';
212  }
213  }
214 
219  public function getProtocol() {
220  if ( $this->protocol === null ) {
221  $this->protocol = self::detectProtocol();
222  }
223  return $this->protocol;
224  }
225 
233  public function interpolateTitle() {
234  // bug 16019: title interpolation on API queries is useless and sometimes harmful
235  if ( defined( 'MW_API' ) ) {
236  return;
237  }
238 
239  $matches = self::getPathInfo( 'title' );
240  foreach ( $matches as $key => $val ) {
241  $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
242  }
243  }
244 
255  static function extractTitle( $path, $bases, $key = false ) {
256  foreach ( (array)$bases as $keyValue => $base ) {
257  // Find the part after $wgArticlePath
258  $base = str_replace( '$1', '', $base );
259  $baseLen = strlen( $base );
260  if ( substr( $path, 0, $baseLen ) == $base ) {
261  $raw = substr( $path, $baseLen );
262  if ( $raw !== '' ) {
263  $matches = array( 'title' => rawurldecode( $raw ) );
264  if ( $key ) {
265  $matches[$key] = $keyValue;
266  }
267  return $matches;
268  }
269  }
270  }
271  return array();
272  }
273 
285  private function &fix_magic_quotes( &$arr, $topLevel = true ) {
286  $clean = array();
287  foreach ( $arr as $key => $val ) {
288  if ( is_array( $val ) ) {
289  $cleanKey = $topLevel ? stripslashes( $key ) : $key;
290  $clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], false );
291  } else {
292  $cleanKey = stripslashes( $key );
293  $clean[$cleanKey] = stripslashes( $val );
294  }
295  }
296  $arr = $clean;
297  return $arr;
298  }
299 
306  private function checkMagicQuotes() {
307  $mustFixQuotes = function_exists( 'get_magic_quotes_gpc' )
308  && get_magic_quotes_gpc();
309  if ( $mustFixQuotes ) {
310  $this->fix_magic_quotes( $_COOKIE );
311  $this->fix_magic_quotes( $_ENV );
312  $this->fix_magic_quotes( $_GET );
313  $this->fix_magic_quotes( $_POST );
314  $this->fix_magic_quotes( $_REQUEST );
315  $this->fix_magic_quotes( $_SERVER );
316  }
317  }
318 
326  function normalizeUnicode( $data ) {
327  if ( is_array( $data ) ) {
328  foreach ( $data as $key => $val ) {
329  $data[$key] = $this->normalizeUnicode( $val );
330  }
331  } else {
333  $data = isset( $wgContLang ) ? $wgContLang->normalize( $data ) : UtfNormal::cleanUp( $data );
334  }
335  return $data;
336  }
337 
346  private function getGPCVal( $arr, $name, $default ) {
347  # PHP is so nice to not touch input data, except sometimes:
348  # http://us2.php.net/variables.external#language.variables.external.dot-in-names
349  # Work around PHP *feature* to avoid *bugs* elsewhere.
350  $name = strtr( $name, '.', '_' );
351  if ( isset( $arr[$name] ) ) {
353  $data = $arr[$name];
354  if ( isset( $_GET[$name] ) && !is_array( $data ) ) {
355  # Check for alternate/legacy character encoding.
356  if ( isset( $wgContLang ) ) {
357  $data = $wgContLang->checkTitleEncoding( $data );
358  }
359  }
360  $data = $this->normalizeUnicode( $data );
361  return $data;
362  } else {
363  return $default;
364  }
365  }
366 
377  public function getVal( $name, $default = null ) {
378  $val = $this->getGPCVal( $this->data, $name, $default );
379  if ( is_array( $val ) ) {
380  $val = $default;
381  }
382  if ( is_null( $val ) ) {
383  return $val;
384  } else {
385  return (string)$val;
386  }
387  }
388 
396  public function setVal( $key, $value ) {
397  $ret = isset( $this->data[$key] ) ? $this->data[$key] : null;
398  $this->data[$key] = $value;
399  return $ret;
400  }
401 
408  public function unsetVal( $key ) {
409  if ( !isset( $this->data[$key] ) ) {
410  $ret = null;
411  } else {
412  $ret = $this->data[$key];
413  unset( $this->data[$key] );
414  }
415  return $ret;
416  }
417 
427  public function getArray( $name, $default = null ) {
428  $val = $this->getGPCVal( $this->data, $name, $default );
429  if ( is_null( $val ) ) {
430  return null;
431  } else {
432  return (array)$val;
433  }
434  }
435 
446  public function getIntArray( $name, $default = null ) {
447  $val = $this->getArray( $name, $default );
448  if ( is_array( $val ) ) {
449  $val = array_map( 'intval', $val );
450  }
451  return $val;
452  }
453 
463  public function getInt( $name, $default = 0 ) {
464  return intval( $this->getVal( $name, $default ) );
465  }
466 
475  public function getIntOrNull( $name ) {
476  $val = $this->getVal( $name );
477  return is_numeric( $val )
478  ? intval( $val )
479  : null;
480  }
481 
492  public function getFloat( $name, $default = 0 ) {
493  return floatval( $this->getVal( $name, $default ) );
494  }
495 
505  public function getBool( $name, $default = false ) {
506  return (bool)$this->getVal( $name, $default );
507  }
508 
518  public function getFuzzyBool( $name, $default = false ) {
519  return $this->getBool( $name, $default ) && strcasecmp( $this->getVal( $name ), 'false' ) !== 0;
520  }
521 
530  public function getCheck( $name ) {
531  # Checkboxes and buttons are only present when clicked
532  # Presence connotes truth, absence false
533  return $this->getVal( $name, null ) !== null;
534  }
535 
548  public function getText( $name, $default = '' ) {
550  $val = $this->getVal( $name, $default );
551  return str_replace( "\r\n", "\n",
552  $wgContLang->recodeInput( $val ) );
553  }
554 
562  public function getValues() {
563  $names = func_get_args();
564  if ( count( $names ) == 0 ) {
565  $names = array_keys( $this->data );
566  }
567 
568  $retVal = array();
569  foreach ( $names as $name ) {
570  $value = $this->getGPCVal( $this->data, $name, null );
571  if ( !is_null( $value ) ) {
572  $retVal[$name] = $value;
573  }
574  }
575  return $retVal;
576  }
577 
584  public function getValueNames( $exclude = array() ) {
585  return array_diff( array_keys( $this->getValues() ), $exclude );
586  }
587 
594  public function getQueryValues() {
595  return $_GET;
596  }
597 
604  public function getRawQueryString() {
605  return $_SERVER['QUERY_STRING'];
606  }
607 
614  public function getRawPostString() {
615  if ( !$this->wasPosted() ) {
616  return '';
617  }
618  return $this->getRawInput();
619  }
620 
628  public function getRawInput() {
629  static $input = false;
630  if ( $input === false ) {
631  $input = file_get_contents( 'php://input' );
632  }
633  return $input;
634  }
635 
641  public function getMethod() {
642  return isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'GET';
643  }
644 
654  public function wasPosted() {
655  return $this->getMethod() == 'POST';
656  }
657 
669  public function checkSessionCookie() {
670  return isset( $_COOKIE[session_name()] );
671  }
672 
681  public function getCookie( $key, $prefix = null, $default = null ) {
682  if ( $prefix === null ) {
684  $prefix = $wgCookiePrefix;
685  }
686  return $this->getGPCVal( $_COOKIE, $prefix . $key, $default );
687  }
688 
696  public function getRequestURL() {
697  if ( isset( $_SERVER['REQUEST_URI'] ) && strlen( $_SERVER['REQUEST_URI'] ) ) {
698  $base = $_SERVER['REQUEST_URI'];
699  } elseif ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) && strlen( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
700  // Probably IIS; doesn't set REQUEST_URI
701  $base = $_SERVER['HTTP_X_ORIGINAL_URL'];
702  } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
703  $base = $_SERVER['SCRIPT_NAME'];
704  if ( isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] != '' ) {
705  $base .= '?' . $_SERVER['QUERY_STRING'];
706  }
707  } else {
708  // This shouldn't happen!
709  throw new MWException( "Web server doesn't provide either " .
710  "REQUEST_URI, HTTP_X_ORIGINAL_URL or SCRIPT_NAME. Report details " .
711  "of your web server configuration to http://bugzilla.wikimedia.org/" );
712  }
713  // User-agents should not send a fragment with the URI, but
714  // if they do, and the web server passes it on to us, we
715  // need to strip it or we get false-positive redirect loops
716  // or weird output URLs
717  $hash = strpos( $base, '#' );
718  if ( $hash !== false ) {
719  $base = substr( $base, 0, $hash );
720  }
721 
722  if ( $base[0] == '/' ) {
723  // More than one slash will look like it is protocol relative
724  return preg_replace( '!^/+!', '/', $base );
725  } else {
726  // We may get paths with a host prepended; strip it.
727  return preg_replace( '!^[^:]+://[^/]+/+!', '/', $base );
728  }
729  }
730 
741  public function getFullRequestURL() {
742  return wfExpandUrl( $this->getRequestURL(), PROTO_CURRENT );
743  }
744 
751  public function appendQuery( $query ) {
752  return $this->appendQueryArray( wfCgiToArray( $query ) );
753  }
754 
762  public function escapeAppendQuery( $query ) {
763  return htmlspecialchars( $this->appendQuery( $query ) );
764  }
765 
772  public function appendQueryValue( $key, $value, $onlyquery = false ) {
773  return $this->appendQueryArray( array( $key => $value ), $onlyquery );
774  }
775 
784  public function appendQueryArray( $array, $onlyquery = false ) {
786  $newquery = $this->getQueryValues();
787  unset( $newquery['title'] );
788  $newquery = array_merge( $newquery, $array );
789  $query = wfArrayToCgi( $newquery );
790  return $onlyquery ? $query : $wgTitle->getLocalURL( $query );
791  }
792 
802  public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) {
803  global $wgUser;
804 
805  $limit = $this->getInt( 'limit', 0 );
806  if ( $limit < 0 ) {
807  $limit = 0;
808  }
809  if ( ( $limit == 0 ) && ( $optionname != '' ) ) {
810  $limit = $wgUser->getIntOption( $optionname );
811  }
812  if ( $limit <= 0 ) {
813  $limit = $deflimit;
814  }
815  if ( $limit > 5000 ) {
816  $limit = 5000; # We have *some* limits...
817  }
818 
819  $offset = $this->getInt( 'offset', 0 );
820  if ( $offset < 0 ) {
821  $offset = 0;
822  }
823 
824  return array( $limit, $offset );
825  }
826 
833  public function getFileTempname( $key ) {
834  $file = new WebRequestUpload( $this, $key );
835  return $file->getTempName();
836  }
837 
844  public function getUploadError( $key ) {
845  $file = new WebRequestUpload( $this, $key );
846  return $file->getError();
847  }
848 
860  public function getFileName( $key ) {
861  $file = new WebRequestUpload( $this, $key );
862  return $file->getName();
863  }
864 
871  public function getUpload( $key ) {
872  return new WebRequestUpload( $this, $key );
873  }
874 
881  public function response() {
882  /* Lazy initialization of response object for this request */
883  if ( !is_object( $this->response ) ) {
884  $class = ( $this instanceof FauxRequest ) ? 'FauxResponse' : 'WebResponse';
885  $this->response = new $class();
886  }
887  return $this->response;
888  }
889 
893  private function initHeaders() {
894  if ( count( $this->headers ) ) {
895  return;
896  }
897 
898  $apacheHeaders = function_exists( 'apache_request_headers' ) ? apache_request_headers() : false;
899  if ( $apacheHeaders ) {
900  foreach ( $apacheHeaders as $tempName => $tempValue ) {
901  $this->headers[strtoupper( $tempName )] = $tempValue;
902  }
903  } else {
904  foreach ( $_SERVER as $name => $value ) {
905  if ( substr( $name, 0, 5 ) === 'HTTP_' ) {
906  $name = str_replace( '_', '-', substr( $name, 5 ) );
907  $this->headers[$name] = $value;
908  } elseif ( $name === 'CONTENT_LENGTH' ) {
909  $this->headers['CONTENT-LENGTH'] = $value;
910  }
911  }
912  }
913  }
914 
920  public function getAllHeaders() {
921  $this->initHeaders();
922  return $this->headers;
923  }
924 
931  public function getHeader( $name ) {
932  $this->initHeaders();
933  $name = strtoupper( $name );
934  if ( isset( $this->headers[$name] ) ) {
935  return $this->headers[$name];
936  } else {
937  return false;
938  }
939  }
940 
947  public function getSessionData( $key ) {
948  if ( !isset( $_SESSION[$key] ) ) {
949  return null;
950  }
951  return $_SESSION[$key];
952  }
953 
960  public function setSessionData( $key, $data ) {
961  $_SESSION[$key] = $data;
962  }
963 
974  public function checkUrlExtension( $extWhitelist = array() ) {
975  global $wgScriptExtension;
976  $extWhitelist[] = ltrim( $wgScriptExtension, '.' );
977  if ( IEUrlExtension::areServerVarsBad( $_SERVER, $extWhitelist ) ) {
978  if ( !$this->wasPosted() ) {
980  $this->getFullRequestURL(), $extWhitelist );
981  if ( $newUrl !== false ) {
982  $this->doSecurityRedirect( $newUrl );
983  return false;
984  }
985  }
986  throw new HttpError( 403,
987  'Invalid file extension found in the path info or query string.' );
988  }
989  return true;
990  }
991 
999  protected function doSecurityRedirect( $url ) {
1000  header( 'Location: ' . $url );
1001  header( 'Content-Type: text/html' );
1002  $encUrl = htmlspecialchars( $url );
1003  echo <<<HTML
1004 <html>
1005 <head>
1006 <title>Security redirect</title>
1007 </head>
1008 <body>
1009 <h1>Security redirect</h1>
1010 <p>
1011 We can't serve non-HTML content from the URL you have requested, because
1012 Internet Explorer would interpret it as an incorrect and potentially dangerous
1013 content type.</p>
1014 <p>Instead, please use <a href="$encUrl">this URL</a>, which is the same as the URL you have requested, except that
1015 "&amp;*" is appended. This prevents Internet Explorer from seeing a bogus file
1016 extension.
1017 </p>
1018 </body>
1019 </html>
1020 HTML;
1021  echo "\n";
1022  return true;
1023  }
1024 
1033  public function getAcceptLang() {
1034  // Modified version of code found at http://www.thefutureoftheweb.com/blog/use-accept-language-header
1035  $acceptLang = $this->getHeader( 'Accept-Language' );
1036  if ( !$acceptLang ) {
1037  return array();
1038  }
1039 
1040  // Return the language codes in lower case
1041  $acceptLang = strtolower( $acceptLang );
1042 
1043  // Break up string into pieces (languages and q factors)
1044  $lang_parse = null;
1045  preg_match_all( '/([a-z]{1,8}(-[a-z]{1,8})*|\*)\s*(;\s*q\s*=\s*(1(\.0{0,3})?|0(\.[0-9]{0,3})?)?)?/',
1046  $acceptLang, $lang_parse );
1047 
1048  if ( !count( $lang_parse[1] ) ) {
1049  return array();
1050  }
1051 
1052  $langcodes = $lang_parse[1];
1053  $qvalues = $lang_parse[4];
1054  $indices = range( 0, count( $lang_parse[1] ) - 1 );
1055 
1056  // Set default q factor to 1
1057  foreach ( $indices as $index ) {
1058  if ( $qvalues[$index] === '' ) {
1059  $qvalues[$index] = 1;
1060  } elseif ( $qvalues[$index] == 0 ) {
1061  unset( $langcodes[$index], $qvalues[$index], $indices[$index] );
1062  }
1063  }
1064 
1065  // Sort list. First by $qvalues, then by order. Reorder $langcodes the same way
1066  array_multisort( $qvalues, SORT_DESC, SORT_NUMERIC, $indices, $langcodes );
1067 
1068  // Create a list like "en" => 0.8
1069  $langs = array_combine( $langcodes, $qvalues );
1070 
1071  return $langs;
1072  }
1073 
1082  protected function getRawIP() {
1083  if ( !isset( $_SERVER['REMOTE_ADDR'] ) ) {
1084  return null;
1085  }
1086 
1087  if ( is_array( $_SERVER['REMOTE_ADDR'] ) || strpos( $_SERVER['REMOTE_ADDR'], ',' ) !== false ) {
1088  throw new MWException( __METHOD__ . " : Could not determine the remote IP address due to multiple values." );
1089  } else {
1090  $ipchain = $_SERVER['REMOTE_ADDR'];
1091  }
1092 
1093  return IP::canonicalize( $ipchain );
1094  }
1095 
1105  public function getIP() {
1106  global $wgUsePrivateIPs;
1107 
1108  # Return cached result
1109  if ( $this->ip !== null ) {
1110  return $this->ip;
1111  }
1112 
1113  # collect the originating ips
1114  $ip = $this->getRawIP();
1115 
1116  # Append XFF
1117  $forwardedFor = $this->getHeader( 'X-Forwarded-For' );
1118  if ( $forwardedFor !== false ) {
1119  $ipchain = array_map( 'trim', explode( ',', $forwardedFor ) );
1120  $ipchain = array_reverse( $ipchain );
1121  if ( $ip ) {
1122  array_unshift( $ipchain, $ip );
1123  }
1124 
1125  # Step through XFF list and find the last address in the list which is a
1126  # trusted server. Set $ip to the IP address given by that trusted server,
1127  # unless the address is not sensible (e.g. private). However, prefer private
1128  # IP addresses over proxy servers controlled by this site (more sensible).
1129  foreach ( $ipchain as $i => $curIP ) {
1130  // ignore 'unknown' value from Squid when 'forwarded_for off' and try next
1131  if ( $curIP === 'unknown' ) {
1132  continue;
1133  }
1134  $curIP = IP::sanitizeIP( IP::canonicalize( $curIP ) );
1135  if ( wfIsTrustedProxy( $curIP ) && isset( $ipchain[$i + 1] ) ) {
1136  if ( wfIsConfiguredProxy( $curIP ) || // bug 48919; treat IP as sane
1137  IP::isPublic( $ipchain[$i + 1] ) ||
1138  $wgUsePrivateIPs
1139  ) {
1140  $nextIP = IP::canonicalize( $ipchain[$i + 1] );
1141  if ( !$nextIP && wfIsConfiguredProxy( $ip ) ) {
1142  // We have not yet made it past CDN/proxy servers of this site,
1143  // so either they are misconfigured or there is some IP spoofing.
1144  throw new MWException( "Invalid IP given in XFF '$forwardedFor'." );
1145  }
1146  $ip = $nextIP;
1147  continue;
1148  }
1149  }
1150  break;
1151  }
1152  }
1153 
1154  # Allow extensions to improve our guess
1155  wfRunHooks( 'GetIP', array( &$ip ) );
1156 
1157  if ( !$ip ) {
1158  throw new MWException( "Unable to determine IP." );
1159  }
1161  wfDebug( "IP: $ip\n" );
1162  $this->ip = $ip;
1163  return $ip;
1164  }
1165 
1171  public function setIP( $ip ) {
1172  $this->ip = $ip;
1173  }
1174 }
1175 
1179 class WebRequestUpload {
1180  protected $request;
1181  protected $doesExist;
1182  protected $fileInfo;
1190  public function __construct( $request, $key ) {
1191  $this->request = $request;
1192  $this->doesExist = isset( $_FILES[$key] );
1193  if ( $this->doesExist ) {
1194  $this->fileInfo = $_FILES[$key];
1195  }
1196  }
1197 
1203  public function exists() {
1204  return $this->doesExist;
1205  }
1206 
1212  public function getName() {
1213  if ( !$this->exists() ) {
1214  return null;
1215  }
1216 
1217  global $wgContLang;
1218  $name = $this->fileInfo['name'];
1219 
1220  # Safari sends filenames in HTML-encoded Unicode form D...
1221  # Horrid and evil! Let's try to make some kind of sense of it.
1223  $name = $wgContLang->normalize( $name );
1224  wfDebug( __METHOD__ . ": {$this->fileInfo['name']} normalized to '$name'\n" );
1225  return $name;
1226  }
1227 
1233  public function getSize() {
1234  if ( !$this->exists() ) {
1235  return 0;
1236  }
1237 
1238  return $this->fileInfo['size'];
1239  }
1246  public function getTempName() {
1247  if ( !$this->exists() ) {
1248  return null;
1249  }
1250 
1251  return $this->fileInfo['tmp_name'];
1252  }
1253 
1260  public function getError() {
1261  if ( !$this->exists() ) {
1262  return 0; # UPLOAD_ERR_OK
1263  }
1264 
1265  return $this->fileInfo['error'];
1266  }
1267 
1274  public function isIniSizeOverflow() {
1275  if ( $this->getError() == UPLOAD_ERR_INI_SIZE ) {
1276  # PHP indicated that upload_max_filesize is exceeded
1277  return true;
1278  }
1279 
1280  $contentLength = $this->request->getHeader( 'CONTENT_LENGTH' );
1281  if ( $contentLength > wfShorthandToInteger( ini_get( 'post_max_size' ) ) ) {
1282  # post_max_size is exceeded
1283  return true;
1284  }
1285 
1286  return false;
1287  }
1288 }
1289 
1295 class FauxRequest extends WebRequest {
1296  private $wasPosted = false;
1297  private $session = array();
1298 
1307  public function __construct( $data = array(), $wasPosted = false, $session = null, $protocol = 'http' ) {
1308  if ( is_array( $data ) ) {
1309  $this->data = $data;
1310  } else {
1311  throw new MWException( "FauxRequest() got bogus data" );
1312  }
1314  if ( $session ) {
1315  $this->session = $session;
1316  }
1317  $this->protocol = $protocol;
1318  }
1319 
1324  private function notImplemented( $method ) {
1325  throw new MWException( "{$method}() not implemented" );
1326  }
1327 
1333  public function getText( $name, $default = '' ) {
1334  # Override; don't recode since we're using internal data
1335  return (string)$this->getVal( $name, $default );
1336  }
1337 
1341  public function getValues() {
1342  return $this->data;
1343  }
1344 
1348  public function getQueryValues() {
1349  if ( $this->wasPosted ) {
1350  return array();
1351  } else {
1352  return $this->data;
1353  }
1354  }
1356  public function getMethod() {
1357  return $this->wasPosted ? 'POST' : 'GET';
1358  }
1363  public function wasPosted() {
1364  return $this->wasPosted;
1365  }
1366 
1367  public function getCookie( $key, $prefix = null, $default = null ) {
1368  return $default;
1369  }
1370 
1371  public function checkSessionCookie() {
1372  return false;
1373  }
1374 
1375  public function getRequestURL() {
1376  $this->notImplemented( __METHOD__ );
1377  }
1378 
1379  public function getProtocol() {
1380  return $this->protocol;
1381  }
1382 
1387  public function getHeader( $name ) {
1388  $name = strtoupper( $name );
1389  return isset( $this->headers[$name] ) ? $this->headers[$name] : false;
1390  }
1391 
1396  public function setHeader( $name, $val ) {
1397  $name = strtoupper( $name );
1398  $this->headers[$name] = $val;
1399  }
1400 
1405  public function getSessionData( $key ) {
1406  if ( isset( $this->session[$key] ) ) {
1407  return $this->session[$key];
1408  }
1409  return null;
1410  }
1416  public function setSessionData( $key, $data ) {
1417  $this->session[$key] = $data;
1418  }
1423  public function getSessionArray() {
1424  return $this->session;
1425  }
1426 
1431  public function getRawQueryString() {
1432  return '';
1433  }
1434 
1439  public function getRawPostString() {
1440  return '';
1441  }
1447  public function getRawInput() {
1448  return '';
1449  }
1450 
1455  public function checkUrlExtension( $extWhitelist = array() ) {
1456  return true;
1457  }
1458 
1462  protected function getRawIP() {
1463  return '127.0.0.1';
1464  }
1465 }
1466 
1475 class DerivativeRequest extends FauxRequest {
1476  private $base;
1484  public function __construct( WebRequest $base, $data, $wasPosted = false ) {
1485  $this->base = $base;
1486  parent::__construct( $data, $wasPosted );
1487  }
1488 
1489  public function getCookie( $key, $prefix = null, $default = null ) {
1490  return $this->base->getCookie( $key, $prefix, $default );
1491  }
1492 
1493  public function checkSessionCookie() {
1494  return $this->base->checkSessionCookie();
1495  }
1496 
1497  public function getHeader( $name ) {
1498  return $this->base->getHeader( $name );
1499  }
1500 
1501  public function getAllHeaders() {
1502  return $this->base->getAllHeaders();
1503  }
1504 
1505  public function getSessionData( $key ) {
1506  return $this->base->getSessionData( $key );
1507  }
1508 
1509  public function setSessionData( $key, $data ) {
1510  $this->base->setSessionData( $key, $data );
1511  }
1512 
1513  public function getAcceptLang() {
1514  return $this->base->getAcceptLang();
1515  }
1516 
1517  public function getIP() {
1518  return $this->base->getIP();
1519  }
1520 
1521  public function getProtocol() {
1522  return $this->base->getProtocol();
1523  }
1524 }
WebRequest\checkSessionCookie
checkSessionCookie()
Returns true if there is a session cookie set.
Definition: WebRequest.php:666
WebRequest\initHeaders
initHeaders()
Initialise the header list.
Definition: WebRequest.php:890
DerivativeRequest
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
Definition: WebRequest.php:1455
PathRouter\add
add( $path, $params=array(), $options=array())
Add a new path pattern to the path router.
Definition: PathRouter.php:159
$wgUser
$wgUser
Definition: Setup.php:552
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: WebRequest.php:1275
WebRequest\getSessionData
getSessionData( $key)
Get data from $_SESSION.
Definition: WebRequest.php:944
WebRequest\fix_magic_quotes
& fix_magic_quotes(&$arr, $topLevel=true)
Recursively strips slashes from the given array; used for undoing the evil that is magic_quotes_gpc.
Definition: WebRequest.php:282
data
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
Definition: hooks.txt:6
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
$wgActionPaths
$wgActionPaths
Definition: img_auth.php:49
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
DerivativeRequest\getAllHeaders
getAllHeaders()
Get an array containing all request headers.
Definition: WebRequest.php:1481
WebRequest\escapeAppendQuery
escapeAppendQuery( $query)
HTML-safe version of appendQuery().
Definition: WebRequest.php:759
FauxRequest\getRawQueryString
getRawQueryString()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
Definition: WebRequest.php:1411
IP\combineHostAndPort
static combineHostAndPort( $host, $port, $defaultPort=false)
Given a host name and a port, combine them into host/port string like you might find in a URL.
Definition: IP.php:289
FauxRequest\getRawPostString
getRawPostString()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
Definition: WebRequest.php:1419
DerivativeRequest\setSessionData
setSessionData( $key, $data)
Definition: WebRequest.php:1489
FauxRequest\wasPosted
wasPosted()
Definition: WebRequest.php:1343
WebRequest\interpolateTitle
interpolateTitle()
Check for title, action, and/or variant data in the URL and interpolate it into the GET variables.
Definition: WebRequest.php:230
UtfNormal\cleanUp
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C,...
Definition: UtfNormal.php:79
WebRequest\checkMagicQuotes
checkMagicQuotes()
If magic_quotes_gpc option is on, run the global arrays through fix_magic_quotes to strip out the stu...
Definition: WebRequest.php:303
DerivativeRequest\getIP
getIP()
Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of...
Definition: WebRequest.php:1497
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1530
$wgCookiePrefix
if( $wgRCFilterByAge) if( $wgSkipSkin) if( $wgLocalInterwiki) if( $wgSharedPrefix===false) if(! $wgCookiePrefix) $wgCookiePrefix
Definition: Setup.php:286
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
FauxRequest\getRawInput
getRawInput()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
Definition: WebRequest.php:1427
WebRequest\getIntOrNull
getIntOrNull( $name)
Fetch an integer value from the input or return null if empty.
Definition: WebRequest.php:472
$limit
if( $sleep) $limit
Definition: importImages.php:99
WebRequest\getRawPostString
getRawPostString()
Return the contents of the POST with no decoding.
Definition: WebRequest.php:611
WebRequest\detectProtocol
static detectProtocol()
Detect the protocol from $_SERVER.
Definition: WebRequest.php:202
WebRequest\getGPCVal
getGPCVal( $arr, $name, $default)
Fetch a value from the given array or return $default if it's not set.
Definition: WebRequest.php:343
DerivativeRequest\getAcceptLang
getAcceptLang()
Parse the Accept-Language header sent by the client into an array.
Definition: WebRequest.php:1493
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
FauxRequest\checkSessionCookie
checkSessionCookie()
Returns true if there is a session cookie set.
Definition: WebRequest.php:1351
IEUrlExtension\areServerVarsBad
static areServerVarsBad( $vars, $extWhitelist=array())
Check a subset of $_SERVER (or the whole of $_SERVER if you like) to see if it indicates that the req...
Definition: IEUrlExtension.php:62
WebRequest\$headers
$headers
Definition: WebRequest.php:39
DerivativeRequest\checkSessionCookie
checkSessionCookie()
Returns true if there is a session cookie set.
Definition: WebRequest.php:1473
HttpError
Show an error that looks like an HTTP server error.
Definition: HttpError.php:28
FauxRequest\getSessionData
getSessionData( $key)
Definition: WebRequest.php:1385
WebRequest\__construct
__construct()
Definition: WebRequest.php:56
WebRequest\getRawQueryString
getRawQueryString()
Return the contents of the Query with no decoding.
Definition: WebRequest.php:601
WebRequest\getFileTempname
getFileTempname( $key)
Return the path to the temporary file where PHP has stored the upload.
Definition: WebRequest.php:830
title
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2703
WebRequest\getText
getText( $name, $default='')
Fetch a text string from the given array or return $default if it's not set.
Definition: WebRequest.php:545
WebRequest\$protocol
string $protocol
Cached URL protocol.
Definition: WebRequest.php:54
DerivativeRequest\getSessionData
getSessionData( $key)
Definition: WebRequest.php:1485
FauxRequest\getRawIP
getRawIP()
Definition: WebRequest.php:1442
FauxRequest\getProtocol
getProtocol()
Get the current URL protocol (http or https)
Definition: WebRequest.php:1359
WebRequest\getMethod
getMethod()
Get the HTTP method used for this request.
Definition: WebRequest.php:638
MWException
MediaWiki exception.
Definition: MWException.php:26
WebRequest\getFileName
getFileName( $key)
Return the original filename of the uploaded file, as reported by the submitting user agent.
Definition: WebRequest.php:857
WebRequest\appendQuery
appendQuery( $query)
Take an arbitrary query and rewrite the present URL to include it.
Definition: WebRequest.php:748
FauxRequest\setHeader
setHeader( $name, $val)
Definition: WebRequest.php:1376
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
WebRequest\setVal
setVal( $key, $value)
Set an arbitrary value into our get/post data.
Definition: WebRequest.php:393
FauxRequest\$session
$session
Definition: WebRequest.php:1277
WebRequest\getRawInput
getRawInput()
Return the raw request body, with no processing.
Definition: WebRequest.php:625
WebRequest\getUpload
getUpload( $key)
Return a WebRequestUpload object corresponding to the key.
Definition: WebRequest.php:868
WebRequest\getValues
getValues()
Extracts the given named values into an array.
Definition: WebRequest.php:559
WebRequest\getPathInfo
static getPathInfo( $want='all')
Extract relevant query arguments from the http request uri's path to be merged with the normal php pr...
Definition: WebRequest.php:82
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:270
DerivativeRequest\getProtocol
getProtocol()
Get the current URL protocol (http or https)
Definition: WebRequest.php:1501
WebRequest\getFullRequestURL
getFullRequestURL()
Return the request URI with the canonical service and hostname, path, and query string.
Definition: WebRequest.php:738
WebRequest\getArray
getArray( $name, $default=null)
Fetch an array from the input or return $default if it's not set.
Definition: WebRequest.php:424
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4010
WebRequest\$response
WebResponse $response
Lazy-init response object.
Definition: WebRequest.php:44
wfShorthandToInteger
wfShorthandToInteger( $string='')
Converts shorthand byte notation to integer form.
Definition: GlobalFunctions.php:3898
wfCgiToArray
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
Definition: GlobalFunctions.php:412
WebRequest\getFloat
getFloat( $name, $default=0)
Fetch a floating point value from the input or return $default if not set.
Definition: WebRequest.php:489
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
FauxRequest\getHeader
getHeader( $name)
Definition: WebRequest.php:1367
WebRequest\getAllHeaders
getAllHeaders()
Get an array containing all request headers.
Definition: WebRequest.php:917
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
WebRequest\getValueNames
getValueNames( $exclude=array())
Returns the names of all input values excluding those in $exclude.
Definition: WebRequest.php:581
$exclude
if(! $in) $exclude
Definition: UtfNormalGenerate.php:65
WebRequestUpload
Object to access the $_FILES array.
Definition: WebRequest.php:1159
FauxRequest\getText
getText( $name, $default='')
Definition: WebRequest.php:1313
DerivativeRequest\$base
$base
Definition: WebRequest.php:1456
WebRequest\appendQueryValue
appendQueryValue( $key, $value, $onlyquery=false)
Definition: WebRequest.php:769
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:188
WebRequest\normalizeUnicode
normalizeUnicode( $data)
Recursively normalizes UTF-8 strings in the given array.
Definition: WebRequest.php:323
FauxRequest\getQueryValues
getQueryValues()
Definition: WebRequest.php:1328
WebRequest\$data
$data
Definition: WebRequest.php:39
FauxRequest\checkUrlExtension
checkUrlExtension( $extWhitelist=array())
Definition: WebRequest.php:1435
WebRequest\getCheck
getCheck( $name)
Return true if the named value is set in the input, whatever that value is (even "0").
Definition: WebRequest.php:527
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:933
WebRequest\getProtocol
getProtocol()
Get the current URL protocol (http or https)
Definition: WebRequest.php:216
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
WebRequest\response
response()
Return a handle to WebResponse style object, for setting cookies, headers and other stuff,...
Definition: WebRequest.php:878
$matches
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
Definition: NoLocalSettings.php:33
$value
$value
Definition: styleTest.css.php:45
WebRequest\checkUrlExtension
checkUrlExtension( $extWhitelist=array())
Check if Internet Explorer will detect an incorrect cache extension in PATH_INFO or QUERY_STRING.
Definition: WebRequest.php:971
IP\splitHostAndPort
static splitHostAndPort( $both)
Given a host/port string, like one might find in the host part of a URL per RFC 2732,...
Definition: IP.php:240
some
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for some
Definition: design.txt:79
WebRequest\getLimitOffset
getLimitOffset( $deflimit=50, $optionname='rclimit')
Check for limit and offset parameters on the input, and return sensible defaults if not given.
Definition: WebRequest.php:799
WebRequest\getIntArray
getIntArray( $name, $default=null)
Fetch an array of integers, or return $default if it's not set.
Definition: WebRequest.php:443
FauxRequest\getCookie
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
Definition: WebRequest.php:1347
FauxRequest\getRequestURL
getRequestURL()
Return the path and query string portion of the request URI.
Definition: WebRequest.php:1355
off
Use of locking define a new flag for $wgAntiLockFlags which allows them to be turned off
Definition: database.txt:164
WebRequest\getCookie
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
Definition: WebRequest.php:678
WebRequest\$ip
String $ip
Cached client IP address.
Definition: WebRequest.php:49
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
Definition: WebRequest.php:38
$hash
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
Definition: hooks.txt:2697
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
FauxRequest\getMethod
getMethod()
Get the HTTP method used for this request.
Definition: WebRequest.php:1336
WebRequest\getUploadError
getUploadError( $key)
Return the upload error or 0.
Definition: WebRequest.php:841
$wgArticlePath
$wgArticlePath
Definition: img_auth.php:48
WebRequest\setSessionData
setSessionData( $key, $data)
Set session data.
Definition: WebRequest.php:957
FauxRequest\getSessionArray
getSessionArray()
Definition: WebRequest.php:1403
FauxRequest\$wasPosted
$wasPosted
Definition: WebRequest.php:1276
it
=Architecture==Two class hierarchies are used to provide the functionality associated with the different content models:*Content interface(and AbstractContent base class) define functionality that acts on the concrete content of a page, and *ContentHandler base class provides functionality specific to a content model, but not acting on concrete content. The most important function of ContentHandler is to act as a factory for the appropriate implementation of Content. These Content objects are to be used by MediaWiki everywhere, instead of passing page content around as text. All manipulation and analysis of page content must be done via the appropriate methods of the Content object. For each content model, a subclass of ContentHandler has to be registered with $wgContentHandlers. The ContentHandler object for a given content model can be obtained using ContentHandler::getForModelID($id). Also Title, WikiPage and Revision now have getContentHandler() methods for convenience. ContentHandler objects are singletons that provide functionality specific to the content type, but not directly acting on the content of some page. ContentHandler::makeEmptyContent() and ContentHandler::unserializeContent() can be used to create a Content object of the appropriate type. However, it is recommended to instead use WikiPage::getContent() resp. Revision::getContent() to get a page 's content as a Content object. These two methods should be the ONLY way in which page content is accessed. Another important function of ContentHandler objects is to define custom action handlers for a content model, see ContentHandler::getActionOverrides(). This is similar to what WikiPage::getActionOverrides() was already doing.==Serialization==With the ContentHandler facility, page content no longer has to be text based. Objects implementing the Content interface are used to represent and handle the content internally. For storage and data exchange, each content model supports at least one serialization format via ContentHandler::serializeContent($content). The list of supported formats for a given content model can be accessed using ContentHandler::getSupportedFormats(). Content serialization formats are identified using MIME type like strings. The following formats are built in:*text/x-wiki - wikitext *text/javascript - for js pages *text/css - for css pages *text/plain - for future use, e.g. with plain text messages. *text/html - for future use, e.g. with plain html messages. *application/vnd.php.serialized - for future use with the api and for extensions *application/json - for future use with the api, and for use by extensions *application/xml - for future use with the api, and for use by extensions In PHP, use the corresponding CONTENT_FORMAT_XXX constant. Note that when using the API to access page content, especially action=edit, action=parse and action=query &prop=revisions, the model and format of the content should always be handled explicitly. Without that information, interpretation of the provided content is not reliable. The same applies to XML dumps generated via maintenance/dumpBackup.php or Special:Export. Also note that the API will provide encapsulated, serialized content - so if the API was called with format=json, and contentformat is also json(or rather, application/json), the page content is represented as a string containing an escaped json structure. Extensions that use JSON to serialize some types of page content may provide specialized API modules that allow access to that content in a more natural form.==Compatibility==The ContentHandler facility is introduced in a way that should allow all existing code to keep functioning at least for pages that contain wikitext or other text based content. However, a number of functions and hooks have been deprecated in favor of new versions that are aware of the page 's content model, and will now generate warnings when used. Most importantly, the following functions have been deprecated:*Revisions::getText() and Revisions::getRawText() is deprecated in favor Revisions::getContent() *WikiPage::getText() is deprecated in favor WikiPage::getContent() Also, the old Article::getContent()(which returns text) is superceded by Article::getContentObject(). However, both methods should be avoided since they do not provide clean access to the page 's actual content. For instance, they may return a system message for non-existing pages. Use WikiPage::getContent() instead. Code that relies on a textual representation of the page content should eventually be rewritten. However, ContentHandler::getContentText() provides a stop-gap that can be used to get text for a page. Its behavior is controlled by $wgContentHandlerTextFallback it
Definition: contenthandler.txt:107
IEUrlExtension\fixUrlForIE6
static fixUrlForIE6( $url, $extWhitelist=array())
Returns a variant of $url which will pass isUrlExtensionBad() but has the same GET parameters,...
Definition: IEUrlExtension.php:141
WebRequest\doSecurityRedirect
doSecurityRedirect( $url)
Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in IE 6.
Definition: WebRequest.php:996
WebRequest\getVal
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it's not set.
Definition: WebRequest.php:374
FauxRequest\notImplemented
notImplemented( $method)
Definition: WebRequest.php:1304
WebRequest\getInt
getInt( $name, $default=0)
Fetch an integer value from the input or return $default if not set.
Definition: WebRequest.php:460
$path
$path
Definition: NoLocalSettings.php:35
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
WebRequest\detectServer
static detectServer()
Work out an appropriate URL prefix containing scheme and host, based on information detected from $_S...
Definition: WebRequest.php:165
FauxRequest\getValues
getValues()
Definition: WebRequest.php:1321
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
Sanitizer\decodeCharReferences
static decodeCharReferences( $text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string.
Definition: Sanitizer.php:1396
WebRequest\getHeader
getHeader( $name)
Get a request header, or false if it isn't set.
Definition: WebRequest.php:928
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
WebRequest\wasPosted
wasPosted()
Returns true if the present request was reached by a POST operation, false otherwise (GET,...
Definition: WebRequest.php:651
WebRequest\unsetVal
unsetVal( $key)
Unset an arbitrary value from our get/post data.
Definition: WebRequest.php:405
WebRequest\getRequestURL
getRequestURL()
Return the path and query string portion of the request URI.
Definition: WebRequest.php:693
WebRequest\extractTitle
static extractTitle( $path, $bases, $key=false)
URL rewriting function; tries to extract page title and, optionally, one other fixed parameter value ...
Definition: WebRequest.php:252
WebResponse
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...
Definition: WebResponse.php:28
WebRequest\getQueryValues
getQueryValues()
Get the values passed in the query string.
Definition: WebRequest.php:591
WebRequest\getFuzzyBool
getFuzzyBool( $name, $default=false)
Fetch a boolean value from the input or return $default if not set.
Definition: WebRequest.php:515
PathRouter
PathRouter class.
Definition: PathRouter.php:73
request
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LoginAuthenticateAudit' this hook is for auditing only etc create2 Corresponds to logging log_action database field and which is displayed in the UI similar to $comment this hook should only be used to add variables that depend on the current page request
Definition: hooks.txt:1632
headers
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add headers
Definition: design.txt:12
DerivativeRequest\getHeader
getHeader( $name)
Definition: WebRequest.php:1477
redirect
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second redirect
Definition: All_system_messages.txt:1267
Language
Internationalisation code.
Definition: Language.php:74
FauxRequest\setSessionData
setSessionData( $key, $data)
Definition: WebRequest.php:1396
WebRequest\getBool
getBool( $name, $default=false)
Fetch a boolean value from the input or return $default if not set.
Definition: WebRequest.php:502
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:497
$wgTitle
if(! $wgRequest->checkUrlExtension()) if(! $wgEnableAPI) $wgTitle
Definition: api.php:63
WebRequest\appendQueryArray
appendQueryArray( $array, $onlyquery=false)
Appends or replaces value of query variables.
Definition: WebRequest.php:781
wfArrayToCgi
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes two arrays as input, and returns a CGI-style string, e.g.
Definition: GlobalFunctions.php:367
DerivativeRequest\getCookie
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
Definition: WebRequest.php:1469