<commit_before><html>
<head>
    <meta charset="utf-8" />
    <title>iFSR Infoscreen Backend</title>
    <link rel="stylesheet" type="text/css" href="milligram.min.css" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
</head>
    
<body>
<?php
	$db = new SQLite3("items.sqlite");
	$db->exec("CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, headline TEXT, content TEXT, image TEXT, visibility INTEGER);");

	if(isset($_POST['new_submit'])) {
		$statement = $db->prepare('INSERT INTO items (headline, content, image, visibility) VALUES (:headline, :content, :image, :visibility);');
		$statement->bindValue(':headline', $_POST['new_headline']);
		$statement->bindValue(':image', $_POST['new_image']);
		$statement->bindValue(':content', $_POST['new_content']);
		$statement->bindValue(':visibility', $_POST['new_visibility']);
		$result = $statement->execute();
	} else if(isset($_POST['delete_submit'])) {
		$statement = $db->prepare('DELETE FROM items WHERE id = :id;');
		$statement->bindValue(':id', $_POST['delete_nr']);
		$result = $statement->execute();
	} else if(isset($_POST['saveEdit_submit'])) {
		$statement = $db->prepare('UPDATE items SET headline=:headline, content=:content, image=:image, visibility=:visibility WHERE id = :id;');
		$statement->bindValue(':id', $_POST['edit_nr']);
		$statement->bindValue(':headline', $_POST['new_headline']);
		$statement->bindValue(':image', $_POST['new_image']);
		$statement->bindValue(':content', $_POST['new_content']);
		$statement->bindValue(':visibility', $_POST['new_visibility']);
		$result = $statement->execute();
	}
?>

    <aside class="articlelist">
        <h4>Alle News</h4>
        <?php
            $res = $db->query("SELECT * FROM items;");
            while ($row = $res->fetchArray()) {
                echo "<div class=\"article\">$row[id]: $row[headline]<br />

		<div class=\"buttons\">
			<form action=\"backend.php\" method=\"POST\">
		    	<input name=\"delete_nr\" type=\"hidden\" value=\"$row[id]\" />
		        <input name=\"delete_submit\" type=\"submit\" class=\"delete\" value=\"Löschen.\" />
		    </form>
			<form action=\"backend.php\" method=\"POST\">
		    	<input name=\"edit_nr\" type=\"hidden\" value=\"$row[id]\" />
		        <input name=\"edit_submit\" type=\"submit\" class=\"edit\" value=\"Ändern.\" />
		    </form> 
		</div>
		</div>";
            }
        ?>

    </aside>
    <div class="content">
	<?php
		if(isset($_POST['edit_submit'])) {
		$statement = $db->prepare("SELECT * FROM items WHERE id = :id;");
		$statement->bindValue(':id', $_POST['edit_nr']);
		$result = $statement->execute();
			while ($row = $result->fetchArray()) {
		    
		    	echo "<h1>Eintrag #$row[id] bearbeiten</h1>
		    	<br />
			        
			        <form action=\"backend.php\" method=\"POST\">
			            <fieldset>
			                <pre class=\"info\">Der Nachrichtentext unterstützt valides <strong>Markdown</strong>.</pre>
			                <label for=\"headline\">Überschrift:</label>
			                <input name=\"new_headline\" placeholder=\"Titel\" id=\"headline\" class=\"inputfield\" value=\"" . htmlspecialchars($row[headline]). "\" required /><commit_msg>fixes the fix for the fix for #26<commit_after><html>
<head>
    <meta charset="utf-8" />
    <title>iFSR Infoscreen Backend</title>
    <link rel="stylesheet" type="text/css" href="milligram.min.css" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
</head>
    
<body>
<?php
	$db = new SQLite3("items.sqlite");
	$db->exec("CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, headline TEXT, content TEXT, image TEXT, visibility INTEGER);");

	if(isset($_POST['new_submit'])) {
		$statement = $db->prepare('INSERT INTO items (headline, content, image, visibility) VALUES (:headline, :content, :image, :visibility);');
		$statement->bindValue(':headline', $_POST['new_headline']);
		$statement->bindValue(':image', $_POST['new_image']);
		$statement->bindValue(':content', $_POST['new_content']);
		$statement->bindValue(':visibility', $_POST['new_visibility']);
		$result = $statement->execute();
	} else if(isset($_POST['delete_submit'])) {
		$statement = $db->prepare('DELETE FROM items WHERE id = :id;');
		$statement->bindValue(':id', $_POST['delete_nr']);
		$result = $statement->execute();
	} else if(isset($_POST['saveEdit_submit'])) {
		$statement = $db->prepare('UPDATE items SET headline=:headline, content=:content, image=:image, visibility=:visibility WHERE id = :id;');
		$statement->bindValue(':id', $_POST['edit_nr']);
		$statement->bindValue(':headline', $_POST['new_headline']);
		$statement->bindValue(':image', $_POST['new_image']);
		$statement->bindValue(':content', $_POST['new_content']);
		$statement->bindValue(':visibility', $_POST['new_visibility']);
		$result = $statement->execute();
	}
?>

    <aside class="articlelist">
        <h4>Alle News</h4>
        <?php
            $res = $db->query("SELECT * FROM items;");
            while ($row = $res->fetchArray()) {
                echo "<div class=\"article\">$row[id]: $row[headline]<br />

		<div class=\"buttons\">
			<form action=\"backend.php\" method=\"POST\">
		    	<input name=\"delete_nr\" type=\"hidden\" value=\"$row[id]\" />
		        <input name=\"delete_submit\" type=\"submit\" class=\"delete\" value=\"Löschen.\" />
		    </form>
			<form action=\"backend.php\" method=\"POST\">
		    	<input name=\"edit_nr\" type=\"hidden\" value=\"$row[id]\" />
		        <input name=\"edit_submit\" type=\"submit\" class=\"edit\" value=\"Ändern.\" />
		    </form> 
		</div>
		</div>";
            }
        ?>

    </aside>
    <div class="content">
	<?php
		if(isset($_POST['edit_submit'])) {
		$statement = $db->prepare("SELECT * FROM items WHERE id = :id;");
		$statement->bindValue(':id', $_POST['edit_nr']);
		$result = $statement->execute();
			while ($row = $result->fetchArray()) {
		    
		    	echo "<h1>Eintrag #$row[id] bearbeiten</h1>
		    	<br />
			        
			        <form action=\"backend.php\" method=\"POST\">
			            <fieldset>
			                <pre class=\"info\">Der Nachrichtentext unterstützt valides <strong>Markdown</strong>.</pre>
			                <label for=\"headline\">Überschrift:</label>
			                <input name=\"new_headline\" placeholder=\"Titel\" id=\"headline\" class=\"inputfield\" value=\"" . htmlspecialchars($row["headline"]). "\" required />
{'fraction_non_alphanumeric': 0.21877834895675838, 'fraction_numerical': 0.0021167221046265497, 'mean_word_length': 3.6914893617021276, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 133, 'https://': 2, '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': '4076249', 'n_tokens_mistral': 2240, 'n_tokens_neox': 2057, 'n_words': 397}