| 46 | | if(!defined('ERROR_WAKKA_LIBRARY_MISSING')) define ('ERROR_WAKKA_LIBRARY_MISSING','The necessary file "libs/Wakka.class.php" could not be found. To run Wikka, please make sure the file exists and is placed in the right directory!'); |
| 47 | | if(!defined('ERROR_WRONG_PHP_VERSION')) define ('ERROR_WRONG_PHP_VERSION', '$_REQUEST[] not found. Wakka requires PHP 4.1.0 or higher!'); |
| 48 | | if(!defined('ERROR_SETUP_FILE_MISSING')) define ('ERROR_SETUP_FILE_MISSING', 'A file of the installer/ upgrader was not found. Please install Wikka again!'); |
| 49 | | if(!defined('ERROR_SETUP_HEADER_MISSING')) define ('ERROR_SETUP_HEADER_MISSING', 'The file "setup/header.php" was not found. Please install Wikka again!'); |
| 50 | | if(!defined('ERROR_SETUP_FOOTER_MISSING')) define ('ERROR_SETUP_FOOTER_MISSING', 'The file "setup/footer.php" was not found. Please install Wikka again!'); |
| 51 | | if(!defined('ERROR_NO_DB_ACCESS')) define ('ERROR_NO_DB_ACCESS', 'The wiki is currently unavailable. <br /><br />Error: Unable to connect to the MySQL database.'); |
| 52 | | if(!defined('PAGE_GENERATION_TIME')) define ('PAGE_GENERATION_TIME', 'Page was generated in %.4f seconds'); // %.4f - generation time in seconds with 4 digits after the dot |
| 53 | | if(!defined('WIKI_UPGRADE_NOTICE')) define ('WIKI_UPGRADE_NOTICE', 'This site is currently being upgraded. Please try again later.'); |
| | 49 | /**#@+ |
| | 50 | * Internationalization constant. |
| | 51 | */ |
| | 52 | if (!defined('ERROR_WAKKA_LIBRARY_MISSING')) define('ERROR_WAKKA_LIBRARY_MISSING','The necessary file "libs/Wakka.class.php" could not be found. To run Wikka, please make sure the file exists and is placed in the right directory!'); |
| | 53 | if (!defined('ERROR_WRONG_PHP_VERSION')) define('ERROR_WRONG_PHP_VERSION', '$_REQUEST[] not found. Wakka requires PHP 4.1.0 or higher!'); |
| | 54 | if (!defined('ERROR_MYSQL_SUPPORT_MISSING')) define('ERROR_MYSQL_SUPPORT_MISSING', 'PHP can\'t find MySQL support but Wikka requires MySQL. Please check the output of <tt>phpinfo()</tt> in a php document for MySQL support: it needs to be compiled into PHP, the module itself needs to be present in the expected location, <strong>and</strong> php.ini needs to have it enabled.<br />Also note that you cannot have <tt>mysqli</tt> and <tt>mysql</tt> support both enabled at the same time.<br />Please double-check all of these things, restart your webserver after any fixes, and then try again!'); |
| | 55 | if (!defined('ERROR_SETUP_FILE_MISSING')) define('ERROR_SETUP_FILE_MISSING', 'A file of the installer/ upgrader was not found. Please install Wikka again!'); |
| | 56 | if (!defined('ERROR_SETUP_HEADER_MISSING')) define('ERROR_SETUP_HEADER_MISSING', 'The file "setup/header.php" was not found. Please install Wikka again!'); |
| | 57 | if (!defined('ERROR_SETUP_FOOTER_MISSING')) define('ERROR_SETUP_FOOTER_MISSING', 'The file "setup/footer.php" was not found. Please install Wikka again!'); |
| | 58 | if (!defined('ERROR_NO_DB_ACCESS')) define('ERROR_NO_DB_ACCESS', 'The wiki is currently unavailable. <br /><br />Error: Unable to connect to the MySQL database.'); |
| | 59 | if (!defined('PAGE_GENERATION_TIME')) define('PAGE_GENERATION_TIME', 'Page was generated in %.4f seconds'); // %.4f - generation time in seconds with 4 digits after the dot |
| | 60 | if (!defined('WIKI_UPGRADE_NOTICE')) define('WIKI_UPGRADE_NOTICE', 'This site is currently being upgraded. Please try again later.'); |
| | 61 | /**#@-*/ |
| | 62 | /** |
| | 63 | * Defines the current Wikka version. Do not change the version number or you will have problems upgrading. |
| | 64 | */ |
| | 65 | if (!defined('WAKKA_VERSION')) define('WAKKA_VERSION', '1.1.6.4'); |
| | 66 | |
| | 67 | /**#@+ |
| | 68 | * Simple constant. May be made a configurable value. |
| | 69 | */ |
| | 70 | /** |
| | 71 | * Defines the default cookie name. |
| | 72 | */ |
| | 73 | if (!defined('BASIC_COOKIE_NAME')) define('BASIC_COOKIE_NAME', 'Wikkawiki'); |
| | 74 | /** |
| | 75 | * Length to use for generated part of id attribute. |
| | 76 | */ |
| | 77 | define('ID_LENGTH',10); // @@@ maybe make length configurable |
| | 78 | /**#@-*/ |
| | 79 | |
| | 80 | // Sanity checks - we die if these conditions aren't met |
| | 81 | |
| | 82 | // stupid version check |
| | 83 | if (!isset($_REQUEST)) |
| | 84 | { |
| | 85 | die(ERROR_WRONG_PHP_VERSION); // TODO replace with php version_compare |
| | 86 | } |
| | 87 | // MySQL needs to be installed and available |
| | 88 | // @@@ message could be refined by detecting detect OS (mention module name) and maybe server name |
| | 89 | if (!function_exists('mysql_connect')) |
| | 90 | { |
| | 91 | die(ERROR_MYSQL_SUPPORT_MISSING); |
| | 92 | } |
| | 93 | |
| | 94 | /** |
| | 95 | * Include main library if it exists. |
| | 96 | * @see libs/Wakka.class.php |
| | 97 | */ |
| | 98 | if (file_exists('libs/Wakka.class.php')) |
| | 99 | { |
| | 100 | require_once('libs/Wakka.class.php'); |
| | 101 | } |
| | 102 | else |
| | 103 | { |
| | 104 | die(ERROR_WAKKA_LIBRARY_MISSING); |
| | 105 | } |
| | 106 | |
| | 107 | // Sanity checks OK - start rolling.... |
| 56 | | |
| 57 | | //error_reporting(E_ALL); |
| 58 | | error_reporting (E_ALL ^ E_NOTICE); |
| 59 | | |
| 60 | | /** |
| 61 | | * Defines the current Wikka version. Do not change the version number or you will have problems upgrading. |
| 62 | | */ |
| 63 | | if (!defined('WAKKA_VERSION')) define('WAKKA_VERSION', '1.1.6.4'); |
| 64 | | /** |
| 65 | | * Defines the default cookie name. |
| 66 | | */ |
| 67 | | if(!defined('BASIC_COOKIE_NAME')) define('BASIC_COOKIE_NAME', 'Wikkawiki'); |
| | 110 | $tstart = getmicrotime(); |
| | 111 | |
| | 112 | set_magic_quotes_runtime(0); |
| | 113 | if (get_magic_quotes_gpc()) |
| | 114 | { |
| | 115 | magicQuotesWorkaround($_POST); |
| | 116 | magicQuotesWorkaround($_GET); |
| | 117 | magicQuotesWorkaround($_COOKIE); |
| | 118 | } |
| | 119 | |
| | 120 | /** |
| | 121 | * Default configuration. |
| | 122 | */ |
| | 123 | // attempt to derive base URL fragments and whether rewrite mode is enabled (#438) |
| | 124 | $t_domain = $_SERVER['SERVER_NAME']; |
| | 125 | $t_port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''; |
| | 126 | $t_request = $_SERVER['REQUEST_URI']; |
| | 127 | |
| | 128 | if (preg_match('@\.php$@', $t_request) && !preg_match('@wikka\.php$@', $t_request)) |
| | 129 | { |
| | 130 | // handle "overridden" redirect from index.php |
| | 131 | $t_request = preg_replace('@/[^.]+\.php@', '/wikka.php', $t_request); // handle "overridden" redirect from index.php |
| | 132 | } |
| | 133 | |
| | 134 | if ( !preg_match('@wakka=@',$_SERVER['REQUEST_URI']) && isset($_SERVER['QUERY_STRING']) && preg_match('@wakka=@',$_SERVER['QUERY_STRING'])) |
| | 135 | { |
| | 136 | // looks like we got a rewritten request via .htaccess |
| | 137 | // remove 'wikka.php' and request (page name) from 'request' part: should not be part of base_url! |
| | 138 | $query_part = preg_replace('@wakka=@', '', $_SERVER['QUERY_STRING']); |
| | 139 | $t_request = preg_replace('@'.preg_quote('wikka.php').'@', '', $t_request); |
| | 140 | $t_request = preg_replace('@'.preg_quote($query_part).'@', '', $t_request); |
| | 141 | $t_query = ''; |
| | 142 | $t_rewrite_mode = 1; |
| | 143 | } |
| | 144 | else |
| | 145 | { |
| | 146 | // no rewritten request apparent |
| | 147 | $t_query = '?wakka='; |
| | 148 | $t_rewrite_mode = 0; |
| | 149 | } |
| | 150 | $wakkaDefaultConfig = array( |
| | 151 | 'mysql_host' => 'localhost', |
| | 152 | 'mysql_database' => 'wikka', |
| | 153 | 'mysql_user' => 'wikka', |
| | 154 | 'table_prefix' => 'wikka_', |
| | 155 | |
| | 156 | 'root_page' => 'HomePage', |
| | 157 | 'wakka_name' => 'MyWikkaSite', |
| | 158 | # 'base_url' => 'http://'.$_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '').$_SERVER['REQUEST_URI'].(preg_match('/'.preg_quote('wikka.php').'$/', $_SERVER['REQUEST_URI']) ? '?wakka=' : ''), |
| | 159 | # 'rewrite_mode' => (preg_match('/'.preg_quote('wikka.php').'$/', $_SERVER['REQUEST_URI']) ? '0' : '1'), |
| | 160 | 'base_url' => 'http://'.$t_domain.$t_port.$t_request.$t_query, |
| | 161 | 'rewrite_mode' => $t_rewrite_mode, |
| | 162 | 'wiki_suffix' => '@wikka', |
| | 163 | |
| | 164 | 'action_path' => 'actions', |
| | 165 | 'handler_path' => 'handlers', |
| | 166 | 'gui_editor' => '1', |
| | 167 | 'stylesheet' => 'wikka.css', |
| | 168 | |
| | 169 | // formatter and code highlighting paths |
| | 170 | 'wikka_formatter_path' => 'formatters', # (location of Wikka formatter - REQUIRED) |
| | 171 | 'wikka_highlighters_path' => 'formatters', # (location of Wikka code highlighters - REQUIRED) |
| | 172 | 'geshi_path' => '3rdparty/plugins/geshi', # (location of GeSHi package) |
| | 173 | 'geshi_languages_path' => '3rdparty/plugins/geshi/geshi', # (location of GeSHi language highlighting files) |
| | 174 | |
| | 175 | 'header_action' => 'header', |
| | 176 | 'footer_action' => 'footer', |
| | 177 | |
| | 178 | 'navigation_links' => '[[CategoryCategory Categories]] :: PageIndex :: RecentChanges :: RecentlyCommented :: [[UserSettings Login/Register]]', |
| | 179 | 'logged_in_navigation_links' => '[[CategoryCategory Categories]] :: PageIndex :: RecentChanges :: RecentlyCommented :: [[UserSettings Change settings/Logout]]', |
| | 180 | |
| | 181 | 'referrers_purge_time' => '30', |
| | 182 | 'pages_purge_time' => '0', |
| | 183 | 'xml_recent_changes' => '10', |
| | 184 | 'hide_comments' => '0', |
| | 185 | 'require_edit_note' => '0', # edit note optional (0, default), edit note required (1) edit note disabled (2) |
| | 186 | 'anony_delete_own_comments' => '1', |
| | 187 | 'public_sysinfo' => '0', # enable or disable public display of system information in SysInfo |
| | 188 | 'double_doublequote_html' => 'safe', |
| | 189 | 'external_link_tail' => '<span class="exttail">∞</span>', |
| | 190 | 'sql_debugging' => '0', |
| | 191 | 'admin_users' => '', |
| | 192 | 'admin_email' => '', |
| | 193 | 'upload_path' => 'uploads', |
| | 194 | 'mime_types' => 'mime_types.txt', |
| | 195 | |
| | 196 | // code hilighting with GeSHi |
| | 197 | 'geshi_header' => 'div', # 'div' (default) or 'pre' to surround code block |
| | 198 | 'geshi_line_numbers' => '1', # disable line numbers (0), or enable normal (1) or fancy line numbers (2) |
| | 199 | 'geshi_tab_width' => '4', # set tab width |
| | 200 | 'grabcode_button' => '1', # allow code block downloading |
| | 201 | |
| | 202 | 'wikiping_server' => '', |
| | 203 | |
| | 204 | 'default_write_acl' => '+', |
| | 205 | 'default_read_acl' => '*', |
| | 206 | 'default_comment_acl' => '*', |
| | 207 | ); |
| | 208 | |
| | 209 | // load config |
| | 210 | $wakkaConfig = array(); |
| | 211 | if (file_exists('wakka.config.php')) rename('wakka.config.php', 'wikka.config.php"'); // upgrade from Wakka |
| | 212 | #if (!$configfile = GetEnv("WAKKA_CONFIG")) $configfile = "wikka.config.php"; |
| | 213 | if (defined('WAKKA_CONFIG')) // use a define instead of GetEnv [SEC] |
| | 214 | { |
| | 215 | $configfile = WAKKA_CONFIG; |
| | 216 | } |
| | 217 | else |
| | 218 | { |
| | 219 | $configfile = 'wikka.config.php'; |
| | 220 | } |
| | 221 | if (file_exists($configfile)) include($configfile); |
| | 222 | |
| | 223 | $wakkaConfigLocation = $configfile; |
| | 224 | $wakkaConfig = array_merge($wakkaDefaultConfig, $wakkaConfig); // merge defaults with config from file |
| | 225 | |
| | 226 | /** |
| | 227 | * Check for locking. |
| | 228 | */ |
| | 229 | if (file_exists('locked')) |
| | 230 | { |
| | 231 | // read password from lockfile |
| | 232 | $lines = file("locked"); |
| | 233 | $lockpw = trim($lines[0]); |
| | 234 | |
| | 235 | // is authentification given? |
| | 236 | if (isset($_SERVER["PHP_AUTH_USER"])) { |
| | 237 | if (!(($_SERVER["PHP_AUTH_USER"] == "admin") && ($_SERVER["PHP_AUTH_PW"] == $lockpw))) { |
| | 238 | $ask = 1; |
| | 239 | } |
| | 240 | } else { |
| | 241 | $ask = 1; |
| | 242 | } |
| | 243 | |
| | 244 | if ($ask) { |
| | 245 | header("WWW-Authenticate: Basic realm=\"".$wakkaConfig["wakka_name"]." Install/Upgrade Interface\""); |
| | 246 | header("HTTP/1.0 401 Unauthorized"); |
| | 247 | print WIKI_UPGRADE_NOTICE; |
| | 248 | exit; |
| | 249 | } |
| | 250 | } |
| | 251 | |
| | 252 | /** |
| | 253 | * Compare versions, start installer if necessary. |
| | 254 | */ |
| | 255 | if (!isset($wakkaConfig['wakka_version'])) $wakkaConfig['wakka_version'] = 0; |
| | 256 | if ($wakkaConfig['wakka_version'] !== WAKKA_VERSION) |
| | 257 | { |
| | 258 | /** |
| | 259 | * Start installer. |
| | 260 | * |
| | 261 | * Data entered by the user is submitted in $_POST, next action for the |
| | 262 | * installer (which will receive this data) is passed as a $_GET parameter! |
| | 263 | */ |
| | 264 | $installAction = 'default'; |
| | 265 | #if (isset($_REQUEST['installAction'])) $installAction = trim($_REQUEST['installAction']); |
| | 266 | if (isset($_GET['installAction'])) $installAction = trim($_GET['installAction']); #312 |
| | 267 | if (file_exists('setup'.DIRECTORY_SEPARATOR.'header.php')) include('setup'.DIRECTORY_SEPARATOR.'header.php'); else print '<em>'.ERROR_SETUP_HEADER_MISSING.'</em>'; #89 |
| | 268 | if (file_exists('setup'.DIRECTORY_SEPARATOR.$installAction.'.php')) include('setup'.DIRECTORY_SEPARATOR.$installAction.'.php'); else print '<em>'.ERROR_SETUP_FILE_MISSING.'</em>'; #89 |
| | 269 | if (file_exists('setup'.DIRECTORY_SEPARATOR.'footer.php')) include('setup'.DIRECTORY_SEPARATOR.'footer.php'); else print '<em>'.ERROR_SETUP_FOOTER_MISSING.'</em>'; #89 |
| | 270 | exit; |
| | 271 | } |
| | 272 | |
| | 273 | /** |
| | 274 | * Start session. |
| | 275 | */ |
| | 276 | session_name(md5(BASIC_COOKIE_NAME.$wakkaConfig['wiki_suffix'])); |
| | 277 | session_start(); |
| | 278 | |
| | 279 | // fetch wakka location |
| | 280 | /** |
| | 281 | * Fetch wakka location (requested page + parameters) |
| | 282 | * |
| | 283 | * @todo files action uses POST, everything else uses GET #312 |
| | 284 | */ |
| | 285 | #$wakka = $_REQUEST["wakka"]; |
| | 286 | $wakka = $_GET['wakka']; #312 |
| | 287 | |
| | 288 | /** |
| | 289 | * Remove leading slash. |
| | 290 | */ |
| | 291 | $wakka = preg_replace("/^\//", "", $wakka); |
| | 292 | |
| | 293 | /** |
| | 294 | * Split into page/method. |
| | 295 | * |
| | 296 | * Note this splits at the FIRST / so $method may contain one or more slashes; |
| | 297 | * this is not allowed, and ultimately handled in the Method() method. [SEC] |
| | 298 | */ |
| | 299 | if (preg_match("#^(.+?)/(.*)$#", $wakka, $matches)) list(, $page, $method) = $matches; |
| | 300 | else if (preg_match("#^(.*)$#", $wakka, $matches)) list(, $page) = $matches; |
| | 301 | //Fix lowercase mod_rewrite bug: URL rewriting makes pagename lowercase. #135 |
| | 302 | if ((strtolower($page) == $page) && (isset($_SERVER['REQUEST_URI']))) #38 |
| | 303 | { |
| | 304 | $pattern = preg_quote($page, '/'); |
| | 305 | if (preg_match("/($pattern)/i", urldecode($_SERVER['REQUEST_URI']), $match_url)) |
| | 306 | { |
| | 307 | $page = $match_url[1]; |
| | 308 | } |
| | 309 | } |
| | 310 | |
| | 311 | /** |
| | 312 | * Create Wakka object |
| | 313 | */ |
| | 314 | $wakka =& new Wakka($wakkaConfig); |
| | 315 | |
| | 316 | /** |
| | 317 | * Check for database access. |
| | 318 | */ |
| | 319 | if (!$wakka->dblink) |
| | 320 | { |
| | 321 | echo '<em class="error">'.ERROR_NO_DB_ACCESS.'</em>'; |
| | 322 | exit; |
| | 323 | } |
| | 324 | |
| | 325 | |
| | 326 | /** |
| | 327 | * Run the engine. |
| | 328 | */ |
| | 329 | if (!isset($method)) $method=''; |
| | 330 | $wakka->Run($page, $method); |
| | 331 | if (!preg_match("/(xml|raw|mm|grabcode)$/", $method)) |
| | 332 | { |
| | 333 | $tend = getmicrotime(); |
| | 334 | //calculate the difference |
| | 335 | $totaltime = ($tend - $tstart); |
| | 336 | //output result |
| | 337 | print '<div class="smallprint">'.sprintf(PAGE_GENERATION_TIME, $totaltime)."</div>\n</body>\n</html>"; |
| | 338 | } |
| | 339 | |
| | 340 | $content = ob_get_contents(); |
| | 341 | /** |
| | 342 | * Use gzip compression if possible. |
| | 343 | */ |
| | 344 | if ( isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr ($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) #38 |
| | 345 | { |
| | 346 | // Tell the browser the content is compressed with gzip |
| | 347 | header ("Content-Encoding: gzip"); |
| | 348 | $page_output = gzencode($content); |
| | 349 | $page_length = strlen($page_output); |
| | 350 | } else { |
| | 351 | $page_output = $content; |
| | 352 | $page_length = strlen($page_output); |
| | 353 | } |
| | 354 | |
| | 355 | // header("Cache-Control: pre-check=0"); |
| | 356 | header("Cache-Control: no-cache"); |
| | 357 | // header("Pragma: "); |
| | 358 | // header("Expires: "); |
| | 359 | |
| | 360 | $etag = md5($content); |
| | 361 | header('ETag: '.$etag); |
| | 362 | |
| | 363 | header('Content-Length: '.$page_length); |
| | 364 | ob_end_clean(); |
| | 365 | |
| | 366 | /** |
| | 367 | * Output the page. |
| | 368 | */ |
| | 369 | echo $page_output; |
| | 370 | |
| | 371 | |
| | 372 | // ---------------------------------------------- |
| | 373 | // Utility and compatibility functions |
| | 374 | // ---------------------------------------------- |
| 120 | | set_magic_quotes_runtime(0); |
| 121 | | if (get_magic_quotes_gpc()) |
| 122 | | { |
| 123 | | magicQuotesWorkaround($_POST); |
| 124 | | magicQuotesWorkaround($_GET); |
| 125 | | magicQuotesWorkaround($_COOKIE); |
| 126 | | } |
| 127 | | |
| 128 | | /** |
| 129 | | * Default configuration. |
| 130 | | */ |
| 131 | | // attempt to derive base URL fragments and whether rewrite mode is enabled (#438) |
| 132 | | $t_domain = $_SERVER['SERVER_NAME']; |
| 133 | | $t_port = $_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''; |
| 134 | | $t_request = $_SERVER['REQUEST_URI']; |
| 135 | | if (preg_match('@\.php$@', $t_request) && !preg_match('@wikka\.php$@', $t_request)) |
| 136 | | { |
| 137 | | $t_request = preg_replace('@/[^.]+\.php@', '/wikka.php', $t_request); // handle "overridden" redirect from index.php (or plain wrong file name!) |
| 138 | | } |
| 139 | | if ( !preg_match('@wakka=@',$_SERVER['REQUEST_URI']) && isset($_SERVER['QUERY_STRING']) && preg_match('@wakka=@',$_SERVER['QUERY_STRING'])) |
| 140 | | { |
| 141 | | // looks like we got a rewritten request via .htaccess |
| 142 | | $t_query = ''; |
| 143 | | $t_request = preg_replace('@'.preg_quote('wikka.php').'@', '', $t_request); |
| 144 | | $t_rewrite_mode = 1; |
| 145 | | } |
| 146 | | else |
| 147 | | { |
| 148 | | // no rewritten request apparent |
| 149 | | $t_query = '?wakka='; |
| 150 | | $t_rewrite_mode = 0; |
| 151 | | } |
| 152 | | $wakkaDefaultConfig = array( |
| 153 | | 'mysql_host' => 'localhost', |
| 154 | | 'mysql_database' => 'wikka', |
| 155 | | 'mysql_user' => 'wikka', |
| 156 | | 'table_prefix' => 'wikka_', |
| 157 | | |
| 158 | | 'root_page' => 'HomePage', |
| 159 | | 'wakka_name' => 'MyWikkaSite', |
| 160 | | # 'base_url' => 'http://'.$_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '').$_SERVER['REQUEST_URI'].(preg_match('/'.preg_quote('wikka.php').'$/', $_SERVER['REQUEST_URI']) ? '?wakka=' : ''), |
| 161 | | # 'rewrite_mode' => (preg_match('/'.preg_quote('wikka.php').'$/', $_SERVER['REQUEST_URI']) ? '0' : '1'), |
| 162 | | 'base_url' => 'http://'.$t_domain.$t_port.$t_request.$t_query, |
| 163 | | 'rewrite_mode' => $t_rewrite_mode, |
| 164 | | 'wiki_suffix' => '@wikka', |
| 165 | | |
| 166 | | 'action_path' => 'actions', |
| 167 | | 'handler_path' => 'handlers', |
| 168 | | 'gui_editor' => '1', |
| 169 | | 'stylesheet' => 'wikka.css', |
| 170 | | |
| 171 | | // formatter and code highlighting paths |
| 172 | | 'wikka_formatter_path' => 'formatters', # (location of Wikka formatter - REQUIRED) |
| 173 | | 'wikka_highlighters_path' => 'formatters', # (location of Wikka code highlighters - REQUIRED) |
| 174 | | 'geshi_path' => '3rdparty/plugins/geshi', # (location of GeSHi package) |
| 175 | | 'geshi_languages_path' => '3rdparty/plugins/geshi/geshi', # (location of GeSHi language highlighting files) |
| 176 | | |
| 177 | | 'header_action' => 'header', |
| 178 | | 'footer_action' => 'footer', |
| 179 | | |
| 180 | | 'navigation_links' => '[[CategoryCategory Categories]] :: PageIndex :: RecentChanges :: RecentlyCommented :: [[UserSettings Login/Register]]', |
| 181 | | 'logged_in_navigation_links' => '[[CategoryCategory Categories]] :: PageIndex :: RecentChanges :: RecentlyCommented :: [[UserSettings Change settings/Logout]]', |
| 182 | | |
| 183 | | 'referrers_purge_time' => '30', |
| 184 | | 'pages_purge_time' => '0', |
| 185 | | 'xml_recent_changes' => '10', |
| 186 | | 'hide_comments' => '0', |
| 187 | | 'require_edit_note' => '0', # edit note optional (0, default), edit note required (1) edit note disabled (2) |
| 188 | | 'anony_delete_own_comments' => '1', |
| 189 | | 'public_sysinfo' => '0', # enable or disable public display of system information in SysInfo |
| 190 | | 'double_doublequote_html' => 'safe', |
| 191 | | 'external_link_tail' => '<span class="exttail">∞</span>', |
| 192 | | 'sql_debugging' => '0', |
| 193 | | 'admin_users' => '', |
| 194 | | 'admin_email' => '', |
| 195 | | 'upload_path' => 'uploads', |
| 196 | | 'mime_types' => 'mime_types.txt', |
| 197 | | |
| 198 | | // code hilighting with GeSHi |
| 199 | | 'geshi_header' => 'div', # 'div' (default) or 'pre' to surround code block |
| 200 | | 'geshi_line_numbers' => '1', # disable line numbers (0), or enable normal (1) or fancy line numbers (2) |
| 201 | | 'geshi_tab_width' => '4', # set tab width |
| 202 | | 'grabcode_button' => '1', # allow code block downloading |
| 203 | | |
| 204 | | 'wikiping_server' => '', |
| 205 | | |
| 206 | | 'default_write_acl' => '+', |
| 207 | | 'default_read_acl' => '*', |
| 208 | | 'default_comment_acl' => '*'); |
| 209 | | |
| 210 | | // load config |
| 211 | | $wakkaConfig = array(); |
| 212 | | if (file_exists("wakka.config.php")) rename("wakka.config.php", "wikka.config.php"); |
| 213 | | #if (!$configfile = GetEnv("WAKKA_CONFIG")) $configfile = "wikka.config.php"; |
| 214 | | if (defined('WAKKA_CONFIG')) // use a define instead of GetEnv [SEC] |
| 215 | | { |
| 216 | | $configfile = WAKKA_CONFIG; |
| 217 | | } |
| 218 | | else |
| 219 | | { |
| 220 | | $configfile = 'wikka.config.php'; |
| 221 | | } |
| 222 | | if (file_exists($configfile)) include($configfile); |
| 223 | | |
| 224 | | $wakkaConfigLocation = $configfile; |
| 225 | | $wakkaConfig = array_merge($wakkaDefaultConfig, $wakkaConfig); |
| 226 | | |
| 227 | | /** |
| 228 | | * Check for locking. |
| 229 | | */ |
| 230 | | if (file_exists('locked')) |
| 231 | | { |
| 232 | | // read password from lockfile |
| 233 | | $lines = file("locked"); |
| 234 | | $lockpw = trim($lines[0]); |
| 235 | | |
| 236 | | // is authentification given? |
| 237 | | if (isset($_SERVER["PHP_AUTH_USER"])) { |
| 238 | | if (!(($_SERVER["PHP_AUTH_USER"] == "admin") && ($_SERVER["PHP_AUTH_PW"] == $lockpw))) { |
| 239 | | $ask = 1; |
| 240 | | } |
| 241 | | } else { |
| 242 | | $ask = 1; |
| 243 | | } |
| 244 | | |
| 245 | | if ($ask) { |
| 246 | | header("WWW-Authenticate: Basic realm=\"".$wakkaConfig["wakka_name"]." Install/Upgrade Interface\""); |
| 247 | | header("HTTP/1.0 401 Unauthorized"); |
| 248 | | print WIKI_UPGRADE_NOTICE; |
| 249 | | exit; |
| 250 | | } |
| 251 | | } |
| 252 | | |
| 253 | | /** |
| 254 | | * Compare versions, start installer if necessary. |
| 255 | | */ |
| 256 | | if (!isset($wakkaConfig["wakka_version"])) $wakkaConfig["wakka_version"] = 0; |
| 257 | | if ($wakkaConfig["wakka_version"] !== WAKKA_VERSION) |
| 258 | | { |
| 259 | | /** |
| 260 | | * Start installer. |
| 261 | | * |
| 262 | | * Data entered by the user is submitted in $_POST, next action for the |
| 263 | | * installer (which will receive this data) is passed as a $_GET parameter! |
| 264 | | */ |
| 265 | | $installAction = 'default'; |
| 266 | | #if (isset($_REQUEST['installAction'])) $installAction = trim($_REQUEST['installAction']); |
| 267 | | if (isset($_GET['installAction'])) $installAction = trim($_GET['installAction']); #312 |
| 268 | | if (file_exists('setup'.DIRECTORY_SEPARATOR.'header.php')) include('setup'.DIRECTORY_SEPARATOR.'header.php'); else print '<em>'.ERROR_SETUP_HEADER_MISSING.'</em>'; #89 |
| 269 | | if (file_exists('setup'.DIRECTORY_SEPARATOR.$installAction.'.php')) include('setup'.DIRECTORY_SEPARATOR.$installAction.'.php'); else print '<em>'.ERROR_SETUP_FILE_MISSING.'</em>'; #89 |
| 270 | | if (file_exists('setup'.DIRECTORY_SEPARATOR.'footer.php')) include('setup'.DIRECTORY_SEPARATOR.'footer.php'); else print '<em>'.ERROR_SETUP_FOOTER_MISSING.'</em>'; #89 |
| 271 | | exit; |
| 272 | | } |
| 273 | | |
| 274 | | /** |
| 275 | | * Start session. |
| 276 | | */ |
| 277 | | session_name(md5(BASIC_COOKIE_NAME.$wakkaConfig['wiki_suffix'])); |
| 278 | | session_start(); |
| 279 | | |
| 280 | | // fetch wakka location |
| 281 | | /** |
| 282 | | * Fetch wakka location (requested page + parameters) |
| 283 | | * |
| 284 | | * @todo files action uses POST, everything else uses GET #312 |
| 285 | | */ |
| 286 | | #$wakka = $_REQUEST["wakka"]; |
| 287 | | $wakka = $_GET['wakka']; #312 |
| 288 | | |
| 289 | | /** |
| 290 | | * Remove leading slash. |
| 291 | | */ |
| 292 | | $wakka = preg_replace("/^\//", "", $wakka); |
| 293 | | |
| 294 | | /** |
| 295 | | * Split into page/method. |
| 296 | | * |
| 297 | | * Note this splits at the FIRST / so $method may contain one or more slashes; |
| 298 | | * this is not allowed, and ultimately handled in the Method() method. [SEC] |
| 299 | | */ |
| 300 | | if (preg_match("#^(.+?)/(.*)$#", $wakka, $matches)) list(, $page, $method) = $matches; |
| 301 | | else if (preg_match("#^(.*)$#", $wakka, $matches)) list(, $page) = $matches; |
| 302 | | //Fix lowercase mod_rewrite bug: URL rewriting makes pagename lowercase. #135 |
| 303 | | if ((strtolower($page) == $page) && (isset($_SERVER['REQUEST_URI']))) #38 |
| 304 | | { |
| 305 | | $pattern = preg_quote($page, '/'); |
| 306 | | if (preg_match("/($pattern)/i", urldecode($_SERVER['REQUEST_URI']), $match_url)) |
| 307 | | { |
| 308 | | $page = $match_url[1]; |
| 309 | | } |
| 310 | | } |
| 311 | | |
| 312 | | /** |
| 313 | | * Create Wakka object |
| 314 | | */ |
| 315 | | $wakka =& new Wakka($wakkaConfig); |
| 316 | | |
| 317 | | /** |
| 318 | | * Check for database access. |
| 319 | | */ |
| 320 | | if (!$wakka->dblink) |
| 321 | | { |
| 322 | | echo '<em class="error">'.ERROR_NO_DB_ACCESS.'</em>'; |
| 323 | | exit; |
| 324 | | } |
| 325 | | |
| 326 | | |
| 327 | | /** |
| 328 | | * Run the engine. |
| 329 | | */ |
| 330 | | if (!isset($method)) $method=''; |
| 331 | | $wakka->Run($page, $method); |
| 332 | | if (!preg_match("/(xml|raw|mm|grabcode)$/", $method)) |
| 333 | | { |
| 334 | | $tend = getmicrotime(); |
| 335 | | //calculate the difference |
| 336 | | $totaltime = ($tend - $tstart); |
| 337 | | //output result |
| 338 | | print '<div class="smallprint">'.sprintf(PAGE_GENERATION_TIME, $totaltime)."</div>\n</body>\n</html>"; |
| 339 | | } |
| 340 | | |
| 341 | | $content = ob_get_contents(); |
| 342 | | /** |
| 343 | | * Use gzip compression if possible. |
| 344 | | */ |
| 345 | | if ( isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr ($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) #38 |
| 346 | | { |
| 347 | | // Tell the browser the content is compressed with gzip |
| 348 | | header ("Content-Encoding: gzip"); |
| 349 | | $page_output = gzencode($content); |
| 350 | | $page_length = strlen($page_output); |
| 351 | | } else { |
| 352 | | $page_output = $content; |
| 353 | | $page_length = strlen($page_output); |
| 354 | | } |
| 355 | | |
| 356 | | // header("Cache-Control: pre-check=0"); |
| 357 | | header("Cache-Control: no-cache"); |
| 358 | | // header("Pragma: "); |
| 359 | | // header("Expires: "); |
| 360 | | |
| 361 | | $etag = md5($content); |
| 362 | | header('ETag: '.$etag); |
| 363 | | |
| 364 | | header('Content-Length: '.$page_length); |
| 365 | | ob_end_clean(); |
| 366 | | |
| 367 | | /** |
| 368 | | * Output the page. |
| 369 | | */ |
| 370 | | echo $page_output; |
| | 415 | |