<?php

require_once str_replace('\\\\', '/', dirname(__FILE__)) . '/../class/config.class.php';
require_once str_replace('\\\\', '/', dirname(__FILE__)) . '/../class/util.class.php';
// sets physical filesystem directory of web site root
// if calculation fails (usually if web server is not apache) set this manually
SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', str_replace("\\", "/", SpawVars::getServerVar("DOCUMENT_ROOT")));
if (!ereg('/$', SpawConfig::getStaticConfigValue('DOCUMENT_ROOT'))) {
    SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', SpawConfig::getStaticConfigValue('DOCUMENT_ROOT') . '/');
}
// sets physical filesystem directory where spaw files reside
// should work fine most of the time but if it fails set SPAW_ROOT manually by providing correct path
SpawConfig::setStaticConfigItem('SPAW_ROOT', str_replace("\\", "/", realpath(dirname(__FILE__) . "/..") . '/'));
// sets virtual path to the spaw directory on the server
// if calculation fails set this manually
SpawConfig::setStaticConfigItem('SPAW_DIR', '/' . str_replace(SpawConfig::getStaticConfigValue("DOCUMENT_ROOT"), '', SpawConfig::getStaticConfigValue("SPAW_ROOT")));
/*
// semi-automatic path calculation
// comment the above settings of DOCUMENT_ROOT, SPAW_ROOT and SPAW_DIR
// and use this block if the above fails.
// set SPAW_DIR manually. If you access demo page by http://domain.com/spaw2/demo/demo.php
// then set SPAW_DIR to /spaw2/
SpawConfig::setStaticConfigItem('SPAW_DIR', '/spaw2/');
// and the following settings will be calculated automaticly
SpawConfig::setStaticConfigItem('SPAW_ROOT', str_replace("\\","/",realpath(dirname(__FILE__)."/..").'/'));
SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', substr(SpawConfig::getStaticConfigValue('SPAW_ROOT'),0,strlen(SpawConfig::getStaticConfigValue('SPAW_ROOT'))-strlen(SpawConfig::getStaticConfigValue('SPAW_DIR'))));
*/
/*
// under IIS you will probably need to setup the above paths manually. it would be something like this
SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', 'c:/inetpub/wwwroot/');
SpawConfig::setStaticConfigItem('SPAW_ROOT', 'c:/inetpub/wwwroot/spaw2/');