hello everyone.
I have 2 problems and i need help kinda fast.
My problem 1)
Im using this Dis http://otland.net/f18/9-80-9-86-forgotten-server-v0-2-15-mystic-spirit-188228/
And my problem 2)
I can't open my site.
Configphp.php
Load.database.php
index.php
Im really bad with this things,if you can help me i well be happy
Thanks for reading,
And sorry for my bad English.
Rep++ ^_^
I have 2 problems and i need help kinda fast.
My problem 1)
Im using this Dis http://otland.net/f18/9-80-9-86-forgotten-server-v0-2-15-mystic-spirit-188228/
And my problem 2)
I can't open my site.
Configphp.php
Lua:
<?php
if(!defined('INITIALIZED'))
exit;
class ConfigPHP extends Errors
{
private $config;
private $loadedFromPath = '';
public function __construct($path = false)
{
if($path)
$this->loadFromFile($path);
}
public function loadFromFile($path)
{
if(Website::fileExists($path))
{
$content = Website::getFileContents($path);
$this->loadedFromPath = $path;
$lines = explode("\n", $content);
unset($lines[0]); // remove <?php
unset($lines[count($lines)]); // remove ? >
$this->loadFromString(implode("\n", $lines));
}
else
WebsiteErrors::addError('#C-4', 'ERROR: <b>#C-4</b> : Class::ConfigPHP - PHP config file doesn\'t exist. Path: <b>' . $path . '</b>');
}
public function fileExists($path)
{
return Website::fileExists($path);
}
public function loadFromString($string)
{
$ret = @eval('$_web_config = array();' . chr(0x0A) . $string . chr(0x0A) . '');
if($ret === false)
{
$error = error_get_last();
new Error_Critic('', ' - cannot load PHP config from string', array(
new Error('MESSAGE', $error['message']),
new Error('FILE', $error['file']),
new Error('LINE', $error['line']),
new Error('FILE PATH', $this->loadedFromPath)
));
}
$this->config = $_web_config;
unset($_web_config);
}
private function parsePhpVariableToText($value)
{
if(is_bool($value))
return ($value) ? 'true' : 'false';
elseif(is_numeric($value))
return $value;
else
return '"' . str_replace('"', '\"' , $value) . '"';
}
public function arrayToPhpString(array $a, $d)
{
$s = '';
if(is_array($a) && count($a) > 0)
foreach($a as $k => $v)
{
if(is_array($v))
$s .= self::arrayToPhpString($v, $d . '["' . $k . '"]');
else
$s .= $d . '["' . $k . '"] = ' . self::parsePhpVariableToText($v) . ';' . chr(0x0A);
}
return $s;
}
public function getConfigAsString()
{
return self::arrayToPhpString($this->config, '$_web_config');
}
public function saveToFile($path = false)
{
if($path)
$savePath = $path;
else
$savePath = $this->loadedFromPath;
Website::putFileContents($savePath, '<?php' . chr(0x0A) . $this->getConfigAsString() . '?>');
}
public function getValue($key)
{
if(isset($this->config[ $key ]))
return $this->config[ $key ];
else
new Error_Critic('#C-5', 'ERROR: <b>#C-5</b> : Class::ConfigPHP - Key <b>' . $key . '</b> doesn\'t exist.');
}
public function setValue($key, $value)
{
$this->config[ $key ] = $value;
}
public function removeKey($key)
{
if(isset($this->config[ $key ]))
unset($this->config[ $key ]);
}
public function isSetKey($key)
{
return isset($this->config[ $key ]);
}
public function getConfig()
{
return $this->config;
}
public function setConfig($value)
{
$this->config = $value;
}
}
Load.database.php
Lua:
<?php
if(!defined('INITIALIZED'))
exit;
if(Website::getServerConfig()->isSetKey('mysqlHost'))
{
define('SERVERCONFIG_SQL_TYPE', 'sqlType');
define('SERVERCONFIG_SQL_HOST', 'mysqlHost');
define('SERVERCONFIG_SQL_PORT', 'mysqlPort');
define('SERVERCONFIG_SQL_USER', 'mysqlUser');
define('SERVERCONFIG_SQL_PASS', 'mysqlPass');
define('SERVERCONFIG_SQL_DATABASE', 'mysqlDatabase');
define('SERVERCONFIG_SQLITE_FILE', 'sqlFile');
}
elseif(Website::getServerConfig()->isSetKey('sqlHost'))
{
define('SERVERCONFIG_SQL_TYPE', 'sqlType');
define('SERVERCONFIG_SQL_HOST', 'sqlHost');
define('SERVERCONFIG_SQL_PORT', 'sqlPort');
define('SERVERCONFIG_SQL_USER', 'sqlUser');
define('SERVERCONFIG_SQL_PASS', 'sqlPass');
define('SERVERCONFIG_SQL_DATABASE', 'sqlDatabase');
define('SERVERCONFIG_SQLITE_FILE', 'sqlFile');
}
else
new Error_Critic('#E-3', 'There is no key <b>sqlHost</b> or <b>mysqlHost</b> in server config', array(new Error('INFO', 'use server config cache: <b>' . (Website::getWebsiteConfig()->getValue('useServerConfigCache') ? 'true' : 'false') . '</b>')));
if(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_TYPE) == 'mysql')
{
Website::setDatabaseDriver(Database::DB_MYSQL);
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_HOST))
Website::getDBHandle()->setDatabaseHost(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_HOST));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_HOST . '</b> in server config file.');
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_PORT))
Website::getDBHandle()->setDatabasePort(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_PORT));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_PORT . '</b> in server config file.');
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_DATABASE))
Website::getDBHandle()->setDatabaseName(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_DATABASE));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_DATABASE . '</b> in server config file.');
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_USER))
Website::getDBHandle()->setDatabaseUsername(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_USER));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_USER . '</b> in server config file.');
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_PASS))
Website::getDBHandle()->setDatabasePassword(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_PASS));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_PASS . '</b> in server config file.');
}
elseif(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_TYPE) == 'sqlite')
{
Website::setDatabaseDriver(Database::DB_SQLITE);
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQLITE_FILE))
Website::getDBHandle()->setDatabaseFile(Website::getServerConfig()->getValue(SERVERCONFIG_SQLITE_FILE));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQLITE_FILE . '</b> in server config file.');
}
elseif(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_TYPE) == 'pgsql')
{
// does pgsql use 'port' parameter? I don't know
Website::setDatabaseDriver(Database::DB_PGSQL);
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_HOST))
Website::getDBHandle()->setDatabaseHost(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_HOST));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_HOST . '</b> in server config file.');
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_DATABASE))
Website::getDBHandle()->setDatabaseName(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_DATABASE));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_DATABASE . '</b> in server config file.');
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_USER))
Website::getDBHandle()->setDatabaseUsername(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_USER));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_USER . '</b> in server config file.');
if(Website::getServerConfig()->isSetKey(SERVERCONFIG_SQL_PASS))
Website::getDBHandle()->setDatabasePassword(Website::getServerConfig()->getValue(SERVERCONFIG_SQL_PASS));
else
new Error_Critic('#E-7', 'There is no key <b>' . SERVERCONFIG_SQL_PASS . '</b> in server config file.');
}
else
new Error_Critic('#E-6', 'Database error. Unknown database type in <b>server config</b> . Must be equal to: "<b>mysql</b>", "<b>sqlite</b>" or "<b>pgsql</b>" . Now is: "<b>' . Website::getServerConfig()->getValue(SERVERCONFIG_SQL_TYPE) . '</b>"');
Website::setPasswordsEncryption(Website::getServerConfig()->getValue('encryptionType'));
$SQL = Website::getDBHandle();
index.php
Lua:
<?php
// comment to show E_NOTICE [undefinied variable etc.], comment if you want make script and see all errors
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);
// true = show sent queries and SQL queries status/status code/error message
define('DEBUG_DATABASE', false);
define('INITIALIZED', true);
// if not defined before, set 'false' to load all normal
if(!defined('ONLY_PAGE'))
define('ONLY_PAGE', false);
// check if site is disabled/requires installation
include_once('./system/load.loadCheck.php');
// fix user data, load config, enable class auto loader
include_once('./system/load.init.php');
// DATABASE
include_once('./system/load.database.php');
if(DEBUG_DATABASE)
Website::getDBHandle()->setPrintQueries(true);
// DATABASE END
// LOGIN
if(!ONLY_PAGE)
include_once('./system/load.login.php');
// LOGIN END
// COMPAT
// some parts in that file can be blocked because of ONLY_PAGE constant
include_once('./system/load.compat.php');
// COMPAT END
// LOAD PAGE
include_once('./system/load.page.php');
// LOAD PAGE END
// LAYOUT
// with ONLY_PAGE we return only page text, not layout
if(!ONLY_PAGE)
include_once('./system/load.layout.php');
else
echo $main_content;
// LAYOUT END
Im really bad with this things,if you can help me i well be happy
Thanks for reading,
And sorry for my bad English.
Rep++ ^_^
Last edited: