MediaWiki  1.23.6
7zip.inc
Go to the documentation of this file.
1 <?php
35  protected $stream;
36 
37  private function stripPath( $path ) {
38  $prefix = 'mediawiki.compress.7z://';
39  return substr( $path, strlen( $prefix ) );
40  }
41 
42  function stream_open( $path, $mode, $options, &$opened_path ) {
43  if ( $mode[0] == 'r' ) {
44  $options = 'e -bd -so';
45  } elseif ( $mode[0] == 'w' ) {
46  $options = 'a -bd -si';
47  } else {
48  return false;
49  }
50  $arg = wfEscapeShellArg( $this->stripPath( $path ) );
51  $command = "7za $options $arg";
52  if ( !wfIsWindows() ) {
53  // Suppress the stupid messages on stderr
54  $command .= ' 2>/dev/null';
55  }
56  $this->stream = popen( $command, $mode[0] ); // popen() doesn't like two-letter modes
57  return ( $this->stream !== false );
58  }
59 
60  function url_stat( $path, $flags ) {
61  return stat( $this->stripPath( $path ) );
62  }
63 
64  // This is all so lame; there should be a default class we can extend
65 
66  function stream_close() {
67  return fclose( $this->stream );
68  }
69 
70  function stream_flush() {
71  return fflush( $this->stream );
72  }
73 
74  function stream_read( $count ) {
75  return fread( $this->stream, $count );
76  }
77 
78  function stream_write( $data ) {
79  return fwrite( $this->stream, $data );
80  }
81 
82  function stream_tell() {
83  return ftell( $this->stream );
84  }
85 
86  function stream_eof() {
87  return feof( $this->stream );
88  }
89 
90  function stream_seek( $offset, $whence ) {
91  return fseek( $this->stream, $offset, $whence );
92  }
93 }
94 stream_wrapper_register( 'mediawiki.compress.7z', 'SevenZipStream' );
SevenZipStream\$stream
$stream
Definition: 7zip.inc:35
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
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
SevenZipStream\stream_write
stream_write( $data)
Definition: 7zip.inc:78
SevenZipStream\stream_read
stream_read( $count)
Definition: 7zip.inc:74
SevenZipStream\stream_seek
stream_seek( $offset, $whence)
Definition: 7zip.inc:90
SevenZipStream\stripPath
stripPath( $path)
Definition: 7zip.inc:37
SevenZipStream\stream_open
stream_open( $path, $mode, $options, &$opened_path)
Definition: 7zip.inc:42
SevenZipStream\url_stat
url_stat( $path, $flags)
Definition: 7zip.inc:60
SevenZipStream\stream_close
stream_close()
Definition: 7zip.inc:66
$options
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 & $options
Definition: hooks.txt:1530
$command
$command
Definition: cdb.php:63
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:2524
wfEscapeShellArg
wfEscapeShellArg()
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell,...
Definition: GlobalFunctions.php:2705
$count
$count
Definition: UtfNormalTest2.php:96
$path
$path
Definition: NoLocalSettings.php:35
SevenZipStream
Stream wrapper around 7za filter program.
Definition: 7zip.inc:34
SevenZipStream\stream_tell
stream_tell()
Definition: 7zip.inc:82
SevenZipStream\stream_flush
stream_flush()
Definition: 7zip.inc:70
SevenZipStream\stream_eof
stream_eof()
Definition: 7zip.inc:86