• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Windows Znote convert this php files to [1.5 SVN]

lopez65

Member
Joined
May 10, 2012
Messages
294
Solutions
1
Reaction score
16
Location
Barcelona
hi
someone could make me these two .*php files to work on 1.5 Znote SVN.

Code:
<?PHP
    if($logged) {
       
        if ($action == '') {
       
        $main_content .= '<center>Here is the list of the current characters that are in the shop!</center>';
        $main_content .= '<BR>';
        $main_content .= '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white width="64px"><CENTER><B>Name</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Vocation</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Level</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Price</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Buy it</B></CENTER></TD></TR>';
        $getall = $SQL->query('SELECT `id`, `name`, `price`, `status` FROM `sellchar` ORDER BY `id`')or die(mysql_error());
        foreach ($getall as $tt) {
            $namer = $tt['name'];
            $queryt = $SQL->query("SELECT `name`, `vocation`, `level` FROM `players` WHERE `name` = '$namer'");
            foreach ($queryt as $ty) {
            if ($ty['vocation'] == 1) {
            $tu = 'Sorcerer';
        } else if ($ty['vocation'] == 2) {
            $tu = 'Druid';   
        } else if ($ty['vocation'] == 3) {
            $tu = 'Paladin';   
        } else if ($ty['vocation'] == 4) {
            $tu = 'Knight';
        } else if ($ty['vocation'] == 5) {
            $tu = 'Sorcerer';
        }  else if ($ty['vocation'] == 6) {
            $tu = 'Druid';   
        } else if ($ty['vocation'] == 7) {
            $tu = 'Paladin';   
        } else if ($ty['vocation'] == 8) {
            $tu = 'Knight';
        }
        $ee = $tt['name'];
        $ii = $tt['price'];
        $main_content .= '<TR BGCOLOR='.$config['site']['darkborder'].'><TD CLASS=black width="64px"><CENTER><B><a href="index.php?subtopic=characters&name='.$tt['name'].'">'.$tt['name'].'</a></B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>'.$tu.'</B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>'.$ty['level'].'</B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>'.$tt['price'].'</B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>
        <form action="?subtopic=buychar&action=buy" method="POST">
        <input type="hidden" name="char" value="'.$ee.'">
        <input type="hidden" name="price" value="'.$ii.'">
        <input type="submit" name="submit" value="Buy it"></B></CENTER></TD></TR></form>';
        }
        }
        $main_content .= '</TABLE>';
       
        }
       
        if ($action == 'buy') {
       
            $name = $_POST['char'];   
            $price = $_POST['price'];   
            $ceh = $SQL->query("SELECT `name` FROM `sellchar` WHERE `name` = '$name'");
           
            if ($ceh) {
           
            if ($name == '') {
           
            $main_content .= '<b><center>Select a character to buy first/b>';
           
            } else {
           
            $user_premium_points = $account_logged->getCustomField('premium_points');
            $user_id = $account_logged->getCustomField('id');
           
            if ($user_premium_points >= $price) {
               
            $check = $SQL->query("SELECT * FROM `sellchar` WHERE `name` = '$name'") or die(mysql_error());
            $check1 = $SQL->query("SELECT * FROM `players` WHERE `name` = '$name'") or die(mysql_error());
            $check2 = $SQL->query("SELECT `oldid` FROM `sellchar` WHERE `name` = '$name'");
            foreach ($check as $result) {
            foreach($check1 as $res) {
            foreach($check2 as $ress) {
           
            $oid = $ress['oldid'];   
            $main_content .= '<center>You bought<b> '.$name.' ( '.$res['level'].' ) </b>for  <b>'.$result['price'].' points.</b><br></center>';
            $main_content .= '<br>';
            $main_content .= '<center><b>The character is in your account, have fun!</b></center>';
            $execute1 = $SQL->query("UPDATE `accounts` SET `premium_points` = `premium_points` - '$price' WHERE `id` = '$user_id'");
            $execute2 = $SQL->query("UPDATE `players` SET `account_id` = '$user_id' WHERE `name` = '$name'");
            $execute2 = $SQL->query("UPDATE `accounts` SET `premium_points` = `premium_points` + '$price' WHERE `id` = '$oid'");
            $execute3 = $SQL->query("DELETE FROM `sellchar` WHERE `name` = '$name'");
           
            }
                }
            }
               
            } else {
               
                $main_content .= '<center><b>You dont have enought premium points</b></center>';
               
                    }
           
                }   
               
            } else {
                $main_content .= '<center><b>Character cannot be buyed</b></center>';
            }
        }
       
    } else {
       
        $main_content .= '<center>Please log in first!</center>';
    }
