mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-17 19:23:27 +02:00
* fixed some MySQL errors on OTS_Player.php
* added function OTS_Player::getAccountId() * (internal) shortened samples inserting code * (internal) shortened config.highscores_ignored_ids updating code * updated TODO
This commit is contained in:
@@ -208,24 +208,23 @@ class OTS_Player extends OTS_Row_DAO
|
||||
$__load['marriage'] = $this->db->hasColumn('players', 'marriage');
|
||||
}
|
||||
|
||||
global $db;
|
||||
if(isset($fields)) { // load only what we wish
|
||||
if(in_array('promotion', $fields)) {
|
||||
if(!$this->db->hasColumn('players', 'promotion')) {
|
||||
unset($fields[array_search('promotion')]);
|
||||
unset($fields[array_search('promotion', $fields)]);
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array('deleted', $fields)) {
|
||||
if($this->db->hasColumn('players', 'deletion')) {
|
||||
unset($fields[array_search('deleted')]);
|
||||
unset($fields[array_search('deleted', $fields)]);
|
||||
$fields[] = 'deletion';
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array('online', $fields)) {
|
||||
if(!$this->db->hasColumn('players', 'online')) {
|
||||
unset($fields[array_search('online')]);
|
||||
unset($fields[array_search('online', $fields)]);
|
||||
}
|
||||
}
|
||||
$this->data = $this->db->query('SELECT ' . implode(', ', $fields) . ' FROM `players` WHERE `id` = ' . (int)$id)->fetch();
|
||||
@@ -613,6 +612,15 @@ class OTS_Player extends OTS_Row_DAO
|
||||
return $account;
|
||||
}
|
||||
|
||||
public function getAccountId()
|
||||
{
|
||||
if( !isset($this->data['account_id']) )
|
||||
{
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
return $this->data['account_id'];
|
||||
}
|
||||
/**
|
||||
* Assigns character to account.
|
||||
*
|
||||
|
@@ -1,39 +1,48 @@
|
||||
<?php
|
||||
|
||||
$config_file = BASE . 'config.local.php';
|
||||
if(!is_writable($config_file)) { // we can't do anything, just ignore
|
||||
return;
|
||||
if(!isset($database_migration_20)) {
|
||||
databaseMigration20();
|
||||
}
|
||||
|
||||
$content_of_file = trim(file_get_contents($config_file));
|
||||
if(strpos($content_of_file, 'highscores_ids_hidden') !== false) { // already present
|
||||
return;
|
||||
function databaseMigration20(&$content = '') {
|
||||
global $db;
|
||||
|
||||
$config_file = BASE . 'config.local.php';
|
||||
if(!is_writable($config_file)) { // we can't do anything, just ignore
|
||||
return false;
|
||||
}
|
||||
|
||||
$content_of_file = trim(file_get_contents($config_file));
|
||||
if(strpos($content_of_file, 'highscores_ids_hidden') !== false) { // already present
|
||||
return true;
|
||||
}
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . " OR `name` = " . $db->quote("Account Manager") . ") ORDER BY `id`;");
|
||||
|
||||
$highscores_ignored_ids = array();
|
||||
if($query->rowCount() > 0) {
|
||||
foreach($query->fetchAll() as $result)
|
||||
$highscores_ignored_ids[] = $result['id'];
|
||||
}
|
||||
else {
|
||||
$highscores_ignored_ids[] = 0;
|
||||
}
|
||||
|
||||
$php_on_end = substr($content_of_file, -2, 2) == '?>';
|
||||
$content = PHP_EOL;
|
||||
if($php_on_end) {
|
||||
$content .= '<?php';
|
||||
}
|
||||
|
||||
$content .= PHP_EOL;
|
||||
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
|
||||
$content .= PHP_EOL;
|
||||
|
||||
if($php_on_end) {
|
||||
$content .= '?>';
|
||||
}
|
||||
|
||||
file_put_contents($config_file, $content, FILE_APPEND);
|
||||
return true;
|
||||
}
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . ") ORDER BY `id`;");
|
||||
|
||||
$highscores_ignored_ids = array();
|
||||
if($query->rowCount() > 0) {
|
||||
foreach($query->fetchAll() as $result)
|
||||
$highscores_ignored_ids[] = $result['id'];
|
||||
}
|
||||
else {
|
||||
$highscores_ignored_ids[] = 0;
|
||||
}
|
||||
|
||||
$php_on_end = substr($content_of_file, -2, 2) == '?>';
|
||||
$content = PHP_EOL;
|
||||
if($php_on_end) {
|
||||
$content .= '<?php';
|
||||
}
|
||||
|
||||
$content .= PHP_EOL;
|
||||
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
|
||||
$content .= PHP_EOL;
|
||||
|
||||
if($php_on_end) {
|
||||
$content .= '?>';
|
||||
}
|
||||
|
||||
file_put_contents($config_file, $content, FILE_APPEND);
|
||||
?>
|
Reference in New Issue
Block a user