daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jun 30th, 2018 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $DB_SERVER = 'localhost';
  3.     $DB_USERNAME = 'jlarnes_admin';
  4.     $DB_PASSWORD = 'admin!';
  5.     $DB_NAME = 'jlarnes_db';
  6.     $DB_TABLE = 'sploders';
  7.    
  8.     $sqllink = mysql_connect($DB_SERVER, $DB_USERNAME, $DB_PASSWORD);
  9.     if (!$sqllink) {
  10.         die('FAILED 1 ' . mysql_error());
  11.     }
  12.    
  13.     $sqldb = mysql_select_db("$DB_NAME", $sqllink);
  14.     if (!$sqldb) {
  15.         die('FAILED 2 ' . mysql_error());
  16.     }
  17.    
  18.     // ID, LOC, TIME, MONEY, COORDS
  19.     $sql = "CREATE TABLE IF NOT EXISTS sploders " .
  20.            "(id VARCHAR(40), " .
  21.            "loc VARCHAR(40), " .
  22.            "time INT, " .
  23.            "money INT, " .
  24.            "coords VARCHAR(40))";
  25.    
  26.     mysql_query($sql);
  27.    
  28.     $CMD = $_GET['action'];
  29.     if ($CMD == 'update') {
  30.         $id = $_GET['id'];
  31.         $loc = $_GET['l'];
  32.         $time = $_GET['t'];
  33.         $money = $_GET['m'];
  34.         $coords = $_GET['c'];
  35.        
  36.         $sql = "UPDATE $DB_TABLE " .
  37.                "SET loc='$loc', money=$money, time=$time, coords='$coords' " .
  38.                "WHERE id='$id'";
  39.        
  40.         mysql_query($sql);
  41.     }
  42.    
  43.     if ($CMD == 'insert') {
  44.         $id = $_GET['id'];
  45.         $loc = $_GET['l'];
  46.         $time = $_GET['t'];
  47.         $money = $_GET['m'];
  48.         $coords = $_GET['c'];
  49.        
  50.         $sql = "INSERT INTO $DB_TABLE " .
  51.                "VALUES ('$id', '$loc', $time, $money, '$coords')";
  52.        
  53.         mysql_query($sql);
  54.     }
  55.    
  56.     if ($CMD == 'getlist') {
  57.         $t = $_GET['t'];
  58.         $p = $_GET['p'] * 10;
  59.         if ($p == '') $p = 0;
  60.         $e = $p + 10;
  61.        
  62.         $sql = "SELECT * FROM $DB_TABLE WHERE time >= $t - 100 ORDER BY money DESC LIMIT $p, $e";
  63.        
  64.         $result = mysql_query($sql);
  65.        
  66.         while ($row = mysql_fetch_assoc($result)) {
  67.             echo $row['id'] . "," . $row['loc'] . "," .
  68.                  $row['money'] . "," . $row['coords'] . "|";
  69.         }
  70.             mysql_query("DELETE FROM $DB_TABLE WHERE time < $t - 100");
  71.     }
  72.    
  73.     if ($CMD == 'showlist') {
  74.         $p = $_GET['p'] * 10;
  75.         if ($p == '') $p = 0;
  76.         $e = $p + 10;
  77.        
  78.         $sql = "SELECT * FROM $DB_TABLE WHERE time >= 0 ORDER BY money DESC LIMIT $p, $e";
  79.        
  80.         $result = mysql_query($sql);
  81.        
  82.         echo "<html>\n  <table border=1>\n    <tr>\n      <td width=100>id</td>\n      <td width=100>loc</td>\n      " .
  83.              "<td width=100>time</td>\n      <td width=100>money</td>\n      <td width=100>coords</td>\n";
  84.         while ($row = mysql_fetch_assoc($result)) {
  85.             echo "    <tr>\n";
  86.             echo "      <td width=100>" . $row['id'] . "</td>\n";
  87.             echo "      <td width=100>" . $row['loc'] . "</td>\n";
  88.             echo "      <td width=100>" . $row['time'] . "</td>\n";
  89.             echo "      <td width=100>" . $row['money'] . "</td>\n";
  90.             echo "      <td width=100>" . $row['coords'] . "</td>\n";
  91.             echo "    </tr>\n";
  92.            
  93.         }
  94.         echo "  </table>\n</html>";
  95.     }
  96.    
  97.     if ($CMD == 'droptable') {
  98.         $sql = "DROP TABLE $DB_TABLE";
  99.        
  100.         mysql_query($sql);
  101.     }
  102.     mysql_close($sqllink);
  103. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top