Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('../functions.php');
- include('../config.php');
- if(!isset($_COOKIE['user'])) redirect('index.php');
- //lets make our id variable
- if(isset($_POST['forum']) || !isset($_GET['forum']))
- {
- $id = $_POST['forum'];
- }
- elseif(isset($_GET['forum']) && !isset($_POST['forum']))
- {
- $id = $_GET['forum'];
- }
- //start working
- if(!ctype_digit($id))
- {
- redirect('index.php');
- }
- else
- {
- //make sure the parent exists
- $query_parent = mysql_query("SELECT type FROM forums WHERE id = '{$id}'");
- $ex_parent = mysql_fetch_assoc($query_parent);
- if(mysql_num_rows($query_parent) < 1)
- {
- redirect('index.php');
- }
- elseif($ex_parent['type'] == 2 && acc_status($_COOKIE['user']) < 2)
- {
- $content = '<div class="frame e">Only staff members can create new threads in this section. <a href="viewforum.php?forum='. $id .'">Back</a></div>';
- }
- else
- {
- if(!isset($_POST['forum']) && !isset($_POST['title']) && !isset($_POST['content']))
- {
- (acc_status($_COOKIE['user']) < 3) ? $chars = 2000 : $chars = 20000;
- $content = '
- <div id="nocontrols" class="phold"></div>
- <div id="command">
- <form method="post" action="create.php">
- <input type="hidden" name="forum" value="'. $id .'">
- <table>
- <tr>
- <td class="commandtitle">Thread Title:</td>
- <td class="commandinput"><input size="40" maxlength="30" id="charlimit_text_b" type="text" class="textinput" name="title"/>
- </td>
- </tr>
- <tr>
- <td class="commandtwo" colspan="2">You have <span id="charlimit_count_b">30</span> characters <span id="charlimit_info_b" style="display: none">remaining</span> for your title.</td>
- </tr>
- <tr>
- <td class="commandtwo" colspan="2">
- <textarea id="charlimit_text_a" name="content" rows="20" cols="60"></textarea><br />
- You have <span id="charlimit_count_a">'. $chars .'</span> characters <span id="charlimit_info_a" style="display: none">remaining</span> for your message.</td>
- </tr>
- <tr>
- <td class="commandtwo" colspan="2"><br />
- <input type="submit" name="add" value="Add thread" />
- <!--<input type="submit" name="preview" value="Preview" /> -->
- <input type="submit" name="cancel" value="Cancel" />
- </td>
- </tr>
- </table>
- </form>
- </div>';
- }
- else
- {
- $title = mysql_real_escape_string(nl2br(trim($_POST['title'])));
- if(acc_status($_COOKIE['user']) > 2)
- {
- $content = mysql_real_escape_string(nl2br(trim($_POST['content'])));
- }
- else
- {
- $content = mysql_real_escape_string(nl2br(strip_tags(trim($_POST['content']))));
- }
- //lets get the current option
- $flood = mysql_query("SELECT floodlimit FROM floodlimit");
- $get_flood = mysql_fetch_assoc($flood);
- //lets get the users last post
- $lastpost = mysql_query("SELECT lastpost FROM users WHERE username = '{$_COOKIE['user']}'");
- $get_lastpost = mysql_fetch_assoc($lastpost);
- if(strlen($title) < 3)
- {
- $content = '<div class="frame e">Your title needs to be at least three characters long.</div>';
- }
- elseif(word_count($content) < 10)
- {
- $content = '<div class="frame e">Your thread needs to be at least ten words.</div>';
- }
- elseif(strlen($content) > 2000 && acc_status($_COOKIE['user']) < 3)
- {
- $content = '<div class="frame e">Your post cannot be greater than 2000 characters.</div>';
- }
- elseif((time()-$get_lastpost['lastpost']) < $get_flood['floodlimit'])
- {
- $content = '<div class="frame e">You must wait '. $get_flood['floodlimit'] .' seconds in-between posts.</div>';
- }
- else
- {
- //if the category type is 2, make the thread automatically hidden
- if($ex_parent['type'] == 3) { $s = 1; } else { $s = 0; }
- //update their lastpost field
- mysql_query("UPDATE users SET lastpost = '". time() ."' WHERE username = '{$_COOKIE['user']}'");
- //insert new thread
- mysql_query("INSERT INTO threads VALUES (null, '{$id}','{$title}', '{$content}', '{$_COOKIE['user']}', NOW(), '". qfc() ."', NOW(), '{$_COOKIE['user']}', '','{$_SERVER['REMOTE_ADDR']}', '0', '0', '{$s}', '')");
- //send them to their new thread
- redirect('viewthread.php?forum='. $id .'&id='. mysql_insert_id());
- }
- }
- }
- }
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html xmlns:IE>
- <head>
- <meta http-equiv="Expires" content="0">
- <meta http-equiv="Pragma" content="no-cache">
- <meta http-equiv="Cache-Control" content="no-cache">
- <meta name="MSSmartTagsPreventParsing" content="TRUE">
- <title><?php echo $title; ?></title>
- <link href="../css/basic-3.css" rel="stylesheet" type="text/css" media="all" />
- <link href="../css/forum-3.css" rel="stylesheet" type="text/css" media="all" />
- <link href="../css/forummsg-1.css" rel="stylesheet" type="text/css" media="all" />
- <!--[if IE 8]>
- <link rel="stylesheet" type="text/css" href="../css/forummsg-ie-1.css" />
- <![endif]-->
- <script language="JavaScript">
- document.getElementById("smilytxt").style.display="";
- function addsmiley(code) {
- var msgtext=document.getElementById("charlimit_text_a");
- msgtext.focus();
- if (document.selection && document.selection.createRange && !msgtext.setSelection) {
- document.selection.createRange().text=code;
- } else {
- var pretext = msgtext.value.substring(0,msgtext.selectionStart);
- var pos = msgtext.selectionStart;
- var posttext = msgtext.value.substring(msgtext.selectionEnd, msgtext.value.length);
- msgtext.value = pretext + code + posttext;
- msgtext.selectionEnd=pos+code.length;
- }
- }
- </script>
- <script type="text/javascript">
- var alerted=false;
- function do_watch(msg, element, count, max, submit) {
- try {
- var stri=element.value.replace(/\r/g, "");
- if(submit) if(stri.length>max) submit.disabled=true;
- if(stri.length>max) {
- if(msg==true && alerted==false) {
- alert('You have gone over your character limit for this message');
- alerted=true;
- }
- element.value=stri=stri.substring(0,max);
- }
- count.childNodes[0].nodeValue=max-stri.length;
- }
- catch(e) {}
- }
- function install_watch(msg, element, count, max, form, submit, reset) {
- try {
- element.onkeyup=function() {
- do_watch(msg, element, count, max, submit);
- };
- element.onkeydown=function() {
- do_watch(msg, element, count, max, submit);
- };
- element.onkeypress=function() {
- do_watch(msg, element, count, max, submit);
- };
- element.onmousemove=function() {
- do_watch(msg, element, count, max, submit);
- };
- element.onchange=function() {
- do_watch(false, element, count, max, submit);
- };
- if(form) {
- form.onsubmit=function() {
- do_watch(msg, element, count, max, submit);
- };
- }
- if(reset && form) {
- reset.onclick=function() {
- form.reset();
- do_watch(msg, element, count, max, submit);
- }
- }
- do_watch(false, element, count, max, submit);
- }
- catch(e) {}
- }
- var charlimiter_run=false;
- function install_charlimiters() {
- if(charlimiter_run) return;
- charlimiter_run=true;
- try {
- var textboxes=document.getElementsByTagName("textarea");
- for(var i=0; i<textboxes.length; i++) install(textboxes[i]);
- var inputs=document.getElementsByTagName("input");
- for(var i=0; i<inputs.length; i++) install(inputs[i]);
- }
- catch(e) {}
- }
- function install(element) {
- var textbox_id_len = new String("charlimit_text").length;
- var text_id=element.id.toString();
- if(text_id.match(/^charlimit_text/i) && text_id.length>=textbox_id_len) {
- var identifier=text_id.substr(textbox_id_len);
- var info=document.getElementById("charlimit_info" + identifier);
- var count=document.getElementById("charlimit_count" + identifier);
- var form=document.getElementById("charlimit_form" + identifier);
- var submit=document.getElementById("charlimit_submit" + identifier);
- var reset=document.getElementById("charlimit_reset" + identifier);
- if(info && count) {
- var msg=false;
- if(identifier.match(/^_msg/i)) msg=true;
- var max_val=parseInt(count.childNodes[0].nodeValue);
- install_watch(msg, element, count, max_val, form, submit, reset);
- info.style.display='inline';
- }
- }
- }
- if(window.addEventListener) window.addEventListener('load', install_charlimiters, true);
- else if(window.attachEvent) window.attachEvent('onload', install_charlimiters);
- else window.onload=install_charlimiters;
- </script>
- </head>
- <body>
- <div id="body">
- <div class="frame e">
- <span style="float: right;">
- <a href="../index.php">Main Page</a> | <a href="../logout.php">Logout</a>
- </span>
- <div>
- <?php
- if(isset($_COOKIE['user']))
- {
- echo 'You are logged in as <span style="color: rgb(255, 187, 34);">'. display_name($_COOKIE['user'],2) .'</span>';
- }
- else
- {
- echo 'You are not logged in.';
- }
- ?>
- </div></div> <br />
- <div style="text-align: center; background: none;">
- <div id="infopane">
- <div class="about">
- <ul class="flat">
- <li><a href="viewforum.php?forum=<?php echo $id; ?>">Return to forums page</a>
- </li>
- </ul>
- </div>
- </div>
- <?php echo $content; ?>
- <div id="smileylegend">
- <span class="title">Smileys: </span><br>
- <span id="smilytxt" style="display: hidden;">Click to add a smiley to your message (will overwrite selected text).</span><br />
- <span onclick="addsmiley(':)')"><IMG class=sm0 alt=":)" title=":)" src="../img/forum/smileys/smile.gif"> :)</span>
- <span onclick="addsmiley(';)')"><IMG class=sm1 alt=";)" title=";)" src="../img/forum/smileys/wink.gif"> ;)</span>
- <span onclick="addsmiley(':P')"><IMG class=sm2 alt=":P" title=":P" src="../img/forum/smileys/tongue.gif"> :P</span>
- <span onclick="addsmiley(':(')"><IMG class=sm3 alt=":(" title=":(" src="../img/forum/smileys/sad.gif"> :(</span>
- <span onclick="addsmiley(':|')"><IMG class=sm4 alt=":|" title=":|" src="../img/forum/smileys/nosmile.gif"> :|</span>
- <span onclick="addsmiley('O_o')"><IMG class=sm5 alt="O_o" title="O_o" src="../img/forum/smileys/o.O.gif"> O_o</span>
- <span onclick="addsmiley(':D')"><IMG class=sm6 alt=":D" title=":D" src="../img/forum/smileys/bigsmile.gif"> :D</span>
- <span onclick="addsmiley('^^')"><IMG class=sm7 alt="^^" title="^^" src="../img/forum/smileys/^^.gif"> ^^</span>
- <span onclick="addsmiley(':O')"><IMG class=sm8 alt=":O" title=":O" src="../img/forum/smileys/shocked.gif"> :O</span>
- <span onclick="addsmiley(':@')"><IMG class=sm9 alt=":@" title=":@" src="../img/forum/smileys/angry.gif"> :@</span>
- </div>
- <br />
- <div class="tandc">
- This website and its contents are copyright © 2011 <a href="http://www.rs2006.net/">RS2006</a>.<!--<br>Use of this website is subject to our <a href="terms/terms.html" class=c>Terms+Conditions</a> and <a href="privacy/privacy.html" class=c>Privacy policy</a>--> <br>Most of the pictures on this website are copyright © 1999 -
- 2012 <a href="http://jagex.com">Jagex Ltd</a>.
- </div>
- </div>
- </div>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment