• 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!

Nicaw Shop System

Dumjaevl

#1 Error Maker
Joined
Sep 9, 2011
Messages
46
Reaction score
2
Location
Sweden
Heya! Does anybody still have Nicaw Shop System on their computer? Google'd and searched here on Otland, but can't find anything ^^


Regards
 
shop.php
PHP:
<?php
include ("include.inc.php");
$ptitle="Shop - $cfg[server_name]";
include ("header.inc.php");
$sale = (1-$cfg['sale']);
?>
<div id="content">
<div class="top">Shop</div>
<div class="midclasses">

<?PHP
$SQL = AAC::$SQL;
$query = mysql_query("SELECT * FROM nicaw_shop")
OR die(mysql_error());
?>
<table>
    <th style="width: 80px;">Image</th>
    <th style="width: 180px;">Name</th>
    <th>Descritpion</th>
    <th style="width: 80px;">Points</th>
    <th style="width: 90px;">Buy</th>
<tr>
<?php
while ($row = mysql_fetch_assoc($query)) {

$id = $row['id'];
echo "<td><center><img style='margin:5px' src='img/items/".$row['id'].".png'></center></td>";

echo "<td><center> ".$row['name']."</center></td>";

echo "<td><center> ".$row['info']."</center></td>";
if ($cfg['sale'] > 0) echo "<td><center><s>".$row['price']."</s> -".((1-$sale)*100)."% <b><br><font color='red'> ".round(($row['price'])*$sale)."p</font></b></center></td>";
else echo "<td><center> ".$row['price']."</center></td>";

$id = $row['id'];
if(empty($_SESSION['account'])) { echo '<td><center><a href="login.php?redirect='.$_SERVER['SCRIPT_NAME'].$_SERVER['QUERY_STRING'].'">Log in to buy</a></center></td>';}
else {echo "<td><center><a href='buy.php?id=$id'>Buy an item</a></center></td>";}

            echo "</tr>";
    }
    echo "</table>";
?>
<br>
</div>
<div class="bot"></div>
</div>
<?php include ("footer.inc.php");?>

buy.php
PHP:
<?php
session_start();

include ("include.inc.php");
//strona dla zalogowanych
try {
    $account = new Account();
    $account->load($_SESSION['account']);
} catch(AccountNotFoundException $e) {
    $_SESSION['account'] = '';
    header('location: login.php?redirect=account.php');
    die();
}
$ptitle="Buying Item - $cfg[server_name]";
include ("header.inc.php");
//
$sale= (1-$cfg['sale']); 

$SQL = AAC::$SQL;
$idd = mysql_real_escape_string($_GET['id']);
$query = mysql_query("SELECT * FROM nicaw_shop WHERE id = $idd")
OR die(mysql_error());
$check = mysql_fetch_assoc($query);
if ($query = $check) {
} else {
 echo '<center><b><span style="color:red">Error</span></b></center>';
}

?>
<div id="content">
<div class="top">Buying:
<?php
$SQL = AAC::$SQL;
$id = $_GET['id'];
$query = mysql_query("SELECT * FROM nicaw_shop WHERE id = $id") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) {
    $name = $row['name'];
    echo $name;
}
?>
</div>
<div class="mid">
<b>Character must be OFFLINE and you have to <font color="red">OPEN even once your DEPOT!</b></font><br>
<b>Postac musi byc offline i <font color="red">chociaz raz musisz OTWORZYĆ swoje DEPO!</font></b><br>
1. Open your depot and make sure that you have free spot.<br>
2. Log out from the game.<br>
3. Select your character (if is not on the list then try to refresh).</br>
4. Type your account password.</br>
5. Click "Purchase Item".</br>
6. Log in to the game and take item from your depot.</br>
<?php
$acc = $account->attrs['accno']; //acc pozyskiwane po zalogowaniu
$id = $_GET['id'];//id przedmiotu
$query = mysql_query("SELECT * FROM nicaw_shop WHERE id = $id")OR die(mysql_error());
while ($row = mysql_fetch_assoc($query)) {
$name = $row['name']; //nazwa przedmiotu
$cost = round(($row['price']*$sale)); //cena
$stackable = $row['stackable']; //stackable
echo 'You have now '.$account->attrs['points'].' Points.<br>';
echo 'You are buying<b> '.$name.'</b> for<b> '.$cost.' Points.</b><br>';
}
echo '<form action="buy.php?id='.$id.'" method="POST" >';
if ($stackable == 1) echo 'Count: <input type="number" name="count" value="1" min="1" max="100">';

echo '<table style="width: 70%"><tr><td>';
echo 'Select your character:<br><select name="username">';
if ($account->players)
    {
    foreach ($account->players as $player)
    {
        $gamer = new Player();
        $gamer->load($player['id']);
        if ($gamer->isOnline()){}else{
              $nick = $player['name'];
              echo '    <option>'.$nick.'</option>';
        }
    }
    echo '</select>*';
    }

echo '</td><td>';
echo '<br>Password:<br><input type="password" name="password"></br></br>';
echo '</td></td></table>';
echo '<input type="submit" name="submit" value=" Purchase Item "><br />';
echo "<br>*If this field is empty you have not got any characeters which fulfill conditions which were posted above.";
echo'<br>';
if ($_POST['submit'])
{
    $count = 1;
    $pass = (mysql_real_escape_string($_POST['password']));
    $user = (mysql_real_escape_string($_POST['username']));
    if (!(empty($_POST['count']))) {$count = (intval($_POST['count']));}
    $_SESSION['coste'] = ($cost*$count);
    if ((!empty($pass)) or (!empty($user))) {
        if (!preg_match("/^[a-zA-Z0-9]{3,30}$/", $pass)) { //hasło tylko litery i cyfry, ograniczenie do 30
            echo '<img src="resource/cross.png"/>';
            echo '<font color="red"><b>&nbsp; Wrong password, you can use only a-z and 0-9</b></font>';
        }            
        else {
            $wynik = mysql_query("SELECT password FROM accounts WHERE id = '$acc'")OR die(mysql_error());
            $row22 = mysql_fetch_array($wynik, MYSQL_ASSOC);
            if ($row22[password] == $pass) { //sprawdza czy hasło w bazie jest równe temu z formularza
                $wynik2 = mysql_query("SELECT account_id FROM players WHERE name = '$user'")OR die(mysql_error()); //sprawdza czy dany player ma ten sam numer acccount co podany w formularzu
                $row23 = mysql_fetch_array($wynik2, MYSQL_ASSOC);
                if ($row23[account_id] == $acc)
                {
                    if ($user) {
                        $check = mysql_query("SELECT id FROM accounts WHERE id = '$acc'")OR die(mysql_error());
                        $row99 = mysql_fetch_assoc($check);
                        if (mysql_num_rows($check) >= 1) {
         
                                $quer = mysql_query("SELECT points FROM accounts WHERE id = '$acc'")OR die(mysql_error());
                                while ($rowwe = mysql_fetch_assoc($quer)) {
                                $row9 = $rowwe['points'];
                            }
                            $valor = $_SESSION['coste'];
                            if ($row9 >= $valor) {
                                $idmg = $_SESSION['ider'];//sprawdzanie gracza i dodawanie przedmiotu
                                $idplayer = mysql_query("SELECT * FROM players WHERE name = '$user'");
                                while ( $row1 = mysql_fetch_assoc($idplayer))
                                {
                                    $idpp = $row1['id'];
                                }
                                $pod = mysql_query("SELECT MAX(sid) AS maxsid FROM player_depotitems WHERE player_id = '$idpp'")OR die(mysql_error());
                                while( $ped = mysql_fetch_assoc($pod))
                                {
                                    $pud = $ped['maxsid'];
                                    $pud++;
                                }
                                $error_tex = "";
                                $f = fopen("logs/shop.txt", "a");
                                $check_open = mysql_query("SELECT * FROM player_depotitems WHERE player_id = '$idpp' AND itemtype = 2594");
                                if (!$check_open) {
                                    $error_tex = "Error: ";
                                }
                                $dar = mysql_query("INSERT INTO player_depotitems VALUES('".$idpp."', '".$pud."', '101', '".$id."', '".$count."', '')")OR die("Error, insert query failed");
                                $lose = mysql_query("UPDATE accounts SET points = $row9 - $valor WHERE id = '$acc'");
                                $tofile_tex = "".$error_tex." ".date('d-m-Y G:i:s')." User ".$user." has bought: ".$count." ".$name.".
\n";
                                fwrite($f, $tofile_tex);
                                fclose($f);
                                echo '<img src="resource/tick.png"/>';
                                echo '<font color="green"><b>&nbsp; You succesfully bought '.$count.' '.$name.'! It was now added to your depot.</font></b>';
                                echo '<br> &nbsp; &nbsp; &nbsp; You have now '.($account->attrs['points'] - $valor).' Points.';
                            }
                            else {
                                $querry = mysql_query("SELECT points FROM accounts WHERE id = '$acc'")OR die(mysql_error());
                                while ($rowe = mysql_fetch_assoc($querry))
                                {
                                    $row19 = $rowe['points'];
                                 
                                    echo '<img src="resource/cross.png"/>';
                                    echo '<font color="red"><b>&nbsp; You need more points, you have <b>'.$row19.' points.</b></font>';
                                }
                             
                            }
                        }
                        else {
                            echo '<img src="resource/cross.png"/>';
                            echo '<font color="red"><b>&nbsp; User doesnt exists.</b></font>';
                        }                    
                    }
                }
                else {
                    echo '<img src="resource/cross.png"/>';
                    echo "<font color=red><b>&nbsp; On this account doesn't have this player.</b></font>";
                }

            }
            else {
                echo '<img src="resource/cross.png"/>';
                echo '<font color="red"><b>&nbsp; Incorrect password.</b></font>';
            }
        }
    }
    else {
        echo '<img src="resource/cross.png"/>';
        echo '<font color="red"><b>&nbsp; Please fill in all fields.</b></font>';
    }
}
?>
</div>
<div class="bot"></div>
</div>
<?php include ("footer.inc.php");?>

