OSDN Git Service

CLI_PATH -> PKWK_CLI_PATH
[pukiwiki/pukiwiki_devel.git] / bin / pkwk14.php
1 <?php
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
6 //
7 // PukiWiki administration script for CLI environment
8
9
10 # Name and Usage --------------------------------------------
11 define('PKWK_CLI_NAME', $argv[0]);
12 //define('PKWK_CLI_PATH', rtrim(getcwd(), '/\\'));
13
14 function usage()
15 {
16         warn('Usage: PKWK_ROOT=path/to/pukiwiki php ' . PKWK_CLI_NAME);
17         exit(1);
18 }
19
20 # Safety ----------------------------------------------------
21 if (php_sapi_name() != 'cli') {
22         echo 'pkwk: Error: Seems not CLI';
23         exit;
24 }
25
26 # Error reporting -------------------------------------------
27
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
31
32 # Common functions ------------------------------------------
33 function warn($string = ''){ fwrite(STDERR, $string . "\n"); }
34 function err( $string = ''){ warn($string); exit(1);  }
35
36 function load_once($filepath)
37 {
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);
42         }
43
44         require_once($filepath);
45 }
46
47
48 # Default variables -----------------------------------------
49
50 // PKWK_ROOT
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);
55         }
56 } else {
57         $pkwk_root = './';
58 }
59 define('PKWK_ROOT', $pkwk_root);
60 unset($pkwk_root);
61
62
63 # Load libraries --------------------------------------------
64
65 define('LIB_DIR', PKWK_ROOT . 'lib' . '/');
66 if (! file_exists(LIB_DIR)) {
67         err('Error: LIB_DIR not found: ' . LIB_DIR);
68 }
69
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');
74
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');
84 }
85
86 load_once(LIB_DIR . 'mail.php');
87 load_once(LIB_DIR . 'spam.php');
88
89
90 # Default variables 2 ---------------------------------------
91
92 define('DATA_HOME', './');
93 // Where to
94 //   * pukiwiki.ini.php
95 //   * xxx_DIR
96
97 if (! defined('LANG'))    define('LANG',    'ja');
98 if (! defined('UI_LANG')) define('UI_LANG', LANG);
99
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/'   );
107
108 if (! defined('SKIN_DIR')) define('SKIN_DIR', 'skin/');
109 if (! defined('IMAGE_DIR')) define('IMAGE_DIR', 'image/');
110
111 switch (LANG) {
112 case 'ja':
113         if (! defined('ZONE'))     define('ZONE', 'JST');
114         if (! defined('ZONETIME')) define('ZONETIME', 9 * 3600); // JST = GMT + 9
115         break;
116 default  :
117         if (! defined('ZONE'))     define('ZONE', 'GMT');
118         if (! defined('ZONETIME')) define('ZONETIME', 0);
119         break;
120 }
121
122 //$script = 'http://localhost.example.org/';
123
124 # Load libraries --------------------------------------------
125 // init.php now fails
126
127 // Load *.ini.php files and init PukiWiki
128 //require(LIB_DIR . 'init.php');
129
130
131 # Start -----------------------------------------------------
132
133 usage();
134
135 ?>