1.2):
- Updated to the new date/clock time system
- Bootstrap design support.
*/
// BBCODE support:
function TransformToBBCode($string) {
$tags = array(
'[center]{$1}[/center]' => '
';
}
//////////////////
// update category
if ($admin_update_category !== false) {
$admin_category_id = (int)$admin_category_id;
// Update the category
mysql_update("UPDATE `znote_forum` SET
`name`='$admin_category_name',
`access`='$admin_category_access',
`closed`='$admin_category_closed',
`hidden`='$admin_category_hidden',
`guild_id`='$admin_category_guild_id'
WHERE `id`='$admin_category_id' LIMIT 1;");
echo '
Board has been updated successfully.
';
}
//////////////////
// edit category
if ($admin_category_edit !== false) {
$admin_category_id = (int)$admin_category_id;
$category = mysql_select_single("SELECT `id`, `name`, `access`, `closed`, `hidden`, `guild_id`
FROM `znote_forum` WHERE `id`='$admin_category_id' LIMIT 1;");
if ($category !== false) {
?>
Category not found.';
}
// delete category
if ($admin_category_delete !== false) {
$admin_category_id = (int)$admin_category_id;
// find all threads in category
$threads = mysql_select_multi("SELECT `id` FROM `znote_forum_threads` WHERE `forum_id`='$admin_category_id';");
// Then loop through all threads, and delete all associated posts:
foreach($threads as $thread) {
mysql_delete("DELETE FROM `znote_forum_posts` WHERE `thread_id`='". $thread['id'] ."';");
}
// Then delete all threads
mysql_delete("DELETE FROM `znote_forum_threads` WHERE `forum_id`='$admin_category_id';");
// Then delete the category
mysql_delete("DELETE FROM `znote_forum` WHERE `id`='$admin_category_id' LIMIT 1;");
echo '
Board, associated threads and all their associated posts deleted.
';
}
// delete post
if ($admin_post_delete !== false) {
$admin_post_id = (int)$admin_post_id;
// Delete the post
mysql_delete("DELETE FROM `znote_forum_posts` WHERE `id`='$admin_post_id' LIMIT 1;");
echo '
You don\'t have permission to post on this thread. [Thread: Closed]
';
} else {
?>
Antispam: You need to wait seconds before you can create or post.
(time() + $config['forum']['cooldownCreate'])));
$category = mysql_select_single("SELECT `access`, `closed`, `guild_id` FROM `znote_forum` WHERE `id`='$create_thread_category' LIMIT 1;");
if ($category !== false) {
$access = true;
if (!$admin) {
if ($category['access'] > $yourAccess) $access = false;
if ($category['guild_id'] > 0) {
$status = false;
foreach($charData as $char) {
if ($char['guild'] == $category['guild_id']) $status = true;
}
if (!$status) $access = false;
}
if ($category['closed'] > 0) $access = false;
}
if ($access) {
mysql_insert("INSERT INTO `znote_forum_threads`
(`forum_id`, `player_id`, `player_name`, `title`, `text`, `created`, `updated`, `sticky`, `hidden`, `closed`)
VALUES (
'$create_thread_category',
'$create_thread_cid',
'". $charData[$create_thread_cid]['name'] ."',
'$create_thread_title',
'$create_thread_text',
'". time() ."',
'". time() ."',
'0', '0', '0');");
SendGet(array('cat'=>$create_thread_category), 'forum.php');
} else echo '
Permission to create thread denied.
';
} else echo 'Category does not exist.';
} else {
?>
Antispam: You need to wait seconds before you can create or post.
post has been updated.';
} else echo "
Your permission to edit this post has been denied.
";
}
/////////////////////
// When you ARE updating thread
if ($update_thread_id !== false && $update_thread_title !== false && $update_thread_text !== false) {
// Fetch the thread data
$thread = mysql_select_single("SELECT `id`, `player_name`, `title`, `text`, `closed` FROM `znote_forum_threads` WHERE `id`='$update_thread_id' LIMIT 1;");
// Verify access
$access = PlayerHaveAccess($yourChars, $thread['player_name']);
if ($thread['closed'] == 1 && $admin === false) $access = false;
if ($admin) $access = true;
if ($access) {
mysql_update("UPDATE `znote_forum_threads` SET `title`='$update_thread_title', `text`='$update_thread_text' WHERE `id`='$update_thread_id';");
echo '
Thread has been updated.
';
} else echo "
Your permission to edit this thread has been denied.
";
}
/////////////////////
// When you want to edit a post
if ($edit_post_id !== false && $edit_post !== false) {
// Fetch the post data
$post = mysql_select_single("SELECT `id`, `thread_id`, `text`, `player_name` FROM `znote_forum_posts` WHERE `id`='$edit_post_id' LIMIT 1;");
$thread = mysql_select_single("SELECT `closed` FROM `znote_forum_threads` WHERE `id`='". $post['thread_id'] ."' LIMIT 1;");
// Verify access
$access = PlayerHaveAccess($yourChars, $post['player_name']);
if ($thread['closed'] == 1 && $admin === false) $access = false;
if ($admin) $access = true;
if ($access) {
?>
Edit Post
You don\'t have permission to edit this post.';
} else
/////////////////////
// When you want to edit a thread
if ($edit_thread_id !== false && $edit_thread !== false) {
// Fetch the thread data
$thread = mysql_select_single("SELECT `id`, `title`, `text`, `player_name`, `closed` FROM `znote_forum_threads` WHERE `id`='$edit_thread_id' LIMIT 1;");
$access = PlayerHaveAccess($yourChars, $thread['player_name']);
if ($thread['closed'] == 1) $access = false;
if ($admin) $access = true;
if ($access) {
?>
Edit Thread
Edit access denied.';
} else
/////////////////////
// When you want to view a thread
if ($getThread !== false) {
$getThread = (int)$getThread;
$threadData = mysql_select_single("SELECT `id`, `forum_id`, `player_id`, `player_name`, `title`, `text`, `created`, `updated`, `sticky`, `hidden`, `closed` FROM `znote_forum_threads` WHERE `id`='$getThread' LIMIT 1;");
if ($threadData !== false) {
$category = mysql_select_single("SELECT `hidden`, `access`, `guild_id` FROM `znote_forum` WHERE `id`='". $threadData['forum_id'] ."' LIMIT 1;");
if ($category === false) die("Thread category does not exist.");
$access = true;
$leader = false;
if ($category['hidden'] == 1 || $category['access'] > 1 || $category['guild_id'] > 0) {
$access = false;
if ($category['hidden'] == 1) $access = PlayerHaveAccess($yourChars, $threadData['player_name']);
if ($category['access'] > 1 && $yourAccess >= $category['access']) $access = true;
foreach($charData as $char) {
if ($category['guild_id'] == $char['guild']) $access = true;
if ($char['guild_rank'] == 3) $leader = true;
}
if ($admin) $access = true;
}
if ($access) {
?>
LinkMap: Forum -
Viewing thread: ". $threadData['title'] .""; ?>
- Created by:
". $threadData['player_name'] ."";
?>
- Posted by:
". $post['player_name'] ."";
?>
0) {
if ($threadData['closed'] == 0 || $yourAccess > 3) {
?>
You don\'t have permission to post on this thread. [Thread: Closed]';
} else {
?>
You must have a character on your account that is level + to reply to this thread.
Your permission to access this thread has been denied.";
} else {
?>
Thread unavailable
Thread is unavailable for you, or do not exist any more.
0 && !empty($_GET['forum'])) {
$tmpCat = getValue($_GET['cat']);
$tmpCatName = getValue($_GET['forum']);
?>
Go back to:
Go back to Forum
$yourAccess) $access = false;
if ($category['guild_id'] > 0) {
$status = false;
foreach($charData as $char) {
if ($char['guild'] == $category['guild_id']) $status = true;
}
if (!$status) $access = false;
}
if ($category['closed'] > 0) $access = false;
}
if ($access) {
?>
Create new thread
Permission to create thread denied.';
}
} else
/////////////////////
// When category is specified
if ($getCat !== false) {
$getCat = (int)$getCat;
// Fetch category rules
$category = mysql_select_single("SELECT `name`, `access`, `closed`, `hidden`, `guild_id` FROM `znote_forum` WHERE `id`='$getCat' AND `access`<='$yourAccess' LIMIT 1;");
if ($category !== false && $category['guild_id'] > 0 && !$admin) {
$access = false;
foreach($charData as $char) if ($category['guild_id'] == $char['guild']) $access = true;
if ($access !== true) $category = false;
}
if ($category !== false) {
// TODO : Verify guild access
//foreach($charData)
echo "
";
// Threads
// - id - forum_id - player_id - player_name - title - text - created - updated - sticky - hidden - closed
$threads = mysql_select_multi("SELECT `id`, `player_name`, `title`, `sticky`, `closed` FROM `znote_forum_threads` WHERE `forum_id`='$getCat' ORDER BY `sticky` DESC, `updated` DESC;");
///// HTML \\\\\
if ($threads !== false) {
?>
Title
By
3) $access = true;
}
if ($access) {
?>
';
?>
';
?>
0) {
if ($category['closed'] == 0 || $admin) {
?>
This board is closed.';
} else echo "
You must have a character on your account that is level ". $config['forum']['level'] ."+ to create new threads.
";
} else echo "
Your permission to access this board has been denied. If you are trying to access a Guild Board, you need level: ". $config['forum']['level'] ."+
";
}
} else {
//////////////////////
// No category specified, show list of available categories
if (!$admin) $categories = mysql_select_multi(
"SELECT `id`, `name`, `access`, `closed`, `hidden`, `guild_id` FROM `znote_forum` WHERE `access`<='$yourAccess' ORDER BY `name`;");
else $categories = mysql_select_multi("SELECT `id`, `name`, `access`, `closed`, `hidden`, `guild_id` FROM `znote_forum` ORDER BY `name`;");
$guildboard = false;
?>
Forum Boards
0) $guild = true;
}
if ($admin || $guild) {
if (!isset($guilds)) {
$guilds = mysql_select_multi("SELECT `id`, `name` FROM `guilds` ORDER BY `name`;");
$guilds[] = array('id' => '0', 'name' => 'No guild');
}
$guildName = array();
foreach($guilds as $guild) {
$guildName[$guild['id']] = $guild['name'];
}
if ($admin) {
?>
Edit
Delete
0) {
$guildboard[] = $category;
$access = false;
}
/*
if ($guild) {
foreach($charData as $char) {
if ($category['guild_id'] == $char['guild']) $access = true;
}
}
*/
if ($access) {
$url = url("forum.php?cat=". $category['id']);
echo '
';
echo '
';
if ($category['closed'] == 1) echo $config['forum']['closed'],' ';
if ($category['hidden'] == 1) echo $config['forum']['hidden'],' ';
if ($category['guild_id'] > 0) {
echo "[". $guildName[$category['guild_id']] ."] ";
}
echo $category['name'] ."
";
// Admin columns
if ($admin) {
?>
';
}
}
}
?>
Guild Boards
0) $guild = true;
}
if ($admin || $guild) {
if (!isset($guilds)) {
$guilds = mysql_select_multi("SELECT `id`, `name` FROM `guilds` ORDER BY `name`;");
$guilds[] = array('id' => '0', 'name' => 'No guild');
}
$guildName = array();
foreach($guilds as $guild) {
$guildName[$guild['id']] = $guild['name'];
}
if ($admin) {
?>
Edit
Delete
';
echo '
';
if ($board['closed'] == 1) echo $config['forum']['closed'],' ';
if ($board['hidden'] == 1) echo $config['forum']['hidden'],' ';
if ($board['guild_id'] > 0) {
echo "[". $guildName[$board['guild_id']] ."] ";
}
echo $board['name'] ."