2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: pkwk14.php,v 1.6 2009/01/13 15:06:18 henoheno Exp $
4 // Copyright (C) 2009 PukiWiki Developers Team
5 // License: GPL v2 or (at your option) any later version
7 // PukiWiki administration script for CLI environment
10 # Name and Usage --------------------------------------------
11 define('PKWK_CLI_NAME', $argv[0]);
12 //define('PKWK_CLI_PATH', rtrim(getcwd(), '/\\'));
16 warn('Usage: PKWK_ROOT=path/to/pukiwiki php ' . PKWK_CLI_NAME);
20 # Safety ----------------------------------------------------
21 if (php_sapi_name() != 'cli') {
22 echo 'pkwk: Error: Seems not CLI';
26 # Error reporting -------------------------------------------
28 //error_reporting(0); // Nothing
29 //error_reporting(E_ERROR | E_PARSE); // Avoid E_WARNING, E_NOTICE, etc
30 error_reporting(E_ALL); // Debug purpose
32 # Common functions ------------------------------------------
33 function warn($string = ''){ fwrite(STDERR, $string . "\n"); }
34 function err( $string = ''){ warn($string); exit(1); }
36 function load_once($filepath)
38 if (strpos($filepath, ':') !== FALSE) {
39 err('load: Error: URL-like string');
42 require_once($filepath);
46 # Environment variables -------------------------------------
48 $env_default => array(
49 // ENVIRONMENT => DEFAULT
51 'PKWK_LIB_DIR', => 'lib',
52 'PKWK_PLUGIN_DIR', => 'plugin',
53 'PKWK_SKIN_DIR', => 'skin',
54 'PKWK_IMAGE_DIR', => 'image',
55 'PKWK_DATA_HOME' => '.',
58 foreach(array_keys($env_default as $key) {
59 if (isset($_ENV[$key])) {
60 $env_default[$key] = rtrim($_ENV[$key], '/\\') . '/';
65 // if (! file_exists($dirs[$key])) {
66 // err('Error: [' . $key . ] No such directory: ' . $dirs[$key]);
70 # Load libraries --------------------------------------------
72 define('LIB_DIR', $env['PKWK_ROOT'] . '/' . $env['PKWK_LIB_DIR'] . '/');
73 if (! file_exists(LIB_DIR)) {
74 err('Error: LIB_DIR not found: ' . LIB_DIR);
77 load_once(LIB_DIR . 'func.php');
78 load_once(LIB_DIR . 'file.php');
79 load_once(LIB_DIR . 'html.php');
80 load_once(LIB_DIR . 'backup.php');
82 load_once(LIB_DIR . 'convert_html.php');
83 load_once(LIB_DIR . 'make_link.php');
84 load_once(LIB_DIR . 'diff.php');
85 load_once(LIB_DIR . 'config.php');
86 load_once(LIB_DIR . 'link.php');
87 load_once(LIB_DIR . 'auth.php');
88 load_once(LIB_DIR . 'proxy.php');
89 if (! extension_loaded('mbstring')) {
90 load_once(LIB_DIR . 'mbstring.php');
93 load_once(LIB_DIR . 'mail.php');
94 load_once(LIB_DIR . 'spam.php');
97 # Default variables 2 ---------------------------------------
99 define('DATA_HOME', './');
101 // * pukiwiki.ini.php
104 if (! defined('LANG')) define('LANG', 'ja');
105 if (! defined('UI_LANG')) define('UI_LANG', LANG);
107 if (! defined('DATA_DIR')) define('DATA_DIR', DATA_HOME . 'wiki/' );
108 if (! defined('DIFF_DIR')) define('DIFF_DIR', DATA_HOME . 'diff/' );
109 if (! defined('BACKUP_DIR')) define('BACKUP_DIR', DATA_HOME . 'backup/' );
110 if (! defined('CACHE_DIR')) define('CACHE_DIR', DATA_HOME . 'cache/' );
111 if (! defined('UPLOAD_DIR')) define('UPLOAD_DIR', DATA_HOME . 'attach/' );
112 if (! defined('COUNTER_DIR')) define('COUNTER_DIR', DATA_HOME . 'counter/' );
113 if (! defined('PLUGIN_DIR')) define('PLUGIN_DIR', DATA_HOME . 'plugin/' );
115 if (! defined('SKIN_DIR')) define('SKIN_DIR', 'skin/');
116 if (! defined('IMAGE_DIR')) define('IMAGE_DIR', 'image/');
120 if (! defined('ZONE')) define('ZONE', 'JST');
121 if (! defined('ZONETIME')) define('ZONETIME', 9 * 3600); // JST = GMT + 9
124 if (! defined('ZONE')) define('ZONE', 'GMT');
125 if (! defined('ZONETIME')) define('ZONETIME', 0);
129 //$script = 'http://localhost.example.org/';
131 # Load libraries --------------------------------------------
132 // init.php now fails
134 // Load *.ini.php files and init PukiWiki
135 //require(LIB_DIR . 'init.php');
138 # Start -----------------------------------------------------