e59-website/include/main-functions.php
2024-08-03 20:17:25 +00:00

22 lines
745 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(PDOException $e) {
error_log($e->getMessage());
die('<div class="error-message"><span>Erreur : ' . $e->getMessage() . " " . $dbUser . "@" . $dbHost . '</span></div>');
}
return $pdo;
}
?>