<commit_before><!DOCTYPE html>
<html lang="en">
<!-- SMIPO Create new thread
	@author James

 -->
<?php
require("connect.php");
$board_id = $_GET['board'];
$req = $_GET['req'];
$sql = 'SELECT * FROM Categories WHERE cat_id = ' . $board_id;
$result = $db->query($sql);
$row = $result->fetchRow();
?>
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>New Thread - SMIPO</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/smipo.css" rel="stylesheet">

    <!-- Fonts -->
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <?php require_once("navigation.php"); ?>

    <div class="container">

        <div class="row">
            <div class="box">
                <div class="col-lg-12">
                    <hr>
                    <h2 class="intro-text text-center"> 
						<?php echo "<p>Posting to the " . $row['cat_name'] . " board</p><br />";?>
                    </h2>
                    <hr>
                </div>
					<div class="row">
					<!-- main content area -->
						<div id="boards">
							<center>
							<?php
								if($req == 'new') {
									// request now equal to post
									echo "<form method='POST' action='newThread.php?board=" . $board_id . "&req=pos'>";
									echo "Topic Name: <input type='text' name='topic'><br>Post Data<br>";
									echo "<textarea name='first_reply' cols='75' rows='10'></textarea><br><br>";
									echo "<input type='submit' value='Submit'>";
									echo "</form>";
									echo "<div class='clearfix'></div>";
									
								}
								else {
									/* Get topic info from post and user info from session variables */
									$topic_name = $_POST['topic'];
									$first_reply = $_POST['first_reply'];
									$username = $_SESSION['user'];
									$user_id = $_SESSION['user_id'];
									$logged_in = $_SESSION['logged_in'];
									$status = $_SESSION['status'];
									/* sanitize topic & first_reply */
									$topic_name = htmlspecialchars($topic_name);
									$topic_name = stripslashes($topic_name);
									$topic_name = mysql_real_escape_string($topic_name);
									//$first_reply = htmlspecialchars($first_reply);
									//$first_reply = stripslashes($first_reply);
									//$first_reply = mysql_real_escape_string($first_reply);
									/* getting board name */
									$board_sql = "SELECT * FROM Categories WHERE cat_id = $board_id";
									$board_result = $db->query($board_sql);
									$board_row = $board_result->fetchRow();
									$board_name = $board_row['cat_name'];
									/* end getting board name */
									/* user is logged in and allowed to post */
									if ($logged_in == true && $status >= 0) {
										$insert_sql = "INSERT INTO Topics (topic_subject, topic_date, topic_cat, topic_by, board_id)" .
													  " VALUES ('$topic_name', CURDATE(), '$board_name', '$username', $board_id)";
										$db->query($insert_sql);
										
										/* getting our newly created thread's ID */
										// FIX THIS QUERY 
										$id_sql = "SELECT * FROM Topics WHERE topic_subject = '$topic_name'";
										$id_result = $db->query($id_sql);
										$id_row = $id_result->fetchRow();
										$thread_id = $id_row['topic_id'];
										/* end getting thread ID */
										<commit_msg>Updated SQL call to get the most recent thread created by user when adding original reply instead of the oldest post with same name.<commit_after><!DOCTYPE html>
<html lang="en">
<!-- SMIPO Create new thread
	@author James

 -->
<?php
require("connect.php");
$board_id = $_GET['board'];
$req = $_GET['req'];
$sql = 'SELECT * FROM Categories WHERE cat_id = ' . $board_id;
$result = $db->query($sql);
$row = $result->fetchRow();
?>
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>New Thread - SMIPO</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/smipo.css" rel="stylesheet">

    <!-- Fonts -->
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <?php require_once("navigation.php"); ?>

    <div class="container">

        <div class="row">
            <div class="box">
                <div class="col-lg-12">
                    <hr>
                    <h2 class="intro-text text-center"> 
						<?php echo "<p>Posting to the " . $row['cat_name'] . " board</p><br />";?>
                    </h2>
                    <hr>
                </div>
					<div class="row">
					<!-- main content area -->
						<div id="boards">
							<center>
							<?php
								if($req == 'new') {
									// request now equal to post
									echo "<form method='POST' action='newThread.php?board=" . $board_id . "&req=pos'>";
									echo "Topic Name: <input type='text' name='topic'><br>Post Data<br>";
									echo "<textarea name='first_reply' cols='75' rows='10'></textarea><br><br>";
									echo "<input type='submit' value='Submit'>";
									echo "</form>";
									echo "<div class='clearfix'></div>";
									
								}
								else {
									/* Get topic info from post and user info from session variables */
									$topic_name = $_POST['topic'];
									$first_reply = $_POST['first_reply'];
									$username = $_SESSION['user'];
									$user_id = $_SESSION['user_id'];
									$logged_in = $_SESSION['logged_in'];
									$status = $_SESSION['status'];
									/* sanitize topic & first_reply */
									$topic_name = htmlspecialchars($topic_name);
									$topic_name = stripslashes($topic_name);
									$topic_name = mysql_real_escape_string($topic_name);
									//$first_reply = htmlspecialchars($first_reply);
									//$first_reply = stripslashes($first_reply);
									//$first_reply = mysql_real_escape_string($first_reply);
									/* getting board name */
									$board_sql = "SELECT * FROM Categories WHERE cat_id = $board_id";
									$board_result = $db->query($board_sql);
									$board_row = $board_result->fetchRow();
									$board_name = $board_row['cat_name'];
									/* end getting board name */
									/* user is logged in and allowed to post */
									if ($logged_in == true && $status >= 0) {
										$insert_sql = "INSERT INTO Topics (topic_subject, topic_date, topic_cat, topic_by, board_id)" .
													  " VALUES ('$topic_name', CURDATE(), '$board_name', '$username', $board_id)";
										$db->query($insert_sql);
										
										/* getting our newly created thread's ID */
										// FIX THIS QUERY 
										$id_sql = "SELECT * FROM Topics WHERE topic_subject = '$topic_name' AND topic_by = '$username' ORDER BY topic_id DESC";
										$id_result = $db->query($id_sql);
										$id_row = $id_result->fetchRow();
										$thread_id = $id_row['topic_id'];
										/* end getting thread ID */
										
{'fraction_non_alphanumeric': 0.1731014492753623, 'fraction_numerical': 0.019246376811594204, 'mean_word_length': 2.53959786622897, 'pattern_counts': {'":': 0, '<': 123, '<?xml version=': 0, '>': 137, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '860723', 'n_tokens_mistral': 3640, 'n_tokens_neox': 2648, 'n_words': 592}