You may have some problems with styles because it was edited for my site and it's upgraded version of this which you can find on forum.

You should also add to config.inc lines:
PHP:
#SHOP - cbS 0.3 = 30%
$cfg['sale'] = '0.3';
And you can easly create sale on your shop!

You have to add "points" field (int32) to "accounts" base (phpmyadmin).
And the "nicaw_shop" base should look like this:
Beznbsptytuu_zps1nipdz1e.png

where:
- no is just next number 1, 2, 3...
- id is itemid
- name is item name
- price
- info is a description
- stackable (0 - no, 1- yes)

I have also the system for sms shop for homepay.pl services if you need.

Good luck!
 
Last edited:
shop.php
PHP:
<?php
include ("include.inc.php");
$ptitle="Shop - $cfg[server_name]";
include ("header.inc.php");
$sale = (1-$cfg['sale']);
?>
<div id="content">
<div class="top">Shop</div>
<div class="midclasses">

<?PHP
$SQL = AAC::$SQL;
$query = mysql_query("SELECT * FROM nicaw_shop")
OR die(mysql_error());
?>
<table>
    <th style="width: 80px;">Image</th>
    <th style="width: 180px;">Name</th>
    <th>Descritpion</th>
    <th style="width: 80px;">Points</th>
    <th style="width: 90px;">Buy</th>
<tr>
<?php
while ($row = mysql_fetch_assoc($query)) {

$id = $row['id'];
echo "<td><center><img style='margin:5px' src='img/items/".$row['id'].".png'></center></td>";

echo "<td><center> ".$row['name']."</center></td>";

echo "<td><center> ".$row['info']."</center></td>";
if ($cfg['sale'] > 0) echo "<td><center><s>".$row['price']."</s> -".((1-$sale)*100)."% <b><br><font color='red'> ".round(($row['price'])*$sale)."p</font></b></center></td>";
else echo "<td><center> ".$row['price']."</center></td>";

$id = $row['id'];
if(empty($_SESSION['account'])) { echo '<td><center><a href="login.php?redirect='.$_SERVER['SCRIPT_NAME'].$_SERVER['QUERY_STRING'].'">Log in to buy</a></center></td>';}
else {echo "<td><center><a href='buy.php?id=$id'>Buy an item</a></center></td>";}

            echo "</tr>";
    }
    echo "</table>";
?>
<br>
</div>
<div class="bot"></div>
</div>
<?php include ("footer.inc.php");?>

buy.php
PHP:
<?php
session_start();

include ("include.inc.php");
//strona dla zalogowanych
try {
    $account = new Account();
    $account->load($_SESSION['account']);
} catch(AccountNotFoundException $e) {
    $_SESSION['account'] = '';
    header('location: login.php?redirect=account.php');
    die();
}
$ptitle="Buying Item - $cfg[server_name]";
include ("header.inc.php");
//
$sale= (1-$cfg['sale']);

