Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author Stuart
- * @copyright 2010
- */
- include_once("config.php");
- include_once("database.class.php");
- session_start();
- $db = new Database($db_host, $db_user, $db_password, $db_name);
- if (!$db->connect()) {
- die("CANT CONNECT TO SQL SERVER...");
- }
- if(isset($_SESSION['plimuslogin'])) {
- if(isset($_POST['additem'])) {
- if(isset($_POST['productid']) && isset($_POST['items'])) {
- $db->query("INSERT INTO `products` (`productcode`, `itemids`) VALUES('".$_POST['productid']."', '".$_POST['items']."')");
- die("Item inserted!");
- } else if(isset($_GET['delete'])) {
- $db->query("DELETE FROM `products` WHERE `id`='".$_GET['delete']."'");
- die("Item deleted!");
- }
- } else {
- ?>
- <h1>Add item to Plimus IPN</h1>
- <form method="post" action="">
- Plimus Product Id: <input type="text" name="productid"><br />
- Items to give: <input type="text" name="items"> <small>(Multiple items seperated by a , example 1,2,3)</small><br/>
- <input type="submit" name="additem" value="Add Item">
- </form>
- <h1>Products in Database</h1>
- <?php
- $query = $db->query("SELECT * FROM `products`");
- while ($row = mysql_fetch_array($query)) {
- echo "Product ID: " . $row['productcode'] . " Items to give: " .$row['itemids'] . " - <a href=\"index.php?delete=".$row['id']."\">DELETE</a><br/>";
- }
- ?>
- <h1>Transactions</h1>
- <?php
- $query = $db->query("SELECT * FROM `items`");
- while ($row = mysql_fetch_array($query)) {
- $given = ($row['given'] == 1) ? "Yes" : "No";
- echo "Time: " . $row['time'] . " Username: " . $row['username'] . " Items: " . $row['items'] . " Quantity: " .$row['quantity'] . " Given: " .$given;
- }
- }
- ?>
- <?php
- } else {
- if(isset($_POST['pswd'])) {
- if($admin_password == $_POST['pswd']) {
- $_SESSION['plimuslogin'] = true;
- header("location: index.php");
- } else {
- alert("Wrong Password, please try again!");
- }
- }
- ?>
- <form method="post" action="">
- Password: <input type="password" name="pswd">
- <input type="submit" name="login" value="Login"><br />
- </form>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement