ts-website/rules.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2016-07-01 02:35:15 +00:00
<?php
require_once __DIR__ . "/include/header.php";
require_once __DIR__ . "/lib/parsedown/parsedown.php";
$parsedown = new Parsedown();
$path = __DIR__ . "/config/rules.md";
if(!file_exists($path)) {
2016-07-25 14:14:04 +00:00
echo '<div class="alert alert-danger"><p class="text-center">' . translate($lang["rules"]["filenotfound"]) . '</div>';
2016-07-01 02:35:15 +00:00
} else {
$file = readFileContent($path);
2016-07-01 20:34:55 +00:00
2016-07-01 02:35:15 +00:00
if(!$file) {
2016-07-25 14:14:04 +00:00
echo '<div class="alert alert-danger"><p class="text-center">' . translate($lang["rules"]["readerror"]) . '</div>';
2016-07-01 02:35:15 +00:00
} else {
?>
<div class="panel panel-default">
<div class="panel-heading">
2016-07-25 14:14:04 +00:00
<h3 class="panel-title"><i class="fa fa-book" aria-hidden="true"></i> <?php tl($lang["rules"]["title"]); ?></h3>
2016-07-01 02:35:15 +00:00
</div>
<div class="panel-body">
<?php echo $parsedown->text($file); ?>
</div>
</div>
<?php
}}
// *******
// METHODS
// *******
function readFileContent($file) {
$fopen = @fopen($file, "r");
if(!$fopen) return false;
$text = fread($fopen,filesize($file));
fclose($fopen);
return $text;
}
require_once __DIR__ . "/include/footer.php";
?>