43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
|
<?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();
|
||
|
}
|
||
|
|
||
|
$sql_adapter = new MySQLHandler($db_connection, $SERVER_HOST);
|
||
|
$adapter = new PostHandler($sql_adapter);
|
||
|
|
||
|
require_once 'dergdown.php';
|
||
|
|
||
|
function dergdown_to_html($text) {
|
||
|
$Parsedown = new Dergdown();
|
||
|
|
||
|
return $Parsedown->text($text);
|
||
|
}
|
||
|
function post_to_html($post) {
|
||
|
return dergdown_to_html($post->markdown);
|
||
|
}
|
||
|
$adapter->markdown_engine = "post_to_html";
|
||
|
|
||
|
?>
|