Version 1 trouvée
192
addrelease.php
Executable file
|
@ -0,0 +1,192 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
||||
?>
|
179
design.css
Executable file
|
@ -0,0 +1,179 @@
|
|||
* {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Trebuchet MS";
|
||||
background-image: url('images/background_pattern.png');
|
||||
text-shadow : 0px 2px 23px white;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #2D4C6B;
|
||||
text-align: center;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 18px 18px 0px 18px;
|
||||
}
|
||||
|
||||
.more, .releaseFilesButton {
|
||||
padding: 0px 5px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0px 0px 10px 0px;
|
||||
}
|
||||
|
||||
li {
|
||||
margin-left: 25px;
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
#body {
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background-color: white;
|
||||
margin: 25px;
|
||||
padding: 10px;
|
||||
box-shadow: 0px 3px 10px #222323;
|
||||
-webkit-box-shadow : 0px 3px 10px #222323;
|
||||
-moz-box-shadow : 0px 3px 10px #222323;
|
||||
background-image: url('images/body_pattern.png');
|
||||
}
|
||||
|
||||
#allreleases {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#copyright {
|
||||
float: right;
|
||||
}
|
||||
|
||||
footer {
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background-color: white;
|
||||
margin: 25px;
|
||||
padding: 10px;
|
||||
box-shadow: 0px 3px 10px #222323;
|
||||
-webkit-box-shadow : 0px 3px 10px #222323;
|
||||
-moz-box-shadow : 0px 3px 10px #222323;
|
||||
background-image: url('images/body_pattern.png');
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0f7eff;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
text-shadow : 0px 2px 15px white;
|
||||
}
|
||||
.release {
|
||||
border: #3d3d3d 2px solid;
|
||||
padding: 10px;
|
||||
background-color: white;
|
||||
color: black;
|
||||
background-image: url('images/release_pattern.png');
|
||||
margin: 0px 15px 15px 15px;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.download , .changelog, .files{
|
||||
border: 1px solid black;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
margin: 5px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.wiki, .releaseFilesContainer {
|
||||
background-color: white;
|
||||
margin: 25px;
|
||||
padding: 10px;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0px 1px 10px #222323;
|
||||
-webkit-box-shadow : 0px 1px 10px #222323;
|
||||
-moz-box-shadow : 0px 1px 10px #222323;
|
||||
}
|
||||
|
||||
.shortDescription {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.releaseFiles {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.releaseFiles p {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.RL_search {
|
||||
background-color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.minecraftDotJar {
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 20px;
|
||||
background-image: url("images/icons/bookshelf.png");
|
||||
}
|
||||
|
||||
.dir , .file {
|
||||
color: black;
|
||||
text-decoration: underline;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: none;
|
||||
border: none;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.dir.closed{
|
||||
background-image: url("images/icons/bookMore.png");
|
||||
}
|
||||
|
||||
.dir.opened{
|
||||
background-image: url("images/icons/bookLess.png");
|
||||
}
|
||||
|
||||
.file {
|
||||
background-image: url("images/icons/paper.png");
|
||||
}
|
||||
|
||||
/*.file a {
|
||||
color: #0f7eff;
|
||||
}*/
|
||||
|
||||
.file.image {
|
||||
background-image: url("images/icons/painting.png");
|
||||
|
||||
}
|
||||
|
||||
.file.technic {
|
||||
background-image: url("images/icons/map.png");
|
||||
}
|
||||
|
||||
.file.txt {
|
||||
background-image: url("images/icons/sign.png");
|
||||
|
||||
}
|
BIN
images/background_pattern.png
Executable file
After Width: | Height: | Size: 42 KiB |
BIN
images/body_pattern.png
Executable file
After Width: | Height: | Size: 244 B |
BIN
images/icons/book.png
Executable file
After Width: | Height: | Size: 293 B |
BIN
images/icons/bookLess.png
Executable file
After Width: | Height: | Size: 316 B |
BIN
images/icons/bookMore.png
Executable file
After Width: | Height: | Size: 323 B |
BIN
images/icons/bookshelf.png
Executable file
After Width: | Height: | Size: 913 B |
BIN
images/icons/bookshelfMore.png
Executable file
After Width: | Height: | Size: 899 B |
BIN
images/icons/map.png
Executable file
After Width: | Height: | Size: 274 B |
BIN
images/icons/painting.png
Executable file
After Width: | Height: | Size: 241 B |
BIN
images/icons/paper.png
Executable file
After Width: | Height: | Size: 247 B |
BIN
images/icons/redstoneTorchOff.png
Executable file
After Width: | Height: | Size: 246 B |
BIN
images/icons/redstoneTorchOn.png
Executable file
After Width: | Height: | Size: 257 B |
BIN
images/icons/sign.png
Executable file
After Width: | Height: | Size: 259 B |
BIN
images/release_pattern.png
Executable file
After Width: | Height: | Size: 15 KiB |
236
index.php
Executable file
|
@ -0,0 +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 © <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>
|
236
indexold.php
Executable file
|
@ -0,0 +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 © <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>
|
1
lastVersions.txt
Executable file
|
@ -0,0 +1 @@
|
|||
1336223378|1.2.5|8e8778078a175a33603a585257f28563|12w18a|37d778548796dd95c4d0ea49a015be06|27|12w18a|apr
|
143
moreinfos.php
Executable file
|
@ -0,0 +1,143 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
?>
|
178
preRelease.php
Executable file
|
@ -0,0 +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);
|
||||
}
|
||||
}
|
||||
?>
|
84
test.php
Executable file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
$lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
|
||||
// set_time_limit('240');
|
||||
function debug($a){return 0;}
|
||||
// V<>rification d'une update en cours
|
||||
debug('test.php started');
|
||||
if ($lastVersions_e[1] == 'UP') {
|
||||
debug('R Up');
|
||||
for ($i = 0; $i <= 200; $i++) {
|
||||
sleep(1);
|
||||
$lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
|
||||
if ($lastVersions_e[1] != 'UP') {
|
||||
echo implode('|', $lastVersions_e);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
echo 'ERREUR La release n\'a pas <20>t<EFBFBD> correctement trait<69>e. Le syst<73>me d\'ajout de release est suspendu pour le moment.';
|
||||
exit();
|
||||
}
|
||||
if ($lastVersions_e[3] == 'UP') {
|
||||
debug('APR Up');
|
||||
for ($i = 0; $i <= 200; $i++) {
|
||||
sleep(1);
|
||||
$lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
|
||||
if ($lastVersions_e[3] != 'UP') {
|
||||
echo implode('|', $lastVersions_e);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
echo 'ERREUR La release n\'a pas <20>t<EFBFBD> correctement trait<69>e. Le syst<73>me d\'ajout de release est suspendu pour le moment.';
|
||||
exit();
|
||||
}
|
||||
if (time()-$lastVersions_e[0] < 5) {
|
||||
echo implode('|', $lastVersions_e);
|
||||
exit();
|
||||
}
|
||||
// TODO Commande serveur
|
||||
// D<>finition de la prochaine APR
|
||||
if (substr($lastVersions_e[3], 0, 2) == substr(date('Y'), 2, 2) AND substr($lastVersions_e[3], 3, 2) == date('W')) {
|
||||
$alphabet = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
|
||||
$nextAPR = substr(date('Y'), 2, 2).'w'.date('W').$alphabet[array_search(substr($lastVersions_e[3], 2), $alphabet)+1];
|
||||
$nextAPR_firstOfWeek = false;
|
||||
} else {
|
||||
$nextAPR = substr(date('Y'), 2, 2).'w'.date('W').'a';
|
||||
$nextAPR_firstOfWeek = true;
|
||||
}
|
||||
debug('$nextAPR='.$nextAPR);
|
||||
// Check de l'APR
|
||||
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')) {
|
||||
include_once('addrelease.php');
|
||||
echo addRelease($nextAPR);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
// Check de la R
|
||||
if (true) {
|
||||
// if (time()-$lastVersions_e[0] >= 30){
|
||||
if (@md5_file('http://s3.amazonaws.com/MinecraftDownload/minecraft.jar') != $lastVersions_e[2]) {
|
||||
debug('nextR check');
|
||||
include_once('addrelease.php');
|
||||
echo addRelease('r');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
// Re-check de la derni<6E>re APR
|
||||
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]) {
|
||||
include_once('addrelease.php');
|
||||
echo addRelease($lastVersions_e[3]);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$lastVersions_e[0] = time();
|
||||
$lastVersions_f = fopen('lastVersions.txt', 'w');
|
||||
fwrite($lastVersions_f, implode('|', $lastVersions_e));
|
||||
fclose($lastVersions_f);
|
||||
echo implode('|', $lastVersions_e);
|
||||
?>
|