PageRenderTime 76ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/install/install.php

http://eude.googlecode.com/
PHP | 169 lines | 151 code | 10 blank | 8 comment | 16 complexity | 46ddd4ebe921005013d9dc7c41446fa2 MD5 | raw file
  1. <?php
  2. /**
  3. * @author Alex10336
  4. * Derničre modification: $Id: install.php 576 2010-07-30 20:47:12Z Alex10336 $
  5. * @license GNU Public License 3.0 ( http://www.gnu.org/licenses/gpl-3.0.txt )
  6. * @license Creative Commons 3.0 BY-SA ( http://creativecommons.org/licenses/by-sa/3.0/deed.fr )
  7. */
  8. include ('../init.php');
  9. if (file_exists('../Script/Entete.php'))
  10. trigger_error('Installation existante', E_USER_ERROR);
  11. if (!file_exists('./install.conf.php'))
  12. trigger_error('Fichier de configuration principal manquant (install.conf.php)', E_USER_ERROR);
  13. $file = 'install';
  14. $sqlfile = ROOT_PATH . 'install' . DIRECTORY_SEPARATOR . $file . '.sql';
  15. $lockfile = ROOT_PATH . 'install' . DIRECTORY_SEPARATOR . $file . '.lock';
  16. if (file_put_contents(ROOT_PATH . 'install' . DIRECTORY_SEPARATOR . 'test.lock', 'test') === false ||
  17. file_put_contents(ROOT_PATH . 'Script' . DIRECTORY_SEPARATOR . 'test.lock', 'test') === false) {
  18. @chmod('./', '0777');
  19. @chmod('../Script/', '0777');
  20. @unlink(ROOT_PATH . 'install' . DIRECTORY_SEPARATOR . 'test.lock');
  21. @unlink(ROOT_PATH . 'Script' . DIRECTORY_SEPARATOR . 'test.lock');
  22. trigger_error('I/O Error test.lock chmod "/install" and "/Script" directory to 777', E_USER_ERROR);
  23. }
  24. if (file_exists($lockfile))
  25. trigger_error('Fichier de vérouillage trouvé, installation partielle/en cours ? (' . $lockfile . ')', E_USER_WARNING);
  26. $max = count(preg_split('/;[\n\r]+/', file_get_contents($sqlfile)));
  27. if (file_exists($lockfile))
  28. $cur = (int) file_get_contents($lockfile);
  29. else
  30. $cur = 0;
  31. $max = $max - $cur;
  32. $lngs = array();
  33. $dir = TEMPLATE_PATH . 'lng'.DIRECTORY_SEPARATOR;
  34. $deflng = preg_split('/[,;]/', $_SERVER["HTTP_ACCEPT_LANGUAGE"], 2, PREG_SPLIT_DELIM_CAPTURE);
  35. $deflng = $deflng[0];
  36. if ($dh = opendir($dir)) {
  37. while (($file = readdir($dh)) !== false) {
  38. if ($file == '.' || $file == '..')
  39. continue;
  40. if (is_dir($dir.$file))
  41. $lngs[] = $file;
  42. }
  43. closedir($dh);
  44. } else
  45. $lngs[] = 'fr';
  46. array_walk($lngs, 'genoption');
  47. $lngs = implode("\n", $lngs);
  48. function genoption(&$value, $key) {
  49. global $deflng;
  50. if ($deflng == $value)
  51. $value = '<option value="'.$value.'" selected>'.$value.'</option>';
  52. else
  53. $value = '<option value="'.$value.'">'.$value.'</option>';
  54. return true;
  55. }
  56. //-- repiquage script/script.php
  57. function bulle($texte, $addover='', $addout='') {
  58. if (is_array($addover))
  59. $addover = implode($addover, '');
  60. if (is_array($addout))
  61. $addout = implode($addout, '');
  62. $texte = htmlspecialchars(str_replace("\n", '', $texte), ENT_QUOTES, 'UTF-8');
  63. return ("onmouseover='montre(\"" . $texte . "\");$addover' onmouseout='cache();$addout'");
  64. }
  65. //-- fin repiquage
  66. $bulle_sqlrooturl = bulle('<u>Exemple:</u><br/>Site: http://app216.free.fr<b>/eu2/test/</b><br/>Emplacement sur le serveur: <b>/eu2/test/</b><br/>Commence et finit par <b>/</b>');
  67. ?><html xmlns="http://www.w3.org/1999/html" lang="fr" xml:lang="fr">
  68. <head>
  69. <title>EU2: DataEngine, Installation</title>
  70. <link rel="stylesheet" type="text/css" href="./template.css?install" media="screen" />
  71. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  72. <link rel="shortcut icon" href="../tpl/lng/fr/btn/eude.png">
  73. <script type="text/javascript" src="../Script/prototype.js?1.6.1"></script>
  74. <script type="text/javascript" src="../Script/Script.js?install"></script>
  75. <script type="text/javascript" src="../tpl/lng/fr/eude.local.js?install"></script>
  76. <script type="text/javascript" src="./sqlbatch.js?install"></script>
  77. </head>
  78. <body>
  79. <style type="text/css">
  80. .required {
  81. color: red;
  82. font-weight: bold;
  83. }
  84. </style>
  85. <div id="curseur" class="infobulle"></div>
  86. <form autocomplete="off" name="install" action="?" method="POST" Onsubmit="return false;">
  87. <input type="hidden" id="sqlmax" value="<?php echo $max; ?>" />
  88. <table id="install" class="table_nospacing table_center color_bg size500">
  89. <tr class="color_bigheader text_center">
  90. <td rowspan="18" width="2px">&nbsp;</td>
  91. <td colspan="2">Installation du <b>D</b>ata <b>E</b>ngine</td>
  92. <td rowspan="18" width="2px">&nbsp;</td>
  93. </tr>
  94. <tr>
  95. <td colspan="2" height="2px"></td>
  96. </tr>
  97. <tr class="color_header">
  98. <td colspan="2"><b>Serveur mysql</b></td>
  99. </tr>
  100. <tr>
  101. <td><span class="required">*</span> <b>Serveur</b></td>
  102. <td><input class="color_row0" type="text" id="sqlserver" value="localhost" /></td>
  103. </tr>
  104. <tr>
  105. <td><span class="required">*</span> <b>Base de donnée</b></td>
  106. <td><input class="color_row0" type="text" id="sqlbase" value="" /></td>
  107. </tr>
  108. <tr>
  109. <td><span class="required">*</span> <b>Nom d'utilisateur</b></td>
  110. <td><input class="color_row0" type="text" id="sqluser" value="" /></td>
  111. </tr>
  112. <tr>
  113. <td><span class="required">*</span> <b>Mot de passe</b></td>
  114. <td><input class="color_row0" type="text" id="sqlpass" value="" /></td>
  115. </tr>
  116. <tr>
  117. <td><b>Préfixe de table</b></td>
  118. <td><input class="color_row0 size80" type="text" id="sqlprefix" value="de_" /></td>
  119. </tr>
  120. <tr class="color_header">
  121. <td colspan="2"><b>Compte</b></td>
  122. </tr>
  123. <tr>
  124. <td><b>Nom d'utilisateur administrateur</b></td>
  125. <td><input class="color_row0" type="text" maxlength="30" id="username" value="admin" /></td>
  126. </tr>
  127. <tr>
  128. <td><b>Mot de passe</b></td>
  129. <td><input class="color_row0" type="text" id="password" value="admin" /></td>
  130. </tr>
  131. <tr class="color_header">
  132. <td colspan="2"><b>Informations complémentaire</b></td>
  133. </tr>
  134. <tr>
  135. <td><b>Langue d'installation</b></td>
  136. <td><select class="color_row0" id="language"><?php echo $lngs; ?></select></td>
  137. </tr>
  138. <tr <?php echo $bulle_sqlrooturl; ?>>
  139. <td><b>Emplacement sur le serveur</b></td>
  140. <td><input class="color_row0" type="text" id="sqlrooturl" value="<?php echo dirname(dirname($_ENV['SCRIPT_URL'])) . '/'; ?>" /></td>
  141. </tr>
  142. <tr>
  143. <td><b>Votre empire</b></td>
  144. <td><input class="color_row0" type="text" maxlength="100" id="empire" value="" /></td>
  145. </tr>
  146. <tr>
  147. <td><b>Votre forum</b></td>
  148. <td><input class="color_row0" type="text" maxlength="256" id="board" value="https://eude.googlecode.com/" /></td>
  149. </tr>
  150. <tr class="color_header text_center">
  151. <td colspan="2"><a href="javascript:test_mysql();">Tester la connexion mysql</a></td>
  152. </tr>
  153. <tr class="color_header text_center">
  154. <td colspan="2"><div id="sqlbatchmsg"></div>
  155. <div id="sqlbatchmsgstep"></div></td>
  156. </tr>
  157. </table>
  158. </form>
  159. </body></html>