commit 54c24457e974e72c68c362a9c752b38f6f6fd8f3 Author: Geoffrey Frogeye Date: Wed Apr 5 08:32:06 2017 +0200 Version 1 trouvée diff --git a/addrelease.php b/addrelease.php new file mode 100755 index 0000000..805bccf --- /dev/null +++ b/addrelease.php @@ -0,0 +1,192 @@ +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.';} + 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�er un nouveau dossier².'; + } + } 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); + } + } +?> \ No newline at end of file diff --git a/data.xml b/data.xml new file mode 100755 index 0000000..10aa7c3 --- /dev/null +++ b/data.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/design.css b/design.css new file mode 100755 index 0000000..ed0bdf4 --- /dev/null +++ b/design.css @@ -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"); + +} \ No newline at end of file diff --git a/images/background_pattern.png b/images/background_pattern.png new file mode 100755 index 0000000..a5e603e Binary files /dev/null and b/images/background_pattern.png differ diff --git a/images/body_pattern.png b/images/body_pattern.png new file mode 100755 index 0000000..5f941f6 Binary files /dev/null and b/images/body_pattern.png differ diff --git a/images/icons/book.png b/images/icons/book.png new file mode 100755 index 0000000..fe758c8 Binary files /dev/null and b/images/icons/book.png differ diff --git a/images/icons/bookLess.png b/images/icons/bookLess.png new file mode 100755 index 0000000..bf439e3 Binary files /dev/null and b/images/icons/bookLess.png differ diff --git a/images/icons/bookMore.png b/images/icons/bookMore.png new file mode 100755 index 0000000..24ac7e8 Binary files /dev/null and b/images/icons/bookMore.png differ diff --git a/images/icons/bookshelf.png b/images/icons/bookshelf.png new file mode 100755 index 0000000..c1c3236 Binary files /dev/null and b/images/icons/bookshelf.png differ diff --git a/images/icons/bookshelfMore.png b/images/icons/bookshelfMore.png new file mode 100755 index 0000000..a07a1ad Binary files /dev/null and b/images/icons/bookshelfMore.png differ diff --git a/images/icons/map.png b/images/icons/map.png new file mode 100755 index 0000000..65e2be2 Binary files /dev/null and b/images/icons/map.png differ diff --git a/images/icons/painting.png b/images/icons/painting.png new file mode 100755 index 0000000..81dda60 Binary files /dev/null and b/images/icons/painting.png differ diff --git a/images/icons/paper.png b/images/icons/paper.png new file mode 100755 index 0000000..a515b28 Binary files /dev/null and b/images/icons/paper.png differ diff --git a/images/icons/redstoneTorchOff.png b/images/icons/redstoneTorchOff.png new file mode 100755 index 0000000..50224b7 Binary files /dev/null and b/images/icons/redstoneTorchOff.png differ diff --git a/images/icons/redstoneTorchOn.png b/images/icons/redstoneTorchOn.png new file mode 100755 index 0000000..41f4cbb Binary files /dev/null and b/images/icons/redstoneTorchOn.png differ diff --git a/images/icons/sign.png b/images/icons/sign.png new file mode 100755 index 0000000..6f1724d Binary files /dev/null and b/images/icons/sign.png differ diff --git a/images/release_pattern.png b/images/release_pattern.png new file mode 100755 index 0000000..10439b0 Binary files /dev/null and b/images/release_pattern.png differ diff --git a/index.php b/index.php new file mode 100755 index 0000000..19d0864 --- /dev/null +++ b/index.php @@ -0,0 +1,236 @@ +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 .= '

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 .= '

'.$shortDescription.'
'; + $prevRelease = $release; +} +?> + + + +Minecraft Checker + + + + + +

Minecraft Checker

+
+

Rechercher des versions

+ + +

Versions référencées

+
+ +
+
+ + + + \ No newline at end of file diff --git a/indexold.php b/indexold.php new file mode 100755 index 0000000..4d49350 --- /dev/null +++ b/indexold.php @@ -0,0 +1,236 @@ +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 .= '

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 .= '

'.$shortDescription.'
'; + $prevRelease = $release; +} +?> + + + +Minecraft Checker + + + + + +

Minecraft Checker

+
+

Rechercher des versions

+ + +

Versions référencées

+
+ +
+
+ + + + \ No newline at end of file diff --git a/lastVersions.txt b/lastVersions.txt new file mode 100755 index 0000000..59b955b --- /dev/null +++ b/lastVersions.txt @@ -0,0 +1 @@ +1336223378|1.2.5|8e8778078a175a33603a585257f28563|12w18a|37d778548796dd95c4d0ea49a015be06|27|12w18a|apr \ No newline at end of file diff --git a/moreinfos.php b/moreinfos.php new file mode 100755 index 0000000..3b24812 --- /dev/null +++ b/moreinfos.php @@ -0,0 +1,143 @@ +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 '.
'; + 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').'.
'; + } + // Téléchargement + echo '

Téléchargement

+Nom : minecraft.jar +Taille : '.$releaseInfos->getAttribute('size').' octets
+MD5 : '.$releaseInfos->getAttribute('md5').'
+SHA-1 : '.$releaseInfos->getAttribute('sha1').'
'; + 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 'Depuis ce serveur
'; } + if (isset($downloadServer)) { + echo 'Depuis minecraft.net
'; } + if (isset($downloadWiki)) { + echo 'Depuis Minecaft Wiki
'; } + } else { + echo 'Aucun lien de téléchargement n\'est disponible.'; + } + echo '
'; + echo '
+

Changelog

+Langue : Français
+Lien vers le wiki
+
'; + $text = '