|
|
|
@ -38,6 +38,7 @@
|
|
|
|
|
* // Application constants
|
|
|
|
|
* define('UPLOAD_PATH', 'image/'); // Folder to save images to
|
|
|
|
|
* define('THUMB_PATH', 'thumb/'); // Folder to save thumbnails to
|
|
|
|
|
* define('ASSETS_PATH', 'assets/'); // Folder to store assets (header images, etc) in
|
|
|
|
|
* define('MAX_FILE_SIZE', 8 << 20); // Maximum image size, 8 MiB
|
|
|
|
|
* define('ADMIN_ID', '<SHA1 uid from your cookies>'); // uid that is able to delete anything
|
|
|
|
|
* define('UID_SALT', '<some string to salt uids with>');
|
|
|
|
@ -61,6 +62,9 @@
|
|
|
|
|
* comment VARCHAR(2048),
|
|
|
|
|
* img VARCHAR(256)
|
|
|
|
|
* );
|
|
|
|
|
*
|
|
|
|
|
* Finally, you will also need ffmpeg and exiftool installed for
|
|
|
|
|
* metadata stripping and thumbnail conversion.
|
|
|
|
|
*/
|
|
|
|
|
require_once('vars.php');
|
|
|
|
|
|
|
|
|
@ -85,24 +89,26 @@
|
|
|
|
|
// Move the file to the target upload folder
|
|
|
|
|
$img_name = time();
|
|
|
|
|
$ext = $extensions[$img['type']];
|
|
|
|
|
$temp = UPLOAD_PATH . "__temp$ext";
|
|
|
|
|
$target = UPLOAD_PATH . $img_name . $ext;
|
|
|
|
|
if(move_uploaded_file($img['tmp_name'], $temp)) {
|
|
|
|
|
if(move_uploaded_file($img['tmp_name'], $target)) {
|
|
|
|
|
$output = null;
|
|
|
|
|
$ret = null;
|
|
|
|
|
|
|
|
|
|
if($img['type'] != 'image/bmp') {
|
|
|
|
|
// Strip EXIF data
|
|
|
|
|
exec("ffmpeg -y -loglevel error -i $temp '$target'", $output, $ret);
|
|
|
|
|
@unlink($temp);
|
|
|
|
|
exec("exiftool -overwrite_original -all:all= '$target'", $output, $ret);
|
|
|
|
|
if($ret != 0)
|
|
|
|
|
return 'Unable to upload image, please contact the webmaster.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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)' " . 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) {
|
|
|
|
|
@unlink($target);
|
|
|
|
|
return 'Unable to create thumbnail, please contact the webmaster.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$thumb_size = getimagesize(THUMB_PATH . "$img_name.jpg");
|
|
|
|
|
} else {
|
|
|
|
|
// The new image file move failed, so delete the temporary file and return an error
|
|
|
|
|
@unlink($img['tmp_name']);
|
|
|
|
@ -145,14 +151,17 @@
|
|
|
|
|
$trip_name = trip_name($name);
|
|
|
|
|
|
|
|
|
|
// Add post to database
|
|
|
|
|
$query = "INSERT INTO posts (user_id, name, trip, email, comment, img) VALUES ($1, $2, $3, $4, $5, $6)";
|
|
|
|
|
$query = 'INSERT INTO posts (user_id, name, trip, email, comment, img, thumb_width, thumb_height) ' .
|
|
|
|
|
'VALUES ($1, $2, $3, $4, $5, $6, $7, $8)';
|
|
|
|
|
$params = [
|
|
|
|
|
empty($uid) ? NULL : $uid,
|
|
|
|
|
empty($trip_name['name']) ? 'Anonymous' : htmlspecialchars($trip_name['name']),
|
|
|
|
|
empty($trip_name['trip']) ? NULL : htmlspecialchars($trip_name['trip']),
|
|
|
|
|
empty($email) ? NULL : $email,
|
|
|
|
|
empty($comment) ? NULL : htmlspecialchars($comment),
|
|
|
|
|
empty($target) ? NULL : basename($target)
|
|
|
|
|
empty($target) ? NULL : basename($target),
|
|
|
|
|
$thumb_size[0],
|
|
|
|
|
$thumb_size[1]
|
|
|
|
|
];
|
|
|
|
|
pg_query_params($query, $params) or die('Query failed: ' . pg_last_error());
|
|
|
|
|
|
|
|
|
@ -173,7 +182,7 @@
|
|
|
|
|
|
|
|
|
|
// Prints the post list
|
|
|
|
|
function show_posts() {
|
|
|
|
|
$query = 'SELECT post_id, user_id, name, trip, email, comment, img, post_time FROM posts ORDER BY posts.post_time';
|
|
|
|
|
$query = 'SELECT post_id, user_id, name, trip, email, comment, img, thumb_width, thumb_height, post_time FROM posts ORDER BY posts.post_time';
|
|
|
|
|
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
|
|
|
|
|
|
|
|
|
|
// Clean up old posts
|
|
|
|
@ -189,7 +198,7 @@
|
|
|
|
|
$show_delete = FALSE;
|
|
|
|
|
echo '<form action="' . $_SERVER['PHP_SELF'] . '#bottom" method="post">';
|
|
|
|
|
while($row = pg_fetch_array($result)) {
|
|
|
|
|
echo "<div id=\"p{$row['post_id']}\" class=\"post\">";
|
|
|
|
|
echo "<div><div id=\"p{$row['post_id']}\" class=\"post\">";
|
|
|
|
|
|
|
|
|
|
$time_rel = time_ago_en($row['post_time']);
|
|
|
|
|
$time_abs = date('Y-m-d H:m (T)', strtotime($row['post_time']));
|
|
|
|
@ -219,10 +228,10 @@
|
|
|
|
|
echo "<a href=\"#p{$ref['post_id']}\">>>{$ref['post_id']}</a> ";
|
|
|
|
|
echo '</p>';
|
|
|
|
|
|
|
|
|
|
echo '<div class="postbody">';
|
|
|
|
|
echo '<div class="postbody cf">';
|
|
|
|
|
if(!empty($row['img'])){
|
|
|
|
|
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'] . '" />';
|
|
|
|
|
echo '<img src="' . THUMB_PATH . preg_replace('/\.(?:png|gif|bmp)$/', '.jpg', $row['img']) . "\" alt=\"{$row['img']}\" width=\"{$row['thumb_width']}\" height=\"{$row['thumb_height']}\" />";
|
|
|
|
|
echo '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -235,9 +244,7 @@
|
|
|
|
|
$comment = str_replace("\n", "<br />", $comment);
|
|
|
|
|
echo "<div>$comment</div>";
|
|
|
|
|
}
|
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
|
|
echo '</div>';
|
|
|
|
|
echo '</div></div></div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pg_free_result($result);
|
|
|
|
@ -306,6 +313,14 @@
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function header_image($mobile) {
|
|
|
|
|
$path = ASSETS_PATH . 'header';
|
|
|
|
|
if($mobile)
|
|
|
|
|
$path .= '/mobile';
|
|
|
|
|
$files = glob("$path/*.gif");
|
|
|
|
|
return $files[array_rand($files)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// code start ////
|
|
|
|
|
|
|
|
|
|
// Connect to the database
|
|
|
|
@ -340,11 +355,6 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mobile = preg_match('/Mobile|Nintendo DSi/', $_SERVER['HTTP_USER_AGENT']);
|
|
|
|
|
if($mobile) {
|
|
|
|
|
$header_image = 'header-mobile.gif';
|
|
|
|
|
} else {
|
|
|
|
|
$header_image = 'header.gif';
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<!DOCTYPE html
|
|
|
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
|
|
@ -445,8 +455,9 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.post {
|
|
|
|
|
display: table;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
padding: 0 10px 10px 0;
|
|
|
|
|
/* height: 100%; */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.posthead {
|
|
|
|
@ -460,12 +471,27 @@
|
|
|
|
|
.postbody img {
|
|
|
|
|
float: left;
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.cf:after {
|
|
|
|
|
content: ".";
|
|
|
|
|
display: block;
|
|
|
|
|
height: 0;
|
|
|
|
|
font-size:0;
|
|
|
|
|
clear: both;
|
|
|
|
|
visibility:hidden;
|
|
|
|
|
}
|
|
|
|
|
.cf { display: inline-block; }
|
|
|
|
|
/* Hides from IE Mac \*/
|
|
|
|
|
* html .cf { height: 1%; }
|
|
|
|
|
.cf { display:block; }
|
|
|
|
|
/* End Hack */
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body class="center">
|
|
|
|
|
<img class="center" src="<?php echo $header_image; ?>" alt="BBS.ピケ.コム" />
|
|
|
|
|
<center>
|
|
|
|
|
<img class="center" src="<?php echo header_image($mobile); ?>" alt="BBS.ピケ.コム" width="384" height="100" />
|
|
|
|
|
</center>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
[<a href="#bottom">bottom</a>]
|
|
|
|
@ -570,7 +596,7 @@
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
Formatting is very simple, just <strong class="quote">>quote</strong>
|
|
|
|
|
by starting a line with > and link to other posts with two >
|
|
|
|
|
by starting a line with > and link to other posts with two >
|
|
|
|
|
and the post number, <del>>>1</del>. No other formatting is
|
|
|
|
|
supported besides the automatic conversion of hyperlinks.
|
|
|
|
|
You may provide a name and/or email address when posting if you wish
|
|
|
|
|