MediaWiki  1.23.2
cdb.php
Go to the documentation of this file.
1 <?php
26 require_once __DIR__ . '/commandLine.inc';
27 
28 function cdbShowHelp( $command ) {
29  $commandList = array(
30  'load' => 'load a cdb file for reading',
31  'get' => 'get a value for a key',
32  'exit' => 'exit cdb',
33  'quit' => 'exit cdb',
34  'help' => 'help about a command',
35  );
36  if ( !$command ) {
37  $command = 'fullhelp';
38  }
39  if ( $command === 'fullhelp' ) {
40  $max_cmd_len = max( array_map( 'strlen', array_keys( $commandList ) ) );
41  foreach ( $commandList as $cmd => $desc ) {
42  printf( "%-{$max_cmd_len}s: %s\n", $cmd, $desc );
43  }
44  } elseif ( isset( $commandList[$command] ) ) {
45  print "$command: $commandList[$command]\n";
46  } else {
47  print "$command: command does not exist or no help for it\n";
48  }
49 }
50 
51 do {
52  $bad = false;
53  $showhelp = false;
54  $quit = false;
55  static $fileHandle = false;
56 
58  if ( $line === false ) {
59  exit;
60  }
61 
62  $args = explode( ' ', $line );
63  $command = array_shift( $args );
64 
65  // process command
66  switch ( $command ) {
67  case 'help':
68  // show an help message
69  cdbShowHelp( array_shift( $args ) );
70  break;
71  case 'load':
72  if ( !isset( $args[0] ) ) {
73  print "Need a filename there buddy\n";
74  break;
75  }
76  $file = $args[0];
77  print "Loading cdb file $file...";
78  try {
80  } catch ( CdbException $e ) {}
81 
82  if ( !$fileHandle ) {
83  print "not a cdb file or unable to read it\n";
84  } else {
85  print "ok\n";
86  }
87  break;
88  case 'get':
89  if ( !$fileHandle ) {
90  print "Need to load a cdb file first\n";
91  break;
92  }
93  if ( !isset( $args[0] ) ) {
94  print "Need to specify a key, Luke\n";
95  break;
96  }
97  try {
98  $res = $fileHandle->get( $args[0] );
99  } catch ( CdbException $e ) {
100  print "Unable to read key from file\n";
101  break;
102  }
103  if ( $res === false ) {
104  print "No such key/value pair\n";
105  } elseif ( is_string( $res ) ) {
106  print "$res\n";
107  } else {
108  var_dump( $res );
109  }
110  break;
111  case 'quit':
112  case 'exit':
113  $quit = true;
114  break;
115 
116  default:
117  $bad = true;
118  } // switch() end
119 
120  if ( $bad ) {
121  if ( $command ) {
122  print "Bad command\n";
123  }
124  } else {
125  if ( function_exists( 'readline_add_history' ) ) {
126  readline_add_history( $line );
127  }
128  }
129 } while ( !$quit );
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
$showhelp
$showhelp
Definition: cdb.php:53
$fileHandle
static $fileHandle
Definition: cdb.php:55
Maintenance\readconsole
static readconsole( $prompt='> ')
Prompt the console for input.
Definition: Maintenance.php:1134
$quit
$quit
Definition: cdb.php:54
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$command
$command
Definition: cdb.php:63
$line
$line
Definition: cdb.php:57
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
$args
if( $line===false) $args
Definition: cdb.php:62
CdbReader\open
static open( $fileName)
Open a file and return a subclass instance.
Definition: Cdb.php:41
CdbException
Exception for Cdb errors.
Definition: Cdb.php:159
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
$e
if( $useReadline) $e
Definition: eval.php:66
$res
$res
Definition: database.txt:21
cdbShowHelp
cdbShowHelp( $command)
Definition: cdb.php:28