Version 2 trouvée

This commit is contained in:
Geoffrey Frogeye 2017-04-05 08:40:30 +02:00
parent 54c24457e9
commit bba4b09ee9
6 changed files with 425 additions and 440 deletions

View file

@ -20,7 +20,7 @@ function addRelease($input) {
$url = 'http://s3.amazonaws.com/MinecraftDownload/minecraft.jar';
} else {
$type = 'apr';
$url = 'http://assets.minecraft.net/'.$input.'/minecraft.zip';
$url = 'http://assets.minecraft.net/'.$input.'/minecraft.jar';
}
// Chargement du XML
@ -43,28 +43,13 @@ function addRelease($input) {
// 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.';
}
}
$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<63>er un nouveau dossier.';
}
$md5 = md5_file($directory.'/minecraft.jar');
directoryConstruct($directory.'/content', $files, $data, directoryOld($release));

File diff suppressed because one or more lines are too long

470
index.php
View file

@ -1,236 +1,236 @@
<?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>
<?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>

View file

@ -1 +1 @@
1336223378|1.2.5|8e8778078a175a33603a585257f28563|12w18a|37d778548796dd95c4d0ea49a015be06|27|12w18a|apr
1341566731|1.2.5|8e8778078a175a33603a585257f28563|UP|ac908492cdfe6c1d81183d2d2d7959a1|34|12w24a|apr

View file

@ -1,178 +1,178 @@
<?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é
}
}
}
}
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);
}
}
<?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é
}
}
}
}
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);
}
}
?>

View file

@ -50,7 +50,7 @@ if (substr($lastVersions_e[3], 0, 2) == substr(date('Y'), 2, 2) AND substr($last
if (true) {
// if (((date('D') == 'Thu') AND $nextAPR_firstOfWeek AND time()-$lastVersions_e[0] >= 5) OR time()-$lastVersions_e[0] >= 10) {
debug('nextAPR check 1');
if (@fopen('http://assets.minecraft.net/'.$nextAPR.'/minecraft.zip', 'r')) {
if (@fopen('http://assets.minecraft.net/'.$nextAPR.'/minecraft.jar', 'r')) {
include_once('addrelease.php');
echo addRelease($nextAPR);
exit();
@ -70,7 +70,7 @@ if (true) {
if (true) {
//if ((time()-$lastVersions_e[0] <= 20 AND !$nextAPR_firstOfWeek) OR (time()-$lastVersions_e[0] >= 60)) {
debug('lastAPR re-check');
if (@md5_file('http://assets.minecraft.net/'.$lastVersions_e[3].'/minecraft.zip') != $lastVersions_e[4]) {
if (@md5_file('http://assets.minecraft.net/'.$lastVersions_e[3].'/minecraft.jar') != $lastVersions_e[4]) {
include_once('addrelease.php');
echo addRelease($lastVersions_e[3]);
exit();