rendered paste body function addboard() {
global $tc_db, $smarty, $tpl_page, $board_class;
$this->AdministratorsOnly();
$tpl_page .= '<h2>' . ucwords(_('Add board')) . '</h2><br>';
if (isset($_POST['directory'])) {
if ($_POST['directory'] != '' && $_POST['desc'] != '') {
$results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . TC_DBPREFIX . "boards` WHERE `name` = '" . mysql_real_escape_string($_POST['directory']) . "'");
if (count($results) == 0) {
if (isset($_POST['makedirs'])) {
echo 'Attempting to create the root board folder...<br>';
if (mkdir(TC_BOARDSDIR . $_POST['directory'], 0755)) {
echo 'Success';
} else {
die ('Failed.');
}
echo 'Attempting to create the res folder...<br>';
if (mkdir(TC_BOARDSDIR . $_POST['directory'] . '/res', 0755)) {
echo 'Success';
} else {
die ('Failed.');
}
echo 'Attempting to create the src folder...<br>';
if (mkdir(TC_BOARDSDIR . $_POST['directory'] . '/src', 0755)) {
echo 'Success';
} else {
die ('Failed.');
}
echo 'Attempting to create the thumb folder...<br>';
if (mkdir(TC_BOARDSDIR . $_POST['directory'] . '/thumb', 0755)) {
echo 'Success';
} else {
die ('Failed.');
}
} else {
echo 'Checking for the root board folder...<br>';
if (is_dir(TC_BOARDSDIR . $_POST['directory'])) {
echo 'Success';
} else {
die ('Failed.');
}
echo 'Checking for the res folder...<br>';
if (is_dir(TC_BOARDSDIR . $_POST['directory'] . '/res')) {
echo 'Success';
} else {
die ('Failed.');
}
echo 'Checking for the src folder...<br>';
if (is_dir(TC_BOARDSDIR . $_POST['directory'] . '/src')) {
echo 'Success';
} else {
die ('Failed.');
}
echo 'Checking for the thumb folder...<br>';
if (is_dir(TC_BOARDSDIR . $_POST['directory'] . '/thumb')) {
echo 'Success';
} else {
die ('Failed.');
}
}
file_put_contents(TC_BOARDSDIR . $_POST['directory'] . '/.htaccess', 'DirectoryIndex board.html');
$tc_db->Execute("INSERT INTO `" . TC_DBPREFIX . "boards` ( `name` , `desc` , `createdon` ) VALUES ( '" . mysql_real_escape_string($_POST['directory']) . "' , '" . mysql_real_escape_string($_POST['desc']) . "' , '" . time() . "' )");
if ($_POST['firstpostid'] < 1) {
$_POST['firstpostid'] = 1;
}
$tc_db->Execute("CREATE TABLE `" . TC_DBPREFIX . "posts_" . mysql_real_escape_string($_POST['directory']) . "` (
`id` int(10) NOT NULL auto_increment,
`threadid` int(10) NOT NULL default '0',
`user` varchar(255) NOT NULL,
`tripcode` varchar(10) NOT NULL,
`email` varchar(255) NOT NULL,
`subject` varchar(255) NOT NULL,
`message` text NOT NULL,
`image` varchar(20) NOT NULL,
`imagetype` varchar(5) NOT NULL,
`imagemd5` text NOT NULL,
`image_w` smallint(5) NOT NULL default '0',
`image_h` smallint(5) NOT NULL default '0',
`image_size` int(10) NOT NULL default '0',
`thumb_w` smallint(5) NOT NULL default '0',
`thumb_h` smallint(5) NOT NULL default '0',
`password` varchar(255) NOT NULL,
`postedat` int(20) NOT NULL,
`lastbumped` int(20) NOT NULL default '0',
`ip` varchar(75) NOT NULL,
`ipmd5` varchar(200) NOT NULL,
`stickied` tinyint(1) NOT NULL default '0',
`locked` tinyint(1) NOT NULL default '0',
`posterauthority` tinyint(1) NOT NULL default '0',
`IS_DELETED` tinyint(1) NOT NULL default '0',
UNIQUE KEY `id` (`id`),
KEY `threadid` (`threadid`),
KEY `lastbumped` (`lastbumped`)
) ENGINE=MyISAM AUTO_INCREMENT=" . mysql_real_escape_string($_POST['firstpostid']) . " ;");
/* Sleep for five seconds, to ensure the table was created before attempting to initialize a board class with it */
sleep(5);
$board_class = new Board(mysql_real_escape_string($_POST['directory']));
$board_class->RegenerateAll();
$tpl_page .= _('Board successfully added.') . '<br><br><a href="' . TC_BOARDSPATH . '/' . $_POST['directory'] . '/">/' . $_POST['directory'] . '/</a>!';
management_addlogentry(_('Added board') . ': /' . $_POST['directory'] . '/', 3);
} else {
$tpl_page .= _('A board with that name already exists.');
}
} else {
$tpl_page .= _('Please fill in all required fields.');
}
}
$tpl_page .= '<form action="manage_page.php?action=addboard" method="post">
<label for="directory">Directory:</label>
<input type="text" name="directory">
<div class="desc">The directory of the board. <b>Only put in the letter(s) of the board directory, no slashes!</b></div><br>
<label for="desc">Description:</label>
<input type="text" name="desc"><div class="desc">The name of the board.</div><br>
<label for="firstpostid">First Post ID:</label>
<input type="text" name="firstpostid" value="1">
<div class="desc">The first post of this board will recieve this ID.</div><br>
<label for="makedirs">Create Directories:</label>
<input type="checkbox" name="makedirs" checked>
<div class="desc">If checked, the script will attempt to create the directories itself. If this fails, create boardname/, boardname/res, boardname/src, and boardname/thumb, and chmod each to 755.</div><br>
<input type="submit" value="Add Board">
</form>';
}