PageRenderTime 26ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wolf/install/requirements.php

http://wolfcms.googlecode.com/
PHP | 175 lines | 134 code | 19 blank | 22 comment | 19 complexity | 914f41496c84f54aae07bca3b2c65040 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /*
  3. * Wolf CMS - Content Management Simplified. <http://www.wolfcms.org>
  4. * Copyright (C) 2009-2010 Martijn van der Kleijn <martijn.niji@gmail.com>
  5. *
  6. * This file is part of Wolf CMS. Wolf CMS is licensed under the GNU GPLv3 license.
  7. * Please see license.txt for the full license text.
  8. */
  9. /**
  10. * @package wolf
  11. * @subpackage installer
  12. */
  13. /* Make sure we've been called using index.php */
  14. if (!defined('INSTALL_SEQUENCE')) {
  15. echo '<p>Illegal call. Terminating.</p>';
  16. exit();
  17. }
  18. // Errors?
  19. $errors = false;
  20. // Check PHP version
  21. $check = (PHP_VERSION >= '5.1.2');
  22. $php = '<span class="'.($check ? 'check' : 'notcheck');
  23. $php .= '">PHP '.PHP_VERSION.'</span>';
  24. if (!$check) $errors = true;
  25. // check if the PDO driver we need is installed
  26. $check = false;
  27. $check = method_exists('PDO','getAvailableDrivers');
  28. $pdo = '<span class="'.(($check) ? 'check' : 'notcheck');
  29. $pdo .= '">'.(($check) ? 'true' : 'false').'</span>';
  30. if (!$check) $errors = true;
  31. // Check if proper PDO drivers are available
  32. $mcheck = false;
  33. $scheck = false;
  34. $pcheck = false;
  35. if ($check) {
  36. $drivers = PDO::getAvailableDrivers();
  37. $mcheck = in_array('mysql', $drivers);
  38. $mysql = '<span class="'.($mcheck ? 'check' : 'notcheck').'">'.($mcheck ? 'true' : 'false').'</span>';
  39. $scheck = in_array('sqlite', $drivers);
  40. $sqlite = '<span class="'.($scheck ? 'check' : 'notcheck').'">'.($scheck ? 'true' : 'false').'</span>';
  41. $pcheck = in_array('pgsql', $drivers);
  42. $pgsql = '<span class="'.($pcheck ? 'check' : 'notcheck').'">'.($pcheck ? 'true' : 'false').'</span>';
  43. // Make sure EITHER MySQL, SQLite or PostgreSQL is supported
  44. if (!$mcheck && !$scheck && !$pcheck) $errors = true;
  45. }
  46. else {
  47. $mysql = '-- n/a --';
  48. $sqlite = '-- n/a --';
  49. $pgsql = '-- n/a --';
  50. }
  51. // Check existence of config file
  52. $check = file_exists(CFG_FILE);
  53. $cfg_exists = '<span class="'.((true === $check) ? 'check' : 'notcheck').'">'.((true === $check) ? 'true' : 'false').'</span>';
  54. if (!$check) $errors = true;
  55. // Check config file is writable
  56. $check = is_writable(CFG_FILE);
  57. $cfg_writable = '<span class="'.($check ? 'check' : 'notcheck').'">'.($check ? 'true' : 'false').'</span>';
  58. if (!$check) $errors = true;
  59. // Check public directory is writable
  60. $check = is_writable(PUBLIC_ROOT);
  61. $public_writable = '<span class="'.($check ? 'check' : 'notcheck').'">'.($check ? 'true' : 'false').'</span>';
  62. if (!$check) $errors = true;
  63. // Test for mod_rewrite availability (is not mandatory)
  64. $check = false;
  65. if (isset($_GET['rewrite']) && $_GET['rewrite'] == 1) {
  66. $check = true;
  67. }
  68. $modrewrite = '<span class="'.($check ? 'check' : 'warning').'">'.($check ? 'true' : 'not detected').'</span>';
  69. // Test for HTTPS support, only possible if user goes to this page with https
  70. $check = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == "on" || $_SERVER['HTTPS'] == "1"));
  71. $https = '<span class="'.($check ? 'check' : 'notcheck').'">'.($check ? 'true' : 'false').'</span>';
  72. ?>
  73. <h1>Requirements check <img src="install-logo.png" alt="Wolf CMS logo" class="logo" /></h1>
  74. <p>
  75. All of the items that are checked below, are <strong>required</strong>
  76. for proper installation and operation of Wolf CMS unless otherwise specified in the footnotes.
  77. </p>
  78. <p>
  79. Please make sure you either have: MySQL 4.1.x upwards, SQLite 3 or PostgreSQL available as a database.
  80. </p>
  81. <table>
  82. <thead>
  83. <tr>
  84. <th id="requirement">Requirement</th>
  85. <th>Available?</th>
  86. </tr>
  87. </thead>
  88. <tbody>
  89. <tr>
  90. <td>PHP 5.1.2</td>
  91. <td class="available"><?php echo $php; ?></td>
  92. </tr>
  93. <tr>
  94. <td>PDO supported</td>
  95. <td class="available"><?php echo $pdo; ?></td>
  96. </tr>
  97. <tr>
  98. <td>PDO supports MySQL <sup>1)</sup></td>
  99. <td class="available"><?php echo $mysql; ?></td>
  100. </tr>
  101. <tr>
  102. <td>PDO supports SQLite 3 <sup>1)</sup></td>
  103. <td class="available"><?php echo $sqlite; ?></td>
  104. </tr>
  105. <tr>
  106. <td>PDO supports PostgreSQL <sup>1)</sup></td>
  107. <td class="available"><?php echo $pgsql; ?></td>
  108. </tr>
  109. <tr>
  110. <td>Config file exists <sup>2)</sup></td>
  111. <td class="available"><?php echo $cfg_exists; ?></td>
  112. </tr>
  113. <tr>
  114. <td>Config file is writable <sup>2)</sup></td>
  115. <td class="available"><?php echo $cfg_writable; ?></td>
  116. </tr>
  117. <tr>
  118. <td>Public directory is writable <sup>3)</sup></td>
  119. <td class="available"><?php echo $public_writable; ?></td>
  120. </tr>
  121. <tr>
  122. <td>Clean URLs support available <sup>4)</sup></td>
  123. <td class="available"><?php echo $modrewrite; ?></td>
  124. </tr>
  125. </tbody>
  126. </table>
  127. <p class="footnotes">
  128. <sup>1)</sup> - Only one database <strong>has</strong> to be supported by PDO.
  129. If you use MySQL, you don't need a SQLite or PostgreSQL driver and visa versa.<br/>
  130. <sup>2)</sup> - "config.php" at install root.<br/>
  131. <sup>3)</sup> - "public" at install root.<br/>
  132. <sup>4)</sup> - If "clean urls support available" says "not detected", make sure you have renamed the _.htaccess file into .htaccess. You only need clean URLs support if you want to remove the question mark from the URLs. (mod_rewrite)
  133. </p>
  134. <p>
  135. <form style="text-align: right;" action="index.php" method="POST">
  136. <?php
  137. if ($errors) {
  138. echo 'Please fix these problems and <button type="submit">test again</button>';
  139. } else {
  140. if (file_exists(CFG_FILE) && filesize(CFG_FILE) == 0) {
  141. if ($scheck && !$mcheck && !$pcheck)
  142. echo '<input type="hidden" name="dbtype" value="sqlite"/>';
  143. else if ($mcheck && !$scheck && !$pcheck)
  144. echo '<input type="hidden" name="dbtype" value="mysql"/>';
  145. else if ($pcheck && !$mcheck && !$scheck)
  146. echo '<input type="hidden" name="dbtype" value="pgsql"/>';
  147. echo '<button name="install" type="submit" value="1">Continue to install</button>';
  148. }
  149. }
  150. ?>
  151. </form>
  152. </p>