SHOW:
|
|
- or go back to the newest paste.
| 1 | - | <? session_start(); |
| 1 | + | if(isset($_POST['addcard'])) {
|
| 2 | - | $version = "Cruel Constrictor"; |
| 2 | + | $cardname = $_POST['card_input']; |
| 3 | $rarity = $_POST['rarity_input']; | |
| 4 | - | ?> |
| 4 | + | $image_front = $_FILES['file']['name']; |
| 5 | $image_back = | |
| 6 | - | <!DOCTYPE html> |
| 6 | + | $image_avatar = |
| 7 | - | <html lang="en"> |
| 7 | + | $image_sprite = |
| 8 | - | <head> |
| 8 | + | |
| 9 | - | <meta charset="utf-8"> |
| 9 | + | $query = $pdo->prepare("INSERT INTO cards (name,rarity,img_front,img_back,img_avatar,img_sprite) VALUES (:name,:rarity,:img_front,:img_back,:img_avatar,:img_sprite)");
|
| 10 | - | <title>MassiveDeck: <? echo $version; ?></title> |
| 10 | + | $query->bindValue(":name", $cardname, PDO::PARAM_STR);
|
| 11 | - | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 11 | + | $query->bindValue(":rarity", $rarity, PDO::PARAM_STR);
|
| 12 | - | <meta name="description" content=""> |
| 12 | + | $query->bindValue(":img_front", $image_front, PDO::PARAM_STR);
|
| 13 | - | <meta name="author" content=""> |
| 13 | + | $query->bindValue(":img_back", $image_back, PDO::PARAM_STR);
|
| 14 | $query->bindValue(":img_avatar", $image_avatar, PDO::PARAM_STR);
| |
| 15 | - | <link href="css/bootstrap.css" rel="stylesheet"> |
| 15 | + | $query->bindValue(":img_sprite", $image_sprite, PDO::PARAM_STR);
|
| 16 | - | <style type="text/css"> |
| 16 | + | $query->execute(); |
| 17 | - | body {
|
| 17 | + | |
| 18 | - | padding-top: 60px; |
| 18 | + | if ($_FILES["file"]["error"] > 0) {
|
| 19 | - | padding-bottom: 40px; |
| 19 | + | echo "Error: " . $_FILES["file"]["error"] . "<br>"; |
| 20 | - | } |
| 20 | + | } |
| 21 | - | </style> |
| 21 | + | |
| 22 | else {
| |
| 23 | - | <link href="css/bootstrap-responsive.css" rel="stylesheet"> |
| 23 | + | echo "Upload: " . $_FILES["image_front"]["name"] . "<br>"; |
| 24 | echo "Type: " . $_FILES["image_front"]["type"] . "<br>"; | |
| 25 | - | </head> |
| 25 | + | echo "Size: " . ($_FILES["image_front"]["size"] / 1024) . " kB<br>"; |
| 26 | echo "Stored in: " . $_FILES["image_front"]["tmp_name"]; | |
| 27 | - | <body> |
| 27 | + | echo "<br>" |
| 28 | echo "Upload: " . $_FILES["image_back"]["name"] . "<br>"; | |
| 29 | - | <div class="navbar navbar-inverse navbar-fixed-top"> |
| 29 | + | echo "Type: " . $_FILES["image_back"]["type"] . "<br>"; |
| 30 | - | <div class="navbar-inner"> |
| 30 | + | echo "Size: " . ($_FILES["image_back"]["size"] / 1024) . " kB<br>"; |
| 31 | - | <div class="container"> |
| 31 | + | echo "Stored in: " . $_FILES["image_back"]["tmp_name"]; |
| 32 | - | <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> |
| 32 | + | echo "<br>" |
| 33 | - | <span class="icon-bar"></span> |
| 33 | + | echo "Upload: " . $_FILES["image_avatar"]["name"] . "<br>"; |
| 34 | - | <span class="icon-bar"></span> |
| 34 | + | echo "Type: " . $_FILES["image_avatar"]["type"] . "<br>"; |
| 35 | - | <span class="icon-bar"></span> |
| 35 | + | echo "Size: " . ($_FILES["image_avatar"]["size"] / 1024) . " kB<br>"; |
| 36 | - | </button> |
| 36 | + | echo "Stored in: " . $_FILES["image_avatar"]["tmp_name"]; |
| 37 | - | <a class="brand" href="#"><? echo $version; ?></a> |
| 37 | + | echo "<br>" |
| 38 | - | <div class="nav-collapse collapse"> |
| 38 | + | echo "Upload: " . $_FILES["image_sprite"]["name"] . "<br>"; |
| 39 | - | <ul class="nav"> |
| 39 | + | echo "Type: " . $_FILES["image_sprite"]["type"] . "<br>"; |
| 40 | - | <li><a href="index.php">Home</a></li> |
| 40 | + | echo "Size: " . ($_FILES["image_sprite"]["size"] / 1024) . " kB<br>"; |
| 41 | - | <li><a href="index.php?page=cards">Cards</a></li> |
| 41 | + | echo "Stored in: " . $_FILES["image_sprite"]["tmp_name"]; |
| 42 | - | <li><a href="#contact">Contact</a></li> |
| 42 | + | echo "<br>" |
| 43 | - | <?php |
| 43 | + | } |
| 44 | - | if(isset($_SESSION['logged_in'])) {
|
| 44 | + | |
| 45 | - | echo "<li><a href='index.php?page=profile'>Profile</a></li>"; |
| 45 | + | $allowedExts = array("gif", "jpeg", "jpg", "png");
|
| 46 | - | if($_SESSION["username"] == "admin") {
|
| 46 | + | $temp = explode(".", $_FILES["file"]["name"]);
|
| 47 | - | echo '<li><a href="index.php?page=addcards">Add Cards</a></li>'; |
| 47 | + | $extension = end($temp); |
| 48 | - | } |
| 48 | + | if ((($_FILES["file"]["type"] == "image/gif") |
| 49 | || ($_FILES["file"]["type"] == "image/jpeg") | |
| 50 | - | } |
| 50 | + | || ($_FILES["file"]["type"] == "image/jpg") |
| 51 | - | ?> |
| 51 | + | || ($_FILES["file"]["type"] == "image/pjpeg") |
| 52 | - | </ul> |
| 52 | + | || ($_FILES["file"]["type"] == "image/x-png") |
| 53 | || ($_FILES["file"]["type"] == "image/png")) | |
| 54 | - | <?php if(isset($_SESSION['logged_in'])) {
|
| 54 | + | && in_array($extension, $allowedExts)) {
|
| 55 | - | echo "<p class='navbar-text pull-right'>Logged in as <a href='#' class='navbar-link'>" . $_SESSION["username"] . " </a>[ <a href='logout.php'>logout</a> ]"; |
| 55 | + | if ($_FILES["file"]["error"] > 0) {
|
| 56 | - | } |
| 56 | + | echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; |
| 57 | - | else {
|
| 57 | + | } |
| 58 | ||
| 59 | - | echo '<form class="navbar-form pull-right" name="formlog" method="post" action="auth.php">'; |
| 59 | + | else {
|
| 60 | - | echo '<input class="span2" type="text" name="username" placeholder="Username"> '; |
| 60 | + | echo "Upload: " . $_FILES["file"]["name"] . "<br>"; |
| 61 | - | echo '<input class="span2" type="password" name="password" placeholder="Password"> '; |
| 61 | + | echo "Type: " . $_FILES["file"]["type"] . "<br>"; |
| 62 | - | echo '<input type="hidden" name="formlog" value="1">'; |
| 62 | + | echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; |
| 63 | - | echo '<button type="submit" class="btn">Sign in</button>'; |
| 63 | + | echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>"; |
| 64 | - | echo '</form>'; |
| 64 | + | |
| 65 | - | } |
| 65 | + | if (file_exists("upload/" . $_FILES["file"]["name"])) {
|
| 66 | echo $_FILES["file"]["name"] . " already exists. "; | |
| 67 | - | ?> |
| 67 | + | } |
| 68 | ||
| 69 | - | </div> |
| 69 | + | else {
|
| 70 | - | </div> |
| 70 | + | move_uploaded_file($_FILES["file"]["tmp_name"], |
| 71 | - | </div> |
| 71 | + | "upload/" . $_FILES["file"]["name"]); |
| 72 | - | </div> |
| 72 | + | echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; |
| 73 | } | |
| 74 | - | <div class="container"> |
| 74 | + | } |
| 75 | } | |
| 76 | ||
| 77 | else {
| |
| 78 | echo "Invalid file"; | |
| 79 | } | |
| 80 | } |