[bottom] - '.bmp', - 'image/gif' => '.gif', - 'image/jpeg' => '.jpg', - 'image/pjpeg' => '.jpg', - 'image/png' => '.png' - ]; - - // Validate and move the uploaded image file, if necessary - if(!empty($img['tmp_name'])) { - if ((($img['type'] == 'image/gif') || ($img['type'] == 'image/jpeg') || ($img['type'] == 'image/pjpeg') - || ($img['type'] == 'image/png') || ($img['type'] == 'image/bmp')) - && ($img['size'] > 0) && ($img['size'] <= MAX_FILE_SIZE)) { - if($img['error'] == 0) { - // Move the file to the target upload folder - $target = UPLOAD_PATH . time() . $extensions[$img['type']]; - if(!move_uploaded_file($img['tmp_name'], $target)) { - // The new image file move failed, so delete the temporary file and return an error - @unlink($img['tmp_name']); - return 'Sorry, there was a problem uploading your image.'; - } +
+ '.bmp', + 'image/gif' => '.gif', + 'image/jpeg' => '.jpg', + 'image/pjpeg' => '.jpg', + 'image/png' => '.png' + ]; + + // Validate and move the uploaded image file, if necessary + if(!empty($img['tmp_name'])) { + if ((($img['type'] == 'image/gif') || ($img['type'] == 'image/jpeg') || ($img['type'] == 'image/pjpeg') + || ($img['type'] == 'image/png') || ($img['type'] == 'image/bmp')) + && ($img['size'] > 0) && ($img['size'] <= MAX_FILE_SIZE)) { + if($img['error'] == 0) { + // Move the file to the target upload folder + $target = UPLOAD_PATH . time() . $extensions[$img['type']]; + if(!move_uploaded_file($img['tmp_name'], $target)) { + // The new image file move failed, so delete the temporary file and return an error + @unlink($img['tmp_name']); + return 'Sorry, there was a problem uploading your image.'; } - } else { - // The new picture file is not valid, so delete the temporary file and return an error - @unlink($img['tmp_name']); - return "Your picture must be a PNG, GIF, JPEG, or BMP image file no greater than {MM_MAXFILESIZE >> 10} KiB."; } + } else { + // The new picture file is not valid, so delete the temporary file and return an error + @unlink($img['tmp_name']); + return "Your picture must be a PNG, GIF, JPEG, or BMP image file no greater than {MM_MAXFILESIZE >> 10} KiB."; } + } - if(empty($comment) && empty($target)) - return 'You must include an image and/or a comment'; + if(empty($comment) && empty($target)) + return 'You must include an image and/or a comment'; - if($save_cookie) { - $pid = $_COOKIE['pid']; - if(empty($pid)) { - $pid = sha1(time() . $img['tmp_name'] . $_SERVER['REMOTE_ADDR'] . PID_SALT); - setcookie("pid", $pid, 0x7FFFFFFF); - } + if($save_cookie) { + $pid = $_COOKIE['pid']; + if(empty($pid)) { + $pid = sha1(time() . $img['tmp_name'] . $_SERVER['REMOTE_ADDR'] . PID_SALT); + setcookie("pid", $pid, 0x7FFFFFFF); } - - // Add post to database - $query = "INSERT INTO posts (poster_id, name, comment, img) VALUES ($1, $2, $3, $4)"; - $params = [ - empty($pid) ? NULL : $pid, - empty($name) ? 'Anonymous' : $name, - empty($comment) ? NULL : $comment, - empty($target) ? NULL : basename($target) - ]; - webhook($params[1], $params[2], 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/' . $target); // Send to discord for moderation - pg_query_params($query, $params) or die('Query failed: ' . pg_last_error()); - - return ""; // Success, no error } - function quote_link($match) { - $query = "SELECT post_id FROM posts WHERE post_id=$1"; - $result = pg_query_params($query, [$match[1]]) or die('Query failed: ' . pg_last_error()); - $row_count = pg_num_rows($result); - pg_free_result($result); - if($row_count > 0) - return "{$match[0]}"; - else - return "- Old posts are automatically deleted once there are more than 50, anything inappropriate will be deleted. -
+ $err = post($name, $comment, $img, $save_cookie); + } else if($_POST['submit'] == 'Delete' && !empty($_COOKIE['pid'])) { + foreach($_POST['delete'] as $id) { + cleanup($id); + } + } + show_posts(); + + pg_free_result($result); + + pg_close($dbc); + ?> + + + ++ Old posts are automatically deleted once there are more than 50, anything inappropriate will be deleted. +
+ +