2024-08-15 22:53:55 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'db_handler/mysql_handler.php';
|
|
|
|
require_once 'db_handler/post_handler.php';
|
|
|
|
|
|
|
|
$db_params = $SITE_CONFIG['db'];
|
|
|
|
$db_connection = null;
|
|
|
|
try {
|
|
|
|
if(false !== getenv('MYSQL_HOST')) {
|
|
|
|
$db_connection = mysqli_connect(getenv('MYSQL_HOST'),
|
|
|
|
getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'),
|
|
|
|
getenv('MYSQL_DATABASE'),
|
|
|
|
getenv('MYSQL_PORT'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$db_connection = mysqli_connect($db_params['host'],
|
|
|
|
$db_params['user'], $db_params['password'],
|
|
|
|
$db_params['database'],
|
|
|
|
$db_params['port']);
|
|
|
|
}
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
echo 'Connection failed<br>';
|
|
|
|
echo 'Error number: ' . mysqli_connect_errno() . '<br>';
|
|
|
|
echo 'Error message: ' . mysqli_connect_error() . '<br>';
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2025-02-13 10:39:04 +01:00
|
|
|
$sql_adapter = new MySQLHandler($db_connection,
|
|
|
|
$SITE_CONFIG['site_defaults']['uri_prefix'],
|
|
|
|
$db_params['prefix']);
|
2024-08-15 22:53:55 +02:00
|
|
|
$adapter = new PostHandler($sql_adapter);
|
|
|
|
|
|
|
|
require_once 'dergdown.php';
|
2024-08-29 20:40:36 +02:00
|
|
|
require_once 'setup/derg_insert.php';
|
2024-08-15 22:53:55 +02:00
|
|
|
|
2024-08-29 20:40:36 +02:00
|
|
|
function dergdown_to_html($post) {
|
|
|
|
$DergInsert = new DergInsertRenderer($post);
|
2024-08-15 22:53:55 +02:00
|
|
|
$Parsedown = new Dergdown();
|
2024-08-29 20:40:36 +02:00
|
|
|
$Parsedown->setDergRenderer($DergInsert);
|
2024-08-15 22:53:55 +02:00
|
|
|
|
2024-08-29 20:40:36 +02:00
|
|
|
$markdown = $post->markdown;
|
|
|
|
|
|
|
|
if($markdown == '') {
|
|
|
|
$markdown = '
|
|
|
|
{{
|
|
|
|
template: fragments/directory/inline.html
|
|
|
|
}}
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $Parsedown->text($markdown);
|
2024-08-15 22:53:55 +02:00
|
|
|
}
|
|
|
|
function post_to_html($post) {
|
2024-08-29 20:40:36 +02:00
|
|
|
return dergdown_to_html($post);
|
2024-08-15 22:53:55 +02:00
|
|
|
}
|
|
|
|
$adapter->markdown_engine = "post_to_html";
|
|
|
|
|
2024-08-24 13:09:28 +02:00
|
|
|
$adapter->site_defaults = $SITE_CONFIG['site_defaults'];
|
|
|
|
|
2024-08-15 22:53:55 +02:00
|
|
|
?>
|