function checkDuplicateFile($hex) { $hexmatches = postsByHex($hex); if (count($hexmatches) > 0) { foreach ($hexmatches as $hexmatch) { fancyDie("Duplicate file uploaded. That file has already been posted <a href=\"res/" . ($hexmatch["parent"] == TINYIB_NEWTHREAD ? $hexmatch["id"] : $hexmatch["parent"]) . ".html#" . $hexmatch["id"] . "\">here</a>."); } } }
$post['thumb'] = $file_name . "s" . $file_type; $post['file'] = $file_name . $file_type; $thumb_location = "thumb/" . $post['thumb']; $file_location = "src/" . $post['file']; if (!($file_type == '.jpg' || $file_type == '.gif' || $file_type == '.png')) { fancyDie("Only GIF, JPG, and PNG files are allowed."); } if (!@getimagesize($_FILES['file']['tmp_name'])) { fancyDie("Failed to read the size of the uploaded file. Please retry the submission."); } $file_info = getimagesize($_FILES['file']['tmp_name']); $file_mime = $file_info['mime']; if (!($file_mime == "image/jpeg" || $file_mime == "image/gif" || $file_mime == "image/png")) { fancyDie("Only GIF, JPG, and PNG files are allowed."); } $hexmatches = postsByHex($post['file_hex']); if (count($hexmatches) > 0) { foreach ($hexmatches as $hexmatch) { if ($hexmatch["parent"] == "0") { $goto = $hexmatch["id"]; } else { $goto = $hexmatch["parent"]; } fancyDie("Duplicate file uploaded. That file has already been posted <a href=\"res/" . $goto . ".html#" . $hexmatch["id"] . "\">here</a>."); } } if (!move_uploaded_file($_FILES['file']['tmp_name'], $file_location)) { fancyDie("Could not copy uploaded file."); } if ($_FILES['file']['size'] != filesize($file_location)) { fancyDie("File transfer failure. Please go back and try again.");