This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
minecraft-checker/index.php

85 lines
3.3 KiB
PHP
Raw Permalink Normal View History

2017-04-05 08:32:06 +02:00
<?php
2017-04-05 08:55:56 +02:00
$lang = false;
2017-04-05 08:32:06 +02:00
2017-04-05 08:55:56 +02:00
if (isset($_GET['lang'])) {
if (is_file('lang/'.$_GET['lang'].'.lang')) {
$lang = $_GET['lang'];
setcookie('lang', $lang, time()+32140800);
}
2017-04-05 08:32:06 +02:00
}
2017-04-05 08:55:56 +02:00
if (!$lang AND isset($_COOKIE['lang'])) {
if (is_file('lang/'.$_COOKIE['lang'].'.lang')) {
$lang = $_COOKIE['lang'];
}
2017-04-05 08:32:06 +02:00
}
2017-04-05 08:55:56 +02:00
if (!$lang) {
$lang = 'fr_FR'; #TODO Function wich detct the language
setcookie('lang', $lang, time()+32140800);
2017-04-05 08:32:06 +02:00
}
2017-04-05 08:55:56 +02:00
$langCacheLink = 'cache/index/'.$lang.'.html';
if (is_file($langCacheLink)) { // If there is a cache file
echo file_get_contents($langCacheLink); // Send it
end;
} else { // Else, construct it
$langData = fopen('lang/'.$lang.'.lang', 'r');
$langParsed = array();
while($langDataLine = fgets($langData)) {
$langDataLineUncommented = explode("#", $langDataLine);
$langDataLineUncommentedExploded = explode('=', $langDataLineUncommented[0]);
if (count($langDataLineUncommentedExploded) == 2) {
$langParsed[ltrim(rtrim($langDataLineUncommentedExploded[0]))] = ltrim(rtrim($langDataLineUncommentedExploded[1]));
2017-04-05 08:32:06 +02:00
}
}
2017-04-05 08:55:56 +02:00
$langIndexText = '<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>'.$langParsed['general.title'].'</title>
<link rel="stylesheet" media="screen" type="text/css" title="design" href="stye/style.css">
<script type="text/javascript" src="script/jQuery.js"></script>
<script type="text/javascript" src="script/releases.js"></script>
</head>
<body lang="'.$langParsed['language.codeHTML'].'">
<h1>'.$langParsed['general.title'];
if ($langParsed['general.version.state'] != '0') {
$langIndexText .= ' '.$langParsed['general.version.state'];
}
$langIndexText .= '</h1>
<div id="body">
<p>'.$langParsed['general.description'].'</p>
<h2>'.$langParsed['allReleases.title'].' <span id="state">'.$langParsed['allReleases.noConnexion'].'</span></h2>
<div id="allReleases">
</div>
</div>
<footer>
<p id="copyright">Copyright &copy; <a href="https://twitter.com/#!/WebFrogeye">WebFrogeye</a> 2012</p>
<p>'.str_replace('%1', '<a href="https://twitter.com/#!/WebFrogeye">@WebFrogeye</a>', $langParsed['footer.script']).'<br/>
'.str_replace('%1', '<a href="https://twitter.com/#!/EphysPotato">@EphysPotato</a>', $langParsed['footer.help']).'<br/>
'.str_replace('%1', '<a href="http://dlp.host56.com/">DLProduction</a>', $langParsed['footer.design']).'<br/>';
if ($langParsed['footer.translation.author'] != '0') {
$langIndexText .= str_replace('%1', '<a href="'.$langParsed['footer.translation.author.link'].'">'.$langParsed['footer.translation.author'].'</a>', $langParsed['footer.translation']).'<br/>';
2017-04-05 08:32:06 +02:00
}
2017-04-05 08:55:56 +02:00
$langIndexText .='<p id="version">'.$langParsed['footer.version'].' '.$langParsed['general.version'];
if ($langParsed['general.version.state'] != '0') {
$langIndexText .= ' '.$langParsed['general.version.state'];
}
$langIndexText .= '.</p>
</footer>
</body>
</html>';
echo $langIndexText;
if (!is_dir('cache')) {
mkdir('cache');
}
if (!is_dir('cache/index')) {
mkdir('cache/index');
}
if ($langCacheData = fopen($langCacheLink, 'w')) {
fwrite($langCacheData, $langIndexText);
}
2017-04-05 08:32:06 +02:00
}
2017-04-05 08:55:56 +02:00
?>