?>

Code:
<?PHP
    if($logged) {
        $main_content .= '<center><b>Here you can put your character on sale!</center></b><br>';
        $main_content .= 'If you put your character on sale anyone can buy it, you will lose acces to that character and you wont be able to log in with that character until someone buys it, you can also delete your offer by talking to an admin!<br><b>when someone buys your character you will get the price in points!</b>';
        $main_content .= '<br>';
        $main_content .= '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white width="64px"><CENTER><B>Sell your characters</B></CENTER></TD></TR>';
        $main_content .= '<TR BGCOLOR='.$config['site']['darkborder'].'><TD CLASS=black width="64px"><B></B>';
       
        $players_from_logged_acc = $account_logged->getPlayersList();
                           
                                $players_from_logged_acc->orderBy('name');
                                $main_content .= '<form action="" method="post"><select name="char">';
                                foreach($players_from_logged_acc as $player)
                                {
                                    $main_content .= '<option>'.$player->getName().'</option>';
                                }
       
        $main_content .= '</select>Select a character to sell<br>';
        $main_content .= '<input type="text" name="price" maxlength="10" size="4" >Select the price of the character<br>';
        $main_content .= '<input type="submit" name="submit" value="Sell character"></TD></TR>';
                            $main_content .= '</form></table>';
                           
                            if (isset($_POST['submit'])) {
                               
                            $char = mysql_real_escape_string($_POST['char']);
                            $price = mysql_real_escape_string($_POST['price']);
                           
                            if ($char && $price) {

                                if(is_numeric(trim($_POST['price']))) {
                               
                                        $check2 = $SQL->query("SELECT * FROM `players` WHERE `name` = '$char'") or die(mysql_error());
                                foreach ($check2 as $re) {
                                    $voc = $re['vocation'];
                                    $oid = $re['account_id'];
                                }
                                $check1 = $SQL->query("UPDATE `players` SET `account_id` = 1 WHERE `name` = '$char'") or die(mysql_error());
                                $check3 = $SQL->query("INSERT INTO `sellchar` VALUES ('','$char','$voc','$price','1','$oid')");
                                $main_content .= '<b><center>You added your character correctly, thanks!</b></center>';
                                header("Location: index.php?subtopic=buychar");
                               
                                } else {
                           
                                $main_content .= '<b><center>Set a numeric price!!</b></center>';
                                }
                               
                            } else {
                                    $main_content .= '<b><center>Fill out all fields!</b></center>';
                            }
                           
                        }
    } else {
        $main_content .= '<b><center>Please log in first!</b></center>';
    }
?>


Gesior these files are for 2012 and would like to pass my account because although Znote comes this as a demo and does not sell the char or anything.

Greetings and thanks for reading
 
Hi @Znote

answer me that privilege that the creator of that great PAAC, really I get this error on the last line of your script:



Code:
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\auctionChar.php on line 152

can you please review master :D:rolleyes:
Greetings and thanks for reading
 
Alright, bugfix1:
PHP:
<?php 
// Load the Znote AAC engine
require_once 'engine/init.php';
// Load the top half of the layout:
include 'layout/overall/header.php'; 
//Only give logged in users access to this page:
protect_page();

