Version alpha

This commit is contained in:
Geoffrey Frogeye 2017-04-05 08:55:56 +02:00
parent 54c24457e9
commit c4b001c253
40 changed files with 9954 additions and 1317 deletions

0
.htaccess Executable file
View file

3
TODO Executable file
View file

@ -0,0 +1,3 @@
- Client support for lang
- Client support for Extended Data
- Server support for XHR Requests

View file

@ -1,192 +0,0 @@
<?php
set_time_limit('240');
function addRelease($input) {
$debug = false;
// D<>finition des variables de travail
$lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
$lastVersions_e_backup = $lastVersions_e;
if ($input == 'r') {
$lastVersions_e[1] = 'UP';
} else {
$lastVersions_e[3] = 'UP';
}
// Enregistrement des donn<6E>es d'ajout
$lastVersions_e[0] = time();
$lastVersions_txt = fopen('lastVersions.txt', 'w');
fwrite($lastVersions_txt, implode('|', $lastVersions_e));
fclose($lastVersions_txt);
if ($input == 'r') {
$type = 'r';
$url = 'http://s3.amazonaws.com/MinecraftDownload/minecraft.jar';
} else {
$type = 'apr';
$url = 'http://assets.minecraft.net/'.$input.'/minecraft.zip';
}
// Chargement du XML
$data = new DomDocument();
$data->load('data.xml');
$dataNode = $data->getElementsByTagName('data')->item(0);
$mcupdatesNode = $dataNode->getElementsByTagName('mcupdates')->item(0);
$id = $mcupdatesNode->getAttribute('total')+1;
$releaseS = $mcupdatesNode->getElementsByTagName('release');
$release = $releaseS->item($releaseS->length-1);
// Creation du noeud XML
$releaseNode = $data->createElement('release');
$mcupdatesNode->appendChild($releaseNode);
$infosNode = $data->createElement('infos');
$releaseNode->appendChild($infosNode);
$files = $data->createElement('files');
$releaseNode->appendChild($files);
// Extraction et copie de minecraft.jar
$directory = $id.' - '.$lastVersions_e[0].' ('.rand(1, 1000).')';
if (!mkdir($directory) OR !copy($url, $directory.'/minecraft.jar')) { return 'ERREUR Impossible de copier le fichier ou de cr<63>er un nouveau dossier.';}
if ($type == 'r') {
$zip = new ZipArchive;
if ($zip->open($directory.'/minecraft.jar') AND mkdir($directory.'/content')) {
$zip->extractTo($directory.'/content');
$zip->close();
}
} else {
$zip = new ZipArchive;
if ($zip->open($directory.'/minecraft.jar') AND mkdir($directory.'/extract')) {
$zip->extractTo($directory.'/extract');
$zip->close();
$zip2 = new ZipArchive;
if ($zip2->open($directory.'/extract/bin/minecraft.jar') AND mkdir($directory.'/content')) {
$zip2->extractTo($directory.'/content');
$zip2->close();
} else {
return 'ERREUR Impossible d\'extraire le fichier ou de cr<63>er un nouveau dossier².';
}
} else {
return 'ERREUR Impossible d\'extraire le fichier ou de cr<63>er un nouveau dossier.';
}
}
$md5 = md5_file($directory.'/minecraft.jar');
directoryConstruct($directory.'/content', $files, $data, directoryOld($release));
// Detection de $givenName
// Code par @EphysPatato
$minecraft_class = file_get_contents($directory.'/content/net/minecraft/client/Minecraft.class');
$givenName = 'false';
if (preg_match('/Minecraft Minecraft (.+)Minecraft main/', $minecraft_class, $matches)) {
$givenName = '';
$givenName_w = $matches[count($matches)-1];
for( $i = 0 ; $i < strlen($givenName_w) ; $i++ )
{
$givenName_cw = substr($givenName_w, $i, 1);
if(($givenName_cw >= 'a' && $givenName_cw <= 'z') || ($givenName_cw >= 'A' && $givenName_cw <= 'Z') || ($givenName_cw >= '0' && $givenName_cw <= '9') || $givenName_cw == '|' || $givenName_cw == '.' || $givenName_cw == '_' || $givenName_cw == '-')
$givenName .= $givenName_cw;
}
}
// Sp<53>cifications selon le type de release
if ($type == 'r') {
$name = $givenName;
$lastVersions_e[1] = $name;
$lastVersions_e[2] = $md5;
$infosNode->setAttribute('wiki', 'http://www.minecraftwiki.net/wiki/Version_history#'.$name);
} else {
$name = $input;
$lastVersions_e[3] = $name;
$lastVersions_e[4] = $md5;
$infosNode->setAttribute('wiki', 'http://www.minecraftwiki.net/wiki/Version_history/Development_versions#'.$name);
}
// Mise des infos dans le XML
$releaseNode->setAttribute('id', $id);
$releaseNode->setAttribute('name', $name);
$releaseNode->setAttribute('type', $type);
$infosNode->setAttribute('givenName', $givenName);
$infosNode->setAttribute('directory', $directory);
$infosNode->setAttribute('link', $url);
$infosNode->setAttribute('size', filesize($directory.'/minecraft.jar'));
$infosNode->setAttribute('md5', $md5);
$infosNode->setAttribute('sha1', sha1_file($directory.'/minecraft.jar'));
$infosNode->setAttribute('date', $lastVersions_e[0]);
$infosNode->setAttribute('shortDescription', 'false');
$mcupdatesNode->setAttribute('total', $id);
// Sauvegarde finale
$lastVersions_e[0] = time();
$lastVersions_e[5] = $id;
$lastVersions_e[6] = $name;
$lastVersions_e[7] = $type;
$id = $mcupdatesNode->setAttribute('total', $id);
$lastVersions_f = fopen('lastVersions.txt', 'w');
$lastError = error_get_last();
if ($debug) { echo substr($lastError['file'], -14); }
if ($lastError /*AND $lastError['type']!= 2 */AND substr($lastError['file'], -14) == 'addrelease.php') {
fwrite($lastVersions_f, implode('|', $lastVersions_e_backup));
rrmdir($directory);
return 'ERREUR "'.$lastError['message'].'" (type : '.$lastError['type'].') dans '.$lastError['file'].' ligne '.$lastError['line'].'.';
} else {
$data->save('data.xml');
fwrite($lastVersions_f, implode('|', $lastVersions_e));
fclose($lastVersions_f);
return implode('|', $lastVersions_e);
}
}
function directoryConstruct($directoryName, $XML, $data, $array) {
$directory = opendir($directoryName);
while($file = readdir($directory)) {
if ($file != '.' AND $file != '..') {
if (is_dir($directoryName.'/'.$file)) {
$newDirectory = $data->createElement('dir');
$XML->appendChild($newDirectory);
$newDirectory->setAttribute('name', $file);
if (isset($array[$file])) {
$newDirectory->setAttribute('comparaison', 'same');
directoryConstruct($directoryName.'/'.$file, $newDirectory, $data, $array[$file]);
} else {
$newDirectory->setAttribute('comparaison', 'added');
directoryConstruct($directoryName.'/'.$file, $newDirectory, $data, array());
}
} else {
$fileXML = $data->createElement('file');
$XML->appendChild($fileXML);
$fileXML->setAttribute('name', $file);
$fileXML->setAttribute('md5', md5_file($directoryName.'/'.$file));
if (isset($array[$file])) {
if ($array[$file] == md5_file($directoryName.'/'.$file)) {
$fileXML->setAttribute('comparaison', 'same');
} else {
$fileXML->setAttribute('comparaison', 'change');
}
} else {
$fileXML->setAttribute('comparaison', 'added');
}
// TODO Verifier si un fichier a <20>t<EFBFBD> supprim<69>
}
}
}
}
function directoryOld($XML) {
$array = array();
$dirS = $XML->getElementsByTagName('dir');
for ($c = $dirS->length, $i = 0; $i < $c; $i++) {
$dir = $dirS->item($i);
$array[$dir->getAttribute('name')]= directoryOld($dir);
}
$fileS = $XML->getElementsByTagName('file');
for ($c = $fileS->length, $i = 0; $i < $c; $i++) {
$file = $fileS->item($i);
$array[$file->getAttribute('name')] = $file->getAttribute('md5');
}
return $array;
}
function rrmdir($dir) { // Par holger1@NOSPAMzentralplan.de
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
?>

3
admin.php Executable file
View file

@ -0,0 +1,3 @@
<?php
?>

2
cache/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

File diff suppressed because one or more lines are too long

3
engine/check.php Executable file
View file

@ -0,0 +1,3 @@
<?php
?>

3
engine/releases.php Executable file
View file

@ -0,0 +1,3 @@
<?php
?>

3
feed.php Executable file
View file

@ -0,0 +1,3 @@
<?php
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

309
index.php
View file

@ -1,236 +1,85 @@
<?php
$data = new DomDocument();
$data->load('data.xml');
$dataNode = $data->getElementsByTagName('data')->item(0);
$mcupdatesNode = $dataNode->getElementsByTagName('mcupdates')->item(0);
$releaseS = $mcupdatesNode->getElementsByTagName('release');
$text = '';
for ($i = $releaseS->length; $i > 1; $i--) {
$release = $releaseS->item($i-1);
$releaseInfos = $release->getElementsByTagName('infos')->item(0);
$text .= '<h3>Minecraft '.$release->getAttribute('name').' ';
if (isset($prevRelease)) {
if ($release->getAttribute('name') == $prevRelease->getAttribute('name')) {
$text .= '(version enterrée) ';
$lang = false;
if (isset($_GET['lang'])) {
if (is_file('lang/'.$_GET['lang'].'.lang')) {
$lang = $_GET['lang'];
setcookie('lang', $lang, time()+32140800);
}
}
if (!$lang AND isset($_COOKIE['lang'])) {
if (is_file('lang/'.$_COOKIE['lang'].'.lang')) {
$lang = $_COOKIE['lang'];
}
}
if (!$lang) {
$lang = 'fr_FR'; #TODO Function wich detct the language
setcookie('lang', $lang, time()+32140800);
}
$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]));
}
}
$shortDescription = $releaseInfos->getAttribute('shortDescription');
if ($shortDescription == 'false') {
$shortDescription = 'Pas de description.';
}
$text .= '</h3><div class="release" id="R'.$release->getAttribute('id').'"><div class="shortDescription">'.$shortDescription.' <input type="button" value="+" class="more" /></div><div class="content"></div></div>';
$prevRelease = $release;
}
?>
<!DOCTYPE html>
<html lang="fr">
$langIndexText = '<!DOCTYPE HTML>
<html>
<head>
<title>Minecraft Checker</title>
<meta charset="utf-8">
<link rel="stylesheet" media="screen" type="text/css" title="design" href="design.css">
<script type="text/javascript">
var checkIntervalForm;
var checkState;
var checkTimeout;
var addXhr;
var allReleases;
var checkXhr;
var lastId = <?php echo $mcupdatesNode->getAttribute('total'); ?>;
window.onload = function () {
checkIntervalForm = document.getElementById('checkActivate');
checkState = document.getElementById('checkState');
checkIntervalForm.addEventListener('change', function(e) {
if (e.target.checked) {
checkState.innerHTML = 'activé';
checkTimeout = true;
check();
console.log('Checking activated');
} else {
checkState.innerHTML = 'désactivé';
clearTimeout(checkTimeout); // TODO Annulation de checkXhr
checkTimeout = false;
checkXhr.abort();
console.log('Checking stopped');
}
}, false);
allReleases = document.getElementById('allreleases');
allReleaseS = allReleases.getElementsByClassName('more');
for (var allReleaseI = 0; allReleaseI < allReleaseS.length; allReleaseI++) {
allReleaseS[allReleaseI].addEventListener('click', releaseOpen, false);
}
console.log('System initialised');
}
function releaseOpen(e) {
e.target.value = '...';
var releaseXhr = new XMLHttpRequest();
releaseXhr.onreadystatechange = function() {
if (releaseXhr.readyState == 4 && (releaseXhr.status == 200 || releaseXhr.status == 0)) {
e.target.removeEventListener('click', releaseOpen, false);
console.log(' Infos recevied');
var content = e.target.parentNode.parentNode.getElementsByClassName('content')[0];
content.innerHTML = releaseXhr.responseText;
if (content.getElementsByClassName('releaseFiles')[0]) {
content.getElementsByClassName('releaseFilesButton')[0].addEventListener('click', releaseFilesOpen, false);
filesDirExpandS = content.getElementsByClassName('dir');
for (var filesDirExpandI = 0; filesDirExpandI < filesDirExpandS.length; filesDirExpandI++) {
filesDirExpandS[filesDirExpandI].addEventListener('click', releaseFilesDirOpen, false);
}
var releaseFilesSelectionS = content.getElementsByClassName('releaseFiles')[0].getElementsByTagName('input');
for (var releaseFilesSelectionI = 0; releaseFilesSelectionI < releaseFilesSelectionS.length; releaseFilesSelectionI++) {
if (releaseFilesSelectionS[releaseFilesSelectionI].name == 'filesSelectionChangement' || releaseFilesSelectionS[releaseFilesSelectionI].name == 'filesSelectionClass') {
releaseFilesSelectionS[releaseFilesSelectionI].addEventListener('click', releaseFilesOrderEvent, false);
}
}
}
e.target.value = '-';
e.target.addEventListener('click', releaseClose, false);
}
};
var releaseId = e.target.parentNode.parentNode.id.split('R')[1];
console.log('Searching details for release ID = '+releaseId+'.');
releaseXhr.open('GET', 'moreinfos.php?i='+releaseId, true);
releaseXhr.send(null);
}
function releaseFilesDirOpen(e) {
e.target.parentNode.getElementsByClassName('dirUl')[0].style.display = '';
e.target.className = 'dir opened';
e.target.removeEventListener('click', releaseFilesDirOpen, false);
e.target.addEventListener('click', releaseFilesDirClose, false);
}
function releaseFilesDirClose(e) {
e.target.parentNode.getElementsByClassName('dirUl')[0].style.display = 'none';
e.target.className = 'dir closed';
e.target.removeEventListener('click', releaseFilesDirClose, false);
e.target.addEventListener('click', releaseFilesDirOpen, false);
}
function releaseClose(e) {
e.target.value = '...';
e.target.parentNode.parentNode.getElementsByClassName('content')[0].innerHTML = '';
e.target.removeEventListener('click', releaseClose, false);
e.target.addEventListener('click', releaseOpen, false);
e.target.value = '+';
}
function releaseFilesOpen(e) {
e.target.value = '...';
var releaseFiles = e.target.parentNode.parentNode.getElementsByClassName('releaseFiles')[0];
releaseFiles.style.display = '';
releaseFilesOrder(releaseFiles);
e.target.removeEventListener('click', releaseFilesOpen, false);
e.target.addEventListener('click', releaseFilesClose, false);
e.target.value = '-';
}
function releaseFilesOrder(releaseFiles) {
var releaseFilesFileS = releaseFiles.getElementsByClassName('file');
var releaseFilesSelectionClassAll = releaseFiles.getElementsByClassName('fileSelectionClassAll')[0].checked;
var releaseFilesSelectionClassNonTechnic = releaseFiles.getElementsByClassName('fileSelectionClassNontechnic')[0].checked;
var releaseFilesSelectionClassNone = releaseFiles.getElementsByClassName('fileSelectionClassNone')[0].checked;
var releaseFilesSelectionChangementAll = releaseFiles.getElementsByClassName('fileSelectionChangementAll')[0].checked;
var releaseFilesSelectionChangementChanged = releaseFiles.getElementsByClassName('fileSelectionChangementChanged')[0].checked;
var releaseFilesSelectionChangementAdded = releaseFiles.getElementsByClassName('fileSelectionChangementAdded')[0].checked;
for (var releaseFilesFileI = 0; releaseFilesFileI < releaseFilesFileS.length; releaseFilesFileI++) {
var releaseFilesFileClassE = releaseFilesFileS[releaseFilesFileI].className.split(' ');
var releaseFilesFileTechnic = in_array('technic', releaseFilesFileClassE);
var releaseFilesFileClass = in_array('class', releaseFilesFileClassE);
var releaseFilesFileChanged = in_array('change', releaseFilesFileClassE);
var releaseFilesFileAdded = in_array('added', releaseFilesFileClassE);
if ((releaseFilesSelectionClassAll || (releaseFilesSelectionClassNonTechnic && (!releaseFilesFileTechnic)) || (releaseFilesSelectionClassNone && (!releaseFilesFileClass))) && (releaseFilesSelectionChangementAll || (releaseFilesSelectionChangementChanged && (releaseFilesFileChanged || releaseFilesFileAdded)) || (releaseFilesSelectionChangementAdded && releaseFilesFileAdded))) {
releaseFilesFileS[releaseFilesFileI].parentNode.style.display = '';
} else {
releaseFilesFileS[releaseFilesFileI].parentNode.style.display = 'none';
}
}
}
function releaseFilesOrderEvent(e) {
releaseFilesOrder(e.target.parentNode.parentNode);
}
function releaseFilesClose(e) {
e.target.value = '+';
e.target.parentNode.parentNode.getElementsByClassName('releaseFiles')[0].style.display = 'none';
e.target.removeEventListener('click', releaseFilesClose, false);
e.target.addEventListener('click', releaseFilesOpen, false);
}
function check() {
checkXhr = new XMLHttpRequest();
checkXhr.onreadystatechange = function() {
if (checkXhr.readyState == 4 && (checkXhr.status == 200 || checkXhr.status == 0)) {
console.log('Check finished, with information : '+checkXhr.responseText);
var newReleaseE = checkXhr.responseText.split('|');
if (newReleaseE.length == 8 && checkTimeout) {
if (newReleaseE[5] == lastId) {
console.log(' Information analysed : no new release (date: '+newReleaseE[0]+').');
checkState.innerHTML = 'attente';
} else if (newReleaseE[5] > lastId) {
console.log(' Information analysed : new release.');
checkState.innerHTML = 'nouvelle version';
// TODO Vérifier si (newReleaseE[5] == lastId+1)
lastRelease = newReleaseE[6];
if (newReleaseE[7] == 'r' && newReleaseE[5] == lastId+1) {
var newReleaseAlertType = 'La release complète';
} else if (newReleaseE[7] == 'apr' && newReleaseE[5] == lastId+1) {
var newReleaseAlertType = 'La pre-release automatique';
} else if (newReleaseE[7] == 'pr' && newReleaseE[5] == lastId+1) {
var newReleaseAlertType = 'La pre-release';
} else {
console.error(' Bad informations on the new release. Reloading page.');
checkState.innerHTML = 'erreur';
location.reload();
return false;
}
lastId = newReleaseE[5];
console.info('New release: name: '+lastRelease+' id:'+newReleaseE[5]+' type: '+newReleaseE[7]+'.');
checkState.innerHTML = 'nouvelle version';
document.title='Version '+lastRelease+' sortie !';
alert(newReleaseAlertType+' '+lastRelease+' est sortie !');
location.reload();
} else {
console.error('Database upset. Reloading page.');
checkState.innerHTML = 'erreur';
location.reload();
}
checkTimeout = setTimeout('check()', 5000);
} else if (!checkTimeout) {
return false;
} else {
console.error('Error comited server-side.');
checkState.innerHTML = 'erreur';
}
}
};
checkXhr.open('GET', 'test.php', true);
checkState.innerHTML = 'recherche';
checkXhr.send(null);
}
function in_array(needle, haystack) {
for (key in haystack) {
if (haystack[key] == needle) {
return true;
}
}
return false;
}
</script>
<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>
<h1>Minecraft Checker</h1>
<div id="body">
<h2>Rechercher des versions</h2>
<p class="RL_search"><input type="checkbox" id="checkActivate" name="checkActivate"/><label for="checkActivate"> Rechercher les nouvelles releases (<span id="checkState">désactivé</span>)</label></p>
<h2>Versions référencées</h2>
<div id="allreleases">
<?php echo $text; ?>
</div>
</div>
<footer>
<p id="copyright">Copyright &copy; <a href="https://twitter.com/#!/WebFrogeye">WebFrogeye</a> 2012</p>
<p>Créé par <a href="https://twitter.com/#!/WebFrogeye">@WebFrogeye</a>.<br/>
Avec l'aide d'<a href="https://twitter.com/#!/EphysPotato">@EphysPotato</a>.<br/>
Sur un design de <a href="http://dlp.host56.com/">DLProduction</a>.<br/>
D'après un script de <a href="https://twitter.com/#!/shellgratuit">@shellgratuit</a>.</p>
</footer>
<div id="cache" style="display: none;"></div>
<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/>';
}
$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>
</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);
}
}
?>

View file

@ -1,236 +0,0 @@
<?php
$data = new DomDocument();
$data->load('data.xml');
$dataNode = $data->getElementsByTagName('data')->item(0);
$mcupdatesNode = $dataNode->getElementsByTagName('mcupdates')->item(0);
$releaseS = $mcupdatesNode->getElementsByTagName('release');
$text = '';
for ($i = $releaseS->length; $i > 1; $i--) {
$release = $releaseS->item($i-1);
$releaseInfos = $release->getElementsByTagName('infos')->item(0);
$text .= '<h3>Minecraft '.$release->getAttribute('name').' ';
if (isset($prevRelease)) {
if ($release->getAttribute('name') == $prevRelease->getAttribute('name')) {
$text .= '(version enterrée) ';
}
}
$shortDescription = $releaseInfos->getAttribute('shortDescription');
if ($shortDescription == 'false') {
$shortDescription = 'Pas de description.';
}
$text .= '</h3><div class="release" id="R'.$release->getAttribute('id').'"><div class="shortDescription">'.$shortDescription.' <input type="button" value="+" class="more" /></div><div class="content"></div></div>';
$prevRelease = $release;
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Minecraft Checker</title>
<meta charset="utf-8">
<link rel="stylesheet" media="screen" type="text/css" title="design" href="design.css">
<script type="text/javascript">
var checkIntervalForm;
var checkState;
var checkTimeout;
var addXhr;
var allReleases;
var checkXhr;
var lastId = <?php echo $mcupdatesNode->getAttribute('total'); ?>;
window.onload = function () {
checkIntervalForm = document.getElementById('checkActivate');
checkState = document.getElementById('checkState');
checkIntervalForm.addEventListener('change', function(e) {
if (e.target.checked) {
checkState.innerHTML = 'activé';
checkTimeout = true;
check();
console.log('Checking activated');
} else {
checkState.innerHTML = 'désactivé';
clearTimeout(checkTimeout); // TODO Annulation de checkXhr
checkTimeout = false;
checkXhr.abort();
console.log('Checking stopped');
}
}, false);
allReleases = document.getElementById('allreleases');
allReleaseS = allReleases.getElementsByClassName('more');
for (var allReleaseI = 0; allReleaseI < allReleaseS.length; allReleaseI++) {
allReleaseS[allReleaseI].addEventListener('click', releaseOpen, false);
}
console.log('System initialised');
}
function releaseOpen(e) {
e.target.value = '...';
var releaseXhr = new XMLHttpRequest();
releaseXhr.onreadystatechange = function() {
if (releaseXhr.readyState == 4 && (releaseXhr.status == 200 || releaseXhr.status == 0)) {
e.target.removeEventListener('click', releaseOpen, false);
console.log(' Infos recevied');
var content = e.target.parentNode.parentNode.getElementsByClassName('content')[0];
content.innerHTML = releaseXhr.responseText;
if (content.getElementsByClassName('releaseFiles')[0]) {
content.getElementsByClassName('releaseFilesButton')[0].addEventListener('click', releaseFilesOpen, false);
filesDirExpandS = content.getElementsByClassName('dir');
for (var filesDirExpandI = 0; filesDirExpandI < filesDirExpandS.length; filesDirExpandI++) {
filesDirExpandS[filesDirExpandI].addEventListener('click', releaseFilesDirOpen, false);
}
var releaseFilesSelectionS = content.getElementsByClassName('releaseFiles')[0].getElementsByTagName('input');
for (var releaseFilesSelectionI = 0; releaseFilesSelectionI < releaseFilesSelectionS.length; releaseFilesSelectionI++) {
if (releaseFilesSelectionS[releaseFilesSelectionI].name == 'filesSelectionChangement' || releaseFilesSelectionS[releaseFilesSelectionI].name == 'filesSelectionClass') {
releaseFilesSelectionS[releaseFilesSelectionI].addEventListener('click', releaseFilesOrderEvent, false);
}
}
}
e.target.value = '-';
e.target.addEventListener('click', releaseClose, false);
}
};
var releaseId = e.target.parentNode.parentNode.id.split('R')[1];
console.log('Searching details for release ID = '+releaseId+'.');
releaseXhr.open('GET', 'moreinfos.php?i='+releaseId, true);
releaseXhr.send(null);
}
function releaseFilesDirOpen(e) {
e.target.parentNode.getElementsByClassName('dirUl')[0].style.display = '';
e.target.className = 'dir opened';
e.target.removeEventListener('click', releaseFilesDirOpen, false);
e.target.addEventListener('click', releaseFilesDirClose, false);
}
function releaseFilesDirClose(e) {
e.target.parentNode.getElementsByClassName('dirUl')[0].style.display = 'none';
e.target.className = 'dir closed';
e.target.removeEventListener('click', releaseFilesDirClose, false);
e.target.addEventListener('click', releaseFilesDirOpen, false);
}
function releaseClose(e) {
e.target.value = '...';
e.target.parentNode.parentNode.getElementsByClassName('content')[0].innerHTML = '';
e.target.removeEventListener('click', releaseClose, false);
e.target.addEventListener('click', releaseOpen, false);
e.target.value = '+';
}
function releaseFilesOpen(e) {
e.target.value = '...';
var releaseFiles = e.target.parentNode.parentNode.getElementsByClassName('releaseFiles')[0];
releaseFiles.style.display = '';
releaseFilesOrder(releaseFiles);
e.target.removeEventListener('click', releaseFilesOpen, false);
e.target.addEventListener('click', releaseFilesClose, false);
e.target.value = '-';
}
function releaseFilesOrder(releaseFiles) {
var releaseFilesFileS = releaseFiles.getElementsByClassName('file');
var releaseFilesSelectionClassAll = releaseFiles.getElementsByClassName('fileSelectionClassAll')[0].checked;
var releaseFilesSelectionClassNonTechnic = releaseFiles.getElementsByClassName('fileSelectionClassNontechnic')[0].checked;
var releaseFilesSelectionClassNone = releaseFiles.getElementsByClassName('fileSelectionClassNone')[0].checked;
var releaseFilesSelectionChangementAll = releaseFiles.getElementsByClassName('fileSelectionChangementAll')[0].checked;
var releaseFilesSelectionChangementChanged = releaseFiles.getElementsByClassName('fileSelectionChangementChanged')[0].checked;
var releaseFilesSelectionChangementAdded = releaseFiles.getElementsByClassName('fileSelectionChangementAdded')[0].checked;
for (var releaseFilesFileI = 0; releaseFilesFileI < releaseFilesFileS.length; releaseFilesFileI++) {
var releaseFilesFileClassE = releaseFilesFileS[releaseFilesFileI].className.split(' ');
var releaseFilesFileTechnic = in_array('technic', releaseFilesFileClassE);
var releaseFilesFileClass = in_array('class', releaseFilesFileClassE);
var releaseFilesFileChanged = in_array('change', releaseFilesFileClassE);
var releaseFilesFileAdded = in_array('added', releaseFilesFileClassE);
if ((releaseFilesSelectionClassAll || (releaseFilesSelectionClassNonTechnic && (!releaseFilesFileTechnic)) || (releaseFilesSelectionClassNone && (!releaseFilesFileClass))) && (releaseFilesSelectionChangementAll || (releaseFilesSelectionChangementChanged && (releaseFilesFileChanged || releaseFilesFileAdded)) || (releaseFilesSelectionChangementAdded && releaseFilesFileAdded))) {
releaseFilesFileS[releaseFilesFileI].parentNode.style.display = '';
} else {
releaseFilesFileS[releaseFilesFileI].parentNode.style.display = 'none';
}
}
}
function releaseFilesOrderEvent(e) {
releaseFilesOrder(e.target.parentNode.parentNode);
}
function releaseFilesClose(e) {
e.target.value = '+';
e.target.parentNode.parentNode.getElementsByClassName('releaseFiles')[0].style.display = 'none';
e.target.removeEventListener('click', releaseFilesClose, false);
e.target.addEventListener('click', releaseFilesOpen, false);
}
function check() {
checkXhr = new XMLHttpRequest();
checkXhr.onreadystatechange = function() {
if (checkXhr.readyState == 4 && (checkXhr.status == 200 || checkXhr.status == 0)) {
console.log('Check finished, with information : '+checkXhr.responseText);
var newReleaseE = checkXhr.responseText.split('|');
if (newReleaseE.length == 8 && checkTimeout) {
if (newReleaseE[5] == lastId) {
console.log(' Information analysed : no new release (date: '+newReleaseE[0]+').');
checkState.innerHTML = 'attente';
} else if (newReleaseE[5] > lastId) {
console.log(' Information analysed : new release.');
checkState.innerHTML = 'nouvelle version';
// TODO Vérifier si (newReleaseE[5] == lastId+1)
lastRelease = newReleaseE[6];
if (newReleaseE[7] == 'r' && newReleaseE[5] == lastId+1) {
var newReleaseAlertType = 'La release complète';
} else if (newReleaseE[7] == 'apr' && newReleaseE[5] == lastId+1) {
var newReleaseAlertType = 'La pre-release automatique';
} else if (newReleaseE[7] == 'pr' && newReleaseE[5] == lastId+1) {
var newReleaseAlertType = 'La pre-release';
} else {
console.error(' Bad informations on the new release. Reloading page.');
checkState.innerHTML = 'erreur';
location.reload();
return false;
}
lastId = newReleaseE[5];
console.info('New release: name: '+lastRelease+' id:'+newReleaseE[5]+' type: '+newReleaseE[7]+'.');
checkState.innerHTML = 'nouvelle version';
document.title='Version '+lastRelease+' sortie !';
alert(newReleaseAlertType+' '+lastRelease+' est sortie !');
location.reload();
} else {
console.error('Database upset. Reloading page.');
checkState.innerHTML = 'erreur';
location.reload();
}
checkTimeout = setTimeout('check()', 5000);
} else if (!checkTimeout) {
return false;
} else {
console.error('Error comited server-side.');
checkState.innerHTML = 'erreur';
}
}
};
checkXhr.open('GET', 'test.php', true);
checkState.innerHTML = 'recherche';
checkXhr.send(null);
}
function in_array(needle, haystack) {
for (key in haystack) {
if (haystack[key] == needle) {
return true;
}
}
return false;
}
</script>
</head>
<body>
<h1>Minecraft Checker</h1>
<div id="body">
<h2>Rechercher des versions</h2>
<p class="RL_search"><input type="checkbox" id="checkActivate" name="checkActivate"/><label for="checkActivate"> Rechercher les nouvelles releases (<span id="checkState">désactivé</span>)</label></p>
<h2>Versions référencées</h2>
<div id="allreleases">
<?php echo $text; ?>
</div>
</div>
<footer>
<p id="copyright">Copyright &copy; <a href="https://twitter.com/#!/WebFrogeye">WebFrogeye</a> 2012</p>
<p>Créé par <a href="https://twitter.com/#!/WebFrogeye">@WebFrogeye</a>.<br/>
Avec l'aide d'<a href="https://twitter.com/#!/EphysPotato">@EphysPotato</a>.<br/>
Sur un design de <a href="http://dlp.host56.com/">DLProduction</a>.<br/>
D'après un script de <a href="https://twitter.com/#!/shellgratuit">@shellgratuit</a>.</p>
</footer>
<div id="cache" style="display: none;"></div>
</body>
</html>

2
jars/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

47
lang/de_DE.lang Executable file
View file

@ -0,0 +1,47 @@
language.name=Deutsch
language.region=Deutschland
language.code=de_DE
language.codeHTML=de
general.title=Minecraft Checker
general.version=1.1
general.version.state=α
general.description=Minecraft Checker kontrollieren Minecraft neue Versionen und warnen Sie. Es erlaubt Sie Informationen über Versionen einfach zu bekommen.
allReleases.title=Referenzierten Versionen
allReleases.noConnexion=(kein connexion)
allReleases.connexionEtablished=(connexion établie)
allReleases.error=(erreur de connexion)
allReleases.suspended=(connexion au serveur suspendue)
allReleases.updating.waiting=(mise à jour des données)
allReleases.updating.done=(données mises à jour)
allReleases.newRelease.waiting=(nouvelle version détéctée)
allReleases.newRelease.added(nouvelle version ajoutée)
#release.title.minecraft=Minecraft
#release.title.classic=Classic
#release.title.indev=Indev
#release.title.infdev=Infdev
#release.title.alpha=Alpha
#release.title.beta=Beta
#release.title.official=(version officielle)
release.title.state.developpement=(version de développement)
release.title.state.willUpdate=(informations pas à jour)
release.title.state.updating=(mise à jour des informations)
release.title.state.updated=(informations mises à jour)
release.title.state.error=(impossible de récupérer les informations sur la mise à jour)
release.title.state.newRelease=(version récente)
release.expandButton.more.value=+
release.expandButton.more.tip=Ouvrir les informations détaillées
release.expandButton.less.value=-
release.expandButton.less.tip=Fermer les informations détaillées
release.expandButton.loading.value=...
release.expandButton.loading.tip=Chargement des informations détaillées
footer.script=Skript von %1.
footer.help=Mit helfen von %1.
footer.design=Bei ein design von %1.
footer.translation=Übersetzung von %1 (bei weitem nicht perfekt).
footer.translation.author=WebFrogeye
footer.translation.author.link=http://twitter.com/WebFrogeye TODO Does not allow any # in
footer.version=Versionen

47
lang/en_US.lang Executable file
View file

@ -0,0 +1,47 @@
language.name=English
language.region=United-States
language.code=en_US
language.codeHTML=en
general.title=Minecraft Checker
general.version=1.1
general.version.state=α
general.description=Minecraft Checker check Minecraft's new versions and alert you. It allow you to get informations about releases simply.
allReleases.title=Referenced versions
allReleases.noConnexion=(no connexion to server)
allReleases.connexionEtablished=(connexion établie)
allReleases.error=(erreur de connexion)
allReleases.suspended=(connexion au serveur suspendue)
allReleases.updating.waiting=(mise à jour des données)
allReleases.updating.done=(données mises à jour)
allReleases.newRelease.waiting=(nouvelle version détéctée)
allReleases.newRelease.added(nouvelle version ajoutée)
#release.title.minecraft=Minecraft
#release.title.classic=Classic
#release.title.indev=Indev
#release.title.infdev=Infdev
#release.title.alpha=Alpha
#release.title.beta=Beta
#release.title.official=(version officielle)
release.title.state.developpement=(version de développement)
release.title.state.willUpdate=(informations pas à jour)
release.title.state.updating=(mise à jour des informations)
release.title.state.updated=(informations mises à jour)
release.title.state.error=(impossible de récupérer les informations sur la mise à jour)
release.title.state.newRelease=(version récente)
release.expandButton.more.value=+
release.expandButton.more.tip=Ouvrir les informations détaillées
release.expandButton.less.value=-
release.expandButton.less.tip=Fermer les informations détaillées
release.expandButton.loading.value=...
release.expandButton.loading.tip=Chargement des informations détaillées
footer.script=Script by %1.
footer.help=With help of %1.
footer.design=On a design by %1.
footer.translation=Translation by %1 (far from perfect).
footer.translation.author=WebFrogeye
footer.translation.author.link=http://twitter.com/WebFrogeye TODO Does not allow any # in
footer.version=Version

46
lang/fr_FR.lang Executable file
View file

@ -0,0 +1,46 @@
language.name=Français
language.region=France
language.code=fr_FR
general.title=Minecraft Checker
general.version=1.1
general.version.state=α
general.description=Minecraft Checker vérifie les nouvelles versions de Minecraft et vous en alerte. Il permet aussi d'avoir des informations sur les versions simplement.
allReleases.title=Versions référencées
allReleases.noConnexion=(pas de connexion au serveur)
allReleases.connexionEtablished=(connexion établie)
allReleases.error=(erreur de connexion)
allReleases.suspended=(connexion au serveur suspendue)
allReleases.updating.waiting=(mise à jour des données)
allReleases.updating.done=(données mises à jour)
allReleases.newRelease.waiting=(nouvelle version détéctée)
allReleases.newRelease.added(nouvelle version ajoutée)
#release.title.minecraft=Minecraft
#release.title.classic=Classic
#release.title.indev=Indev
#release.title.infdev=Infdev
#release.title.alpha=Alpha
#release.title.beta=Beta
#release.title.official=(version officielle)
release.title.state.developpement=(version de développement)
release.title.state.willUpdate=(informations pas à jour)
release.title.state.updating=(mise à jour des informations)
release.title.state.updated=(informations mises à jour)
release.title.state.error=(impossible de récupérer les informations sur la mise à jour)
release.title.state.newRelease=(version récente)
release.expandButton.more.value=+
release.expandButton.more.tip=Ouvrir les informations détaillées
release.expandButton.less.value=-
release.expandButton.less.tip=Fermer les informations détaillées
release.expandButton.loading.value=...
release.expandButton.loading.tip=Chargement des informations détaillées
footer.script=Script par %1.
footer.help=Avec l'aide d'%1.
footer.design=Sur un design de %1.
footer.translation=Traduction de %1.
footer.translation.author=0
footer.translation.author.link=# TODO Does not allow any # in
footer.version=Version

View file

@ -1 +0,0 @@
1336223378|1.2.5|8e8778078a175a33603a585257f28563|12w18a|37d778548796dd95c4d0ea49a015be06|27|12w18a|apr

17
maintenance.php Executable file
View file

@ -0,0 +1,17 @@
<?php
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Minecraft Checker - Maintenance</title>
</head>
<body>
<h1>Minecraft Checker - Maintenance</h1>
<div>
<p>Minecraft Checker is currently in maintenance. It will be back soon.</p>
<p>Minecraft Checker est en mantenance. Il reviendra sous peu. Pour plus d'informations, consultez le compte twitter de @WebFrogeye.</p>
</div>
</body>
</html>

View file

@ -1,143 +0,0 @@
<?php
date_default_timezone_set('Europe/Paris');
if (isset($_GET['i']))
{
$data = new DomDocument();
$data->load('data.xml');
$dataNode = $data->getElementsByTagName('data')->item(0);
$mcupdatesNode = $dataNode->getElementsByTagName('mcupdates')->item(0);
$releaseS = $mcupdatesNode->getElementsByTagName('release');
// $lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
$prevRelease = false;
for ($c = $releaseS->length, $i = 0; $i < $c; $i++) {
$release = $releaseS->item($i);
if ($_GET['i'] == $release->getAttribute('id')) {
$releaseInfos = $release->getElementsByTagName('infos')->item(0);
$releaseDateE = explode('/', $releaseInfos->getAttribute('date'));
$date = $releaseInfos->getAttribute('date');
echo 'Sortie le '.date('d', $date).'/'.date('m', $date).'/'.date('Y', $date);
/*if (date('G', $date) != 0 OR date('i', $date) != 0) {
echo ' à '.date('G', $date).':'.date('i', $date).' (environ)';
}*/
echo '.<br/>';
if ($release->getAttribute('name') != $releaseInfos->getAttribute('givenName')) {
echo 'Le nom de la version donné dans le jeu est '.$releaseInfos->getAttribute('givenName').' mais le nom réel est '.$release->getAttribute('name').'.<br/>';
}
// Téléchargement
echo '<div class="download"><h4>Téléchargement</h4>
Nom : <strong>minecraft.jar</strong>
Taille : <strong>'.$releaseInfos->getAttribute('size').' octets</strong><br/>
MD5 : <strong>'.$releaseInfos->getAttribute('md5').'</strong><br/>
SHA-1 : <strong>'.$releaseInfos->getAttribute('sha1').'</strong><br/>';
if (is_dir($releaseInfos->getAttribute('directory'))) {
$downloadLocal = $releaseInfos->getAttribute('directory').'/minecraft.jar'; }
if (@fopen($releaseInfos->getAttribute('link'), 'r') AND ($release->getAttribute('type') != 'r' OR $i+1 == $c)) {
$downloadServer = $releaseInfos->getAttribute('link');
} else {
// TODO AR? Prévoir ça (variable $changes par exemple)
}
// TODO AR $downloadWiki
if (isset($downloadLocal) OR isset($downloadServer) OR isset($downloadWiki)) {
if (isset($downloadLocal)) {
echo '<a href="'.$downloadLocal.'">Depuis ce serveur</a><br/>'; }
if (isset($downloadServer)) {
echo '<a href="'.$downloadServer.'">Depuis minecraft.net</a><br/> '; }
if (isset($downloadWiki)) {
echo '<a href="'.$downloadWiki.'">Depuis Minecaft Wiki</a><br/> '; }
} else {
echo 'Aucun lien de téléchargement n\'est disponible.';
}
echo '</div>';
echo '<div class="changelog">
<h4>Changelog</h4>
Langue : Français<br/>
<a class="wikiLink" href="'.$releaseInfos->getAttribute('wiki').'">Lien vers le wiki</a><br/>
</div>';
$text = '<ul>';
if ($release->getElementsByTagName('files')->item(0)) {
echo '<div class="files">
<h4>Fichiers du .jar</h4>';
$directory = $releaseInfos->getAttribute('directory');
$haveLink = (is_dir($directory) AND is_dir($directory.'/content'));
$elementS = $release->getElementsByTagName('files')->item(0)->childNodes;
$filesModificationsStat = array(0, 0, 0, 0);
$directoryXML = directoryXML($elementS, $releaseInfos->getAttribute('directory').'/content');
if ($prevRelease)
echo 'Comparaison par rapport à la version : '.$prevRelease->getAttribute('name').'.<br/>';
echo '<span class="changeStats">'.$filesModificationsStat[3].' fichiers au total, '.$filesModificationsStat[2].' inchangés, '.$filesModificationsStat[1].' ajoutés et '.$filesModificationsStat[0].' modifiés (dont fichiers obstrués). <input class="releaseFilesButton" type="button" value="+" /></span><br/>';
// TODO Supprimer (s) (conditions)
echo '<div class="releaseFiles" style="display: none;"><p>Tri selon les fichiers modifiés : <input type="radio" name="filesSelectionChangement" class="fileSelectionChangementAll" title="Pas de filtre pour les modifications de fichier" checked /><input type="radio" name="filesSelectionChangement" class="fileSelectionChangementChanged" title="Filtrer les fichiers restés inchangés" /><input type="radio" name="filesSelectionChangement" class="fileSelectionChangementAdded" title="Filtrer les fichiers uniquement modifiés (ne garder que les fichiers ajoutés)"/></p><p>
Tri selon le type de fichier : <input type="radio" name="filesSelectionClass" class="fileSelectionClassAll" title="Pas de filtre pour les types de fichiers"/><input type="radio" name="filesSelectionClass" checked class="fileSelectionClassNontechnic" title="Filtrer les fichiers obstrués"/><input type="radio" name="filesSelectionClass" class="fileSelectionClassNone" title="Filtrer les fichiers .class"/></p><div class="releaseFilesContainer">
<strong class="minecraftDotJar">Minecraft.jar</strong><br/><ul>'.$directoryXML.'</ul></div></div>';
echo '</div>';
}
exit();
}
else {
$prevRelease = $release;
}
}
echo 'ERREUR L\'information demmandée n\'a pas été trouvée.<br/>
Si il s\'agit d\'une sortie récente, attendez un peu et réésayez.';
} else {
echo 'ERREUR Les informations demmandées ne sont pas correctes.';
}
function directoryXML($XML, $path) {
global $filesModificationsStat;
global $haveLink;
$text = '';
for ($c = $XML->length, $i = 0; $i < $c; $i++) {
$element = $XML->item($i);
if ($element->tagName == 'dir') {
if ($directoryXML = directoryXML($element->childNodes, $path.'/'.$element->getAttribute('name'))) {
$text .= '<li><span class="dir closed">'.$element->getAttribute('name').'</span><ul class="dirUl" style="display: none;">'.$directoryXML.'</ul></li>';
}
} elseif ($element->tagName == 'file') {
/*
if ((isset($_GET['allowClass']) OR strlen(@$exploded[0]) > 3 OR @$exploded[1] != 'class' OR $element->getAttribute('comparaison')== 'addded') AND (isset($_GET['allowSame']) OR $element->getAttribute('comparaison')!= 'same')) { */
$className = 'file';
switch ($element->getAttribute('comparaison')) {
case 'change':
$comparaison = '≠';
$className .= ' change';
$filesModificationsStat[0]++;
break;
case 'added':
$comparaison = '+';
$className .= ' added';
$filesModificationsStat[1]++;
break;
case 'same';
$comparaison = '=';
$className .= ' same';
$filesModificationsStat[2]++;
break;
default:
$comparaison = '?';
break;
}
$exploded = explode('.', $element->getAttribute('name'));
if (@$exploded[1] == 'class') {
$className .= ' class';
}
if (strlen($exploded[0]) < 4 AND @$exploded[1] == 'class') {
$className .= ' technic';
}
if (@$exploded[1] == 'png') {
$className .= ' image';
}
if (@$exploded[1] == 'txt') {
$className .= ' txt';
}
$filesModificationsStat[3]++;
$text .= '<li><span class="'.$className.'">';
if ($haveLink) { $text.= '<a href="'.$path.'/'.$element->getAttribute('name').'">'; }
$text .= $element->getAttribute('name');
if ($haveLink) { $text .= '</a>'; }
$text .= '</span>('.$comparaison.')</li>';
}
}
return $text;
}
?>

View file

@ -1,178 +0,0 @@
<?php
set_time_limit('240');
addRelease('1_2_5');
function addRelease($input) {
$debug = false;
// Définition des variables de travail
$lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
$lastVersions_e_backup = $lastVersions_e;
if ($input == 'r') {
$lastVersions_e[1] = 'UP';
} else {
$lastVersions_e[3] = 'UP';
}
// Enregistrement des données d'ajout
$lastVersions_e[0] = time();
$lastVersions_txt = fopen('lastVersions.txt', 'w');
fwrite($lastVersions_txt, implode('|', $lastVersions_e));
fclose($lastVersions_txt);
if ($input == 'r') {
$type = 'r';
$url = 'http://s3.amazonaws.com/MinecraftDownload/minecraft.jar';
} else {
$type = 'pr';
$url = 'http://assets.minecraft.net/'.$input.'/minecraft.jar';
}
// Chargement du XML
$data = new DomDocument();
$data->load('data.xml');
$dataNode = $data->getElementsByTagName('data')->item(0);
$mcupdatesNode = $dataNode->getElementsByTagName('mcupdates')->item(0);
$id = $mcupdatesNode->getAttribute('total')+1;
$releaseS = $mcupdatesNode->getElementsByTagName('release');
$release = $releaseS->item($releaseS->length-1);
// Creation du noeud XML
$releaseNode = $data->createElement('release');
$mcupdatesNode->appendChild($releaseNode);
$infosNode = $data->createElement('infos');
$releaseNode->appendChild($infosNode);
$files = $data->createElement('files');
$releaseNode->appendChild($files);
// Extraction et copie de minecraft.jar
$directory = $id.' - '.$lastVersions_e[0].' ('.rand(1, 1000).')';
if (!mkdir($directory) OR !copy($url, $directory.'/minecraft.jar')) { return 'ERREUR Impossible de copier le fichier ou de créer un nouveau dossier.';}
$zip = new ZipArchive;
if ($zip->open($directory.'/minecraft.jar') AND mkdir($directory.'/content')) {
$zip->extractTo($directory.'/content');
$zip->close();
} else {
return 'ERREUR Impossible d\'extraire le fichier ou de créer un nouveau dossier.';
}
$md5 = md5_file($directory.'/minecraft.jar');
directoryConstruct($directory.'/content', $files, $data, directoryOld($release));
// Detection de $givenName
// Code par @EphysPatato
$minecraft_class = file_get_contents($directory.'/content/net/minecraft/client/Minecraft.class');
$givenName = 'false';
if (preg_match('/Minecraft Minecraft (.+)Minecraft main/', $minecraft_class, $matches)) {
$givenName = '';
$givenName_w = $matches[count($matches)-1];
for( $i = 0 ; $i < strlen($givenName_w) ; $i++ )
{
$givenName_cw = substr($givenName_w, $i, 1);
if(($givenName_cw >= 'a' && $givenName_cw <= 'z') || ($givenName_cw >= 'A' && $givenName_cw <= 'Z') || ($givenName_cw >= '0' && $givenName_cw <= '9') || $givenName_cw == '|' || $givenName_cw == '.' || $givenName_cw == '_' || $givenName_cw == '-')
$givenName .= $givenName_cw;
}
}
// Spécifications selon le type de release
if ($type == 'r') {
$name = $givenName;
$lastVersions_e[1] = $name;
$lastVersions_e[2] = $md5;
$infosNode->setAttribute('wiki', 'http://www.minecraftwiki.net/wiki/Version_history#'.$name);
} else {
$name = $input;
$lastVersions_e[3] = $name;
$lastVersions_e[4] = $md5;
$infosNode->setAttribute('wiki', 'http://www.minecraftwiki.net/wiki/Version_history/Development_versions#'.$name);
}
// Mise des infos dans le XML
$releaseNode->setAttribute('id', $id);
$releaseNode->setAttribute('name', $name);
$releaseNode->setAttribute('type', $type);
$infosNode->setAttribute('givenName', $givenName);
$infosNode->setAttribute('directory', $directory);
$infosNode->setAttribute('link', $url);
$infosNode->setAttribute('size', filesize($directory.'/minecraft.jar'));
$infosNode->setAttribute('md5', $md5);
$infosNode->setAttribute('sha1', sha1_file($directory.'/minecraft.jar'));
$infosNode->setAttribute('date', $lastVersions_e[0]);
$infosNode->setAttribute('shortDescription', 'false');
$mcupdatesNode->setAttribute('total', $id);
// Sauvegarde finale
$lastVersions_e[0] = time();
$lastVersions_e[5] = $id;
$lastVersions_e[6] = $name;
$lastVersions_e[7] = $type;
$id = $mcupdatesNode->setAttribute('total', $id);
$lastVersions_f = fopen('lastVersions.txt', 'w');
$lastError = error_get_last();
if ($debug) { echo substr($lastError['file'], -14); }
if ($lastError /*AND $lastError['type']!= 2 */AND substr($lastError['file'], -14) == 'addrelease.php') {
fwrite($lastVersions_f, implode('|', $lastVersions_e_backup));
rrmdir($directory);
return 'ERREUR "'.$lastError['message'].'" (type : '.$lastError['type'].') dans '.$lastError['file'].' ligne '.$lastError['line'].'.';
} else {
$data->save('data.xml');
fwrite($lastVersions_f, implode('|', $lastVersions_e));
fclose($lastVersions_f);
return implode('|', $lastVersions_e);
}
}
function directoryConstruct($directoryName, $XML, $data, $array) {
$directory = opendir($directoryName);
while($file = readdir($directory)) {
if ($file != '.' AND $file != '..') {
if (is_dir($directoryName.'/'.$file)) {
$newDirectory = $data->createElement('dir');
$XML->appendChild($newDirectory);
$newDirectory->setAttribute('name', $file);
if (isset($array[$file])) {
$newDirectory->setAttribute('comparaison', 'same');
directoryConstruct($directoryName.'/'.$file, $newDirectory, $data, $array[$file]);
} else {
$newDirectory->setAttribute('comparaison', 'added');
directoryConstruct($directoryName.'/'.$file, $newDirectory, $data, array());
}
} else {
$fileXML = $data->createElement('file');
$XML->appendChild($fileXML);
$fileXML->setAttribute('name', $file);
$fileXML->setAttribute('md5', md5_file($directoryName.'/'.$file));
if (isset($array[$file])) {
if ($array[$file] == md5_file($directoryName.'/'.$file)) {
$fileXML->setAttribute('comparaison', 'same');
} else {
$fileXML->setAttribute('comparaison', 'change');
}
} else {
$fileXML->setAttribute('comparaison', 'added');
}
// TODO Verifier si un fichier a été supprimé
}