$SQL = AAC::$SQL;
$idd = mysql_real_escape_string($_GET['id']);
$query = mysql_query("SELECT * FROM nicaw_shop WHERE id = $idd")
OR die(mysql_error());
$check = mysql_fetch_assoc($query);
if ($query = $check) {
} else {
 echo '<center><b><span style="color:red">Error</span></b></center>';
}

?>
<div id="content">
<div class="top">Buying:
<?php
$SQL = AAC::$SQL;
$id = $_GET['id'];
$query = mysql_query("SELECT * FROM nicaw_shop WHERE id = $id") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) {
    $name = $row['name'];
    echo $name;
}
?>
</div>
<div class="mid">
<b>Character must be OFFLINE and you have to <font color="red">OPEN even once your DEPOT!</b></font><br>
<b>Postac musi byc offline i <font color="red">chociaz raz musisz OTWORZYĆ swoje DEPO!</font></b><br>
1. Open your depot and make sure that you have free spot.<br>
2. Log out from the game.<br>
3. Select your character (if is not on the list then try to refresh).</br>
4. Type your account password.</br>
5. Click "Purchase Item".</br>
6. Log in to the game and take item from your depot.</br>
<?php
$acc = $account->attrs['accno']; //acc pozyskiwane po zalogowaniu
$id = $_GET['id'];//id przedmiotu
$query = mysql_query("SELECT * FROM nicaw_shop WHERE id = $id")OR die(mysql_error());
while ($row = mysql_fetch_assoc($query)) {
$name = $row['name']; //nazwa przedmiotu
$cost = round(($row['price']*$sale)); //cena
$stackable = $row['stackable']; //stackable
echo 'You have now '.$account->attrs['points'].' Points.<br>';
echo 'You are buying<b> '.$name.'</b> for<b> '.$cost.' Points.</b><br>';
}
echo '<form action="buy.php?id='.$id.'" method="POST" >';
if ($stackable == 1) echo 'Count: <input type="number" name="count" value="1" min="1" max="100">';

echo '<table style="width: 70%"><tr><td>';
echo 'Select your character:<br><select name="username">';
if ($account->players)
    {
    foreach ($account->players as $player)
    {
        $gamer = new Player();
        $gamer->load($player['id']);
        if ($gamer->isOnline()){}else{
              $nick = $player['name'];
              echo '    <option>'.$nick.'</option>';
        }
    }
    echo '</select>*';
    }

echo '</td><td>';
echo '<br>Password:<br><input type="password" name="password"></br></br>';
echo '</td></td></table>';
echo '<input type="submit" name="submit" value=" Purchase Item "><br />';
echo "<br>*If this field is empty you have not got any characeters which fulfill conditions which were posted above.";
echo'<br>';
if ($_POST['submit'])
{
    $count = 1;
    $pass = (mysql_real_escape_string($_POST['password']));
    $user = (mysql_real_escape_string($_POST['username']));
    if (!(empty($_POST['count']))) {$count = (intval($_POST['count']));}
    $_SESSION['coste'] = ($cost*$count);
    if ((!empty($pass)) or (!empty($user))) {
        if (!preg_match("/^[a-zA-Z0-9]{3,30}$/", $pass)) { //hasło tylko litery i cyfry, ograniczenie do 30
            echo '<img src="resource/cross.png"/>';
            echo '<font color="red"><b>&nbsp; Wrong password, you can use only a-z and 0-9</b></font>';
        }           
        else {
            $wynik = mysql_query("SELECT password FROM accounts WHERE id = '$acc'")OR die(mysql_error());
            $row22 = mysql_fetch_array($wynik, MYSQL_ASSOC);
            if ($row22[password] == $pass) { //sprawdza czy hasło w bazie jest równe temu z formularza
                $wynik2 = mysql_query("SELECT account_id FROM players WHERE name = '$user'")OR die(mysql_error()); //sprawdza czy dany player ma ten sam numer acccount co podany w formularzu
                $row23 = mysql_fetch_array($wynik2, MYSQL_ASSOC);
                if ($row23[account_id] == $acc)
                {
                    if ($user) {
                        $check = mysql_query("SELECT id FROM accounts WHERE id = '$acc'")OR die(mysql_error());
                        $row99 = mysql_fetch_assoc($check);
                        if (mysql_num_rows($check) >= 1) {
        
                                $quer = mysql_query("SELECT points FROM accounts WHERE id = '$acc'")OR die(mysql_error());
                                while ($rowwe = mysql_fetch_assoc($quer)) {
                                $row9 = $rowwe['points'];
                            }
                            $valor = $_SESSION['coste'];
                            if ($row9 >= $valor) {
                                $idmg = $_SESSION['ider'];//sprawdzanie gracza i dodawanie przedmiotu
                                $idplayer = mysql_query("SELECT * FROM players WHERE name = '$user'");
                                while ( $row1 = mysql_fetch_assoc($idplayer))
                                {
                                    $idpp = $row1['id'];
                                }
                                $pod = mysql_query("SELECT MAX(sid) AS maxsid FROM player_depotitems WHERE player_id = '$idpp'")OR die(mysql_error());
                                while( $ped = mysql_fetch_assoc($pod))
                                {
                                    $pud = $ped['maxsid'];
                                    $pud++;
                                }
                                $error_tex = "";
                                $f = fopen("logs/shop.txt", "a");
                                $check_open = mysql_query("SELECT * FROM player_depotitems WHERE player_id = '$idpp' AND itemtype = 2594");
                                if (!$check_open) {
                                    $error_tex = "Error: ";
                                }
                                $dar = mysql_query("INSERT INTO player_depotitems VALUES('".$idpp."', '".$pud."', '101', '".$id."', '".$count."', '')")OR die("Error, insert query failed");
                                $lose = mysql_query("UPDATE accounts SET points = $row9 - $valor WHERE id = '$acc'");
                                $tofile_tex = "".$error_tex." ".date('d-m-Y G:i:s')." User ".$user." has bought: ".$count." ".$name.".
\n";
                                fwrite($f, $tofile_tex);
                                fclose($f);
                                echo '<img src="resource/tick.png"/>';
                                echo '<font color="green"><b>&nbsp; You succesfully bought '.$count.' '.$name.'! It was now added to your depot.</font></b>';
                                echo '<br> &nbsp; &nbsp; &nbsp; You have now '.($account->attrs['points'] - $valor).' Points.';
                            }
                            else {
                                $querry = mysql_query("SELECT points FROM accounts WHERE id = '$acc'")OR die(mysql_error());
                                while ($rowe = mysql_fetch_assoc($querry))
                                {
                                    $row19 = $rowe['points'];
                                
                                    echo '<img src="resource/cross.png"/>';
                                    echo '<font color="red"><b>&nbsp; You need more points, you have <b>'.$row19.' points.</b></font>';
                                }
                            
                            }
                        }
                        else {
                            echo '<img src="resource/cross.png"/>';
                            echo '<font color="red"><b>&nbsp; User doesnt exists.</b></font>';
                        }                   
                    }
                }
                else {
                    echo '<img src="resource/cross.png"/>';
                    echo "<font color=red><b>&nbsp; On this account doesn't have this player.</b></font>";
                }

            }
            else {
                echo '<img src="resource/cross.png"/>';
                echo '<font color="red"><b>&nbsp; Incorrect password.</b></font>';
            }
        }
    }
    else {
        echo '<img src="resource/cross.png"/>';
        echo '<font color="red"><b>&nbsp; Please fill in all fields.</b></font>';
    }
}
?>
</div>
<div class="bot"></div>
</div>
<?php include ("footer.inc.php");?>

You may have some problems with styles because it was edited for my site and it's upgraded version of this which you can find on forum.

You should also add to config.inc lines:
PHP:
#SHOP - cbS 0.3 = 30%
$cfg['sale'] = '0.3';
And you can easly create sale on your shop!

You have to add "points" field (int32) to "accounts" base (phpmyadmin).
And the "nicaw_shop" base should look like this:
Beznbsptytuu_zps1nipdz1e.png

where:
- no is just next number 1, 2, 3...
- id is itemid
- name is item name
- price
- info is a description
- stackable (0 - no, 1- yes)

I have also the system for sms shop for homepay.pl services if you need.

Good luck!

Thanks alot mate! Though, i got a problem on Shop.php, check your inbox! :)
 
Back
Top