• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Mysql_Real_Query and site problem

killing

Member
Joined
Feb 23, 2012
Messages
815
Reaction score
11
Location
BIH
hello everyone.
I have 2 problems and i need help kinda fast.

My problem 1)
CiYTPnB.png

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.
aHI5cDJ.png


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:
Website issue, load.database.php (blue = before)
Code:
Website::setPasswordsEncryption(Website::getServerConfig()->getValue('[COLOR=#0000ff]encryptionType[/COLOR]'));
Code:
Website::setPasswordsEncryption(Website::getServerConfig()->getValue('[COLOR=#ff0000]passwordType[/COLOR]'));

You should use the 0.2.13+ version which is compatible with the 0.2 series. https://github.com/gesior/Gesior2012/archive/TFS-0.2.13+.zip
 
The first problem has been fixed as well, he used wrong MySQL schema.
 
Change the directory path in the NPC's XML file.
Lua:
script="data/npc/scripts/NPCNAME.lua"
 
Thanks i well try to repp you

- - - Updated - - -

Ninja i have one more problem.

lO9aRAl.png


I hope to you can help me.
 
Last edited:
0.2
XML:
<event type="login" name="PlayerLogin" script="login.lua"/>
0.3
XML:
<event type="login" name="PlayerLogin" event="script" value="login.lua"/>

As you can see there are some differences between these two, make sure it looks like the first one.
 
creaturescripts.xml
Lua:
 <event type="think" name="PartyPower" event="script" value="New Things/partygame.lua"/>
    <event type="kill" name="KillingInTheNameOf1" event="script" value="New Things/KillingInTheNameOf1.lua"/>
    <event type="advance" name="5points" event="script" value="New Things/5pts.lua"/>
    <event type="kill" name="KillingInTheNameOf" event="script" value="New Things/killinginthenameof.lua"/>
    <event type="kill" name="duszek" script="duszek.lua"/>
    <event type="death" name="Portal" event="script" value="death portal.lua" />
    <event type="death" name="Undead Gladiator" script="undead gladiator.lua"/>
    <event type="death" name="Reward" event="script" value="reward.lua"/> 	
    <event type="death" name="Golgordan" script="golgordan.lua"/>
    <event type="death" name="Werewolf" script="werewolf.lua"/>
    <event type="advance" name="MaxLevel" event="script" value="maxlevel.lua"/>
    <event type="advance" name="LevelUp" event="script" value="levelup.lua"/>
    <event type="combat" name="Immortal" event="script" value="immortal.lua"/>
    <event type="login" name="PlayerLogin" event="script" value="login.lua"/>
	<event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
	<event type="receivemail" name="Mail" event="script" value="mail.lua"/>
	<event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
	<event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
	<event type="think" name="Idle" event="script" value="idle.lua"/>
	<event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
    <event type="think" name="Courtel" event="script" value="Courtel.lua"/>  
    <event type="think" name="Vampire Bride" event="script" value="Vampire Bride.lua"/>    
    <event type="think" name="Nifra" event="script" value="nifra.lua"/> 
    <event type="outfit" name="Addons" event="script" value="outfits.lua"/>
	<event type="advance" name="lvlup" event="script" value="lvlup.lua"/>
	<event type="preparedeath" name="onPrepareDeath" event="script" value="preparedeath.lua"/>
	<event type="login" name="Conected" script="conected.lua"/>
	<event type="advance" name="Advance" script="advance.lua"/>
    <event type="login" name="expRate" event="script" value="extraExpRate.lua"/>
	<event type="attack" name="AttackGuild" script="attackguild.lua"/>  
	<event type="login" name="fraglook_register" event="script" value="fraglook.lua"/> 
    <event type="look" name="fraglook" event="script" value="fraglook.lua"/>
	<event type="look" name="questlook" event="script" value="questlook.lua"/>
	<event type="combat" name="Kamulec" event="script" value="metin_stones.lua"/>  
	<event type="preparedeath" name="Blessedaol" event="script" value="New Things/Blessssedaol.lua"/>

- - - Updated - - -

Ninja i have fixed House Problem No more problems on the Houses
But i can't Log in the Game something with Conected.idk
SX17Dq5.png


Send me a Messager on the Skype.

- - - Updated - - -

Conected.lua
Lua:
function onLogin(cid)
playerpos = getPlayerPosition(cid)
doSendAnimatedText(playerpos, "Online!", TEXTCOLOR_ORANGE)
	return TRUE
end

I want to have this in my OT.
 

Similar threads

Back
Top