54 lines
1.8 KiB
PHP
Executable File
54 lines
1.8 KiB
PHP
Executable File
<?php
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
|
include("$root/vendor/erusev/parsedown/Parsedown.php");
|
|
|
|
require "$root/database/credentials.php";
|
|
// Connect the database
|
|
try{
|
|
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
|
|
$user,
|
|
$password,
|
|
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
|
));
|
|
}catch (Exception $e){
|
|
die("Error : ".$e->getMessage());
|
|
}
|
|
$req = $db->prepare('SELECT * FROM `categories`');
|
|
$req->execute();
|
|
$rows = $req->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$Parsedown = new Parsedown();
|
|
?>
|
|
<h3><?=_('Categories')?></h3>
|
|
<table id="categories">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col"><?=_('Title')?></th>
|
|
<th scope="col"><?=_('Description')?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
foreach ($rows as $row) {
|
|
?>
|
|
<tr>
|
|
|
|
<td><a href="topics/?cat=<?=$row['id']?>"><?=$row['cat_name']?></a></td></p>
|
|
<td><?=$Parsedown->text($row['cat_description'])?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?> </tbody>
|
|
</table>
|
|
<h3><?=_("Create a category")?></h3>
|
|
<form action="createcategory.php" method="post">
|
|
<label for="title"><?=_('Category title')?></label>
|
|
<input type="text" id="title" name="title" placeholder="<?=_('Enter a name for the new category..')?>" required>
|
|
<label for="description"><?=_('Category description')?></label>
|
|
<textarea name="description" id="description" cols="30" rows="5" placeholder="<?=_('Enter a description for the new category (support Markdown)..')?>" required></textarea>
|
|
<input type="submit" value="<?=_('submit')?>" name="submit"><input type="reset" value="<?=_('reset')?>">
|
|
</form>
|