// Fetch the action response in a secured manner to prevent possibility of hacks.
if (isset($_POST['action']) && !empty($_POST['action'])) $action = getValue($_POST['action']);
else $action = '';



// If there is no action submitted, display the shop:
if ($action == '') {
    // Draw the html structure
    ?>
    <center>Here is the list of the current characters that are in the shop!</center>
    <BR>
    <TABLE BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
        <TR class="yellow">
            <TD CLASS=white width="64px">
                <CENTER><B>Name</B></CENTER>
            </TD>
            <TD CLASS=white width="64px">
                <CENTER><B>Vocation</B></CENTER>
            </TD>
            <TD CLASS=white width="64px">
                <CENTER><B>Level</B></CENTER>
            </TD>
            <TD CLASS=white width="64px">
                <CENTER><B>Price</B></CENTER>
            </TD>
            <TD CLASS=white width="64px">
                <CENTER><B>Buy it</B></CENTER>
            </TD>
        </TR>
        <?php
        // Fetch all characters for sale from database
        $getall = mysql_select_multi('SELECT `id`, `name`, `price`, `status` FROM `sellchar` ORDER BY `id`;');
        if ($getall !== false && !empty($getall)) {
            // Loop through all characters for sale
            foreach ($getall as $tt) {
                // Duplicate data to variables coz the original coder got nothing better to do.
                $namer = $tt['name'];
                // Fetches character data from players table
                $ty = mysql_select_single("SELECT `name`, `vocation`, `level` FROM `players` WHERE `name` = '$namer' LIMIT 1;");
                // If the character actually exist
                if ($ty !== false && !empty($ty)) {
                    // Fetch vocation name
                    $tu = $config['vocations'][$ty['vocation']];
                    // Duplicating the same data to another variable coz yolo.
                    $ee = $tt['name'];
                    // And duplicates the price for this character. 
                    $ii = $tt['price'];

                    // Displays the character data we have fetched and display it on the table list. 
                    ?>
                    <TR class="yellow">
                        <TD CLASS=black width="64px">
                            <CENTER>
                                <B><a href="characterprofile.php?name=<?php echo $tt['name']; ?>"><?php echo $tt['name']; ?></a></B>
                            </CENTER>
                        </TD>
                        <TD CLASS=black width="64px">
                            <CENTER><B><?php echo $tu; ?></B></CENTER>
                        </TD>
                        <TD CLASS=black width="64px">
                            <CENTER><B><?php echo $ty['level']; ?></B></CENTER>
                        </TD>
                        <TD CLASS=black width="64px">
                            <CENTER><B><?php echo $tt['price']; ?></B></CENTER>
                        </TD>
                        <TD CLASS=black width="64px">
                            <CENTER>
                                <B>
                                    <form action="?action=buy" method="POST">
                                        <input type="hidden" name="char" value="<?php echo $ee; ?>">
                                        <input type="hidden" name="price" value="<?php echo $ii; ?>">
                                        <input type="submit" name="submit" value="Buy it">
                                    </form>
                                </B>
                            </CENTER>
                        </TD>
                    </TR>
                    <?php
                }
            }
        }
        ?>
    </TABLE>
    <?php
    // If the visitor has decided to buy a character
} elseif ($action == 'buy') {
    // Fetch neccesary sales data
    $name = getValue($_POST['char']);  
    $price = getValue($_POST['price']);

    // Fetches the same name from database, this time intended to verify its existence. 
    $exist = mysql_select_single("SELECT `name` FROM `sellchar` WHERE `name` = '$name' LIMIT 1;");
    // A false existance is futile, but a not false existance means it exists. :)
    // When using Znote AAC queries, it will return false if no match/not exist, while an array with data if it exist.
    if ($exist !== false && !empty($exist)) {
        // If the name is nothing, then obviously you tried to buy a character that didnt exist. 
        // This should never be triggered as we just confirmed the characters existence. :/
        if ($name == '') {
            echo '<b><center>Select a character to buy first</center></b>';
        } else {
            // Now for realz it exist, lets proceed by fetched the available premium points of the logged in user.
            $user_premium_points = $user_znote_data['points'];
            // And the account id so we know which bank to withdraw the funds from. :)
            $user_id = $user_data['id'];

            // If this account can afford this purchase:
            if ($user_premium_points >= $price) {

                // Its time for more verifications!
                $result = mysql_select_single("SELECT * FROM `sellchar` WHERE `name` = '$name' LIMIT 1;");
                $res = mysql_select_single("SELECT * FROM `players` WHERE `name` = '$name' LIMIT 1;");
                $ress = mysql_select_single("SELECT `oldid` FROM `sellchar` WHERE `name` = '$name' LIMIT 1;");
                if ($result !== false && !empty($result)) {
                    if ($res !== false && !empty($res)) {
                        if ($ress !== false && !empty($ress)) {
                            // Lets fetch the old account id, so we also know which bank to add funds to after the transaction.
                            $oid = $ress['oldid'];
                            ?>
                            <center>
                                You bought <b><?php echo $name; ?> ( <?php echo $res['level']; ?> )</b> for <b><?php echo $result['price']; ?> points.</b>
                                <br>
                            </center>
                            <br>
                            <center><b>The character is in your account, have fun!</b></center>
                            <?php
                            // Then transfer the character and the funds. 
                            mysql_update("UPDATE `accounts` SET `premium_points` = `premium_points` - '$price' WHERE `id` = '$user_id' LIMIT 1;");
                            mysql_update("UPDATE `players` SET `account_id` = '$user_id' WHERE `name` = '$name' LIMIT 1;");
                            mysql_update("UPDATE `accounts` SET `premium_points` = `premium_points` + '$price' WHERE `id` = '$oid' LIMIT 1;");
                            // then delete this character from the "sale" list. 
                            mysql_delete("DELETE FROM `sellchar` WHERE `name` = '$name' LIMIT 1;");
                        }
                    }
                }
            } else {
                echo '<center><b>You dont have enought premium points</b></center>';
            }
        }
    } else {
        echo '<center><b>Character cannot be buyed</b></center>';
    }
} else {
    echo '<center>Please log in first!</center>';
}

