X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=4536b8f766585564cbc0cefc6ad55a98709fc870;hb=eb2f439768d34254964e798d9523211ba8ea2f5f;hp=0e596530c3339bd9651ed67e5cc930c3f752fef1;hpb=d9f412635fa4057a4b3b4d174b798c28dc54b038;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 0e596530c3..4536b8f766 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1656,6 +1656,8 @@ function wfClientAcceptsGzip( $force = false ) { } /** + * @deprecated since 1.28, use Parser::escapeWikitext() directly + * * Escapes the given text so that it may be output using addWikiText() * without any linking, formatting, etc. making its way through. This * is achieved by substituting certain characters with HTML entities. @@ -1665,47 +1667,8 @@ function wfClientAcceptsGzip( $force = false ) { * @return string */ function wfEscapeWikiText( $text ) { - global $wgEnableMagicLinks; - static $repl = null, $repl2 = null; - if ( $repl === null ) { - $repl = [ - '"' => '"', '&' => '&', "'" => ''', '<' => '<', - '=' => '=', '>' => '>', '[' => '[', ']' => ']', - '{' => '{', '|' => '|', '}' => '}', ';' => ';', - "\n#" => "\n#", "\r#" => "\r#", - "\n*" => "\n*", "\r*" => "\r*", - "\n:" => "\n:", "\r:" => "\r:", - "\n " => "\n ", "\r " => "\r ", - "\n\n" => "\n ", "\r\n" => " \n", - "\n\r" => "\n ", "\r\r" => "\r ", - "\n\t" => "\n ", "\r\t" => "\r ", // "\n\t\n" is treated like "\n\n" - "\n----" => "\n----", "\r----" => "\r----", - '__' => '__', '://' => '://', - ]; - - $magicLinks = array_keys( array_filter( $wgEnableMagicLinks ) ); - // We have to catch everything "\s" matches in PCRE - foreach ( $magicLinks as $magic ) { - $repl["$magic "] = "$magic "; - $repl["$magic\t"] = "$magic "; - $repl["$magic\r"] = "$magic "; - $repl["$magic\n"] = "$magic "; - $repl["$magic\f"] = "$magic "; - } - - // And handle protocols that don't use "://" - global $wgUrlProtocols; - $repl2 = []; - foreach ( $wgUrlProtocols as $prot ) { - if ( substr( $prot, -1 ) === ':' ) { - $repl2[] = preg_quote( substr( $prot, 0, -1 ), '/' ); - } - } - $repl2 = $repl2 ? '/\b(' . implode( '|', $repl2 ) . '):/i' : '/^(?!)/'; - } - $text = substr( strtr( "\n$text", $repl ), 1 ); - $text = preg_replace( $repl2, '$1:', $text ); - return $text; + global $wgParser; + return $wgParser->escapeWikitext( $text ); } /** @@ -1992,56 +1955,7 @@ function wfRestoreWarnings() { # Autodetect, convert and provide timestamps of various types -/** - * Unix time - the number of seconds since 1970-01-01 00:00:00 UTC - */ -define( 'TS_UNIX', 0 ); - -/** - * MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS) - */ -define( 'TS_MW', 1 ); - -/** - * MySQL DATETIME (YYYY-MM-DD HH:MM:SS) - */ -define( 'TS_DB', 2 ); - -/** - * RFC 2822 format, for E-mail and HTTP headers - */ -define( 'TS_RFC2822', 3 ); - -/** - * ISO 8601 format with no timezone: 1986-02-09T20:00:00Z - * - * This is used by Special:Export - */ -define( 'TS_ISO_8601', 4 ); - -/** - * An Exif timestamp (YYYY:MM:DD HH:MM:SS) - * - * @see http://exif.org/Exif2-2.PDF The Exif 2.2 spec, see page 28 for the - * DateTime tag and page 36 for the DateTimeOriginal and - * DateTimeDigitized tags. - */ -define( 'TS_EXIF', 5 ); - -/** - * Oracle format time. - */ -define( 'TS_ORACLE', 6 ); - -/** - * Postgres format time. - */ -define( 'TS_POSTGRES', 7 ); - -/** - * ISO 8601 basic format with no timezone: 19860209T200000Z. This is used by ResourceLoader - */ -define( 'TS_ISO_8601_BASIC', 9 ); +require_once __DIR__ . '/libs/time/defines.php'; /** * Get a timestamp string in one of various formats @@ -2052,13 +1966,11 @@ define( 'TS_ISO_8601_BASIC', 9 ); * @return string|bool String / false The same date in the format specified in $outputtype or false */ function wfTimestamp( $outputtype = TS_UNIX, $ts = 0 ) { - try { - $timestamp = new MWTimestamp( $ts ); - return $timestamp->getTimestamp( $outputtype ); - } catch ( TimestampException $e ) { + $ret = MWTimestamp::convert( $outputtype, $ts ); + if ( $ret === false ) { wfDebug( "wfTimestamp() fed bogus time value: TYPE=$outputtype; VALUE=$ts\n" ); - return false; } + return $ret; } /** @@ -2084,7 +1996,7 @@ function wfTimestampOrNull( $outputtype = TS_UNIX, $ts = null ) { */ function wfTimestampNow() { # return NOW - return wfTimestamp( TS_MW, time() ); + return MWTimestamp::now( TS_MW ); } /** @@ -2127,35 +2039,7 @@ function wfTempDir() { return $wgTmpDirectory; } - $tmpDir = array_map( "getenv", [ 'TMPDIR', 'TMP', 'TEMP' ] ); - $tmpDir[] = sys_get_temp_dir(); - $tmpDir[] = ini_get( 'upload_tmp_dir' ); - - foreach ( $tmpDir as $tmp ) { - if ( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) { - return $tmp; - } - } - - /** - * PHP on Windows will detect C:\Windows\Temp as not writable even though PHP can write to it - * so create a directory within that called 'mwtmp' with a suffix of the user running the - * current process. - * The user is included as if various scripts are run by different users they will likely - * not be able to access each others temporary files. - */ - if ( wfIsWindows() ) { - $tmp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mwtmp' . '-' . get_current_user(); - if ( !file_exists( $tmp ) ) { - mkdir( $tmp ); - } - if ( file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) { - return $tmp; - } - } - - throw new MWException( 'No writable temporary directory could be found. ' . - 'Please set $wgTmpDirectory to a writable directory.' ); + return TempFSFile::getUsableTempDirectory(); } /**