2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: pkwk14.php,v 1.5 2009/01/12 04:19:12 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');
40 } else if (! file_exists($filepath)) {
41 err('load: Error: No such file: ' . $filepath);
44 require_once($filepath);
48 # Default variables -----------------------------------------
51 if (isset($_ENV['PKWK_ROOT'])) {
52 $pkwk_root = rtrim($_ENV['PKWK_ROOT'], '/\\') . '/';
53 if (! file_exists($pkwk_root)) {
54 err('Error: [PKWK_ROOT] No such directory: ' . $pkwk_root);
59 define('PKWK_ROOT', $pkwk_root);
63 # Load libraries --------------------------------------------
65 define('LIB_DIR', PKWK_ROOT . 'lib' . '/');
66 if (! file_exists(LIB_DIR)) {
67 err('Error: LIB_DIR not found: ' . LIB_DIR);
70 load_once(LIB_DIR . 'func.php');
71 load_once(LIB_DIR . 'file.php');
72 load_once(LIB_DIR . 'html.php');
73 load_once(LIB_DIR . 'backup.php');
75 load_once(LIB_DIR . 'convert_html.php');
76 load_once(LIB_DIR . 'make_link.php');
77 load_once(LIB_DIR . 'diff.php');
78 load_once(LIB_DIR . 'config.php');
79 load_once(LIB_DIR . 'link.php');
80 load_once(LIB_DIR . 'auth.php');
81 load_once(LIB_DIR . 'proxy.php');
82 if (! extension_loaded('mbstring')) {
83 load_once(LIB_DIR . 'mbstring.php');
86 load_once(LIB_DIR . 'mail.php');
87 load_once(LIB_DIR . 'spam.php');
90 # Default variables 2 ---------------------------------------
92 define('DATA_HOME', './');
97 if (! defined('LANG')) define('LANG', 'ja');
98 if (! defined('UI_LANG')) define('UI_LANG', LANG);
100 if (! defined('DATA_DIR')) define('DATA_DIR', DATA_HOME . 'wiki/' );
101 if (! defined('DIFF_DIR')) define('DIFF_DIR', DATA_HOME . 'diff/' );
102 if (! defined('BACKUP_DIR')) define('BACKUP_DIR', DATA_HOME . 'backup/' );
103 if (! defined('CACHE_DIR')) define('CACHE_DIR', DATA_HOME . 'cache/' );
104 if (! defined('UPLOAD_DIR')) define('UPLOAD_DIR', DATA_HOME . 'attach/' );
105 if (! defined('COUNTER_DIR')) define('COUNTER_DIR', DATA_HOME . 'counter/' );
106 if (! defined('PLUGIN_DIR')) define('PLUGIN_DIR', DATA_HOME . 'plugin/' );
108 if (! defined('SKIN_DIR')) define('SKIN_DIR', 'skin/');
109 if (! defined('IMAGE_DIR')) define('IMAGE_DIR', 'image/');
113 if (! defined('ZONE')) define('ZONE', 'JST');
114 if (! defined('ZONETIME')) define('ZONETIME', 9 * 3600); // JST = GMT + 9
117 if (! defined('ZONE')) define('ZONE', 'GMT');
118 if (! defined('ZONETIME')) define('ZONETIME', 0);
122 //$script = 'http://localhost.example.org/';
124 # Load libraries --------------------------------------------
125 // init.php now fails
127 // Load *.ini.php files and init PukiWiki
128 //require(LIB_DIR . 'init.php');
131 # Start -----------------------------------------------------