diff --git a/LUA/TFS_02/talkaction shopsystem/znoteshop.lua b/LUA/TFS_02/talkaction shopsystem/znoteshop.lua index af6d2b2..de6fd08 100644 --- a/LUA/TFS_02/talkaction shopsystem/znoteshop.lua +++ b/LUA/TFS_02/talkaction shopsystem/znoteshop.lua @@ -57,9 +57,9 @@ function onSay(cid, words, param) local outfits = {} if itemid > 1000 then - local first = math.floor(itemid/1000) - table.insert(outfits, first) - itemid = itemid - (first * 1000) + local first = math.floor(itemid/1000) + table.insert(outfits, first) + itemid = itemid - (first * 1000) end table.insert(outfits, itemid) diff --git a/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua b/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua index e184499..93ace81 100644 --- a/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua +++ b/LUA/TFS_03/talkaction shopsystem/Alternatives/znoteshop.lua @@ -59,9 +59,9 @@ function onSay(cid, words, param) local outfits = {} if itemid > 1000 then - local first = math.floor(itemid/1000) - table.insert(outfits, first) - itemid = itemid - (first * 1000) + local first = math.floor(itemid/1000) + table.insert(outfits, first) + itemid = itemid - (first * 1000) end table.insert(outfits, itemid) diff --git a/LUA/TFS_03/talkaction shopsystem/znoteshop.lua b/LUA/TFS_03/talkaction shopsystem/znoteshop.lua index eace78e..82b7cef 100644 --- a/LUA/TFS_03/talkaction shopsystem/znoteshop.lua +++ b/LUA/TFS_03/talkaction shopsystem/znoteshop.lua @@ -70,9 +70,9 @@ function onSay(cid, words, param) local outfits = {} if itemid > 1000 then - local first = math.floor(itemid/1000) - table.insert(outfits, first) - itemid = itemid - (first * 1000) + local first = math.floor(itemid/1000) + table.insert(outfits, first) + itemid = itemid - (first * 1000) end table.insert(outfits, itemid) diff --git a/LUA/TFS_10/globalevent powergamers/powergamers.lua b/LUA/TFS_10/globalevent powergamers/powergamers.lua index ac56fb8..942f3a8 100644 --- a/LUA/TFS_10/globalevent powergamers/powergamers.lua +++ b/LUA/TFS_10/globalevent powergamers/powergamers.lua @@ -2,24 +2,24 @@ -- can be added to data/global.lua if you want to use eternal storage for another purpose than this. -- Regular TFS global storage values get reset every time server reboots. This does not. local function getEternalStorage(key, parser) - local value = result.getString(db.storeQuery("SELECT `value` FROM `znote_global_storage` WHERE `key` = ".. key .. ";"), "value") - if not value then - if parser then - return false - else - return -1 - end - end - return tonumber(value) or value + local value = result.getString(db.storeQuery("SELECT `value` FROM `znote_global_storage` WHERE `key` = ".. key .. ";"), "value") + if not value then + if parser then + return false + else + return -1 + end + end + return tonumber(value) or value end local function setEternalStorage(key, value) - if getEternalStorage(key, true) then - db.query("UPDATE `znote_global_storage` SET `value` = '".. value .. "' WHERE `key` = ".. key .. ";") - else - db.query("INSERT INTO `znote_global_storage` (`key`, `value`) VALUES (".. key ..", ".. value ..");") - end - return true + if getEternalStorage(key, true) then + db.query("UPDATE `znote_global_storage` SET `value` = '".. value .. "' WHERE `key` = ".. key .. ";") + else + db.query("INSERT INTO `znote_global_storage` (`key`, `value`) VALUES (".. key ..", ".. value ..");") + end + return true end -- SQL Query to execute: -- @@ -53,11 +53,11 @@ UPDATE `znote_players` AS `z` INNER JOIN `players` AS `p` ON `p`.`id`=`z`.`play -- function onThink(interval, lastExecution, thinkInterval) - if tonumber(os.date("%d")) ~= getEternalStorage(23856) then - setEternalStorage(23856, (tonumber(os.date("%d")))) - db.query("UPDATE `znote_players` SET `onlinetime7`=`onlinetime6`, `onlinetime6`=`onlinetime5`, `onlinetime5`=`onlinetime4`, `onlinetime4`=`onlinetime3`, `onlinetime3`=`onlinetime2`, `onlinetime2`=`onlinetime1`, `onlinetime1`=`onlinetimetoday`, `onlinetimetoday`=0;") - db.query("UPDATE `znote_players` `z` INNER JOIN `players` `p` ON `p`.`id`=`z`.`player_id` SET `z`.`exphist7`=`z`.`exphist6`, `z`.`exphist6`=`z`.`exphist5`, `z`.`exphist5`=`z`.`exphist4`, `z`.`exphist4`=`z`.`exphist3`, `z`.`exphist3`=`z`.`exphist2`, `z`.`exphist2`=`z`.`exphist1`, `z`.`exphist1`=`p`.`experience`-`z`.`exphist_lastexp`, `z`.`exphist_lastexp`=`p`.`experience`;") - end - db.query("UPDATE `znote_players` SET `onlinetimetoday` = `onlinetimetoday` + 60, `onlinetimeall` = `onlinetimeall` + 60 WHERE `player_id` IN (SELECT `player_id` FROM `players_online` WHERE `players_online`.`player_id` = `znote_players`.`player_id`)") - return true + if tonumber(os.date("%d")) ~= getEternalStorage(23856) then + setEternalStorage(23856, (tonumber(os.date("%d")))) + db.query("UPDATE `znote_players` SET `onlinetime7`=`onlinetime6`, `onlinetime6`=`onlinetime5`, `onlinetime5`=`onlinetime4`, `onlinetime4`=`onlinetime3`, `onlinetime3`=`onlinetime2`, `onlinetime2`=`onlinetime1`, `onlinetime1`=`onlinetimetoday`, `onlinetimetoday`=0;") + db.query("UPDATE `znote_players` `z` INNER JOIN `players` `p` ON `p`.`id`=`z`.`player_id` SET `z`.`exphist7`=`z`.`exphist6`, `z`.`exphist6`=`z`.`exphist5`, `z`.`exphist5`=`z`.`exphist4`, `z`.`exphist4`=`z`.`exphist3`, `z`.`exphist3`=`z`.`exphist2`, `z`.`exphist2`=`z`.`exphist1`, `z`.`exphist1`=`p`.`experience`-`z`.`exphist_lastexp`, `z`.`exphist_lastexp`=`p`.`experience`;") + end + db.query("UPDATE `znote_players` SET `onlinetimetoday` = `onlinetimetoday` + 60, `onlinetimeall` = `onlinetimeall` + 60 WHERE `player_id` IN (SELECT `player_id` FROM `players_online` WHERE `players_online`.`player_id` = `znote_players`.`player_id`)") + return true end diff --git a/admin.php b/admin.php index a136aa0..a822df9 100644 --- a/admin.php +++ b/admin.php @@ -1,7 +1,7 @@ "; - + @@ -220,7 +219,7 @@ echo "Last cached on: ". hhb_tohtml(getClock($basic['cached'], true)) .".
"; - + @@ -234,7 +233,7 @@ echo "Last cached on: ". hhb_tohtml(getClock($basic['cached'], true)) .".
"; - + diff --git a/admin_reports.php b/admin_reports.php index 2185b95..eafa1be 100644 --- a/admin_reports.php +++ b/admin_reports.php @@ -7,12 +7,12 @@ include 'layout/overall/header.php'; // Report status types. When a player make new report it will be default to 0. // Feel free to add/remove and change name/color of status types. $statusTypes = array( - 0 => 'Reported', - 1 => 'To-Do List', - 2 => 'Confirmed bug', - 3 => 'Invalid', - 4 => 'Rejected', - 5 => 'Fixed' + 0 => 'Reported', + 1 => 'To-Do List', + 2 => 'Confirmed bug', + 3 => 'Invalid', + 4 => 'Rejected', + 5 => 'Fixed' ); // Which status IDs should give option to add to changelog? $statusChangeLog = array(0,5); @@ -22,222 +22,222 @@ $hideStatus = array(3, 4, 5); // Fetch data from SQL $reportsData = mysql_select_multi('SELECT id, name, posx, posy, posz, report_description, date, status FROM znote_player_reports ORDER BY id DESC;'); -// If sql data is not empty +// If SQL data is not empty if ($reportsData !== false) { - // Order reports array by ID for easy reference later on. - $reports = array(); - for ($i = 0; $i < count($reportsData); $i++) - foreach ($statusTypes as $key => $value) - if ($key == $reportsData[$i]['status']) - $reports[$key][$reportsData[$i]['id']] = $reportsData[$i]; + // Order reports array by ID for easy reference later on. + $reports = array(); + for ($i = 0; $i < count($reportsData); $i++) + foreach ($statusTypes as $key => $value) + if ($key == $reportsData[$i]['status']) + $reports[$key][$reportsData[$i]['id']] = $reportsData[$i]; } // POST logic (Update report and give player points) if (!empty($_POST)) { - // Fetch POST data - $playerName = getValue($_POST['playerName']); - $status = getValue($_POST['status']); - $price = getValue($_POST['price']); - $customPoints = getValue($_POST['customPoints']); - $reportId = getValue($_POST['id']); + // Fetch POST data + $playerName = getValue($_POST['playerName']); + $status = getValue($_POST['status']); + $price = getValue($_POST['price']); + $customPoints = getValue($_POST['customPoints']); + $reportId = getValue($_POST['id']); - $changelogReportId = (int)$_POST['changelogReportId']; - $changelogValue = &$_POST['changelogValue']; - $changelogText = getValue($_POST['changelogText']); - $changelogStatus = ($changelogReportId !== false && $changelogValue === '2' && $changelogText !== false) ? true : false; + $changelogReportId = (int)$_POST['changelogReportId']; + $changelogValue = &$_POST['changelogValue']; + $changelogText = getValue($_POST['changelogText']); + $changelogStatus = ($changelogReportId !== false && $changelogValue === '2' && $changelogText !== false) ? true : false; - if ($customPoints !== false) $price = (int)($price + $customPoints); + if ($customPoints !== false) $price = (int)($price + $customPoints); - // Update SQL - mysql_update("UPDATE `znote_player_reports` SET `status`='$status' WHERE `id`='$reportId' LIMIT 1;"); - echo "

Report status updated to ".$statusTypes[(int)$status] ."!

"; - // Update local array representation - foreach ($reports as $sid => $sa) - foreach ($sa as $rid => $ra) - if ($reportId == $rid) { - $reports[$status][$reportId] = $reports[$sid][$rid]; - $reports[$status][$reportId]['status'] = $status; - unset($reports[$sid][$rid]); - } + // Update SQL + mysql_update("UPDATE `znote_player_reports` SET `status`='$status' WHERE `id`='$reportId' LIMIT 1;"); + echo "

Report status updated to ".$statusTypes[(int)$status] ."!

"; + // Update local array representation + foreach ($reports as $sid => $sa) + foreach ($sa as $rid => $ra) + if ($reportId == $rid) { + $reports[$status][$reportId] = $reports[$sid][$rid]; + $reports[$status][$reportId]['status'] = $status; + unset($reports[$sid][$rid]); + } - // If we should do anything with changelog: - if ($changelogStatus) { - $time = time(); - // Check if changelog exist (`id`, `text`, `time`, `report_id`, `status`) - $changelog = mysql_select_single("SELECT * FROM `znote_changelog` WHERE `report_id`='$changelogReportId' LIMIT 1;"); - // If changelog exist - $updatechangelog = false; - if ($changelog !== false) { - // Update it - mysql_update("UPDATE `znote_changelog` SET `text`='$changelogText', `time`='$time' WHERE `id`='".$changelog['id']."' LIMIT 1;"); - echo "

Changelog message updated!

"; - $updatechangelog = true; - } else { - // Create it - mysql_insert("INSERT INTO `znote_changelog` (`text`, `time`, `report_id`, `status`) - VALUES ('$changelogText', '$time', '$changelogReportId', '$status');"); - echo "

Changelog message created!

"; - $updatechangelog = true; - } - if ($updatechangelog) { - // Cache changelog - $cache = new Cache('engine/cache/changelog'); - $cache->setContent(mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;")); - $cache->save(); - } - - } - // If we should give user price - if ($price > 0) { - $account = mysql_select_single("SELECT `a`.`id`, `a`.`email` FROM `accounts` AS `a` - INNER JOIN `players` AS `p` ON `p`.`account_id` = `a`.`id` - WHERE `p`.`name` = '$playerName' LIMIT 1;"); - - if ($account !== false) { - // transaction log - mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$reportId', 'report@admin.".$user_data['name']." to ".$account['email']."', '".$account['id']."', '0', '".$price."')"); - // Process payment - $data = mysql_select_single("SELECT `points` AS `old_points` FROM `znote_accounts` WHERE `account_id`='".$account['id']."';"); - // Give points to user - $new_points = $data['old_points'] + $price; - mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='".$account['id']."'"); + // If we should do anything with changelog: + if ($changelogStatus) { + $time = time(); + // Check if changelog exist (`id`, `text`, `time`, `report_id`, `status`) + $changelog = mysql_select_single("SELECT * FROM `znote_changelog` WHERE `report_id`='$changelogReportId' LIMIT 1;"); + // If changelog exist + $updatechangelog = false; + if ($changelog !== false) { + // Update it + mysql_update("UPDATE `znote_changelog` SET `text`='$changelogText', `time`='$time' WHERE `id`='".$changelog['id']."' LIMIT 1;"); + echo "

Changelog message updated!

"; + $updatechangelog = true; + } else { + // Create it + mysql_insert("INSERT INTO `znote_changelog` (`text`, `time`, `report_id`, `status`) + VALUES ('$changelogText', '$time', '$changelogReportId', '$status');"); + echo "

Changelog message created!

"; + $updatechangelog = true; + } + if ($updatechangelog) { + // Cache changelog + $cache = new Cache('engine/cache/changelog'); + $cache->setContent(mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;")); + $cache->save(); + } + + } + // If we should give user price + if ($price > 0) { + $account = mysql_select_single("SELECT `a`.`id`, `a`.`email` FROM `accounts` AS `a` + INNER JOIN `players` AS `p` ON `p`.`account_id` = `a`.`id` + WHERE `p`.`name` = '$playerName' LIMIT 1;"); + + if ($account !== false) { + // transaction log + mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$reportId', 'report@admin.".$user_data['name']." to ".$account['email']."', '".$account['id']."', '0', '".$price."')"); + // Process payment + $data = mysql_select_single("SELECT `points` AS `old_points` FROM `znote_accounts` WHERE `account_id`='".$account['id']."';"); + // Give points to user + $new_points = $data['old_points'] + $price; + mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='".$account['id']."'"); - // Remind GM that he sent points to character - echo "".$playerName." has been granted ".$price." points for his reports."; - } - } + // Remind GM that he sent points to character + echo "".$playerName." has been granted ".$price." points for his reports."; + } + } // GET logic (Edit report data and specify how many [if any] points to give to user) } elseif (!empty($_GET)) { - // Fetch GET data - $action = getValue($_GET['action']); - $playerName = getValue($_GET['name']); - $reportId = getValue($_GET['id']); + // Fetch GET data + $action = getValue($_GET['action']); + $playerName = getValue($_GET['name']); + $reportId = getValue($_GET['id']); - // Fetch the report we intend to modify - foreach ($reports as $sid => $sa) - foreach ($sa as $rid => $ra) - if ($rid == $reportId) - $report = $reports[$sid][$reportId]; - - // Create html form - ?> -
-
- Player: - - -
Set status: -
- Give user points: - +
- -
- - Add / update changelog message?
- - -
- -
-
- $sa) + foreach ($sa as $rid => $ra) + if ($rid == $reportId) + $report = $reports[$sid][$reportId]; + + // Create HTML form + ?> +
+
+ Player: + + +
Set status: +
+ Give user points: + +
+ +
+ + Add / update changelog message?
+ + +
+ +
+
+ -
- $statusArray) { - ?> -

(Visible)

- - - - - - - - $report) { - ?> - - - - - - -
InfoDescription
- Report ID: # -
Name: -
Position: -
Reported: -
Status: . Edit -
-
- +
+ $statusArray) { + ?> +

(Visible)

+ + + + + + + + $report) { + ?> + + + + + + +
InfoDescription
+ Report ID: # +
Name: +
Position: +
Reported: +
Status: . Edit +
+
+ No reports submitted."; ?> - \ No newline at end of file + diff --git a/auctionChar.php b/auctionChar.php index c5b6733..eaf03e6 100644 --- a/auctionChar.php +++ b/auctionChar.php @@ -1,16 +1,16 @@ 0) $duration['hour'] = ($duration['day'] - (int)$duration['day']) * 24; if (isset($duration['hour'])) { - if (($duration['hour'] - (int)$duration['hour']) > 0) + if (($duration['hour'] - (int)$duration['hour']) > 0) $duration['minute'] = ($duration['hour'] - (int)$duration['hour']) * 60; if (isset($duration['minute'])) { - if (($duration['minute'] - (int)$duration['minute']) > 0) + if (($duration['minute'] - (int)$duration['minute']) > 0) $duration['second'] = ($duration['minute'] - (int)$duration['minute']) * 60; } } @@ -49,23 +49,23 @@ if ($auction['characterAuction']) { $step = $auction['step']; $step_duration = $auction['step_duration']; $actions = array( - 'list', // list all available players in auction - 'view', // view a specific player - 'create', // select which character to add and initial price - 'add', // add character to list - 'bid', // Bid or buy a specific player - 'refund', // Refund a player you added back to your account - 'claim' // Claim a character you won through purchase or bid + 'list', // list all available players in auction + 'view', // view a specific player + 'create', // select which character to add and initial price + 'add', // add character to list + 'bid', // Bid or buy a specific player + 'refund', // Refund a player you added back to your account + 'claim' // Claim a character you won through purchase or bid ); // Default action is list, but $_GET or $_POST will override it. $action = 'list'; // Load selected string from actions array based on input, strict whitelist validation - if (isset( $_GET['action']) && in_array( $_GET['action'], $actions)) { - $action = $actions[array_search( $_GET['action'], $actions, true)]; + if (isset( $_GET['action']) && in_array( $_GET['action'], $actions)) { + $action = $actions[array_search( $_GET['action'], $actions, true)]; } - if (isset($_POST['action']) && in_array($_POST['action'], $actions)) { - $action = $actions[array_search($_POST['action'], $actions, true)]; + if (isset($_POST['action']) && in_array($_POST['action'], $actions)) { + $action = $actions[array_search($_POST['action'], $actions, true)]; } // Passive check to see if bid period has expired and someone won a deal @@ -86,8 +86,8 @@ if ($auction['characterAuction']) { if (!empty($soldIds)) { mysql_update(" UPDATE `znote_auction_player` - SET `sold`=1 - WHERE `id` IN(".implode(',', $soldIds).") + SET `sold` = 1 + WHERE `id` IN(".implode(',', $soldIds).") LIMIT ".COUNT($soldIds)."; "); } @@ -106,13 +106,13 @@ if ($auction['characterAuction']) { // The account of the buyer, if he can afford what he is trying to pay $account = mysql_select_single(" SELECT - `a`.`id`, + `a`.`id`, `za`.`points` - FROM `accounts` a + FROM `accounts` a INNER JOIN `znote_accounts` za ON `a`.`id` = `za`.`account_id` - WHERE `a`.`id`= {$this_account_id} - AND `za`.`points` >= {$price} + WHERE `a`.`id`= {$this_account_id} + AND `za`.`points` >= {$price} LIMIT 1; "); //data_dump($account, false, "Buyer account:"); @@ -120,23 +120,23 @@ if ($auction['characterAuction']) { // The character to buy, presuming it isn't sold, buyer isn't the owner, buyer can afford it if ($account !== false) { $character = mysql_select_single(" - SELECT + SELECT `za`.`id` AS `zaid`, `za`.`player_id`, `za`.`original_account_id`, `za`.`bidder_account_id`, `za`.`time_begin`, `za`.`time_end`, - `za`.`price`, - `za`.`bid`, - `za`.`deposit`, - `za`.`sold` + `za`.`price`, + `za`.`bid`, + `za`.`deposit`, + `za`.`sold` FROM `znote_auction_player` za WHERE `za`.`id` = {$zaid} - AND `za`.`sold` = 0 - AND `za`.`original_account_id` != {$this_account_id} + AND `za`.`sold` = 0 + AND `za`.`original_account_id` != {$this_account_id} AND `za`.`price` <= {$price} - AND `za`.`bid`+{$step} <= {$price} + AND `za`.`bid`+{$step} <= {$price} LIMIT 1 "); //data_dump($character, false, "Character to buy:"); @@ -146,8 +146,8 @@ if ($auction['characterAuction']) { if ($character['bid'] > 0 && $character['bidder_account_id'] > 0) { mysql_update(" UPDATE `znote_accounts` - SET `points` = `points`+{$character['bid']} - WHERE `account_id` = {$character['bidder_account_id']} + SET `points` = `points`+{$character['bid']} + WHERE `account_id` = {$character['bidder_account_id']} LIMIT 1; "); // If previous bidder is not you, increase bidding period by 1 hour @@ -156,7 +156,7 @@ if ($auction['characterAuction']) { mysql_update(" UPDATE `znote_auction_player` SET `time_end` = `time_end`+{$step_duration} - WHERE `id` = {$character['zaid']} + WHERE `id` = {$character['zaid']} LIMIT 1; "); } @@ -164,15 +164,15 @@ if ($auction['characterAuction']) { // Remove points from buyer mysql_update(" UPDATE `znote_accounts` - SET `points` = `points`-{$price} - WHERE `account_id` = {$account['id']} + SET `points` = `points`-{$price} + WHERE `account_id` = {$account['id']} LIMIT 1; "); // Update auction, and set new bidder data $time = time(); mysql_update(" UPDATE `znote_auction_player` - SET + SET `bidder_account_id` = {$account['id']}, `bid` = {$price}, `sold` = CASE WHEN {$time} >= `time_end` THEN 1 ELSE 0 END @@ -183,8 +183,8 @@ if ($auction['characterAuction']) { if (time() >= $character['time_end']) { mysql_update(" UPDATE `znote_accounts` - SET `points` = `points`+{$character['deposit']} - WHERE `account_id` = {$account['id']} + SET `points` = `points`+{$character['deposit']} + WHERE `account_id` = {$account['id']} LIMIT 1; "); } else { @@ -197,7 +197,7 @@ if ($auction['characterAuction']) { } } - // See a specific character in auction, + // See a specific character in auction, // silently fallback to list if he doesn't exist or is already sold if ($action === 'view') { // View a character in the auction if (!isset($zaid)) { @@ -206,7 +206,7 @@ if ($auction['characterAuction']) { if ($zaid !== false) { // Retrieve basic character information $character = mysql_select_single(" - SELECT + SELECT `za`.`id` AS `zaid`, `za`.`player_id`, `za`.`original_account_id`, @@ -214,33 +214,33 @@ if ($auction['characterAuction']) { `za`.`time_begin`, `za`.`time_end`, CASE WHEN `za`.`price` > `za`.`bid` - THEN `za`.`price` + THEN `za`.`price` ELSE `za`.`bid`+{$step} END AS `price`, - CASE WHEN `za`.`original_account_id` = {$this_account_id} + CASE WHEN `za`.`original_account_id` = {$this_account_id} THEN 1 ELSE 0 END AS `own`, - CASE WHEN `za`.`original_account_id` = {$this_account_id} + CASE WHEN `za`.`original_account_id` = {$this_account_id} THEN `p`.`name` ELSE '' END AS `name`, - CASE WHEN `za`.`original_account_id` = {$this_account_id} + CASE WHEN `za`.`original_account_id` = {$this_account_id} THEN `za`.`bid` ELSE 0 END AS `bid`, - CASE WHEN `za`.`original_account_id` = {$this_account_id} + CASE WHEN `za`.`original_account_id` = {$this_account_id} THEN `za`.`deposit` ELSE 0 END AS `deposit`, - `p`.`vocation`, - `p`.`level`, - `p`.`balance`, - `p`.`lookbody` AS `body`, - `p`.`lookfeet` AS `feet`, - `p`.`lookhead` AS `head`, - `p`.`looklegs` AS `legs`, - `p`.`looktype` AS `type`, + `p`.`vocation`, + `p`.`level`, + `p`.`balance`, + `p`.`lookbody` AS `body`, + `p`.`lookfeet` AS `feet`, + `p`.`lookhead` AS `head`, + `p`.`looklegs` AS `legs`, + `p`.`looktype` AS `type`, `p`.`lookaddons` AS `addons`, `p`.`maglevel` AS `magic`, `p`.`skill_fist` AS `fist`, @@ -277,9 +277,9 @@ if ($auction['characterAuction']) { ORDER BY MIN(`pid`) ASC "); $account = mysql_select_single(" - SELECT `points` - FROM `znote_accounts` - WHERE `account_id`={$this_account_id} + SELECT `points` + FROM `znote_accounts` + WHERE `account_id` = {$this_account_id} AND `points` >= {$character['price']} LIMIT 1; "); @@ -448,11 +448,11 @@ if ($auction['characterAuction']) { if ($pid > 0 && $cost >= $auction['lowestPrice']) { $account = mysql_select_single(" SELECT `a`.`id`, `a`.`password`, `za`.`points` - FROM `accounts` a + FROM `accounts` a INNER JOIN `znote_accounts` za ON `a`.`id` = `za`.`account_id` - WHERE `a`.`id`= {$this_account_id} - AND `a`.`password`='{$password}' + WHERE `a`.`id`= {$this_account_id} + AND `a`.`password`='{$password}' AND `za`.`points` >= {$deposit} LIMIT 1 ;"); @@ -460,34 +460,34 @@ if ($auction['characterAuction']) { // Check if player exist, is offline and not already in auction // And is not a tutor or a GM+. $player = mysql_select_single(" - SELECT `p`.`id`, `p`.`name`, - CASE - WHEN `po`.`player_id` IS NULL + SELECT `p`.`id`, `p`.`name`, + CASE + WHEN `po`.`player_id` IS NULL THEN 0 ELSE 1 END AS `online`, - CASE - WHEN `za`.`player_id` IS NULL + CASE + WHEN `za`.`player_id` IS NULL THEN 0 ELSE 1 END AS `alreadyInAuction` - FROM `players` p - LEFT JOIN `players_online` po + FROM `players` p + LEFT JOIN `players_online` po ON `p`.`id` = `po`.`player_id` - LEFT JOIN `znote_auction_player` za - ON `p`.`id` = `za`.`player_id` - AND `p`.`account_id` = `za`.`original_account_id` + LEFT JOIN `znote_auction_player` za + ON `p`.`id` = `za`.`player_id` + AND `p`.`account_id` = `za`.`original_account_id` AND `za`.`claimed` = 0 WHERE `p`.`id` = {$pid} - AND `p`.`account_id` = {$this_account_id} + AND `p`.`account_id` = {$this_account_id} AND `p`.`group_id` = 1 LIMIT 1 ;"); // Verify storage account ID exist $storage_account = mysql_select_single(" - SELECT `id` - FROM `accounts` - WHERE `id`={$auction['storage_account_id']} + SELECT `id` + FROM `accounts` + WHERE `id`={$auction['storage_account_id']} LIMIT 1; "); if ($storage_account === false) { @@ -534,22 +534,22 @@ if ($auction['characterAuction']) { mysql_update(" UPDATE `players` SET `account_id` = {$auction['storage_account_id']} - WHERE `id` = {$pid} + WHERE `id` = {$pid} LIMIT 1; "); // Hide character from public character list (in pidprofile.php) mysql_update(" UPDATE `znote_players` - SET `hide_char` = 1 - WHERE `player_id` = {$pid} + SET `hide_char` = 1 + WHERE `player_id` = {$pid} LIMIT 1; "); // Remove deposit from account $afterDeposit = $account['points'] - $deposit; mysql_update(" UPDATE `znote_accounts` - SET `points` = {$afterDeposit} - WHERE `account_id` = {$account['id']} + SET `points` = {$afterDeposit} + WHERE `account_id` = {$account['id']} LIMIT 1; "); } @@ -565,7 +565,7 @@ if ($auction['characterAuction']) { $time = time(); // If original account is the one trying to get it back, // and bidding period is over, - // and its not labelled as sold + // and its not labeled as sold // and nobody has bid on it $character = mysql_select_single(" SELECT `player_id` @@ -573,9 +573,9 @@ if ($auction['characterAuction']) { WHERE `id`= {$zaid} AND `original_account_id` = {$this_account_id} AND `time_end` <= {$time} - AND `bidder_account_id` = 0 + AND `bidder_account_id` = 0 AND `bid` = 0 - AND `sold` = 0 + AND `sold` = 0 LIMIT 1 "); //data_dump($character, false, "Character"); @@ -583,22 +583,22 @@ if ($auction['characterAuction']) { // Move character to buyer account and give it a new name mysql_update(" UPDATE `players` - SET `account_id` = {$this_account_id} - WHERE `id` = {$character['player_id']} + SET `account_id` = {$this_account_id} + WHERE `id` = {$character['player_id']} LIMIT 1; "); // Set label to sold mysql_update(" UPDATE `znote_auction_player` - SET `sold` = 1 - WHERE `id`= {$zaid} + SET `sold` = 1 + WHERE `id`= {$zaid} LIMIT 1; "); // Show character in public character list (in characterprofile.php) mysql_update(" UPDATE `znote_players` - SET `hide_char` = 0 - WHERE `player_id` = {$character['player_id']} + SET `hide_char` = 0 + WHERE `player_id` = {$character['player_id']} LIMIT 1; "); } @@ -650,56 +650,56 @@ if ($auction['characterAuction']) { // end name validation if (empty($errors)) { // Make sure you have access to claim this zaid character. - // And that you havent already claimed it. + // And that you haven't already claimed it. // And that the character isn't online... $character = mysql_select_single(" - SELECT + SELECT `za`.`id` AS `zaid`, `za`.`player_id`, - `p`.`account_id` + `p`.`account_id` FROM `znote_auction_player` za - INNER JOIN `players` p + INNER JOIN `players` p ON `za`.`player_id` = `p`.`id` LEFT JOIN `players_online` po ON `p`.`id` = `po`.`player_id` WHERE `za`.`id` = {$zaid} AND `za`.`sold` = 1 - AND `p`.`account_id` != {$this_account_id} - AND `za`.`bidder_account_id` = {$this_account_id} - AND `po`.`player_id` IS NULL + AND `p`.`account_id` != {$this_account_id} + AND `za`.`bidder_account_id` = {$this_account_id} + AND `po`.`player_id` IS NULL "); //data_dump($character, false, "Character"); if ($character !== false) { // Set character to claimed mysql_update(" - UPDATE `znote_auction_player` - SET `claimed`='1' - WHERE `id` = {$character['zaid']} + UPDATE `znote_auction_player` + SET `claimed`='1' + WHERE `id` = {$character['zaid']} "); // Move character to buyer account and give it a new name mysql_update(" UPDATE `players` SET `name` = '{$name}', - `account_id` = {$this_account_id} - WHERE `id` = {$character['player_id']} + `account_id` = {$this_account_id} + WHERE `id` = {$character['player_id']} LIMIT 1; "); // Show character in public character list (in characterprofile.php) mysql_update(" UPDATE `znote_players` - SET `hide_char` = 0 - WHERE `player_id` = {$character['player_id']} + SET `hide_char` = 0 + WHERE `player_id` = {$character['player_id']} LIMIT 1; "); // Remove character from other players VIP lists mysql_delete(" - DELETE FROM `account_viplist` - WHERE `player_id` = {$character['player_id']} + DELETE FROM `account_viplist` + WHERE `player_id` = {$character['player_id']} "); // Remove the character deathlist mysql_delete(" - DELETE FROM `player_deaths` - WHERE `player_id` = {$character['player_id']} + DELETE FROM `player_deaths` + WHERE `player_id` = {$character['player_id']} "); } else { $errors[] = "You either don't have access to claim this character, or you have already claimed it, or this character isn't sold yet, or we were unable to find this auction order."; @@ -715,7 +715,7 @@ if ($auction['characterAuction']) { - + $error): ?> @@ -734,28 +734,28 @@ if ($auction['characterAuction']) { // If this account have successfully bought or won an auction // Intercept the list action and let the user do claim actions $pending = mysql_select_multi(" - SELECT - `za`.`id` AS `zaid`, - CASE WHEN `za`.`price` > `za`.`bid` - THEN `za`.`price` - ELSE `za`.`bid` + SELECT + `za`.`id` AS `zaid`, + CASE WHEN `za`.`price` > `za`.`bid` + THEN `za`.`price` + ELSE `za`.`bid` END AS `price`, `za`.`time_begin`, `za`.`time_end`, - `p`.`vocation`, - `p`.`level`, - `p`.`lookbody` AS `body`, - `p`.`lookfeet` AS `feet`, - `p`.`lookhead` AS `head`, - `p`.`looklegs` AS `legs`, - `p`.`looktype` AS `type`, + `p`.`vocation`, + `p`.`level`, + `p`.`lookbody` AS `body`, + `p`.`lookfeet` AS `feet`, + `p`.`lookhead` AS `head`, + `p`.`looklegs` AS `legs`, + `p`.`looktype` AS `type`, `p`.`lookaddons` AS `addons` - FROM `znote_auction_player` za + FROM `znote_auction_player` za INNER JOIN `players` p ON `za`.`player_id` = `p`.`id` - WHERE `p`.`account_id` = {$auction['storage_account_id']} + WHERE `p`.`account_id` = {$auction['storage_account_id']} AND `za`.`claimed` = 0 - AND `za`.`sold` = 1 + AND `za`.`sold` = 1 AND `za`.`bidder_account_id` = {$this_account_id} ORDER BY `p`.`level` desc "); @@ -803,25 +803,25 @@ if ($auction['characterAuction']) { // Show the list $characters = mysql_select_multi(" SELECT - `za`.`id` AS `zaid`, - CASE WHEN `za`.`price` > `za`.`bid` + `za`.`id` AS `zaid`, + CASE WHEN `za`.`price` > `za`.`bid` THEN `za`.`price` - ELSE `za`.`bid`+{$step} + ELSE `za`.`bid`+{$step} END AS `price`, `za`.`time_begin`, `za`.`time_end`, - `p`.`vocation`, - `p`.`level`, - `p`.`lookbody` AS `body`, - `p`.`lookfeet` AS `feet`, - `p`.`lookhead` AS `head`, - `p`.`looklegs` AS `legs`, - `p`.`looktype` AS `type`, + `p`.`vocation`, + `p`.`level`, + `p`.`lookbody` AS `body`, + `p`.`lookfeet` AS `feet`, + `p`.`lookhead` AS `head`, + `p`.`looklegs` AS `legs`, + `p`.`looktype` AS `type`, `p`.`lookaddons` AS `addons` - FROM `znote_auction_player` za + FROM `znote_auction_player` za INNER JOIN `players` p ON `za`.`player_id` = `p`.`id` - WHERE `p`.`account_id` = {$auction['storage_account_id']} + WHERE `p`.`account_id` = {$auction['storage_account_id']} AND `za`.`sold` = 0 ORDER BY `p`.`level` desc; "); @@ -831,7 +831,7 @@ if ($auction['characterAuction']) {

Admin: Character auction history

#Issues occured while claiming your nameIssues occurred while claiming your name
@@ -875,20 +875,20 @@ if ($auction['characterAuction']) { $minToCreate = (int)ceil(($auction['lowestPrice'] / 100) * $auction['deposit']); $own_characters = mysql_select_multi(" SELECT - `p`.`id`, - `p`.`name`, - `p`.`level`, - `p`.`vocation`, - `a`.`points` - FROM `players` p + `p`.`id`, + `p`.`name`, + `p`.`level`, + `p`.`vocation`, + `a`.`points` + FROM `players` p INNER JOIN `znote_accounts` a ON `p`.`account_id` = `a`.`account_id` - LEFT JOIN `znote_auction_player` za - ON `p`.`id` = `za`.`player_id` - AND `p`.`account_id` = `za`.`original_account_id` + LEFT JOIN `znote_auction_player` za + ON `p`.`id` = `za`.`player_id` + AND `p`.`account_id` = `za`.`original_account_id` AND `za`.`claimed` = 0 - LEFT JOIN `players_online` po - ON `p`.`id` = `po`.`player_id` + LEFT JOIN `players_online` po + ON `p`.`id` = `po`.`player_id` WHERE `p`.`account_id`={$this_account_id} AND `za`.`player_id` IS NULL AND `po`.`player_id` IS NULL @@ -905,7 +905,7 @@ if ($auction['characterAuction']) {

Character: (Must be offline)

@@ -743,9 +743,9 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) { $mostdmg = ($d['mostdamage_is_player']) ? "".$d['mostdamage_by']."" : $d['mostdamage_by']; - + echo "
and by $mostdmg."; - + if ($d['mostdamage_unjustified']) { echo " (unjustified)"; } @@ -824,15 +824,15 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) { ?>
- + \ No newline at end of file +include 'layout/overall/footer.php'; ?> diff --git a/credits.php b/credits.php index 6336c04..c305573 100644 --- a/credits.php +++ b/credits.php @@ -14,10 +14,10 @@ if(!function_exists('curl_version')): // CURL enabled. Lets create an API web request to github. $request = curl_init(); curl_setopt($request, CURLOPT_URL, 'https://api.github.com/repos/Znote/ZnoteAAC/contributors'); - curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($request, CURLOPT_USERAGENT, 'ZnoteAAC'); // GitHub requires user agent header. curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false); - + // Load contributors and close the request. $developers = json_decode(curl_exec($request), true); // Sorted by contributions. curl_close($request); @@ -83,4 +83,4 @@ endif; text-align: center; } - \ No newline at end of file + diff --git a/engine/database/connect.php b/engine/database/connect.php index cb11a49..52aadf4 100644 --- a/engine/database/connect.php +++ b/engine/database/connect.php @@ -3,14 +3,14 @@ $time = time(); if (!isset($version)) $version = '1.5_SVN'; if (!function_exists("elapsedTime")) { - function elapsedTime($l_start = false, $l_time = false) { - if ($l_start === false) global $l_start; - if ($l_time === false) global $l_time; - - $l_time = explode(' ', microtime()); - $l_finish = $l_time[1] + $l_time[0]; - return round(($l_finish - $l_start), 4); - } + function elapsedTime($l_start = false, $l_time = false) { + if ($l_start === false) global $l_start; + if ($l_time === false) global $l_time; + + $l_time = explode(' ', microtime()); + $l_finish = $l_time[1] + $l_time[0]; + return round(($l_finish - $l_start), 4); + } } // ALTER TABLE `znote_accounts` ADD `active_email` TINYINT(4) NOT NULL DEFAULT '0' AFTER `active`; @@ -35,39 +35,40 @@ $install = " $connect = new mysqli($config['sqlHost'], $config['sqlUser'], $config['sqlPassword'], $config['sqlDatabase']); if ($connect->connect_errno) { - die("Failed to connect to MySQL: (" . $connect->connect_errno . ") " . $connect->connect_error . $install); + die("Failed to connect to MySQL: (" . $connect->connect_errno . ") " . $connect->connect_error . $install); } function mysql_znote_escape_string($escapestr) { - global $connect; - return mysqli_real_escape_string($connect, $escapestr); + global $connect; + return mysqli_real_escape_string($connect, $escapestr); } + // Select single row from database function mysql_select_single($query) { - global $connect; - global $aacQueries; - $aacQueries++; + global $connect; + global $aacQueries; + $aacQueries++; - global $accQueriesData; - $accQueriesData[] = "[" . elapsedTime() . "] " . $query; - $result = mysqli_query($connect,$query) or die(var_dump($query)."
(query - SQL error)
Type: select_single (select single row from database)

".mysqli_error($connect)); - $row = mysqli_fetch_assoc($result); - return !empty($row) ? $row : false; + global $accQueriesData; + $accQueriesData[] = "[" . elapsedTime() . "] " . $query; + $result = mysqli_query($connect,$query) or die(var_dump($query)."
(query - SQL error)
Type: select_single (select single row from database)

".mysqli_error($connect)); + $row = mysqli_fetch_assoc($result); + return !empty($row) ? $row : false; } // Selecting multiple rows from database. function mysql_select_multi($query){ - global $connect; - global $aacQueries; - $aacQueries++; - global $accQueriesData; - $accQueriesData[] = "[" . elapsedTime() . "] " . $query; - $array = array(); - $results = mysqli_query($connect,$query) or die(var_dump($query)."
(query - SQL error)
Type: select_multi (select multiple rows from database)

".mysqli_error($connect)); - while($row = mysqli_fetch_assoc($results)) { - $array[] = $row; - } - return !empty($array) ? $array : false; + global $connect; + global $aacQueries; + $aacQueries++; + global $accQueriesData; + $accQueriesData[] = "[" . elapsedTime() . "] " . $query; + $array = array(); + $results = mysqli_query($connect,$query) or die(var_dump($query)."
(query - SQL error)
Type: select_multi (select multiple rows from database)

".mysqli_error($connect)); + while($row = mysqli_fetch_assoc($results)) { + $array[] = $row; + } + return !empty($array) ? $array : false; } ////// @@ -81,11 +82,11 @@ function mysql_insert($query){ voidQuery($query); } function mysql_delete($query){ voidQuery($query); } // Send a void query function voidQuery($query) { - global $connect; - global $aacQueries; - $aacQueries++; - global $accQueriesData; - $accQueriesData[] = "[" . elapsedTime() . "] " . $query; - mysqli_query($connect,$query) or die(var_dump($query)."
(query - SQL error)
Type: voidQuery (voidQuery is used for update, insert or delete from database)

".mysqli_error($connect)); + global $connect; + global $aacQueries; + $aacQueries++; + global $accQueriesData; + $accQueriesData[] = "[" . elapsedTime() . "] " . $query; + mysqli_query($connect,$query) or die(var_dump($query)."
(query - SQL error)
Type: voidQuery (voidQuery is used for update, insert or delete from database)

".mysqli_error($connect)); } -?> \ No newline at end of file +?> diff --git a/engine/function/mail.php b/engine/function/mail.php index 1c3cb87..d604261 100644 --- a/engine/function/mail.php +++ b/engine/function/mail.php @@ -89,10 +89,10 @@ class Mail { //send the message, check for errors $status = false; if (!$mail->send()) { - echo "Mailer Error: " . $mail->ErrorInfo; - exit(); + echo "Mailer Error: " . $mail->ErrorInfo; + exit(); } else { - $status = true; + $status = true; } return $status; } diff --git a/engine/function/users.php b/engine/function/users.php index c1a8414..cc4d606 100644 --- a/engine/function/users.php +++ b/engine/function/users.php @@ -58,13 +58,13 @@ function fetchLatestDeaths_03($rowz = 30, $killers = false) { $countz = 0; if ($rowz === false || $killers === true) $getdeaths = mysql_select_multi("SELECT * FROM player_deaths ORDER BY date DESC;"); else $getdeaths = mysql_select_multi("SELECT * FROM `player_deaths` ORDER BY `date` DESC LIMIT 0, $rowz;"); - $data = false; + $data = false; //while ($showdeaths = mysql_fetch_assoc($getdeaths)) { - if ($getdeaths !== false) { - for ($i = 0; $i < count($getdeaths); $i++) { - $pid = $getdeaths[$i]['player_id']; - $level = $getdeaths[$i]['level']; - $kid = user_get_kid($getdeaths[$i]['id']); + if ($getdeaths !== false) { + for ($i = 0; $i < count($getdeaths); $i++) { + $pid = $getdeaths[$i]['player_id']; + $level = $getdeaths[$i]['level']; + $kid = user_get_kid($getdeaths[$i]['id']); $killedby = user_name(user_get_killer_id($kid)); @@ -78,7 +78,7 @@ function fetchLatestDeaths_03($rowz = 30, $killers = false) { $player = 2; $killedby = "Deleted player."; } - $getname = mysql_select_single("SELECT `name` FROM `players` WHERE `id` = '$pid' LIMIT 1;"); + $getname = mysql_select_single("SELECT `name` FROM `players` WHERE `id` = '$pid' LIMIT 1;"); $name = $getname['name']; $row = array(); $row['level'] = $level; @@ -98,47 +98,47 @@ function fetchLatestDeaths_03($rowz = 30, $killers = false) { } } } else $data[] = $row; - } - } + } + } return $data; } // Support list function support_list() { - $TFS = Config('ServerEngine'); + $TFS = Config('ServerEngine'); - if ($TFS == 'TFS_10') $staffs = mysql_select_multi("SELECT `p`.`id`, `a`.`type` as `group_id`, `p`.`name`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `p`.`account_id` = `a`.`id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;"); - else $staffs = mysql_select_multi("SELECT `a`.`type` as `group_id`, `p`.`name`, `p`.`online`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `a`.`id` = `p`.`account_id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;"); + if ($TFS == 'TFS_10') $staffs = mysql_select_multi("SELECT `p`.`id`, `a`.`type` as `group_id`, `p`.`name`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `p`.`account_id` = `a`.`id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;"); + else $staffs = mysql_select_multi("SELECT `a`.`type` as `group_id`, `p`.`name`, `p`.`online`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `a`.`id` = `p`.`account_id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;"); - foreach($staffs as $k => $v) { - foreach($staffs as $key => $value) { - if($k != $key && $v['account_id'] == $value['account_id']) { - unset($staffs[$k]); - } - } - } - $staffs = array_values($staffs); + foreach($staffs as $k => $v) { + foreach($staffs as $key => $value) { + if($k != $key && $v['account_id'] == $value['account_id']) { + unset($staffs[$k]); + } + } + } + $staffs = array_values($staffs); - if ($staffs !== false && $TFS == 'TFS_10') { - for ($i = 0; $i < count($staffs); $i++) { - // Fix online status on TFS 1.0 - $staffs[$i]['online'] = (isset($staffs[$i]['id']) && user_is_online_10($staffs[$i]['id'])) ? 1 : 0; - unset($staffs[$i]['id']); - } - } - return $staffs; + if ($staffs !== false && $TFS == 'TFS_10') { + for ($i = 0; $i < count($staffs); $i++) { + // Fix online status on TFS 1.0 + $staffs[$i]['online'] = (isset($staffs[$i]['id']) && user_is_online_10($staffs[$i]['id'])) ? 1 : 0; + unset($staffs[$i]['id']); + } + } + return $staffs; } function support_list03() { - $staffs = mysql_select_multi("SELECT `group_id`, `name`, `online`, `account_id` FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` ASC;"); + $staffs = mysql_select_multi("SELECT `group_id`, `name`, `online`, `account_id` FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` ASC;"); - if ($staffs !== false) { - for ($i = 0; $i < count($staffs); $i++) { - // $staffs[$i][''] - unset($staffs[$i]['account_id']); - } - } - return $staffs; + if ($staffs !== false) { + for ($i = 0; $i < count($staffs); $i++) { + // $staffs[$i][''] + unset($staffs[$i]['account_id']); + } + } + return $staffs; } // NEWS @@ -430,23 +430,22 @@ function update_player_guild_position_10($cid, $rid) { // Update player's guild nick function update_player_guildnick($cid, $nick) { - $cid = (int)$cid; - $nick = sanitize($nick); - if (!empty($nick)) { - - mysql_update("UPDATE `players` SET `guildnick`='$nick' WHERE `id`=$cid"); - } else { - mysql_update("UPDATE `players` SET `guildnick`='' WHERE `id`=$cid"); - } + $cid = (int)$cid; + $nick = sanitize($nick); + if (!empty($nick)) { + mysql_update("UPDATE `players` SET `guildnick`='$nick' WHERE `id`=$cid"); + } else { + mysql_update("UPDATE `players` SET `guildnick`='' WHERE `id`=$cid"); + } } function update_player_guildnick_10($cid, $nick) { - $cid = (int)$cid; - $nick = sanitize($nick); - if (!empty($nick)) { - mysql_update("UPDATE `guild_membership` SET `nick`='$nick' WHERE `player_id`=$cid"); - } else { - mysql_update("UPDATE `guild_membership` SET `nick`='' WHERE `player_id`=$cid"); - } + $cid = (int)$cid; + $nick = sanitize($nick); + if (!empty($nick)) { + mysql_update("UPDATE `guild_membership` SET `nick`='$nick' WHERE `player_id`=$cid"); + } else { + mysql_update("UPDATE `guild_membership` SET `nick`='' WHERE `player_id`=$cid"); + } } // Get guild data, using guild id. @@ -554,9 +553,9 @@ function get_guilds_list() { // Get array of player data related to a guild. function get_guild_players($gid) { - $gid = (int)$gid; // Sanitizing the parameter id - if (config('ServerEngine') !== 'TFS_10') return mysql_select_multi("SELECT `p`.`id`, `p`.`rank_id`, `p`.`name`, `p`.`level`, `p`.`guildnick`, `p`.`vocation`, `p`.`online`, `gr`.`name` AS `rank_name`, `gr`.`level` AS `rank_level` FROM `players` AS `p` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `p`.`rank_id` WHERE `gr`.`guild_id` ='$gid' ORDER BY `gr`.`id`, `p`.`name`;"); - else return mysql_select_multi("SELECT `p`.`id`, `p`.`name`, `p`.`level`, `p`.`vocation`, `gm`.`rank_id`, `gm`.`nick` AS `guildnick`, `gr`.`name` AS `rank_name`, `gr`.`level` AS `rank_level` FROM `players` AS `p` LEFT JOIN `guild_membership` AS `gm` ON `gm`.`player_id` = `p`.`id` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `gm`.`rank_id` WHERE `gm`.`guild_id` = '$gid' ORDER BY `gm`.`rank_id`, `p`.`name`"); + $gid = (int)$gid; // Sanitizing the parameter id + if (config('ServerEngine') !== 'TFS_10') return mysql_select_multi("SELECT `p`.`id`, `p`.`rank_id`, `p`.`name`, `p`.`level`, `p`.`guildnick`, `p`.`vocation`, `p`.`online`, `gr`.`name` AS `rank_name`, `gr`.`level` AS `rank_level` FROM `players` AS `p` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `p`.`rank_id` WHERE `gr`.`guild_id` ='$gid' ORDER BY `gr`.`id`, `p`.`name`;"); + else return mysql_select_multi("SELECT `p`.`id`, `p`.`name`, `p`.`level`, `p`.`vocation`, `gm`.`rank_id`, `gm`.`nick` AS `guildnick`, `gr`.`name` AS `rank_name`, `gr`.`level` AS `rank_level` FROM `players` AS `p` LEFT JOIN `guild_membership` AS `gm` ON `gm`.`player_id` = `p`.`id` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `gm`.`rank_id` WHERE `gm`.`guild_id` = '$gid' ORDER BY `gm`.`rank_id`, `p`.`name`"); } // Get guild level data (avg level, total level, count of players) @@ -660,20 +659,20 @@ function gesior_sql_killer($did) { // ADMIN FUNCTIONS function set_ingame_position($name, $acctype) { - $acctype = (int)$acctype; - $name = sanitize($name); + $acctype = (int)$acctype; + $name = sanitize($name); - $acc_id = user_character_account_id($name); - $char_id = user_character_id($name); + $acc_id = user_character_account_id($name); + $char_id = user_character_id($name); - $group_id = 1; - if ($acctype == 4) { - $group_id = 2; - } elseif ($acctype >= 5) { - $group_id = 3; - } - mysql_update("UPDATE `accounts` SET `type` = '$acctype' WHERE `id` =$acc_id;"); - mysql_update("UPDATE `players` SET `group_id` = '$group_id' WHERE `id` =$char_id;"); + $group_id = 1; + if ($acctype == 4) { + $group_id = 2; + } elseif ($acctype >= 5) { + $group_id = 3; + } + mysql_update("UPDATE `accounts` SET `type` = '$acctype' WHERE `id` =$acc_id;"); + mysql_update("UPDATE `players` SET `group_id` = '$group_id' WHERE `id` =$char_id;"); } // .3 @@ -1290,11 +1289,11 @@ function user_create_character($character_data) { // This is TFS 0.2 compatible import data with Znote AAC mysql schema if (config('ServerEngine') !== 'OTHIRE') { $import_data = array( - 'name' => $character_data['name'], + 'name' => $character_data['name'], 'group_id' => 1, 'account_id' => $character_data['account_id'], 'level' => $create['level'], - 'vocation' => $vocation, + 'vocation' => $vocation, 'health' => $health, 'healthmax' => $health, 'experience' => level_to_experience($create['level']), @@ -1335,11 +1334,11 @@ function user_create_character($character_data) { ); } else { $import_data = array( - 'name' => $character_data['name'], + 'name' => $character_data['name'], 'group_id' => 1, 'account_id' => $character_data['account_id'], 'level' => $create['level'], - 'vocation' => $vocation, + 'vocation' => $vocation, 'health' => $health, 'healthmax' => $health, 'experience' => level_to_experience($create['level']), @@ -1590,10 +1589,10 @@ function user_exist($username) { } function user_name($id) { //USERNAME FROM PLAYER ID - $id = (int)$id; - $name = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='$id';"); - if ($name !== false) return $name['name']; - else return false; + $id = (int)$id; + $name = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='$id';"); + if ($name !== false) return $name['name']; + else return false; } // Checks that character name exist diff --git a/guilds.php b/guilds.php index 696c9f3..6214b47 100644 --- a/guilds.php +++ b/guilds.php @@ -699,7 +699,7 @@ if ($highest_access >= 2) { - +