diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2010-11-30 23:12:54 +1100 |
|---|---|---|
| committer | Paul Merrill <napalminc@gmail.com> | 2010-12-01 04:14:16 -0800 |
| commit | a3b604243b5347fab24e9d9d31380362d489dc6d (patch) | |
| tree | e6145637f79d4f6630ce8fa83c7fa35d083fda02 /inc/functions.php | |
| parent | e66c1e7f8dcd6c6f293aa33abea3d5626190001a (diff) | |
Check if thread exists before posting.
Diffstat (limited to 'inc/functions.php')
| -rw-r--r-- | inc/functions.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/inc/functions.php b/inc/functions.php index c4fd77dd..453f5146 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -44,13 +44,29 @@ function openBoard($uri) { global $sql; - $boards_res = mysql_query(sprintf("SELECT * FROM `boards` WHERE `uri` = '%s' LIMIT 1", mysql_real_escape_string($uri)), $sql) or error(mysql_error($sql)); + $boards_res = mysql_query(sprintf( + "SELECT * FROM `boards` WHERE `uri` = '%s' LIMIT 1", + mysql_real_escape_string($uri) + ), $sql) or error(mysql_error($sql)); + if($_board = mysql_fetch_array($boards_res)) { setupBoard($_board); return true; } else return false; } + function threadExists($id) { + global $sql; + $thread_res = mysql_query(sprintf( + "SELECT 1 FROM `posts` WHERE `id` = '%d' AND `thread` IS NULL LIMIT 1", + $id + ), $sql) or error(mysql_error($sql)); + + if(mysql_num_rows($thread_res) > 0) { + return true; + } else return false; + } + function post($post, $OP) { global $sql, $board; if($OP) { |
