Guest User

Untitled

a guest
Mar 1st, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include('../functions.php');
  3. include('../config.php');
  4.  
  5. if(!isset($_COOKIE['user'])) redirect('index.php');
  6.  
  7. //lets make our id variable
  8. if(isset($_POST['forum']) || !isset($_GET['forum']))
  9. {
  10.     $id = $_POST['forum'];
  11. }
  12. elseif(isset($_GET['forum']) && !isset($_POST['forum']))
  13. {
  14.     $id = $_GET['forum'];
  15. }
  16.  
  17. //start working
  18. if(!ctype_digit($id))
  19. {
  20.     redirect('index.php');
  21. }
  22. else
  23. {
  24.     //make sure the parent exists
  25.     $query_parent = mysql_query("SELECT type FROM forums WHERE id = '{$id}'");
  26.     $ex_parent = mysql_fetch_assoc($query_parent);
  27.    
  28.     if(mysql_num_rows($query_parent) < 1)
  29.     {
  30.         redirect('index.php');
  31.     }
  32.     elseif($ex_parent['type'] == 2 && acc_status($_COOKIE['user']) < 2)
  33.     {
  34.         $content = '<div class="frame e">Only staff members can create new threads in this section. <a href="viewforum.php?forum='. $id .'">Back</a></div>';
  35.     }
  36.     else
  37.     {
  38.         if(!isset($_POST['forum']) && !isset($_POST['title']) && !isset($_POST['content']))
  39.         {
  40.             (acc_status($_COOKIE['user']) < 3) ? $chars = 2000 : $chars = 20000;
  41.        
  42.             $content = '
  43.             <div id="nocontrols" class="phold"></div>
  44.             <div id="command">
  45.             <form method="post" action="create.php">
  46.             <input type="hidden" name="forum" value="'. $id .'">
  47.             <table>
  48.             <tr>
  49.                 <td class="commandtitle">Thread Title:</td>
  50.                 <td class="commandinput"><input size="40" maxlength="30" id="charlimit_text_b" type="text" class="textinput" name="title"/>
  51.                 </td>
  52.             </tr>
  53.             <tr>
  54.                 <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>
  55.             </tr>
  56.             <tr>
  57.                 <td class="commandtwo" colspan="2">
  58.                 <textarea id="charlimit_text_a" name="content" rows="20" cols="60"></textarea><br />
  59.                 You have <span id="charlimit_count_a">'. $chars .'</span> characters <span id="charlimit_info_a" style="display: none">remaining</span> for your message.</td>
  60.             </tr>
  61.             <tr>
  62.             <td class="commandtwo" colspan="2"><br />
  63.                 <input type="submit" name="add" value="Add thread" /> &nbsp; &nbsp;
  64.                 <!--<input type="submit" name="preview" value="Preview" /> &nbsp; &nbsp;-->
  65.                 <input type="submit" name="cancel" value="Cancel" /> &nbsp; &nbsp;
  66.             </td>
  67.             </tr>
  68.             </table>
  69.             </form>
  70.             </div>';
  71.         }
  72.         else
  73.         {
  74.             $title = mysql_real_escape_string(nl2br(trim($_POST['title'])));
  75.            
  76.             if(acc_status($_COOKIE['user']) > 2)
  77.             {
  78.                 $content = mysql_real_escape_string(nl2br(trim($_POST['content'])));
  79.             }
  80.             else
  81.             {
  82.                 $content = mysql_real_escape_string(nl2br(strip_tags(trim($_POST['content']))));
  83.             }
  84.            
  85.             //lets get the current option
  86.             $flood = mysql_query("SELECT floodlimit FROM floodlimit");
  87.             $get_flood = mysql_fetch_assoc($flood);
  88.            
  89.             //lets get the users last post
  90.             $lastpost = mysql_query("SELECT lastpost FROM users WHERE username = '{$_COOKIE['user']}'");
  91.             $get_lastpost = mysql_fetch_assoc($lastpost);
  92.            
  93.             if(strlen($title) < 3)
  94.             {
  95.                 $content =  '<div class="frame e">Your title needs to be at least three characters long.</div>';
  96.             }
  97.             elseif(word_count($content) < 10)
  98.             {
  99.                 $content = '<div class="frame e">Your thread needs to be at least ten words.</div>';
  100.             }
  101.             elseif(strlen($content) > 2000 && acc_status($_COOKIE['user']) < 3)
  102.             {
  103.                 $content = '<div class="frame e">Your post cannot be greater than 2000 characters.</div>';
  104.             }
  105.             elseif((time()-$get_lastpost['lastpost']) < $get_flood['floodlimit'])
  106.             {
  107.                 $content = '<div class="frame e">You must wait '. $get_flood['floodlimit'] .' seconds in-between posts.</div>';
  108.             }
  109.             else
  110.             {
  111.                 //if the category type is 2, make the thread automatically hidden
  112.                 if($ex_parent['type'] == 3) { $s = 1; } else { $s = 0; }
  113.                
  114.                 //update their lastpost field
  115.                 mysql_query("UPDATE users SET lastpost = '". time() ."' WHERE username = '{$_COOKIE['user']}'");
  116.                
  117.                 //insert new thread
  118.                 mysql_query("INSERT INTO threads VALUES (null, '{$id}','{$title}', '{$content}', '{$_COOKIE['user']}', NOW(), '". qfc() ."', NOW(), '{$_COOKIE['user']}', '','{$_SERVER['REMOTE_ADDR']}', '0', '0', '{$s}', '')");
  119.  
  120.                 //send them to their new thread
  121.                 redirect('viewthread.php?forum='. $id .'&id='. mysql_insert_id());
  122.             }
  123.         }
  124.     }
  125. }
  126. ?>
  127. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  128. <html xmlns:IE>
  129. <head>
  130. <meta http-equiv="Expires" content="0">
  131. <meta http-equiv="Pragma" content="no-cache">
  132. <meta http-equiv="Cache-Control" content="no-cache">
  133. <meta name="MSSmartTagsPreventParsing" content="TRUE">
  134. <title><?php echo $title; ?></title>
  135. <link href="../css/basic-3.css" rel="stylesheet" type="text/css" media="all" />
  136. <link href="../css/forum-3.css" rel="stylesheet" type="text/css" media="all" />
  137. <link href="../css/forummsg-1.css" rel="stylesheet" type="text/css" media="all" />
  138. <!--[if IE 8]>
  139. <link rel="stylesheet" type="text/css" href="../css/forummsg-ie-1.css" />
  140. <![endif]-->
  141. <script language="JavaScript">
  142.     document.getElementById("smilytxt").style.display="";
  143.     function addsmiley(code) {
  144.         var msgtext=document.getElementById("charlimit_text_a");
  145.         msgtext.focus();
  146.         if (document.selection && document.selection.createRange && !msgtext.setSelection) {
  147.             document.selection.createRange().text=code;
  148.         } else {
  149.             var pretext = msgtext.value.substring(0,msgtext.selectionStart);
  150.             var pos = msgtext.selectionStart;
  151.             var posttext = msgtext.value.substring(msgtext.selectionEnd, msgtext.value.length);
  152.             msgtext.value = pretext + code + posttext;
  153.             msgtext.selectionEnd=pos+code.length;
  154.         }
  155.     }
  156. </script>
  157. <script type="text/javascript">
  158. var alerted=false;
  159. function do_watch(msg, element, count, max, submit) {
  160.  try {
  161.   var stri=element.value.replace(/\r/g, "");
  162.   if(submit) if(stri.length>max) submit.disabled=true;
  163.   if(stri.length>max) {
  164.    if(msg==true && alerted==false) {
  165.     alert('You have gone over your character limit for this message');
  166.     alerted=true;
  167.    }
  168.    element.value=stri=stri.substring(0,max);
  169.   }
  170.   count.childNodes[0].nodeValue=max-stri.length;
  171.  }
  172.  catch(e) {}
  173. }
  174. function install_watch(msg, element, count, max, form, submit, reset) {
  175.  try {
  176.   element.onkeyup=function() {
  177.    do_watch(msg, element, count, max, submit);
  178.   };
  179.   element.onkeydown=function() {
  180.    do_watch(msg, element, count, max, submit);
  181.   };
  182.   element.onkeypress=function() {
  183.    do_watch(msg, element, count, max, submit);
  184.   };
  185.   element.onmousemove=function() {
  186.    do_watch(msg, element, count, max, submit);
  187.   };
  188.   element.onchange=function() {
  189.    do_watch(false, element, count, max, submit);
  190.   };
  191.   if(form) {
  192.    form.onsubmit=function() {
  193.     do_watch(msg, element, count, max, submit);
  194.    };
  195.   }
  196.   if(reset && form) {
  197.    reset.onclick=function() {
  198.     form.reset();
  199.     do_watch(msg, element, count, max, submit);
  200.    }
  201.   }
  202.   do_watch(false, element, count, max, submit);
  203.  }
  204.  catch(e) {}
  205. }
  206. var charlimiter_run=false;
  207. function install_charlimiters() {
  208.  if(charlimiter_run) return;
  209.  charlimiter_run=true;
  210.  try {
  211.   var textboxes=document.getElementsByTagName("textarea");
  212.   for(var i=0; i<textboxes.length; i++) install(textboxes[i]);
  213.   var inputs=document.getElementsByTagName("input");
  214.   for(var i=0; i<inputs.length; i++) install(inputs[i]);
  215.  }
  216.  catch(e) {}
  217. }
  218. function install(element) {
  219.  var textbox_id_len = new String("charlimit_text").length;
  220.  var text_id=element.id.toString();
  221.  if(text_id.match(/^charlimit_text/i) && text_id.length>=textbox_id_len) {
  222.   var identifier=text_id.substr(textbox_id_len);
  223.   var info=document.getElementById("charlimit_info" + identifier);
  224.   var count=document.getElementById("charlimit_count" + identifier);
  225.   var form=document.getElementById("charlimit_form" + identifier);
  226.   var submit=document.getElementById("charlimit_submit" + identifier);
  227.   var reset=document.getElementById("charlimit_reset" + identifier);
  228.   if(info && count) {
  229.    var msg=false;
  230.    if(identifier.match(/^_msg/i)) msg=true;
  231.    var max_val=parseInt(count.childNodes[0].nodeValue);
  232.    install_watch(msg, element, count, max_val, form, submit, reset);
  233.    info.style.display='inline';
  234.   }
  235.  }
  236. }
  237. if(window.addEventListener) window.addEventListener('load', install_charlimiters, true);
  238. else if(window.attachEvent) window.attachEvent('onload', install_charlimiters);
  239. else window.onload=install_charlimiters;
  240.  
  241. </script>
  242. </head>
  243. <body>
  244.     <div id="body">
  245.         <div class="frame e">
  246.             <span style="float: right;">
  247.             <a href="../index.php">Main Page</a> | <a href="../logout.php">Logout</a>
  248.             </span>
  249.             <div>
  250.             <?php
  251.                 if(isset($_COOKIE['user']))
  252.                 {
  253.                     echo 'You are logged in as <span style="color: rgb(255, 187, 34);">'. display_name($_COOKIE['user'],2) .'</span>';
  254.                 }
  255.                 else
  256.                 {
  257.                     echo 'You are not logged in.';
  258.                 }
  259.             ?>
  260.            </div></div>     <br />
  261.  
  262.         <div style="text-align: center; background: none;">
  263.             <div id="infopane">
  264.                 <div class="about">
  265.  
  266.                     <ul class="flat">
  267.                         <li><a href="viewforum.php?forum=<?php echo $id; ?>">Return to forums page</a>
  268.                         </li>
  269.                     </ul>
  270.  
  271.                 </div>
  272.             </div>
  273.            
  274.                 <?php echo $content; ?>
  275.             <div id="smileylegend">
  276.                 <span class="title">Smileys: </span><br>
  277.                 <span id="smilytxt" style="display: hidden;">Click to add a smiley to your message (will overwrite selected text).</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  278.                 <span onclick="addsmiley(':)')"><IMG class=sm0 alt=":)" title=":)" src="../img/forum/smileys/smile.gif"> :)</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  279.                 <span onclick="addsmiley(';)')"><IMG class=sm1 alt=";)" title=";)" src="../img/forum/smileys/wink.gif"> ;)</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  280.                 <span onclick="addsmiley(':P')"><IMG class=sm2 alt=":P" title=":P" src="../img/forum/smileys/tongue.gif"> :P</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  281.                 <span onclick="addsmiley(':(')"><IMG class=sm3 alt=":(" title=":(" src="../img/forum/smileys/sad.gif"> :(</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  282.                 <span onclick="addsmiley(':|')"><IMG class=sm4 alt=":|" title=":|" src="../img/forum/smileys/nosmile.gif"> :|</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  283.                 <span onclick="addsmiley('O_o')"><IMG class=sm5 alt="O_o" title="O_o" src="../img/forum/smileys/o.O.gif"> O_o</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  284.                 <span onclick="addsmiley(':D')"><IMG class=sm6 alt=":D" title=":D" src="../img/forum/smileys/bigsmile.gif"> :D</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  285.                 <span onclick="addsmiley('^^')"><IMG class=sm7 alt="^^" title="^^" src="../img/forum/smileys/^^.gif"> ^^</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  286.                 <span onclick="addsmiley(':O')"><IMG class=sm8 alt=":O" title=":O" src="../img/forum/smileys/shocked.gif"> :O</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  287.                 <span onclick="addsmiley(':@')"><IMG class=sm9 alt=":@" title=":@" src="../img/forum/smileys/angry.gif"> :@</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  288.             </div>
  289.             <br />
  290.             <div class="tandc">
  291.  
  292.             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 &copy; 1999 -
  293.                 2012                <a href="http://jagex.com">Jagex Ltd</a>.
  294.             </div>
  295.         </div>
  296.  
  297.     </div>
  298. </body>
Advertisement
Add Comment
Please, Sign In to add comment