e59-website/include/main-functions.php
2024-08-03 09:58:43 +00:00

22 lines
710 B
PHP
Executable File

<?php // Functions
function markdownContent($filePath, $rootFilePath) {
$markdownContent = file_get_contents($filePath);
require_once $rootFilePath . 'include/parsedown.php';
$parsedown = new Parsedown();
return $parsedown->text($markdownContent);
}
function sqlConnect($dbHost, $dbName, $dbUser, $dbPass) {
try {
$pdo = new PDO('mysql:host=' . $dbHost . ';dbname=' . $dbName . ';charset=UTF8mb4', $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(Exception $e) {
error_log($e->getMessage());
die('<div class="error-message"><span>Erreur : ' . $e->getMessage() . '</span></div>');
}
return $pdo;
}
?>