Advertisement
Guest User

Untitled

a guest
Jun 10th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.23 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @author Stuart
  5.  * @copyright 2010
  6.  */
  7. include_once("config.php");
  8. include_once("database.class.php");
  9. session_start();
  10. $db = new Database($db_host, $db_user, $db_password, $db_name);
  11. if (!$db->connect()) {
  12.     die("CANT CONNECT TO SQL SERVER...");
  13. }
  14. if(isset($_SESSION['plimuslogin'])) {
  15.     if(isset($_POST['additem'])) {
  16.         if(isset($_POST['productid']) && isset($_POST['items'])) {
  17.             $db->query("INSERT INTO `products` (`productcode`, `itemids`) VALUES('".$_POST['productid']."', '".$_POST['items']."')");
  18.             die("Item inserted!");
  19.         } else if(isset($_GET['delete'])) {
  20.             $db->query("DELETE FROM `products` WHERE `id`='".$_GET['delete']."'");
  21.             die("Item deleted!");
  22.         }
  23.     } else {
  24. ?>
  25.     <h1>Add item to Plimus IPN</h1>
  26.     <form method="post" action="">
  27.     Plimus Product Id: <input type="text" name="productid"><br />
  28.     Items to give: <input type="text" name="items"> <small>(Multiple items seperated by a , example 1,2,3)</small><br/>
  29.     <input type="submit" name="additem" value="Add Item">
  30.     </form>
  31.     <h1>Products in Database</h1>
  32.     <?php
  33.         $query = $db->query("SELECT * FROM `products`");
  34.         while ($row = mysql_fetch_array($query)) {
  35.             echo "Product ID: " . $row['productcode'] . " Items to give: " .$row['itemids'] . " - <a href=\"index.php?delete=".$row['id']."\">DELETE</a><br/>";
  36.         }
  37.     ?>
  38.     <h1>Transactions</h1>
  39.     <?php
  40.     $query = $db->query("SELECT * FROM `items`");
  41.         while ($row = mysql_fetch_array($query)) {
  42.             $given = ($row['given'] == 1) ? "Yes" : "No";
  43.             echo "Time: " . $row['time'] . " Username: " . $row['username'] . " Items: " . $row['items'] . " Quantity: " .$row['quantity'] . " Given: " .$given;
  44.         }
  45.     }
  46.     ?>
  47. <?php
  48. } else {
  49.     if(isset($_POST['pswd'])) {
  50.         if($admin_password == $_POST['pswd']) {
  51.             $_SESSION['plimuslogin'] = true;
  52.             header("location: index.php");
  53.         } else {
  54.             alert("Wrong Password, please try again!");
  55.         }
  56.     }
  57. ?>
  58. <form method="post" action="">
  59. Password: <input type="password" name="pswd">
  60. <input type="submit" name="login" value="Login"><br />
  61. </form>
  62. <?php
  63. }
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement