@ -88,6 +88,9 @@
}
}
}
}
if(strlen($comment) > 2048)
return 'Comment must be 2048 or fewer characters';
if(empty($comment) & & empty($target))
if(empty($comment) & & empty($target))
return 'You must include an image and/or a comment';
return 'You must include an image and/or a comment';
@ -96,6 +99,7 @@
if(empty($uid)) {
if(empty($uid)) {
$uid = sha1(time() . $img['tmp_name'] . $_SERVER['REMOTE_ADDR'] . UID_SALT);
$uid = sha1(time() . $img['tmp_name'] . $_SERVER['REMOTE_ADDR'] . UID_SALT);
setcookie("uid", $uid, 0x7FFFFFFF);
setcookie("uid", $uid, 0x7FFFFFFF);
$_COOKIE['uid'] = $uid; // so that the checkbox is checked
}
}
}
}
@ -127,7 +131,7 @@
// Prints the post list
// Prints the post list
function show_posts() {
function show_posts() {
$query = 'SELECT post_id, user_id, name, comment, img, TO_CHAR(post_time, \'YYYY-MM-DD HH24:MI (TZ)\') AS post_time FROM posts';
$query = 'SELECT post_id, user_id, name, comment, img, TO_CHAR(post_time, \'YYYY-MM-DD HH24:MI (TZ)\') AS 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
@ -154,7 +158,7 @@
echo "< a href = \"#p{$row['post_id']}\" > #{$row['post_id']}< / a > ";
echo "< a href = \"#p{$row['post_id']}\" > #{$row['post_id']}< / a > ";
// Find references
// Find references
$post_id = pg_escape_string($row['post_id']);
$post_id = pg_escape_string($row['post_id']);
$ref_query = "SELECT post_id FROM posts WHERE comment LIKE '%> > $post_id%'";
$ref_query = "SELECT post_id FROM posts WHERE comment LIKE '%> > $post_id%' ORDER BY post_time ";
$ref_result = pg_query_params($ref_query, []) or die('Query failed: ' . pg_last_error());
$ref_result = pg_query_params($ref_query, []) or die('Query failed: ' . pg_last_error());
while($ref = pg_fetch_array($ref_result))
while($ref = pg_fetch_array($ref_result))
echo "< a href = \"#p{$ref['post_id']}\" > > > {$ref['post_id']}< / a > ";
echo "< a href = \"#p{$ref['post_id']}\" > > > {$ref['post_id']}< / a > ";
@ -170,7 +174,7 @@
if(!empty($row['comment'])) {
if(!empty($row['comment'])) {
$comment = $row['comment'];
$comment = $row['comment'];
$comment = preg_replace('/^> (?!> \d).+/m', '< strong > $0< / strong > ', $comment);
$comment = preg_replace('/^> (?!> \d).+/m', '< strong > $0< / strong > ', $comment);
$comment = preg_replace('/https?:\/\/ [^\s]+/m', '< a href = "$0" > $0< / a > ', $comment);
$comment = preg_replace('/( https?|mailto|tel|ftp) :[^\s]+/m', '< a href = "$0" > $0< / a > ', $comment);
$comment = preg_replace_callback('/> > \s*(\d+)/', quote_link, $comment);
$comment = preg_replace_callback('/> > \s*(\d+)/', quote_link, $comment);
$comment = str_replace("\n", "< br / > ", $comment);
$comment = str_replace("\n", "< br / > ", $comment);
echo "< p > $comment< / p > ";
echo "< p > $comment< / p > ";
@ -313,9 +317,9 @@
< / p >
< / p >
< p >
< p >
< a href = " http: //validator.w3.org/check?uri=<?php echo urlencode ( 'http://' . $_SERVER [ 'SERVER_NAME' ] . $_SERVER [ 'PHP_SELF' ]); ?> " target = "_blank" >
< a href = " //validator.w3.org/check?uri=<?php echo urlencode ( 'http://' . $_SERVER [ 'SERVER_NAME' ] . $_SERVER [ 'PHP_SELF' ]); ?> " target = "_blank" >
< img src = " http: //www.w3.org/Icons/valid-xhtml10" alt = "Valid XHTML 1.0 Transitional" height = "31" width = "88" / >
< img src = " //www.w3.org/Icons/valid-xhtml10" alt = "Valid XHTML 1.0 Transitional" height = "31" width = "88" / >
< / a >
< / a >
< / p >
< / p >
< / body >
< / body >
< / html >
< / html >