|
|
@ -61,7 +61,10 @@
|
|
|
|
* trip VARCHAR(10),
|
|
|
|
* trip VARCHAR(10),
|
|
|
|
* email VARCHAR(256),
|
|
|
|
* email VARCHAR(256),
|
|
|
|
* comment VARCHAR(2048),
|
|
|
|
* comment VARCHAR(2048),
|
|
|
|
* img VARCHAR(256)
|
|
|
|
* img VARCHAR(256),
|
|
|
|
|
|
|
|
* thumb_width INT,
|
|
|
|
|
|
|
|
* thumb_height INT,
|
|
|
|
|
|
|
|
* spoiler BOOL
|
|
|
|
* );
|
|
|
|
* );
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* CREATE TABLE access
|
|
|
|
* CREATE TABLE access
|
|
|
@ -80,7 +83,7 @@
|
|
|
|
//// Functions: ////
|
|
|
|
//// Functions: ////
|
|
|
|
|
|
|
|
|
|
|
|
// Adds a post to the database
|
|
|
|
// Adds a post to the database
|
|
|
|
function post($name, $email, $comment, $img, $save_cookie, $captcha, $captcha_answer) {
|
|
|
|
function post($name, $email, $comment, $img, $spoiler, $save_cookie, $captcha, $captcha_answer) {
|
|
|
|
$extensions = [
|
|
|
|
$extensions = [
|
|
|
|
'image/bmp' => '.bmp',
|
|
|
|
'image/bmp' => '.bmp',
|
|
|
|
'image/gif' => '.gif',
|
|
|
|
'image/gif' => '.gif',
|
|
|
@ -131,6 +134,9 @@
|
|
|
|
return 'Unable to upload image, please contact the webmaster.';
|
|
|
|
return 'Unable to upload image, please contact the webmaster.';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!$spoiler) {
|
|
|
|
|
|
|
|
$thumb_size = getimagesize(ASSETS_PATH . "spoiler.gif");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Create thumbnail
|
|
|
|
// Create thumbnail
|
|
|
|
exec("ffmpeg -y -loglevel error -i '$target' -filter_complex 'color=#ffccdd[c];[c][0]scale2ref[cs][0s];[cs][0s]overlay=shortest=1[o];[o]scale=min(200\,iw):-1[o];[o]scale=-1:min(100\,ih)' -frames:v 1 " . THUMB_PATH . "$img_name.jpg", $output, $ret);
|
|
|
|
exec("ffmpeg -y -loglevel error -i '$target' -filter_complex 'color=#ffccdd[c];[c][0]scale2ref[cs][0s];[cs][0s]overlay=shortest=1[o];[o]scale=min(200\,iw):-1[o];[o]scale=-1:min(100\,ih)' -frames:v 1 " . THUMB_PATH . "$img_name.jpg", $output, $ret);
|
|
|
|
if($ret != 0) {
|
|
|
|
if($ret != 0) {
|
|
|
@ -139,6 +145,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$thumb_size = getimagesize(THUMB_PATH . "$img_name.jpg");
|
|
|
|
$thumb_size = getimagesize(THUMB_PATH . "$img_name.jpg");
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// The new image file move failed, so delete the temporary file and return an error
|
|
|
|
// The new image file move failed, so delete the temporary file and return an error
|
|
|
|
@unlink($img['tmp_name']);
|
|
|
|
@unlink($img['tmp_name']);
|
|
|
@ -172,8 +179,8 @@
|
|
|
|
$trip_name = trip_name($name);
|
|
|
|
$trip_name = trip_name($name);
|
|
|
|
|
|
|
|
|
|
|
|
// Add post to database
|
|
|
|
// Add post to database
|
|
|
|
$query = 'INSERT INTO posts (user_id, name, trip, email, comment, img, thumb_width, thumb_height) ' .
|
|
|
|
$query = 'INSERT INTO posts (user_id, name, trip, email, comment, img, thumb_width, thumb_height, spoiler) ' .
|
|
|
|
'VALUES ($1, $2, $3, $4, $5, $6, $7, $8)';
|
|
|
|
'VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)';
|
|
|
|
$params = [
|
|
|
|
$params = [
|
|
|
|
empty($uid) ? NULL : $uid,
|
|
|
|
empty($uid) ? NULL : $uid,
|
|
|
|
empty($trip_name['name']) ? 'Anonymous' : htmlspecialchars($trip_name['name']),
|
|
|
|
empty($trip_name['name']) ? 'Anonymous' : htmlspecialchars($trip_name['name']),
|
|
|
@ -182,7 +189,8 @@
|
|
|
|
empty($comment) ? NULL : htmlspecialchars($comment),
|
|
|
|
empty($comment) ? NULL : htmlspecialchars($comment),
|
|
|
|
empty($target) ? NULL : basename($target),
|
|
|
|
empty($target) ? NULL : basename($target),
|
|
|
|
$thumb_size[0],
|
|
|
|
$thumb_size[0],
|
|
|
|
$thumb_size[1]
|
|
|
|
$thumb_size[1],
|
|
|
|
|
|
|
|
$spoiler ? 'T' : 'F'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
pg_query_params($query, $params) or die('Query failed: ' . pg_last_error());
|
|
|
|
pg_query_params($query, $params) or die('Query failed: ' . pg_last_error());
|
|
|
|
|
|
|
|
|
|
|
@ -203,7 +211,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
// Prints the post list
|
|
|
|
// Prints the post list
|
|
|
|
function show_posts() {
|
|
|
|
function show_posts() {
|
|
|
|
$query = 'SELECT post_id, user_id, name, trip, email, comment, img, thumb_width, thumb_height, post_time FROM posts ORDER BY posts.post_time';
|
|
|
|
$query = 'SELECT post_id, user_id, name, trip, email, comment, img, thumb_width, thumb_height, spoiler, post_time FROM posts ORDER BY posts.post_time';
|
|
|
|
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
|
|
|
|
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
|
|
|
|
|
|
|
|
|
|
|
|
// Clean up old posts
|
|
|
|
// Clean up old posts
|
|
|
@ -257,7 +265,8 @@
|
|
|
|
echo '<div class="postbody clearfix">';
|
|
|
|
echo '<div class="postbody clearfix">';
|
|
|
|
if(!empty($row['img'])){
|
|
|
|
if(!empty($row['img'])){
|
|
|
|
echo '<a href="' . UPLOAD_PATH . $row['img'] . '" target="_blank">';
|
|
|
|
echo '<a href="' . UPLOAD_PATH . $row['img'] . '" target="_blank">';
|
|
|
|
echo '<img src="' . THUMB_PATH . preg_replace('/\.(?:png|gif|bmp)$/', '.jpg', $row['img']) . "\" alt=\"{$row['img']}\" width=\"{$row['thumb_width']}\" height=\"{$row['thumb_height']}\" />";
|
|
|
|
$thumb_path = ($row['spoiler'] == 't') ? (ASSETS_PATH . 'spoiler.gif') : (THUMB_PATH . preg_replace('/\.(?:png|gif|bmp)$/', '.jpg', $row['img']));
|
|
|
|
|
|
|
|
echo "<img src=\"$thumb_path\" alt=\"{$row['img']}\" width=\"{$row['thumb_width']}\" height=\"{$row['thumb_height']}\" />";
|
|
|
|
echo '</a>';
|
|
|
|
echo '</a>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -383,11 +392,12 @@
|
|
|
|
$email = trim($_POST['email']);
|
|
|
|
$email = trim($_POST['email']);
|
|
|
|
$comment = trim($_POST['comment']);
|
|
|
|
$comment = trim($_POST['comment']);
|
|
|
|
$img = $_FILES['img'];
|
|
|
|
$img = $_FILES['img'];
|
|
|
|
|
|
|
|
$spoiler = isset($_POST['spoiler']) && !empty($_FILES['img']['tmp_name']);
|
|
|
|
$save_cookie = isset($_POST['save_cookie']);
|
|
|
|
$save_cookie = isset($_POST['save_cookie']);
|
|
|
|
$captcha = trim($_POST['captcha']);
|
|
|
|
$captcha = trim($_POST['captcha']);
|
|
|
|
$captcha_answer = trim($_POST['captcha_answer']);
|
|
|
|
$captcha_answer = trim($_POST['captcha_answer']);
|
|
|
|
|
|
|
|
|
|
|
|
$err = post($name, $email, $comment, $img, $save_cookie, $captcha, $captcha_answer);
|
|
|
|
$err = post($name, $email, $comment, $img, $spoiler, $save_cookie, $captcha, $captcha_answer);
|
|
|
|
if($err == "") {
|
|
|
|
if($err == "") {
|
|
|
|
# Redirect to latest post
|
|
|
|
# Redirect to latest post
|
|
|
|
$query = 'SELECT post_id FROM posts ORDER BY posts.post_time DESC LIMIT 1';
|
|
|
|
$query = 'SELECT post_id FROM posts ORDER BY posts.post_time DESC LIMIT 1';
|
|
|
@ -480,6 +490,11 @@
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<label for="spoiler">Spoiler:</label>
|
|
|
|
|
|
|
|
<input type="checkbox" id="spoiler" name="spoiler" />
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
<label for="captcha">CAPTCHA:</label></td>
|
|
|
|
<label for="captcha">CAPTCHA:</label></td>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<code><?php echo $captcha_str; ?></code>
|
|
|
|
<code><?php echo $captcha_str; ?></code>
|
|
|
@ -514,6 +529,10 @@
|
|
|
|
<td><label for="img">Image:</label></td>
|
|
|
|
<td><label for="img">Image:</label></td>
|
|
|
|
<td><input type="file" id="img" name="img" /> (Limit: <?php echo MAX_FILE_SIZE >> 10; ?> KiB)</td>
|
|
|
|
<td><input type="file" id="img" name="img" /> (Limit: <?php echo MAX_FILE_SIZE >> 10; ?> KiB)</td>
|
|
|
|
</tr>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td><label for="spoiler">Spoiler:</label></td>
|
|
|
|
|
|
|
|
<td><input type="checkbox" id="spoiler" name="spoiler" /></td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<td><label for="captcha">CAPTCHA:</label></td>
|
|
|
|
<td><label for="captcha">CAPTCHA:</label></td>
|
|
|
|
<td>
|
|
|
|
<td>
|
|
|
|