From d57f835c91fbcc38d70b8e5f495e5cbd2f7b88d7 Mon Sep 17 00:00:00 2001 From: Stefan Brannfjell Date: Mon, 9 Sep 2013 20:45:56 +0200 Subject: [PATCH] TFS 1.0 functionality: House list works. /Todo: House auctioning. --- config.php | 15 ++++---- houses.php | 93 +++++++++++++++++++++++++++++++++++++++++++++++- layout/aside.php | 2 +- 3 files changed, 102 insertions(+), 8 deletions(-) diff --git a/config.php b/config.php index 0c4026f..170e6c1 100644 --- a/config.php +++ b/config.php @@ -4,7 +4,7 @@ // TFS 0.3 = TFS_03 (If ur using 0.3.6, set $config['salt'] to false)! // TFS 0.4 = TFS_03 // TFS 1.0 = TFS_10 (Under developement) - $config['TFSVersion'] = 'TFS_03'; + $config['TFSVersion'] = 'TFS_10'; $config['site_title'] = 'Znote AAC'; $config['site_title_context'] = 'Because open communities are good communities. :3'; @@ -14,13 +14,13 @@ // ------------------------ \\ // phpmyadmin username for OT server: (DONT USE "root" if ur hosting to public.). - $config['sqlUser'] = 'username'; + $config['sqlUser'] = 'new'; // phpmyadmin password for OT server: - $config['sqlPassword'] = 'password'; + $config['sqlPassword'] = 'new'; // The database name to connect to. (This is usually same as username). - $config['sqlDatabase'] = 'database'; + $config['sqlDatabase'] = 'new'; // Hostname is usually localhost or 127.0.0.1. $config['sqlHost'] = 'localhost'; @@ -63,7 +63,10 @@ // townID => 'townName' etc: ['3'=>'Thais'] $config['towns'] = array( 2 => 'Thyrfing', + 3 => 'Town 3', ); + // Default town id to display when visting house list page page. (TFS 1.0+). + $config['HouseListDefaultTown'] = 1; // Leave on black square in map and player should get teleported to their selected town. // If chars get buggy set this position to a beginner location to force players there. @@ -194,8 +197,8 @@ 'enabled' => true, 'guildboard' => true, 'level' => 5, - 'cooldownPost' => 60, - 'cooldownCreate' => 180, + 'cooldownPost' => 1,//60, + 'cooldownCreate' => 1,//180, 'hidden' => '[H]', 'closed' => '[C]', 'sticky' => '[S]', diff --git a/houses.php b/houses.php index 8f39e7e..653397e 100644 --- a/houses.php +++ b/houses.php @@ -140,6 +140,97 @@ if (empty($_POST) === false && $config['TFSVersion'] === 'TFS_03') { Something is wrong with the cache.

'; - } + } else if ($config['TFSVersion'] === 'TFS_10') { + // Fetch values + $townid = (getValue($_POST['selected']) !== false) ? (int)$_POST['selected'] : $config['HouseListDefaultTown']; + $towns = $config['towns']; + + // Create Search house box + ?> +
+ Select town: + + + +
+ hasExpired()) { + $houses = mysql_select_multi("SELECT `id`, `owner`, `paid`, `warnings`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses`;"); + + if ($houses !== false) { + // Fetch player names + $playerlist = array(); + foreach ($houses as $h) if ($h['owner'] > 0) $playerlist[] = $h['owner']; + if (!empty($playerlist)) { + $ids = join(',',$playerlist); + $tmpPlayers = mysql_select_multi("SELECT `id`, `name` FROM players WHERE `id` IN ($ids);"); + // Sort $tmpPlayers by player id + $tmpById = array(); + foreach ($tmpPlayers as $p) $tmpById[$p['id']] = $p['name']; + for ($i = 0; $i < count($houses); $i++) { + if ($houses[$i]['owner'] > 0) $houses[$i]['ownername'] = $tmpById[$houses[$i]['owner']]; + } + } + + $cache->setContent($houses); + $cache->save(); + } + } else { + $houses = $cache->load(); + } + if ($houses !== false || !empty($houses)) { + // Intialize stuff + //data_dump($houses, false, "House data"); + ?> + + + + + + + + + + + + + + + + ". $house['ownername'] .""; + } else { + echo ""; + } + ?> + + + +
NameSizeBedsRentOwnerTown
None
+ Failed to fetch data from sql->houses table.

Is the table empty?

"; + } // End TFS 1.0 logic } include 'layout/overall/footer.php'; ?> \ No newline at end of file diff --git a/layout/aside.php b/layout/aside.php index 3d4ce54..5a26050 100644 --- a/layout/aside.php +++ b/layout/aside.php @@ -10,7 +10,7 @@ include 'layout/widgets/topplayers.php'; include 'layout/widgets/highscore.php'; include 'layout/widgets/serverinfo.php'; - if ($config['TFSVersion'] === 'TFS_03') include 'layout/widgets/houses.php'; + if ($config['TFSVersion'] !== 'TFS_02') include 'layout/widgets/houses.php'; // Remove // to enable twitter, edit twitter stuff in /widgets/twitter.php //include 'layout/widgets/twitter.php'; ?>