// Load the bottom half of the layout
include 'layout/overall/footer.php'; 
?>
 
Because I get this error, I thought I just need the table Znote_auction_char ??

Here is the list of the current characters that are in the shop!
string(69) "SELECT `id`, `name`, `price`, `status` FROM `sellchar` ORDER BY `id`;"
(query - SQL error)
Type: select_multi (select multiple rows from database)

Table 'forgotten.sellchar' doesn't exist

auctiuon.jpg
auctiuon.jpg


auctio1.jpg
 
You need the original tables, (sellchar, not forgotten.sellchar). The code is converted gesior code so it relies on the same tables as on gesior.

The reason it says "forgotten" is because its your database name I assume.

Table 'forgotten.sellchar' doesn't exist
means:
The table "sellchar" does not exist in the database "forgotten".
 
No, but this:
Code:
CREATE TABLE IF NOT EXISTS `sellchar` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) NOT NULL,
`vocation` int(11) NOT NULL,
`price` int(11) NOT NULL,
`status` varchar(40) NOT NULL,
`oldid` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

kiHVnc_1.png
 
@Znote

Ok, you're the best, just one thing, already fixed but does not leave me any menu to add or add a character to sell ???


Yeah I only converted one of the 2 scripts you posted. I don't have time to convert the other one as I am very busy.
 
Yeah I only converted one of the 2 scripts you posted. I don't have time to convert the other one as I am very busy.

Well I have so little hurry ... your first your most important things in your real life, if you have time and feel like, because you do friend.
greetings and thanks for replying.
 
Doesnt matter, when you convert something to your AAC, you should convert it good in every aspect, not let people use bad performance scripts.
I intend to make this system from scratch done properly and commit it to my repo. I already started but had to leave it due to lack of time.
 
Back
Top