<?php
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/
function magicquotessuck( &$a )
{
if ( is_array( $a ) )
{
foreach ( $a as $k => $v )
{
if ( is_array( $v ) )
{
magicquotessuck( $a[$k] );
}
else
{
$a[$k] = stripslashes( $v );
}
}
}
}
error_reporting( E_ALL ^ E_NOTICE );
if ( ini_get( "zlib.output_compression" ) )
{
ob_start( );
}
else
{
ob_start( "ob_gzhandler" );
}
define( "XML_HTMLSAX3", dirname( __FILE__ )."/lib/HTMLSax3/" );
if ( !isset( $_REQUEST ) )
{
exit( "\$_REQUEST[] not found. WackoWiki requires PHP 4.1.0 or higher!" );
}
set_magic_quotes_runtime( 0 );
if ( get_magic_quotes_gpc( ) )
{
magicquotessuck( &$GLOBALS['GLOBALS']['_POST'] );
magicquotessuck( &$GLOBALS['GLOBALS']['_GET'] );
magicquotessuck( &$GLOBALS['GLOBALS']['_COOKIE'] );
magicquotessuck( &$GLOBALS['GLOBALS']['_SERVER'] );
magicquotessuck( &$GLOBALS['GLOBALS']['_REQUEST'] );
}
if ( strstr( $_SERVER['SERVER_SOFTWARE'], "IIS" ) )
{
$GLOBALS['GLOBALS']['_SERVER']['REQUEST_URI'] = $_SERVER['PATH_INFO'];
}
include( "crosssite.php" );
include( "dist/default_config.php" );
if ( !( $configfile = getenv( "WAKKA_CONFIG" ) ) )
{
$configfile = $crossSiteConfigFile;
}
if ( @file_exists( $configfile ) )
{
include( $configfile );
}
$wakkaConfigLocation = $configfile;
$wakkaConfig = array_merge( $wakkaDefaultConfig, ( array )$wakkaConfig );
if ( @file_exists( "locked" ) )
{
$lines = file( "locked" );
$lockpw = trim( $lines[0] );
if ( isset( $_SERVER['PHP_AUTH_USER'] ) )
{
if ( !( $_SERVER['PHP_AUTH_USER'] == "admin" ) && !( $_SERVER['PHP_AUTH_PW'] == $lockpw ) )
{
$ask = 1;
}
}
else
{
$ask = 1;
}
if ( $ask )
{
header( "WWW-Authenticate: Basic realm=\"".$wakkaConfig['wakka_name']." Install/Upgrade Interface\"" );
header( "HTTP/1.0 401 Unauthorized" );
echo "This site is currently being upgraded. Please try again later.";
exit( );
}
}
if ( $wakkaConfig['wacko_version'] != WACKO_VERSION )
{
if ( !$_REQUEST['installAction'] || !strstr( $_SERVER['SERVER_SOFTWARE'], "IIS" ) )
{
$req = $_SERVER['REQUEST_URI'];
if ( $req[strlen( $req ) - 1] != "/" && strstr( $req, ".php" ) != ".php" )
{
header( "Location: http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."/" );
exit( );
}
}
if ( !( $installAction = trim( $_REQUEST['installAction'] ) ) )
{
$installAction = "lang";
}
include( "setup/header.php" );
if ( @file_exists( "setup/".$installAction.".php" ) )
{
include( "setup/".$installAction.".php" );
}
else
{
echo "<em>Invalid action</em>";
}
include( "setup/footer.php" );
exit( );
}
if ( !isset( $wakkaConfig['root_url'] ) )
{
$wakkaConfig['root_url'] = preg_replace( "#/[^/]*\$#", "/", $wakkaConfig['base_url'] );
}
$wakkaConfig['theme_url'] = $wakkaConfig['root_url']."themes/".$wakkaConfig['theme']."/";
if ( !isset( $wakkaConfig['user_table'] ) || !$wakkaConfig['user_table'] )
{
$wakkaConfig['user_table'] = $wakkaConfig['table_prefix']."users";
}
if ( isset( $_SERVER['PATH_INFO'] ) && function_exists( "virtual" ) )
{
$request = $_SERVER['PATH_INFO'];
}
else
{
$request = $_REQUEST['wakka'];
}
if ( stristr( $_SERVER['SERVER_SOFTWARE'], "Apache/1" ) && stristr( $_SERVER['SERVER_SOFTWARE'], "Win32" ) && $wakkaConfig['rewrite_mode'] )
{
$dir = str_replace( "http://".$_SERVER['SERVER_NAME'].( $_SERVER['SERVER_PORT'] != 80 ? ":".$_SERVER['SERVER_PORT'] : "" ), "", $wakkaConfig['base_url'] );
$request = preg_replace( "+^".preg_quote( rtrim( $dir, "/" ) )."+i", "", $_SERVER['REDIRECT_URL'] );
}
$request = preg_replace( "/^\\//", "", $request );
$method = "";
$userMagicCode = "";
$p = strpos( $request, "_" );
if ( $p === 0 )
{
$req_t = explode( "/", $request, 2 );
$request = $req_t[1];
$userMagicCode = substr( $req_t[0], 1 );
}
$p = strpos( $request, "/" );
if ( $p === FALSE )
{
$p = strlen( $request ) + 1;
}
$handler = substr( $request, 0, $p );
if ( !ereg( "^[A-Za-z0-9]+\$", $handler ) )
{
$handler = "page";
}
else if ( !file_exists( $wakkaConfig['handler_path']."/".$handler ) )
{
$handler = "page";
}
else
{
$request = substr( $request, $p - strlen( $request ) + 1 );
}
$p = strrpos( $request, "/" );
if ( $p === FALSE )
{
$page = $request;
}
else
{
$page = substr( $request, 0, $p );
$m1 = $method = strtolower( substr( $request, $p - strlen( $request ) + 1 ) );
if ( !file_exists( ( $wakkaConfig['common_path'] != "" ? $wakkaConfig['common_path']."/" : "" ).$wakkaConfig['handler_path']."/".$handler."/".$method.".php" ) )
{
$page = $request;
$method = "";
}
else if ( preg_match( "/^(.*?)\\/(".$wakkaConfig['standart_handlers'].")(\$|\\/(.*)\$)/i", $page, $match ) )
{
$page = $match[1];
$method = $match[2];
}
}
if ( !isset( $wakkaConfig['db_layer'] ) )
{
$wakkaConfig['db_layer'] = "mysql";
}
$dbfile = ( $wakkaConfig['common_path'] != "" ? $wakkaConfig['common_path']."/" : "" )."db/".$wakkaConfig['db_layer'].".php";
if ( @file_exists( $dbfile ) )
{
include( $dbfile );
}
else
{
exit( "Error loading DBAL." );
}
require( "xcbase.php" );
require( "classes/qsminikernel.php" );
if ( $wakkaConfig['subdomain_processing'] == "1" )
{
include( "sites/".$crossSiteName."/subdomains/sub".( $crossSiteSubdomain == "" ? "" : ".".$crossSiteSubdomain ).".php" );
}
else
{
include( "handlers/".$handler.".init.php" );
}
?>