mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-05-02 20:29:21 +02:00
Fixed several bugs with old SQL code.
This commit is contained in:
parent
0713d99a1b
commit
7d56b8ea9f
19
admin.php
19
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
|
// Give points to character
|
||||||
if (empty($_POST['points_char']) === false && empty($_POST['points_value']) === false) {
|
if (empty($_POST['points_char']) === false && empty($_POST['points_value']) === false) {
|
||||||
@ -140,7 +123,7 @@ if (empty($errors) === false){
|
|||||||
<?php
|
<?php
|
||||||
$basic = user_znote_data('version', 'installed', 'cached');
|
$basic = user_znote_data('version', 'installed', 'cached');
|
||||||
if ($basic['version'] !== $version) {
|
if ($basic['version'] !== $version) {
|
||||||
mysql_query("UPDATE `znote` SET `version`='$version';") or die(mysql_error());
|
mysql_update("UPDATE `znote` SET `version`='$version';") or die(mysql_error());
|
||||||
$basic = user_znote_data('version', 'installed', 'cached');
|
$basic = user_znote_data('version', 'installed', 'cached');
|
||||||
}
|
}
|
||||||
echo "Running Znote AAC Version: ". $basic['version'] .".<br>";
|
echo "Running Znote AAC Version: ". $basic['version'] .".<br>";
|
||||||
|
@ -8,7 +8,7 @@ if (empty($_POST) === false) {
|
|||||||
// Delete
|
// Delete
|
||||||
if ($action === 'd') {
|
if ($action === 'd') {
|
||||||
echo '<font color="green"><b>News deleted!</b></font>';
|
echo '<font color="green"><b>News deleted!</b></font>';
|
||||||
mysql_query("DELETE FROM `znote_news` WHERE `id`='$id';");
|
mysql_delete("DELETE FROM `znote_news` WHERE `id`='$id';");
|
||||||
$cache = new Cache('engine/cache/news');
|
$cache = new Cache('engine/cache/news');
|
||||||
$news = fetchAllNews();
|
$news = fetchAllNews();
|
||||||
$cache->setContent($news);
|
$cache->setContent($news);
|
||||||
@ -61,7 +61,7 @@ if (empty($_POST) === false) {
|
|||||||
echo '<font color="green"><b>News created successfully!</b></font>';
|
echo '<font color="green"><b>News created successfully!</b></font>';
|
||||||
list($charid, $title, $text) = array((int)$_POST['selected_char'], mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['text']));
|
list($charid, $title, $text) = array((int)$_POST['selected_char'], mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['text']));
|
||||||
$date = time();
|
$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.
|
// Reload the cache.
|
||||||
$cache = new Cache('engine/cache/news');
|
$cache = new Cache('engine/cache/news');
|
||||||
$news = fetchAllNews();
|
$news = fetchAllNews();
|
||||||
@ -72,7 +72,7 @@ if (empty($_POST) === false) {
|
|||||||
if ($action === 's') {
|
if ($action === 's') {
|
||||||
echo '<font color="green"><b>News successfully updated!</b></font>';
|
echo '<font color="green"><b>News successfully updated!</b></font>';
|
||||||
list($title, $text) = array(mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['text']));
|
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');
|
$cache = new Cache('engine/cache/news');
|
||||||
$news = fetchAllNews();
|
$news = fetchAllNews();
|
||||||
$cache->setContent($news);
|
$cache->setContent($news);
|
||||||
|
@ -57,8 +57,6 @@ if (!empty($_POST['change_gender'])) {
|
|||||||
|
|
||||||
// Fetch character tickets
|
// Fetch character tickets
|
||||||
$tickets = shop_account_gender_tickets($account_id);
|
$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) {
|
if ($tickets !== false || $config['free_sex_change'] == true) {
|
||||||
// They are allowed to change gender
|
// They are allowed to change gender
|
||||||
$last = false;
|
$last = false;
|
||||||
|
15
shop.php
15
shop.php
@ -23,15 +23,18 @@ if (!empty($_POST['buy'])) {
|
|||||||
|
|
||||||
// Verify that user can afford this offer.
|
// Verify that user can afford this offer.
|
||||||
if ($player_points >= $buy['points']) {
|
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.");
|
if ((int)$old_points != (int)$player_points) die("1: Failed to equalize your points.");
|
||||||
// Remove points if they can afford
|
// Remove points if they can afford
|
||||||
// Give points to user
|
// Give points to user
|
||||||
$expense_points = $buy['points'];
|
$expense_points = $buy['points'];
|
||||||
$new_points = $old_points - $expense_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));
|
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)
|
// Do the magic (insert into db, or change sex etc)
|
||||||
@ -42,15 +45,15 @@ if (!empty($_POST['buy'])) {
|
|||||||
echo '<font color="green" size="4">You now have '.$buy['count'].' additional days of premium membership.</font>';
|
echo '<font color="green" size="4">You now have '.$buy['count'].' additional days of premium membership.</font>';
|
||||||
} else if ($buy['type'] == 3) {
|
} else if ($buy['type'] == 3) {
|
||||||
// Character sex
|
// 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 '<font color="green" size="4">You now have access to change character gender on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the gender.</font>';
|
echo '<font color="green" size="4">You now have access to change character gender on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the gender.</font>';
|
||||||
} else {
|
} 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 '<font color="green" size="4">Your order is ready to be delivered. Write this command in-game to get it: [!shop].<br>Make sure you are in depot and can carry it before executing the command!</font>';
|
echo '<font color="green" size="4">Your order is ready to be delivered. Write this command in-game to get it: [!shop].<br>Make sure you are in depot and can carry it before executing the command!</font>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// No matter which type, we will always log it.
|
// 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 '<font color="red" size="4">You need more points, this offer cost '.$buy['points'].' points.</font>';
|
} else echo '<font color="red" size="4">You need more points, this offer cost '.$buy['points'].' points.</font>';
|
||||||
//var_dump($buy);
|
//var_dump($buy);
|
||||||
|
@ -17,42 +17,28 @@ require '../engine/function/users.php';
|
|||||||
|
|
||||||
// install functions
|
// install functions
|
||||||
function fetch_all_accounts() {
|
function fetch_all_accounts() {
|
||||||
$count = user_count_accounts();
|
return mysql_select_multi("SELECT `id` FROM `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;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_count_znote_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) {
|
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() {
|
function fetch_znote_accounts() {
|
||||||
$count = user_count_znote_accounts();
|
return mysql_select_multi("SELECT `account_id` FROM `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;}
|
|
||||||
}
|
}
|
||||||
// end install functions
|
// end install functions
|
||||||
|
|
||||||
// count all accounts, znote accounts, find out which accounts needs to be converted.
|
// count all accounts, znote accounts, find out which accounts needs to be converted.
|
||||||
$all_account = fetch_all_accounts();
|
$all_account = fetch_all_accounts();
|
||||||
$znote_account = fetch_znote_accounts();
|
$znote_account = fetch_znote_accounts();
|
||||||
if (isset($all_account)) {
|
if ($all_account !== false) {
|
||||||
// <
|
|
||||||
if ($znote_account != false) { // If existing znote compatible account exists:
|
if ($znote_account != false) { // If existing znote compatible account exists:
|
||||||
foreach ($all_account as $all) { // Loop through every element in znote_account array
|
foreach ($all_account as $all) { // Loop through every element in znote_account array
|
||||||
if (!in_array($all, $znote_account)) {
|
if (!in_array($all, $znote_account)) {
|
||||||
@ -64,7 +50,6 @@ require '../engine/function/users.php';
|
|||||||
$old_accounts[] = $all;
|
$old_accounts[] = $all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// >
|
|
||||||
}
|
}
|
||||||
// end ^
|
// end ^
|
||||||
|
|
||||||
@ -99,7 +84,7 @@ require '../engine/function/users.php';
|
|||||||
foreach ($old_accounts as $old) {
|
foreach ($old_accounts as $old) {
|
||||||
|
|
||||||
// Make acc data compatible:
|
// 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;
|
$updated_acc += 1;
|
||||||
|
|
||||||
// Fetch unsalted password
|
// 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);
|
if ($config['TFSVersion'] == 'TFS_03' && $config['salt'] === true) $p_pass = sha1($password['salt'].$p_pass);
|
||||||
|
|
||||||
// Update their password so they are sha1 encrypted
|
// 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;
|
$updated_pass += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +126,7 @@ require '../engine/function/users.php';
|
|||||||
if (user_character_is_compatible($c) == 0) {
|
if (user_character_is_compatible($c) == 0) {
|
||||||
// Then lets make it compatible:
|
// 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;
|
$updated_char += 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user