summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2011-01-03 17:28:18 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2011-01-03 17:28:18 +1100
commit05712d745713944e2e2535879f1cc82fdae2070f (patch)
tree5e893d7b70eefa45833a76e2c55e3297915a8491
parent3a3578c80507d80d571297b6bbf2502d5da73fd9 (diff)
Check if board already exists when creating it
-rw-r--r--inc/config.php1
-rw-r--r--mod.php5
2 files changed, 5 insertions, 1 deletions
diff --git a/inc/config.php b/inc/config.php
index 521d3eb3..7bd2228c 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -81,6 +81,7 @@
define('ERROR_MISSEDAFIELD', 'Your browser didn\'t submit an input when it should have.', true);
define('ERROR_REQUIRED', 'The %s field is required.', true);
define('ERROR_INVALIDFIELD', 'The %s field was invalid.', true);
+ define('ERROR_BOARDEXISTS', 'There is already a %s board.', true);
define('ERROR_NOACCESS', 'You don\'t have permission to do that.', true);
define('ERROR_INVALIDPOST', 'That post doesn\'t exist…', true);
define('ERROR_404', 'Page not found.', true);
diff --git a/mod.php b/mod.php
index 7c910a4a..00f4ab96 100644
--- a/mod.php
+++ b/mod.php
@@ -183,6 +183,9 @@
if(!preg_match('/^\w+$/', $b['uri']))
error(sprintf(ERROR_INVALIDFIELD, 'URI'));
+ if(openBoard($b['uri']))
+ error(sprintf(ERROR_BOARDEXISTS, sprintf(BOARD_ABBREVIATION, $b['uri'])));
+
$query = prepare("INSERT INTO `boards` VALUES (NULL, :uri, :title, :subtitle)");
$query->bindValue(':uri', $b['uri']);
$query->bindValue(':title', $b['title']);
@@ -378,7 +381,7 @@
// 1yr2hrs30mins
// 1y2h30m
$expire = 0;
- if(preg_match('/^((\d+)\s?ye?a?r?s?)?\s?+((\d+)\s?we?e?k?s?)?\s?+((\d+)\s?da?y?s?)?((\d+)\s?ho?u?r?s?)?\s?+((\d+)?mi?n?u?t?e?s?)?\s?+((\d+)\s?se?c?o?n?d?s?)?$/', $_POST['length'], $m)) {
+ if(preg_match('/^((\d+)\s?ye?a?r?s?)?\s?+((\d+)\s?we?e?k?s?)?\s?+((\d+)\s?da?y?s?)?((\d+)\s?ho?u?r?s?)?\s?+((\d+)\s?mi?n?u?t?e?s?)?\s?+((\d+)\s?se?c?o?n?d?s?)?$/', $_POST['length'], $m)) {
if(isset($m[2])) {
// Years
$expire += $m[2]*60*60*24*365;