<commit_before><?php
// Configurations and includes for PHP
require 'resources/functions.php';
require 'resources/config.php';
require 'resources/rpiCAS.php';

if (!phpCAS::isAuthenticated()) {
	// If they're not currently logged in, take them to the RPI CAS page
    phpCAS::forceAuthentication();
}

// Establish a connection to the database for this page.
$conn = new PDO('mysql:host=localhost;dbname=slatecrate', $config['DB_USERNAME'], $config['DB_PASSWORD']);

require 'partials/head.partial.php';
require 'partials/navigation.partial.php';

try {
	if(isset($_GET["class"])) {
		$c = $_GET["class"];
		$var = $conn->prepare("SELECT `title` FROM `categories` WHERE `category_id` = $c");
		$var->execute();
		$result = $var->fetch(PDO::FETCH_ASSOC);
		$categoryTitle = $result["title"];
	}
	$admin = $conn->prepare("SELECT `isadmin` FROM `users` WHERE `rcs_id` = '" . phpCAS::getUser() . "'");
	$admin->execute();
	$isadmin = false;
	while($result = $admin->fetch(PDO::FETCH_ASSOC)){
		if($result["isadmin"] == 1){ $isadmin = true; }
	}
} catch(PDOException $e) {
	echo $e;
}

if(isset($_GET["class"])) {
	$pageHeader = "Links for " . $categoryTitle;
} else {
	$pageHeader = "Links for all classes";
}

require 'partials/pageheader.partial.php';
?>
<div class="container mtb">
<?php
//add class if we need to
if(isset($_POST["linkName"])){
    try{
        $string = "'" . $_POST["URL"] . "', " . $_POST["user"] . ", " . "CURDATE(), '" . $_POST["linkName"] . "'";

        $conn->query("INSERT INTO `links` (`link`, `rcs_id`, `category_id`, `creation_date`, `title`)
            VALUES (" . $string . ");");

			echo "<div class='row'><div class='col-xs-12'>" .
					successAlert("Your new link, entitled " . $_POST["linkName"] . ", was successfully added!") .
				"</div></div>";
    }catch(PDOException $e){
    }
}
if(isset($_POST["delete"])){
	try {
    	$conn->query("DELETE FROM `links` WHERE `link_id` = " . $_POST["delete"]);

		echo "<div class='row'><div class='col-xs-12'>" .
				successAlert("The link was successfully deleted!") .
			"</div></div>";
	} catch(PDOException $e) {
		echo "<div class='row'><div class='col-xs-12'>" .
				errorAlert($e) .
			 "</div></div>";
    }
}

try {
	if(isset($_GET["class"])) {
		$var = $conn->prepare("SELECT * FROM `links` WHERE `category_id` = $c");
		$var->execute();
	} else {
		$var = $conn->prepare("SELECT * FROM `links`");
		$var->execute();
	}
} catch(PDOException $e) {
	echo $e;
}
?>

    <div class="row">
		<div class="col-md-4 col-sm-3">
			<a href="classes.php" class="btn btn-primary">
				<span class="fa fa-chevron-left"></span> Back to Classes
			</a>
		</div>
		<div class="col-md-4 col-sm-6">
			<div class="form-group form-group-sm">
				<input class="form-control" placeholder="Search Links" />
			</div>
		</div>
		<div class="col-md-4">
			<?php
				echo "<a href='addLink.php";
				if(isset($_GET["class"])) {
					echo "?class=$c";
				}
				echo "' class='btn btn-primary pull-right'>
					<span class='fa fa-plus'></spab>
					Add a link
				</a>";
			?><commit_msg>Fixed typo causing font problem<commit_after><?php
// Configurations and includes for PHP
require 'resources/functions.php';
require 'resources/config.php';
require 'resources/rpiCAS.php';

if (!phpCAS::isAuthenticated()) {
	// If they're not currently logged in, take them to the RPI CAS page
    phpCAS::forceAuthentication();
}

// Establish a connection to the database for this page.
$conn = new PDO('mysql:host=localhost;dbname=slatecrate', $config['DB_USERNAME'], $config['DB_PASSWORD']);

require 'partials/head.partial.php';
require 'partials/navigation.partial.php';

try {
	if(isset($_GET["class"])) {
		$c = $_GET["class"];
		$var = $conn->prepare("SELECT `title` FROM `categories` WHERE `category_id` = $c");
		$var->execute();
		$result = $var->fetch(PDO::FETCH_ASSOC);
		$categoryTitle = $result["title"];
	}
	$admin = $conn->prepare("SELECT `isadmin` FROM `users` WHERE `rcs_id` = '" . phpCAS::getUser() . "'");
	$admin->execute();
	$isadmin = false;
	while($result = $admin->fetch(PDO::FETCH_ASSOC)){
		if($result["isadmin"] == 1){ $isadmin = true; }
	}
} catch(PDOException $e) {
	echo $e;
}

if(isset($_GET["class"])) {
	$pageHeader = "Links for " . $categoryTitle;
} else {
	$pageHeader = "Links for all classes";
}

require 'partials/pageheader.partial.php';
?>
<div class="container mtb">
<?php
//add class if we need to
if(isset($_POST["linkName"])){
    try{
        $string = "'" . $_POST["URL"] . "', " . $_POST["user"] . ", " . "CURDATE(), '" . $_POST["linkName"] . "'";

        $conn->query("INSERT INTO `links` (`link`, `rcs_id`, `category_id`, `creation_date`, `title`)
            VALUES (" . $string . ");");

			echo "<div class='row'><div class='col-xs-12'>" .
					successAlert("Your new link, entitled " . $_POST["linkName"] . ", was successfully added!") .
				"</div></div>";
    }catch(PDOException $e){
    }
}
if(isset($_POST["delete"])){
	try {
    	$conn->query("DELETE FROM `links` WHERE `link_id` = " . $_POST["delete"]);

		echo "<div class='row'><div class='col-xs-12'>" .
				successAlert("The link was successfully deleted!") .
			"</div></div>";
	} catch(PDOException $e) {
		echo "<div class='row'><div class='col-xs-12'>" .
				errorAlert($e) .
			 "</div></div>";
    }
}

try {
	if(isset($_GET["class"])) {
		$var = $conn->prepare("SELECT * FROM `links` WHERE `category_id` = $c");
		$var->execute();
	} else {
		$var = $conn->prepare("SELECT * FROM `links`");
		$var->execute();
	}
} catch(PDOException $e) {
	echo $e;
}
?>

    <div class="row">
		<div class="col-md-4 col-sm-3">
			<a href="classes.php" class="btn btn-primary">
				<span class="fa fa-chevron-left"></span> Back to Classes
			</a>
		</div>
		<div class="col-md-4 col-sm-6">
			<div class="form-group form-group-sm">
				<input class="form-control" placeholder="Search Links" />
			</div>
		</div>
		<div class="col-md-4">
			<?php
				echo "<a href='addLink.php";
				if(isset($_GET["class"])) {
					echo "?class=$c";
				}
				echo "' class='btn btn-primary pull-right'>
					<span class='fa fa-plus'></span>
					Add a link
				</a>";
			?>
{'fraction_non_alphanumeric': 0.2226217718208565, 'fraction_numerical': 0.003922850604772802, 'mean_word_length': 3.79921568627451, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 93, 'https://': 0, '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': '6999655', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2178, 'n_words': 472}