[ARCHIVE 2012] Récupère des informations sur les nouvelles versions de Minecraft
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

test.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. date_default_timezone_set('Europe/Paris');
  3. $lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
  4. // set_time_limit('240');
  5. function debug($a){return 0;}
  6. // V�rification d'une update en cours
  7. debug('test.php started');
  8. if ($lastVersions_e[1] == 'UP') {
  9. debug('R Up');
  10. for ($i = 0; $i <= 200; $i++) {
  11. sleep(1);
  12. $lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
  13. if ($lastVersions_e[1] != 'UP') {
  14. echo implode('|', $lastVersions_e);
  15. exit();
  16. }
  17. }
  18. echo 'ERREUR La release n\'a pas �t� correctement trait�e. Le syst�me d\'ajout de release est suspendu pour le moment.';
  19. exit();
  20. }
  21. if ($lastVersions_e[3] == 'UP') {
  22. debug('APR Up');
  23. for ($i = 0; $i <= 200; $i++) {
  24. sleep(1);
  25. $lastVersions_e = explode('|', file_get_contents('lastVersions.txt'));
  26. if ($lastVersions_e[3] != 'UP') {
  27. echo implode('|', $lastVersions_e);
  28. exit();
  29. }
  30. }
  31. echo 'ERREUR La release n\'a pas �t� correctement trait�e. Le syst�me d\'ajout de release est suspendu pour le moment.';
  32. exit();
  33. }
  34. if (time()-$lastVersions_e[0] < 5) {
  35. echo implode('|', $lastVersions_e);
  36. exit();
  37. }
  38. // TODO Commande serveur
  39. // D�finition de la prochaine APR
  40. if (substr($lastVersions_e[3], 0, 2) == substr(date('Y'), 2, 2) AND substr($lastVersions_e[3], 3, 2) == date('W')) {
  41. $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');
  42. $nextAPR = substr(date('Y'), 2, 2).'w'.date('W').$alphabet[array_search(substr($lastVersions_e[3], 2), $alphabet)+1];
  43. $nextAPR_firstOfWeek = false;
  44. } else {
  45. $nextAPR = substr(date('Y'), 2, 2).'w'.date('W').'a';
  46. $nextAPR_firstOfWeek = true;
  47. }
  48. debug('$nextAPR='.$nextAPR);
  49. // Check de l'APR
  50. if (true) {
  51. // if (((date('D') == 'Thu') AND $nextAPR_firstOfWeek AND time()-$lastVersions_e[0] >= 5) OR time()-$lastVersions_e[0] >= 10) {
  52. debug('nextAPR check 1');
  53. if (@fopen('http://assets.minecraft.net/'.$nextAPR.'/minecraft.jar', 'r')) {
  54. include_once('addrelease.php');
  55. echo addRelease($nextAPR);
  56. exit();
  57. }
  58. }
  59. // Check de la R
  60. if (true) {
  61. // if (time()-$lastVersions_e[0] >= 30){
  62. if (@md5_file('http://s3.amazonaws.com/MinecraftDownload/minecraft.jar') != $lastVersions_e[2]) {
  63. debug('nextR check');
  64. include_once('addrelease.php');
  65. echo addRelease('r');
  66. exit();
  67. }
  68. }
  69. // Re-check de la derni�re APR
  70. if (true) {
  71. //if ((time()-$lastVersions_e[0] <= 20 AND !$nextAPR_firstOfWeek) OR (time()-$lastVersions_e[0] >= 60)) {
  72. debug('lastAPR re-check');
  73. if (@md5_file('http://assets.minecraft.net/'.$lastVersions_e[3].'/minecraft.jar') != $lastVersions_e[4]) {
  74. include_once('addrelease.php');
  75. echo addRelease($lastVersions_e[3]);
  76. exit();
  77. }
  78. }
  79. $lastVersions_e[0] = time();
  80. $lastVersions_f = fopen('lastVersions.txt', 'w');
  81. fwrite($lastVersions_f, implode('|', $lastVersions_e));
  82. fclose($lastVersions_f);
  83. echo implode('|', $lastVersions_e);
  84. ?>