Skip to content

Commit

Permalink
Merge pull request #22 from WibbenZ/gesior/TFS-1.0
Browse files Browse the repository at this point in the history
Rework encryptionTypes, disable serverlist, update load.database.php
  • Loading branch information
gesior committed Sep 8, 2015
2 parents ca3d1ee + 420dd1f commit 7c4b429
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 48 deletions.
23 changes: 16 additions & 7 deletions classes/website.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,23 @@ public static function fileExists($path)
return file_exists($path);
}

public static function setPasswordsEncryption($encryption)
{
if(isset(self::$passwordsEncryptions[strtolower($encryption)]))
self::$passwordsEncryption = strtolower($encryption);
else
public static function updatePasswordEncryption()
{
$encryptionTypeLowerd = strtolower(self::getServerConfig()->getValue('passwordType'));
if (empty($encryptionTypeLowerd)) { // TFS 1.1+
$encryptionTypeLowerd = $config['site']['encryptionType'];
if (empty($encryptionTypeLowerd)) {
$encryptionTypeLowerd = 'sha1';
}
}

if (isset(self::$passwordsEncryptions[$encryptionTypeLowerd])) {
self::$passwordsEncryption = $encryptionTypeLowerd;
} else {
new Error_Critic('#C-12', 'Invalid passwords encryption ( ' . htmlspecialchars($encryption) . '). Must be one of these: ' . implode(', ', self::$passwordsEncryptions));
}
}

public static function getPasswordsEncryption()
{
return self::$passwordsEncryption;
Expand Down Expand Up @@ -227,4 +236,4 @@ public static function getCountryCode($IP)
}
return $lastCountryCode;
}
}
}
6 changes: 3 additions & 3 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$config['site']['item_images_extension'] = '.gif';
$config['site']['flag_images_url'] = 'http://flag-images.ots.me/';
$config['site']['flag_images_extension'] = '.png';
$config['site']['encryptionType'] = 'sha1';

# Create Account Options
$config['site']['one_email'] = false;
Expand All @@ -25,7 +26,6 @@
$config['site']['newchar_towns'] = array(2);
$config['site']['max_players_per_account'] = 7;


# Emails Config
$config['site']['send_emails'] = false;
$config['site']['mail_address'] = "xxxx@gmx.com";
Expand All @@ -37,7 +37,7 @@
$config['site']['smtp_pass'] = "xxxx";

# PAGE: whoisonline.php
$config['site']['private-servlist.com_server_id'] = 1;
$config['site']['private-servlist.com_server_id'] = 0;
/*
Server id on 'private-servlist.com' to show Players Online Chart (whoisonline.php page), set 0 to disable Chart feature.
To use this feature you must register on 'private-servlist.com' and add your server.
Expand Down Expand Up @@ -91,4 +91,4 @@
$config['site']['darkborder'] = '#D4C0A1';
$config['site']['lightborder'] = '#F1E0C6';
$config['site']['download_page'] = false;
$config['site']['serverinfo_page'] = true;
$config['site']['serverinfo_page'] = true;
2 changes: 1 addition & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function setServerPath($newPath)
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.');
Website::setPasswordsEncryption(Website::getServerConfig()->getValue('passwordType'));
Website::updatePasswordEncryption();
$SQL = Website::getDBHandle();
}

Expand Down
5 changes: 4 additions & 1 deletion system/load.compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@
$topic = $subtopic;

$passwordency = Website::getServerConfig()->getValue('passwordType');
if($passwordency == 'plain')
if (empty($passwordency)) {
$passwordency = 'sha1';
} else if ($passwordency == 'plain') {
$passwordency = '';
}

$news_content = '';
$vocation_name = array();
Expand Down
82 changes: 46 additions & 36 deletions system/load.database.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
<?php
if(!defined('INITIALIZED'))
exit;
if (!defined('INITIALIZED')) {
exit;
}

if(Website::getServerConfig()->isSetKey('mysqlHost'))
{
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');
}
else
new Error_Critic('#E-3', 'There is no key <b>mysqlHost</b> in server config', array(new Error('INFO', 'use server config cache: <b>' . (Website::getWebsiteConfig()->getValue('useServerConfigCache') ? 'true' : 'false') . '</b>')));
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.');
if (Website::getServerConfig()->isSetKey('mysqlHost')) {
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');
} else {
new Error_Critic('#E-3', 'There is no key <b>mysqlHost</b> in server config', array(new Error('INFO', 'use server config cache: <b>' . (Website::getWebsiteConfig()->getValue('useServerConfigCache') ? 'true' : 'false') . '</b>')));
}

Website::setPasswordsEncryption(Website::getServerConfig()->getValue('passwordType'));
$SQL = Website::getDBHandle();
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.');
}

Website::updatePasswordEncryption();
$SQL = Website::getDBHandle();

0 comments on commit 7c4b429

Please sign in to comment.