function saveList($data) { global $db; //Create list entry $st = $db->prepare("INSERT INTO shoppingLists(`created`, `ip`) VALUES (UNIX_TIMESTAMP(), :ip)"); $st->bindValue(":ip", $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR); $st->execute(); //Get id and create key $id = $db->lastInsertId(); //Save data to paste $pasteKey = savePaste($data); $key = sha1("thenewguyfromdownstairs" . $id); $st = $db->prepare("UPDATE shoppingLists SET `key`=:key,`pasteKey`=:pasteKey WHERE id=:id LIMIT 1"); $st->bindValue(":key", $key, PDO::PARAM_STR); $st->bindValue(":pasteKey", $pasteKey, PDO::PARAM_STR); $st->bindValue(":id", $id, PDO::PARAM_INT); $st->execute(); return $key; }
<?php include "functions.php"; //Save paste if it was recieved if (isset($_POST['paste'])) { $key = savePaste($_POST['paste']); header('Location: /paste/' . $key); } ?> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <!-- Latest compiled and minified CSS --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-sanitize.min.js"></script> <script type="text/javascript" src="/shopping/items.js"></script> <script src="/itemdb/itemdb.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <?php include "../switcher.php"; ?> <link rel="stylesheet" href="/itemdb/css/custom.css"> <!-- Optional theme --> <!-- Latest compiled and minified JavaScript -->
function saveLScan($lscan, $system = "") { global $db; //Save the json object in the pastebin dumb system $pasteKey = savePaste(json_encode($lscan)); //Tally total $total = 0; foreach ($lscan['corps'] as $corp) { $total += $corp['quantity']; } //Create scan entry $st = $db->prepare("INSERT INTO lscanScans(`created`, `ip`, `system`, `pasteKey`, `total`) VALUES (UNIX_TIMESTAMP(), :ip, :system, :pasteKey, :total)"); $st->bindValue(":ip", $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR); $st->bindValue(":system", $system, PDO::PARAM_STR); $st->bindValue(":pasteKey", $pasteKey, PDO::PARAM_STR); $st->bindValue(":total", $total, PDO::PARAM_INT); $st->execute(); //Get id and create key $id = $db->lastInsertId(); $key = sha1("bigatron" . $id); $st = $db->prepare("UPDATE lscanScans SET `key`=:key WHERE id=:id LIMIT 1"); $st->bindValue(":key", $key, PDO::PARAM_STR); $st->bindValue(":id", $id, PDO::PARAM_INT); $st->execute(); return $key; }