feat(auth,api): begin work on API input
This commit is contained in:
parent
0dcf36052e
commit
c607d57221
11 changed files with 44 additions and 11 deletions
|
@ -1,45 +0,0 @@
|
|||
<?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";
|
||||
|
||||
$adapter->site_defaults = $SITE_CONFIG['site_defaults'];
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue