diff --git a/admin.php b/admin.php
index e464e9a..b8dafa4 100644
--- a/admin.php
+++ b/admin.php
@@ -62,23 +62,6 @@ if (empty($_POST) === false) {
}
}
}
-
- /* Give points to character
- if (empty($_POST['points_char']) === false && empty($_POST['points_value']) === false) {
- // fetch account id
- $char = $_POST['points_char'];
- $points = $_POST['points_value'];
- $accid = user_character_account_id($char);
- if ($points > 0) {
- if ($accid > 0) {
- $new_points = $points;
- $old_points = mysql_result(mysql_query("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$accid';"), 0, 'points');
- $new_points += $old_points;
- $update_account = mysql_query("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$accid'");
- $errors[] = 'Success! Character '. $char .' has recieved '. $points .' premium points.';
- } else $errors[] = 'Account id is invalid. (Did you write correct character name?)'. $accid;
- } else $errors[] = 'Why the heck give a character 0 points?!';
- }*/
// Give points to character
if (empty($_POST['points_char']) === false && empty($_POST['points_value']) === false) {
@@ -140,7 +123,7 @@ if (empty($errors) === false){
";
diff --git a/admin_news.php b/admin_news.php
index e10d7ef..8188d72 100644
--- a/admin_news.php
+++ b/admin_news.php
@@ -8,7 +8,7 @@ if (empty($_POST) === false) {
// Delete
if ($action === 'd') {
echo 'News deleted!';
- mysql_query("DELETE FROM `znote_news` WHERE `id`='$id';");
+ mysql_delete("DELETE FROM `znote_news` WHERE `id`='$id';");
$cache = new Cache('engine/cache/news');
$news = fetchAllNews();
$cache->setContent($news);
@@ -61,7 +61,7 @@ if (empty($_POST) === false) {
echo 'News created successfully!';
list($charid, $title, $text) = array((int)$_POST['selected_char'], mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['text']));
$date = time();
- mysql_query("INSERT INTO `znote_news` (`title`, `text`, `date`, `pid`) VALUES ('$title', '$text', '$date', '$charid');");
+ mysql_insert("INSERT INTO `znote_news` (`title`, `text`, `date`, `pid`) VALUES ('$title', '$text', '$date', '$charid');");
// Reload the cache.
$cache = new Cache('engine/cache/news');
$news = fetchAllNews();
@@ -72,7 +72,7 @@ if (empty($_POST) === false) {
if ($action === 's') {
echo 'News successfully updated!';
list($title, $text) = array(mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['text']));
- mysql_query("UPDATE `znote_news` SET `title`='$title',`text`='$text' WHERE `id`='$id';") or die("FUCK!");
+ mysql_update("UPDATE `znote_news` SET `title`='$title',`text`='$text' WHERE `id`='$id';") or die("FUCK!");
$cache = new Cache('engine/cache/news');
$news = fetchAllNews();
$cache->setContent($news);
diff --git a/myaccount.php b/myaccount.php
index 7c87a8f..0fccb2a 100644
--- a/myaccount.php
+++ b/myaccount.php
@@ -57,8 +57,6 @@ if (!empty($_POST['change_gender'])) {
// Fetch character tickets
$tickets = shop_account_gender_tickets($account_id);
- //$tickets = mysql_result(mysql_query("SELECT `count` FROM `znote_shop_orders` WHERE `account_id`='' AND `type`='3';"), 0, 'count');
- //$dbid = mysql_result(mysql_query("SELECT `id` FROM `znote_shop_orders` WHERE `account_id`='$account_id' AND `type`='3';"), 0, 'id');
if ($tickets !== false || $config['free_sex_change'] == true) {
// They are allowed to change gender
$last = false;
diff --git a/shop.php b/shop.php
index 518a079..52251c2 100644
--- a/shop.php
+++ b/shop.php
@@ -23,15 +23,18 @@ if (!empty($_POST['buy'])) {
// Verify that user can afford this offer.
if ($player_points >= $buy['points']) {
- $old_points = mysql_result(mysql_query("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';"), 0, 'points');
+ $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
+ if (!$data) die("0: Account is not converted to work with Znote AAC");
+ $old_points = $data['points'];
if ((int)$old_points != (int)$player_points) die("1: Failed to equalize your points.");
// Remove points if they can afford
// Give points to user
$expense_points = $buy['points'];
$new_points = $old_points - $expense_points;
- $update_account = mysql_query("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");
+ $update_account = mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");
- $verify = mysql_result(mysql_query("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';"), 0, 'points');
+ $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
+ $verify = $data['points'];
if ((int)$old_points == (int)$verify) die("2: Failed to equalize your points.". var_dump((int)$old_points, (int)$verify, $new_points, $expense_points));
// Do the magic (insert into db, or change sex etc)
@@ -42,15 +45,15 @@ if (!empty($_POST['buy'])) {
echo 'You now have '.$buy['count'].' additional days of premium membership.';
} else if ($buy['type'] == 3) {
// Character sex
- mysql_query("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')") or die(mysql_error());
+ mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
echo 'You now have access to change character gender on your characters. Visit My Account to select character and change the gender.';
} else {
- mysql_query("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')") or die(mysql_error());
+ mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
echo 'Your order is ready to be delivered. Write this command in-game to get it: [!shop].
Make sure you are in depot and can carry it before executing the command!';
}
// No matter which type, we will always log it.
- mysql_query("INSERT INTO `znote_shop_logs` (`account_id`, `player_id`, `type`, `itemid`, `count`, `points`, `time`) VALUES ('$cid', '0', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '". $buy['points'] ."', '$time')") or die(mysql_error());
+ mysql_insert("INSERT INTO `znote_shop_logs` (`account_id`, `player_id`, `type`, `itemid`, `count`, `points`, `time`) VALUES ('$cid', '0', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '". $buy['points'] ."', '$time')");
} else echo 'You need more points, this offer cost '.$buy['points'].' points.';
//var_dump($buy);
diff --git a/special/database2znoteaac.php b/special/database2znoteaac.php
index 9cbc9b2..56e2c05 100644
--- a/special/database2znoteaac.php
+++ b/special/database2znoteaac.php
@@ -17,42 +17,28 @@ require '../engine/function/users.php';
// install functions
function fetch_all_accounts() {
- $count = user_count_accounts();
- $query = mysql_query("SELECT `id` FROM `accounts`");
-
- for ($i = 0; $i < $count; $i++) {
- $row = mysql_fetch_row($query) or die(mysql_error());
- $array[] = $row[0];
- }
-
- if (isset($array)) {return $array; } else {return false;}
+ return mysql_select_multi("SELECT `id` FROM `accounts`");
}
function user_count_znote_accounts() {
- return mysql_result(mysql_query("SELECT COUNT(`account_id`) from `znote_accounts`;"), 0);
+ $data = mysql_select_single("SELECT COUNT(`account_id`) AS `count` from `znote_accounts`;");
+ return ($data !== false) ? $data['count'] : 0;
}
function user_character_is_compatible($pid) {
- return mysql_result(mysql_query("SELECT COUNT(`player_id`) from `znote_players` WHERE `player_id` = '$pid';"), 0);
+ $data = mysql_select_single("SELECT COUNT(`player_id`) AS `count` from `znote_players` WHERE `player_id` = '$pid';");
+ return ($data !== false) ? $data['count'] : 0;
}
function fetch_znote_accounts() {
- $count = user_count_znote_accounts();
- $query = mysql_query("SELECT `account_id` FROM `znote_accounts`");
- for ($i = 0; $i < $count; $i++) {
- $row = mysql_fetch_row($query) or die(mysql_error());
- $array[] = $row[0];
- }
-
- if (isset($array)) {return $array; } else {return false;}
+ return mysql_select_multi("SELECT `account_id` FROM `znote_accounts`");
}
// end install functions
// count all accounts, znote accounts, find out which accounts needs to be converted.
$all_account = fetch_all_accounts();
$znote_account = fetch_znote_accounts();
- if (isset($all_account)) {
- // <
+ if ($all_account !== false) {
if ($znote_account != false) { // If existing znote compatible account exists:
foreach ($all_account as $all) { // Loop through every element in znote_account array
if (!in_array($all, $znote_account)) {
@@ -64,7 +50,6 @@ require '../engine/function/users.php';
$old_accounts[] = $all;
}
}
- // >
}
// end ^
@@ -99,7 +84,7 @@ require '../engine/function/users.php';
foreach ($old_accounts as $old) {
// Make acc data compatible:
- mysql_query("INSERT INTO `znote_accounts` (`account_id`, `ip`, `created`) VALUES ('$old', '0', '$time')") or die(mysql_error());
+ mysql_insert("INSERT INTO `znote_accounts` (`account_id`, `ip`, `created`) VALUES ('$old', '0', '$time')");
$updated_acc += 1;
// Fetch unsalted password
@@ -119,7 +104,7 @@ require '../engine/function/users.php';
if ($config['TFSVersion'] == 'TFS_03' && $config['salt'] === true) $p_pass = sha1($password['salt'].$p_pass);
// Update their password so they are sha1 encrypted
- mysql_query("UPDATE `accounts` SET `password`='$p_pass' WHERE `id`='$old';") or die(mysql_error());
+ mysql_update("UPDATE `accounts` SET `password`='$p_pass' WHERE `id`='$old';");
$updated_pass += 1;
}
@@ -141,7 +126,7 @@ require '../engine/function/users.php';
if (user_character_is_compatible($c) == 0) {
// Then lets make it compatible:
- mysql_query("INSERT INTO `znote_players` (`player_id`, `created`, `hide_char`, `comment`) VALUES ('$c', '$time', '0', '')") or die(mysql_error());
+ mysql_insert("INSERT INTO `znote_players` (`player_id`, `created`, `hide_char`, `comment`) VALUES ('$c', '$time', '0', '')");
$updated_char += 1;
}