<br />Don't understand? Don't worry! Watch this <a href="http://youtu.be/r9pEc7T3cJg" target="_BLANK">video guide!</a></p> <form action="" method="post"> Image URL:<br /><input type="text" name="image" size="70"><br /> Image Title:<br /><input type="text" name="title" size="70"><br /> Image Description:<br /><textarea name="desc" cols="55" rows="15"></textarea><br /> <input type="submit" name="Submit" value="Post Image Article"> </form> <?php } if (!empty($_POST['image']) && !empty($_POST['title']) && !empty($_POST['desc'])) { $image = sanitize($_POST['image']); $image = str_replace("www", "", str_replace(":", "", str_replace("/", "", str_replace(".", "!", str_replace("1m.yt", "", str_replace("http", "", $image)))))); $title = sanitize($_POST['title']); $desc = sanitize($_POST['desc']); // Insert to database insertImage((int) $session_user_id, $title, $desc, $image); $pw = explode("!", $image); ?> <h1>Image Posted</h1> <p>However, your image will not be listed until a GM have verified it.<br /> Feel free to remind the GM in-game to login on website and approve the image post.</p> <h2>Preview:</h2> <table> <tr class="yellow"> <td><h3><?php echo $title; ?> </h3></td> </tr> <tr> <td>
$valid_formats = array("jpeg", "jpg", "gif"); // Code based from http://techstream.org/Web-Development/PHP/Multiple-File-Upload-with-PHP-and-MySQL if (isset($_FILES['images'])) { foreach ($_FILES['images']['tmp_name'] as $key => $tmp_name) { $file_name = $key . $_FILES['images']['name'][$key]; $file_size = $_FILES['images']['size'][$key]; $file_ext = strtolower(end(explode('.', $_FILES['image']['name'][$key]))); if (in_array($file_ext, $valid_formats) == false) { $errors[] = "Invalid Image Format"; } // Get a unique photo ID $uniq_photo_id = genUniqId($newDB); // Get the resized thumbnail of the image $thumbnail_blob = makeThumb($_FILES['images']['tmp_name'][$key], $_FILES['images']['type'][$key]); // Insert the image into the database insertImage($newDB->getConnection(), $uniq_photo_id, $username, $descriptive_info, file_get_contents($thumbnail_blob), file_get_contents($_FILES['images']['tmp_name'][$key])); } } // Close this connection $newDB->disconnect(); // Jump to upload page and report success $_SESSION["success"] = 'successuploaded'; header("Location: uploadForm.php"); // This function inserts the image and it's descriptive information into the database function insertImage($conn, $photo_id, $owner_name, $descriptive_info, $thumbnail, $photo) { $photo_blob = oci_new_descriptor($conn, OCI_D_LOB); $thumbnail_blob = oci_new_descriptor($conn, OCI_D_LOB); $subject = $descriptive_info[0]; $place = $descriptive_info[1]; $date_time = $descriptive_info[2];
firstSaveExe(); break; case 'load': load(); break; case 'loadTemp': loadTemp(); break; case 'loadQuickStart': loadQuickStart(); break; case 'getUploadedImageFileNames': getUploadedImageFileNames(); break; case 'insertImage': insertImage(); break; case 'importDiagramExe': importDiagramExe(); break; case 'deleteDiagramExe': deleteDiagramExe(); break; /*************************** */ /*********QUICK start****** */ /*************************** */ /*************************** */ /*********QUICK start****** */ /*************************** */ case 'closeQuickStart': closeQuickStart();
// Check if file already exists if (file_exists($target_file)) { $reponse = "Sorry, file already exists."; $uploadOk = 0; } // Check file size /*if ($_FILES["photo_upload"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; }*/ // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $reponse = "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } $isFirstPost = false; // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $reponse = "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["photo_upload"]["tmp_name"], $target_file)) { $isFirstPost = insertImage($_SESSION['user_id'], $target_file_db, $_POST['photo_caption']); } else { $reponse = "Sorry, there was an error uploading your file."; } } if ($isFirstPost) { callApi('POST', 'http://localhost:8080/MoussaRaser/api/events', array('eventType' => 'firstpost', 'toUserId' => $_SESSION['gamification_user_id'])); } echo json_encode(['isFirstPost' => $isFirstPost, 'reponse' => $reponse, 'path' => $target_file_db, 'text' => $_POST['photo_caption'], 'profile_photo' => $_SESSION['profile_photo'], 'username' => $_SESSION['username']]);