PageRenderTime 53ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/install/action.summary.php

http://modx-ja.googlecode.com/
PHP | 310 lines | 266 code | 14 blank | 30 comment | 83 complexity | 652de2ec25e74f080ee6c20c5c6b76d5 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. $installMode = intval($_POST['installmode']);
  3. echo "<h2>" . $_lang['preinstall_validation'] . "</h2>";
  4. echo "<h3>" . $_lang['summary_setup_check'] . "</h3>";
  5. $errors = 0;
  6. // check PHP version
  7. echo "<p>" . $_lang['checking_php_version'];
  8. $php_ver_comp = version_compare(phpversion(), "4.4.2");
  9. $php_ver_comp2 = version_compare(phpversion(), "4.4.9");
  10. // -1 if left is less, 0 if equal, +1 if left is higher
  11. if ($php_ver_comp < 0) {
  12. echo "<span class=\"notok\">" . $_lang['failed'] . "</span>".$_lang['you_running_php'] . phpversion() . $_lang["modx_requires_php"]."</p>";
  13. $errors += 1;
  14. } else {
  15. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  16. if ($php_ver_comp2 < 0) {
  17. echo "<fieldset>" . $_lang['php_security_notice'] . "</fieldset>";
  18. }
  19. }
  20. // check php register globals off
  21. echo "<p>" . $_lang['checking_registerglobals'];
  22. $register_globals = (int) ini_get('register_globals');
  23. if ($register_globals == '1'){
  24. echo "<span class=\"notok\">" . $_lang['failed']. "</span></p><p><strong>".$_lang['checking_registerglobals_note']."</strong></p>";
  25. // $errors += 1; // comment out for now so we still allow installs if folks are simply stubborn
  26. } else {
  27. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  28. }
  29. // check sessions
  30. echo "<p>" . $_lang['checking_sessions'];
  31. if ($_SESSION['test'] != 1) {
  32. echo "<span class=\"notok\">" . $_lang['failed']. "</span></p>";
  33. $errors += 1;
  34. } else {
  35. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  36. }
  37. // check directories
  38. // cache exists?
  39. echo "<p>" . $_lang['checking_if_cache_exist'];
  40. if (!file_exists("../assets/cache") || !file_exists("../assets/cache/rss")) {
  41. echo "<span class=\"notok\">" . $_lang['failed'] . "</span></p>";
  42. $errors += 1;
  43. } else {
  44. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  45. }
  46. // cache writable?
  47. echo "<p>" . $_lang['checking_if_cache_writable'];
  48. if (!is_writable("../assets/cache") || !file_exists("../assets/media")) {
  49. echo "<span class=\"notok\">" . $_lang['failed'] . "</span></p>";
  50. $errors += 1;
  51. } else {
  52. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  53. }
  54. // cache files writable?
  55. echo "<p>" . $_lang['checking_if_cache_file_writable'];
  56. if (!file_exists("../assets/cache/siteCache.idx.php")) {
  57. // make an attempt to create the file
  58. @ $hnd = fopen("../assets/cache/siteCache.idx.php", 'w');
  59. @ fwrite($hnd, "<?php //MODx site cache file ?>");
  60. @ fclose($hnd);
  61. }
  62. if (!is_writable("../assets/cache/siteCache.idx.php")) {
  63. echo "<span class=\"notok\">" . $_lang['failed'] . "</span></p>";
  64. $errors += 1;
  65. } else {
  66. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  67. }
  68. echo "<p>".$_lang['checking_if_cache_file2_writable'];
  69. if (!is_writable("../assets/cache/sitePublishing.idx.php")) {
  70. echo "<span class=\"notok\">".$_lang['failed']."</span></p>";
  71. $errors += 1;
  72. } else {
  73. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  74. }
  75. // File Browser directories exists?
  76. echo "<p>".$_lang['checking_if_images_exist'];
  77. if (!file_exists("../assets/images") || !file_exists("../assets/files") || !file_exists("../assets/flash") || !file_exists("../assets/media")) {
  78. echo "<span class=\"notok\">".$_lang['failed']."</span></p>";
  79. $errors += 1;
  80. } else {
  81. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  82. }
  83. // File Browser directories writable?
  84. echo "<p>".$_lang['checking_if_images_writable'];
  85. if (!is_writable("../assets/images") || !is_writable("../assets/files") || !is_writable("../assets/flash") || !is_writable("../assets/media")) {
  86. echo "<span class=\"notok\">".$_lang['failed']."</span></p>";
  87. $errors += 1;
  88. } else {
  89. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  90. }
  91. // export exists?
  92. echo "<p>".$_lang['checking_if_export_exists'];
  93. if (!file_exists("../assets/export")) {
  94. echo "<span class=\"notok\">".$_lang['failed']."</span></p>";
  95. $errors += 1;
  96. } else {
  97. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  98. }
  99. // export writable?
  100. echo "<p>".$_lang['checking_if_export_writable'];
  101. if (!is_writable("../assets/export")) {
  102. echo "<span class=\"notok\">".$_lang['failed']."</span></p>";
  103. $errors += 1;
  104. } else {
  105. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  106. }
  107. // config.inc.php writable?
  108. echo "<p>".$_lang['checking_if_config_exist_and_writable'];
  109. if (!file_exists("../manager/includes/config.inc.php")) {
  110. // make an attempt to create the file
  111. @ $hnd = fopen("../manager/includes/config.inc.php", 'w');
  112. @ fwrite($hnd, "<?php //MODx configuration file ?>");
  113. @ fclose($hnd);
  114. }
  115. $isWriteable = is_writable("../manager/includes/config.inc.php");
  116. if (!$isWriteable) {
  117. echo "<span class=\"notok\">".$_lang['failed']."</span></p><p><strong>".$_lang['config_permissions_note']."</strong></p>";
  118. $errors += 1;
  119. } else {
  120. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  121. }
  122. // connect to the database
  123. if ($installMode == 1) {
  124. include "../manager/includes/config.inc.php";
  125. } else {
  126. // get db info from post
  127. $database_server = $_POST['databasehost'];
  128. $database_user = $_SESSION['databaseloginname'];
  129. $database_password = $_SESSION['databaseloginpassword'];
  130. $database_collation = $_POST['database_collation'];
  131. $database_charset = substr($database_collation, 0, strpos($database_collation, '_') - 1);
  132. $database_connection_charset = $_POST['database_connection_charset'];
  133. $database_connection_method = $_POST['database_connection_method'];
  134. $dbase = $_POST['database_name'];
  135. $table_prefix = $_POST['tableprefix'];
  136. }
  137. echo "<p>".$_lang['creating_database_connection'];
  138. if (!@ $conn = mysql_connect($database_server, $database_user, $database_password)) {
  139. $errors += 1;
  140. echo "<span class=\"notok\">".$_lang['database_connection_failed']."</span><p />".$_lang['database_connection_failed_note']."</p>";
  141. } else {
  142. echo "<span class=\"ok\">".$_lang['ok']."</span></p>";
  143. }
  144. // make sure we can use the database
  145. if ($installMode > 0 && !@ mysql_query("USE {$dbase}")) {
  146. $errors += 1;
  147. echo "<span class=\"notok\">".$_lang['database_use_failed']."</span><p />".$_lang["database_use_failed_note"]."</p>";
  148. }
  149. // check the database collation if not specified in the configuration
  150. if (!isset ($database_connection_charset) || empty ($database_connection_charset)) {
  151. if (!$rs = @ mysql_query("show session variables like 'collation_database'")) {
  152. $rs = @ mysql_query("show session variables like 'collation_server'");
  153. }
  154. if ($rs && $collation = mysql_fetch_row($rs)) {
  155. $database_collation = $collation[1];
  156. }
  157. if (empty ($database_collation)) {
  158. $database_collation = 'utf8_general_ci';
  159. }
  160. $database_charset = substr($database_collation, 0, strpos($database_collation, '_') - 1);
  161. $database_connection_charset = $database_charset;
  162. }
  163. // determine the database connection method if not specified in the configuration
  164. if (!isset($database_connection_method) || empty($database_connection_method)) {
  165. $database_connection_method = 'SET CHARACTER SET';
  166. }
  167. // check table prefix
  168. if ($conn && $installMode == 0) {
  169. echo "<p>" . $_lang['checking_table_prefix'] . $table_prefix . "`: ";
  170. if ($rs= @ mysql_query("SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
  171. echo "<span class=\"notok\">" . $_lang['failed'] . "</span></b>" . $_lang['table_prefix_already_inuse'] . "</p>";
  172. $errors += 1;
  173. echo "<p>" . $_lang['table_prefix_already_inuse_note'] . "</p>";
  174. } else {
  175. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  176. }
  177. } elseif ($conn && $installMode == 2) {
  178. echo "<p>" . $_lang['checking_table_prefix'] . $table_prefix . "`: ";
  179. if (!$rs = @ mysql_query("SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
  180. echo "<span class=\"notok\">" . $_lang['failed'] . "</span></b>" . $_lang['table_prefix_not_exist'] . "</p>";
  181. $errors += 1;
  182. echo "<p>" . $_lang['table_prefix_not_exist_note'] . "</p>";
  183. } else {
  184. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  185. }
  186. }
  187. // check mysql version
  188. if ($conn) {
  189. echo "<p>" . $_lang['checking_mysql_version'];
  190. if ( version_compare(mysql_get_server_info(), '5.0.51', '=') ) {
  191. echo "<span class=\"notok\">" . $_lang['warning'] . "</span></b>&nbsp;&nbsp;<strong>". $_lang['mysql_5051'] . "</strong></p>";
  192. echo "<p><span class=\"notok\">" . $_lang['mysql_5051_warning'] . "</span></p>";
  193. } else {
  194. echo "<span class=\"ok\">" . $_lang['ok'] . "</span>&nbsp;&nbsp;<strong>" . $_lang['mysql_version_is'] . mysql_get_server_info() . "</strong></p>";
  195. }
  196. }
  197. // check for strict mode
  198. if ($conn) {
  199. echo "<p>". $_lang['checking_mysql_strict_mode'];
  200. $mysqlmode = @ mysql_query("SELECT @@global.sql_mode");
  201. if (@mysql_num_rows($mysqlmode) > 0){
  202. $modes = mysql_fetch_array($mysqlmode, MYSQL_NUM);
  203. //$modes = array("STRICT_TRANS_TABLES"); // for testing
  204. // print_r($modes);
  205. foreach ($modes as $mode) {
  206. if (stristr($mode, "STRICT_TRANS_TABLES") !== false || stristr($mode, "STRICT_ALL_TABLES") !== false) {
  207. echo "<span class=\"notok\">" . $_lang['warning'] . "</span></b> <strong>&nbsp;&nbsp;" . $_lang['strict_mode'] . "</strong></p>";
  208. echo "<p><span class=\"notok\">" . $_lang['strict_mode_error'] . "</span></p>";
  209. } else {
  210. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  211. }
  212. }
  213. } else {
  214. echo "<span class=\"ok\">" . $_lang['ok'] . "</span></p>";
  215. }
  216. }
  217. // Version and strict mode check end
  218. // andrazk 20070416 - add install flag and disable manager login
  219. // assets/cache writable?
  220. if (is_writable("../assets/cache")) {
  221. if (file_exists('../assets/cache/installProc.inc.php')) {
  222. @chmod('../assets/cache/installProc.inc.php', 0755);
  223. unlink('../assets/cache/installProc.inc.php');
  224. }
  225. // make an attempt to create the file
  226. @ $hnd = fopen("../assets/cache/installProc.inc.php", 'w');
  227. @ fwrite($hnd, '<?php $installStartTime = '.time().'; ?>');
  228. @ fclose($hnd);
  229. }
  230. if($installMode > 0 && $_POST['installdata'] == "1") {
  231. echo "<p class=\"notes\"><strong>{$_lang['sample_web_site']}:</strong> {$_lang['sample_web_site_note']}</p>\n";
  232. }
  233. if ($errors > 0) {
  234. ?>
  235. <p>
  236. <?php
  237. echo $_lang['setup_cannot_continue'];
  238. echo $errors > 1 ? $errors." " : "";
  239. if ($errors > 1) echo $_lang['errors'];
  240. else echo $_lang['error'];
  241. if ($errors > 1) echo $_lang['please_correct_errors'];
  242. else echo $_lang['please_correct_error'];
  243. if ($errors > 1) echo $_lang['and_try_again_plural'];
  244. else echo $_lang['and_try_again'];
  245. echo $_lang['visit_forum'];
  246. ?>
  247. </p>
  248. <?php
  249. }
  250. echo "<p>&nbsp;</p>";
  251. $nextAction= $errors > 0 ? 'summary' : 'install';
  252. $nextButton= $errors > 0 ? $_lang['retry'] : $_lang['install'];
  253. $nextVisibility= $errors > 0 || isset($_POST['chkagree']) ? 'visible' : 'hidden';
  254. $agreeToggle= $errors > 0 ? '' : ' onclick="if(document.getElementById(\'chkagree\').checked){document.getElementById(\'nextbutton\').style.visibility=\'visible\';}else{document.getElementById(\'nextbutton\').style.visibility=\'hidden\';}"';
  255. ?>
  256. <form name="install" id="install_form" action="index.php?action=<?php echo $nextAction ?>" method="post">
  257. <div>
  258. <input type="hidden" value="<?php echo $install_language?>" name="language" />
  259. <input type="hidden" value="<?php echo $manager_language?>" name="managerlanguage" />
  260. <input type="hidden" value="<?php echo $installMode ?>" name="installmode" />
  261. <input type="hidden" value="<?php echo trim($_POST['database_name'], '`'); ?>" name="database_name" />
  262. <input type="hidden" value="<?php echo $_POST['tableprefix'] ?>" name="tableprefix" />
  263. <input type="hidden" value="<?php echo $_POST['database_collation'] ?>" name="database_collation" />
  264. <input type="hidden" value="<?php echo $_POST['database_connection_charset'] ?>" name="database_connection_charset" />
  265. <input type="hidden" value="<?php echo $_POST['database_connection_method'] ?>" name="database_connection_method" />
  266. <input type="hidden" value="<?php echo $_POST['databasehost'] ?>" name="databasehost" />
  267. <input type="hidden" value="<?php echo $_POST['cmsadmin'] ?>" name="cmsadmin" />
  268. <input type="hidden" value="<?php echo $_POST['cmsadminemail'] ?>" name="cmsadminemail" />
  269. <input type="hidden" value="<?php echo $_POST['cmspassword'] ?>" name="cmspassword" />
  270. <input type="hidden" value="<?php echo $_POST['cmspasswordconfirm'] ?>" name="cmspasswordconfirm" />
  271. <input type="hidden" value="1" name="options_selected" />
  272. <input type="hidden" value="<?php echo $_POST['installdata'] ?>" name="installdata" />
  273. <?php
  274. $templates = isset ($_POST['template']) ? $_POST['template'] : array ();
  275. foreach ($templates as $i => $template) echo "<input type=\"hidden\" name=\"template[]\" value=\"$template\" />\n";
  276. $tvs = isset ($_POST['tv']) ? $_POST['tv'] : array ();
  277. foreach ($tvs as $i => $tv) echo "<input type=\"hidden\" name=\"tv[]\" value=\"$tv\" />\n";
  278. $chunks = isset ($_POST['chunk']) ? $_POST['chunk'] : array ();
  279. foreach ($chunks as $i => $chunk) echo "<input type=\"hidden\" name=\"chunk[]\" value=\"$chunk\" />\n";
  280. $snippets = isset ($_POST['snippet']) ? $_POST['snippet'] : array ();
  281. foreach ($snippets as $i => $snippet) echo "<input type=\"hidden\" name=\"snippet[]\" value=\"$snippet\" />\n";
  282. $plugins = isset ($_POST['plugin']) ? $_POST['plugin'] : array ();
  283. foreach ($plugins as $i => $plugin) echo "<input type=\"hidden\" name=\"plugin[]\" value=\"$plugin\" />\n";
  284. $modules = isset ($_POST['module']) ? $_POST['module'] : array ();
  285. foreach ($modules as $i => $module) echo "<input type=\"hidden\" name=\"module[]\" value=\"$module\" />\n";
  286. ?>
  287. </div>
  288. <h2><?php echo $_lang['agree_to_terms'];?></h2>
  289. <p>
  290. <input type="checkbox" value="1" id="chkagree" name="chkagree" style="line-height:18px" <?php echo isset($_POST['chkagree']) ? 'checked="checked" ':""; ?><?php echo $agreeToggle;?>/><label for="chkagree" style="display:inline;float:none;line-height:18px;"> <?php echo $_lang['iagree_box']?> </label>
  291. </p>
  292. <p class="buttonlinks">
  293. <a href="javascript:document.getElementById('install_form').action='index.php?action=options&language=<?php $install_language?>';document.getElementById('install_form').submit();" class="prev" title="<?php echo $_lang['btnback_value']?>"><span><?php echo $_lang['btnback_value']?></span></a>
  294. <a id="nextbutton" href="javascript:document.getElementById('install_form').submit();" title="<?php echo $nextButton ?>" style="visibility:<?php echo $nextVisibility;?>"><span><?php echo $nextButton ?></span></a>
  295. </p>
  296. </form>