1.2): - Updated to the new date/clock time system - Bootstrap design support. Changelog (1.2 --> 1.3): - Show character outfit as avatar - Show in-game position Changelog (1.3 -> 1.4): - Fix SQL query error when editing Board name. */ // BBCODE support: function TransformToBBCode($string) { $tags = array( '[center]{$1}[/center]' => '
$1
', '[b]{$1}[/b]' => '$1', '[img]{$1}[/img]' => 'image', '[link]{$1}[/link]' => '$1', '[link={$1}]{$2}[/link]' => '$2', '[url={$1}]{$2}[/url]' => '$2', '[color={$1}]{$2}[/color]' => '$2', '[*]{$1}[/*]' => '
  • $1
  • ', '[youtube]{$1}[/youtube]' => '
    ', ); foreach ($tags as $tag => $value) { $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/')); $string = preg_replace('/'.$code.'/i', $value, $string); if (strpos($string, "='1' AND `account_id`='". $user_data['id'] ."';"); else $yourChars = mysql_select_multi("SELECT `id`, `name`, `group_id` FROM `players` WHERE `level`>='". $config['forum']['level'] ."' AND `account_id`='". $user_data['id'] ."';"); if (!$yourChars) $yourChars = array(); $charCount = count($yourChars); $yourAccess = accountAccess($user_data['id'], $config['ServerEngine']); if ($admin) { if (!empty($_POST)) { $guilds = mysql_select_multi("SELECT `id`, `name` FROM `guilds` ORDER BY `name`;"); $guilds[] = array('id' => '0', 'name' => 'No guild'); } $yourAccess = 100; } // Your characters, indexed by char_id $charData = array(); foreach ($yourChars as $char) { $charData[$char['id']] = $char; if (get_character_guild_rank($char['id']) > 0) { $guild = get_player_guild_data($char['id']); $charData[$char['id']]['guild'] = $guild['guild_id']; $charData[$char['id']]['guild_rank'] = $guild['rank_level']; } else $charData[$char['id']]['guild'] = '0'; } $cooldownw = array( $user_znote_data['cooldown'], time(), $user_znote_data['cooldown'] - time() ); ///////////////// // Guild Leader & admin $leader = false; foreach($charData as $char) { if ($char['guild'] > 0 && $char['guild_rank'] == 3) $leader = true; } if ($admin && !empty($_POST) || $leader && !empty($_POST)) { $admin_thread_delete = getValue($_POST['admin_thread_delete']); $admin_thread_close = getValue($_POST['admin_thread_close']); $admin_thread_open = getValue($_POST['admin_thread_open']); $admin_thread_sticky = getValue($_POST['admin_thread_sticky']); $admin_thread_unstick = getValue($_POST['admin_thread_unstick']); $admin_thread_id = getValue($_POST['admin_thread_id']); // delete thread if ($admin_thread_delete !== false) { $admin_thread_id = (int)$admin_thread_id; $access = false; if (!$admin) { $thread = mysql_select_single("SELECT `forum_id` FROM `znote_forum_threads` WHERE `id`='$admin_thread_id';"); $forum = mysql_select_single("SELECT `guild_id` FROM `znote_forum` WHERE `id`='". $thread['forum_id'] ."';"); foreach($charData as $char) if ($char['guild'] == $forum['guild_id'] && $char['guild_rank'] == 3) $access = true; } else $access = true; if ($access) { // Delete all associated posts mysql_delete("DELETE FROM `znote_forum_posts` WHERE `thread_id`='$admin_thread_id';"); // Delete thread itself mysql_delete("DELETE FROM `znote_forum_threads` WHERE `id`='$admin_thread_id' LIMIT 1;"); echo '

    Thread and all associated posts deleted.

    '; } else echo '

    Permission denied.

    '; } // Close thread if ($admin_thread_close !== false) { $admin_thread_id = (int)$admin_thread_id; $access = false; if (!$admin) { $thread = mysql_select_single("SELECT `forum_id` FROM `znote_forum_threads` WHERE `id`='$admin_thread_id';"); $forum = mysql_select_single("SELECT `guild_id` FROM `znote_forum` WHERE `id`='". $thread['forum_id'] ."';"); foreach($charData as $char) if ($char['guild'] == $forum['guild_id'] && $char['guild_rank'] == 3) $access = true; } else $access = true; if ($access) { mysql_update("UPDATE `znote_forum_threads` SET `closed`='1' WHERE `id`='$admin_thread_id' LIMIT 1;"); //die("UPDATE `znote_forum_threads` SET `closed`='1' WHERE `id`='$admin_thread_id' LIMIT 1;"); echo '

    Thread has been closed.

    '; } else echo '

    Permission denied.

    '; } // open thread if ($admin_thread_open !== false) { $admin_thread_id = (int)$admin_thread_id; $access = false; if (!$admin) { $thread = mysql_select_single("SELECT `forum_id` FROM `znote_forum_threads` WHERE `id`='$admin_thread_id';"); $forum = mysql_select_single("SELECT `guild_id` FROM `znote_forum` WHERE `id`='". $thread['forum_id'] ."';"); foreach($charData as $char) if ($char['guild'] == $forum['guild_id'] && $char['guild_rank'] == 3) $access = true; } else $access = true; if ($access) { mysql_update("UPDATE `znote_forum_threads` SET `closed`='0' WHERE `id`='$admin_thread_id' LIMIT 1;"); echo '

    Thread has been opened.

    '; } else echo '

    Permission denied.

    '; } // stick thread if ($admin_thread_sticky !== false) { $admin_thread_id = (int)$admin_thread_id; $access = false; if (!$admin) { $thread = mysql_select_single("SELECT `forum_id` FROM `znote_forum_threads` WHERE `id`='$admin_thread_id';"); $forum = mysql_select_single("SELECT `guild_id` FROM `znote_forum` WHERE `id`='". $thread['forum_id'] ."';"); foreach($charData as $char) if ($char['guild'] == $forum['guild_id'] && $char['guild_rank'] == 3) $access = true; } else $access = true; if ($access) { mysql_update("UPDATE `znote_forum_threads` SET `sticky`='1' WHERE `id`='$admin_thread_id' LIMIT 1;"); echo '

    Thread has been sticked.

    '; } else echo '

    Permission denied.

    '; } // unstick thread if ($admin_thread_unstick !== false) { $admin_thread_id = (int)$admin_thread_id; $access = false; if (!$admin) { $thread = mysql_select_single("SELECT `forum_id` FROM `znote_forum_threads` WHERE `id`='$admin_thread_id';"); $forum = mysql_select_single("SELECT `guild_id` FROM `znote_forum` WHERE `id`='". $thread['forum_id'] ."';"); foreach($charData as $char) if ($char['guild'] == $forum['guild_id'] && $char['guild_rank'] == 3) $access = true; } else $access = true; if ($access) { mysql_update("UPDATE `znote_forum_threads` SET `sticky`='0' WHERE `id`='$admin_thread_id' LIMIT 1;"); echo '

    Thread has been unsticked.

    '; } else echo '

    Permission denied.

    '; } } ///////////////// // ADMIN FUNCT if ($admin && !empty($_POST)) { $admin_post_id = getValue($_POST['admin_post_id']); $admin_post_delete = getValue($_POST['admin_post_delete']); $admin_category_delete = getValue($_POST['admin_category_delete']); $admin_category_edit = getValue($_POST['admin_category_edit']); $admin_category_id = getValue($_POST['admin_category_id']); $admin_update_category = getValue($_POST['admin_update_category']); $admin_category_name = getValue($_POST['admin_category_name']); $admin_category_access = getValue($_POST['admin_category_access']); $admin_category_closed = getValue($_POST['admin_category_closed']); $admin_category_hidden = getValue($_POST['admin_category_hidden']); $admin_category_guild_id = getValue($_POST['admin_category_guild_id']); if ($admin_category_access === false) $admin_category_access = 0; if ($admin_category_closed === false) $admin_category_closed = 0; if ($admin_category_hidden === false) $admin_category_hidden = 0; if ($admin_category_guild_id === false) $admin_category_guild_id = 0; $admin_board_create_name = getValue($_POST['admin_board_create_name']); $admin_board_create_access = getValue($_POST['admin_board_create_access']); $admin_board_create_closed = getValue($_POST['admin_board_create_closed']); $admin_board_create_hidden = getValue($_POST['admin_board_create_hidden']); $admin_board_create_guild_id = getValue($_POST['admin_board_create_guild_id']); if ($admin_board_create_access === false) $admin_board_create_access = 0; if ($admin_board_create_closed === false) $admin_board_create_closed = 0; if ($admin_board_create_hidden === false) $admin_board_create_hidden = 0; if ($admin_board_create_guild_id === false) $admin_board_create_guild_id = 0; // Create board if ($admin_board_create_name !== false) { // Insert data mysql_insert("INSERT INTO `znote_forum` (`name`, `access`, `closed`, `hidden`, `guild_id`) VALUES ('$admin_board_create_name', '$admin_board_create_access', '$admin_board_create_closed', '$admin_board_create_hidden', '$admin_board_create_guild_id');"); echo '

    Board has been created.

    '; } ////////////////// // 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 '

    Post has been deleted.

    '; } } // End admin function // Fetching get values if (!empty($_GET)) { $getCat = getValue($_GET['cat']); $getForum = getValue($_GET['forum']); $getThread = getValue($_GET['thread']); $new_thread_category = getValue($_POST['new_thread_category']); $new_thread_cid = getValue($_POST['new_thread_cid']); $create_thread_cid = getValue($_POST['create_thread_cid']); $create_thread_title = getValue($_POST['create_thread_title']); $create_thread_text = getValue($_POST['create_thread_text']); $create_thread_category = getValue($_POST['create_thread_category']); $update_thread_id = getValue($_POST['update_thread_id']); $update_thread_title = getValue($_POST['update_thread_title']); $update_thread_text = getValue($_POST['update_thread_text']); $edit_thread = getValue($_POST['edit_thread']); $edit_thread_id = getValue($_POST['edit_thread_id']); $reply_thread = getValue($_POST['reply_thread']); $reply_text = getValue($_POST['reply_text']); $reply_cid = getValue($_POST['reply_cid']); $edit_post = getValue($_POST['edit_post']); $edit_post_id = getValue($_POST['edit_post_id']); $update_post_id = getValue($_POST['update_post_id']); $update_post_text = getValue($_POST['update_post_text']); ///////////////////// // When you are POSTING in an existing thread if ($reply_thread !== false && $reply_text !== false && $reply_cid !== false) { $reply_cid = (int)$reply_cid; if ($user_znote_data['cooldown'] < time()) { user_update_znote_account(array('cooldown'=>(time() + $config['forum']['cooldownPost']))); $thread = mysql_select_single("SELECT `closed` FROM `znote_forum_threads` WHERE `id`='$reply_thread' LIMIT 1;"); if ($thread['closed'] == 1 && $admin === false) $access = false; else $access = true; if ($access) { mysql_insert("INSERT INTO `znote_forum_posts` (`thread_id`, `player_id`, `player_name`, `text`, `created`, `updated`) VALUES ('$reply_thread', '$reply_cid', '". $charData[$reply_cid]['name'] ."', '$reply_text', '". time() ."', '". time() ."');"); if ($config['forum']['newPostsBumpThreads']) mysql_update("UPDATE `znote_forum_threads` SET `updated`='". time() ."' WHERE `id`='$reply_thread';"); } else 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) { $threadPlayer = ($config['forum']['outfit_avatars'] || $config['forum']['player_position']) ? mysql_select_single("SELECT `id`, `group_id`, `sex`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons` FROM `players` WHERE `id`='".$threadData['player_id']."';") : false; ?> LinkMap:
    Forum -
    Viewing thread: ". $threadData['title'] .""; ?> > - Created by: ". $threadData['player_name'] .""; endif; ?>
    '>
    img


    > - Posted by: ". $post['player_name'] .""; endif; ?>
    '>
    img


    0) { if ($threadData['closed'] == 0 || $yourAccess > 3) { ?>

    [b]Bold Text[/b], [img]Direct Image Link[/img], [center]Cented Text[/center],
    [link]http://youtube.com/[/link], [color=GREEN]Green Text![/color], [*] - Dotted [/*]



    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 "

    Forum Board: ". $category['name'] ."

    "; // 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) { ?> 3) $access = true; } if ($access) { ?> '; ?> '; ?>
    Title By
    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; ?> 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) { ?> 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 '"; // Admin columns if ($admin) { ?> '; } } } ?>
    Forum Boards Edit Delete
    '; 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'] ."

    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) { ?> '; echo '"; // Admin columns if ($admin) { ?> '; } } if ($count == 0 && !$admin) echo ''; ?>
    Guild Boards Edit Delete
    '; 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'] ."
    You don\'t have access to any guildboards.

    Create board:



    Required access:

    Board closed:
    Board hidden:

    Guild board: