PageRenderTime 29ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/install/index.php

https://github.com/sinantalebi/esoTalk
PHP | 250 lines | 184 code | 46 blank | 20 comment | 18 complexity | e7b456ef04101f34e6010d505b37937c MD5 | raw file
  1. <?php
  2. // Copyright 2009 Simon Zerner, Toby Zerner
  3. // This file is part of esoTalk. Please see the included license file for usage information.
  4. // Installer wrapper: sets up the Install controller and displays the installer interface.
  5. define("IN_ESOTALK", 1);
  6. // Unset the page execution time limit.
  7. @set_time_limit(0);
  8. // Require essential files.
  9. require "../lib/functions.php";
  10. require "../lib/database.php";
  11. // Start a session if one does not already exist.
  12. if (!session_id()) session_start();
  13. // Undo register_globals.
  14. undoRegisterGlobals();
  15. // If magic quotes is on, strip the slashes that it added.
  16. if (get_magic_quotes_gpc()) {
  17. $_GET = array_map("undoMagicQuotes", $_GET);
  18. $_POST = array_map("undoMagicQuotes", $_POST);
  19. $_COOKIE = array_map("undoMagicQuotes", $_COOKIE);
  20. }
  21. // Sanitize the request data. This is pretty much the same as using htmlentities.
  22. $_POST = sanitize($_POST);
  23. $_GET = sanitize($_GET);
  24. $_COOKIE = sanitize($_COOKIE);
  25. // Set up the Install controller, which will perform all installation tasks.
  26. require "install.controller.php";
  27. $install = new Install();
  28. $install->init();
  29. ?>
  30. <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  31. <!-- This page was generated by esoTalk (http://esotalk.com) -->
  32. <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
  33. <head>
  34. <title>esoTalk Installer</title>
  35. <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
  36. <script type='text/javascript' src='../js/esotalk.js'></script>
  37. <link type='text/css' rel='stylesheet' href='install.css'/>
  38. </head>
  39. <body>
  40. <form action='' method='post'>
  41. <div id='container'>
  42. <?php
  43. switch ($install->step) {
  44. // Fatal checks.
  45. case "fatalChecks": ?>
  46. <h1><img src='logo.gif' alt=''/> Uh oh, something's not right!</h1>
  47. <p>The following errors were found with your esoTalk setup. They must be resolved before you can continue the installation.</p>
  48. <hr/>
  49. <ul>
  50. <?php foreach ($install->errors as $error) echo "<li>$error</li>"; ?>
  51. </ul>
  52. <p>If you run into any other problems or just want some help with the installation, feel free to ask for assistance at the <a href='http://forum.esotalk.com/'>esoTalk support forum</a> where a bunch of friendly people will be happy to help you out.</p>
  53. <hr/>
  54. <p id='footer'><input class='button' value='Try again' type='submit'/></p>
  55. <?php break;
  56. // Warning checks.
  57. case "warningChecks": ?>
  58. <h1><img src='logo.gif' alt=''/> Warning!</h1>
  59. <p>The following errors were found with your esoTalk setup. You can continue the esoTalk install without resolving them, but some esoTalk functionality may be limited.</p>
  60. <hr/>
  61. <ul>
  62. <?php foreach ($install->errors as $error) echo "<li>$error</li>"; ?>
  63. </ul>
  64. <p>If you run into any other problems or just want some help with the installation, feel free to ask for assistance at the <a href='http://forum.esotalk.com/'>esoTalk support forum</a> where a bunch of friendly people will be happy to help you out.</p>
  65. <hr/>
  66. <p id='footer'><input class='button' value='Next step &#155;' type='submit' name='next'/></p>
  67. <?php break;
  68. // Specify setup information.
  69. case "info": ?>
  70. <h1><img src='logo.gif' alt=''/> Specify setup information</h1>
  71. <p>Welcome to the esoTalk installer! We need a few details from you so we can get your forum set up and ready to go.</p>
  72. <p>If you have any trouble, get help on the <a href='http://forum.esotalk.com/'>esoTalk support forum</a>!</p>
  73. <hr/>
  74. <ul class='form'>
  75. <li><label>Forum title</label> <input id='forumTitle' name='forumTitle' tabindex='1' type='text' class='text' value='<?php echo @$_POST["forumTitle"]; ?>'/>
  76. <?php if (isset($install->errors["forumTitle"])): ?><div class='warning msg'><?php echo $install->errors["forumTitle"]; ?></div><?php endif; ?></li>
  77. <li><label>Default language</label> <div><select id='language' name='language' tabindex='2'>
  78. <?php foreach ($install->languages as $language) echo "<option value='$language'" . ((!empty($_POST["language"]) ? $_POST["language"] : "English (casual)") == $language ? " selected='selected'" : "") . ">$language</option>"; ?>
  79. </select><br/>
  80. <small>More language packs are <a href='http://esotalk.com/languages'>available for download</a>!</small></div></li>
  81. </ul>
  82. <hr/>
  83. <p>esoTalk needs access to a MySQL database to store all your forum's data in, such as conversations and posts. If you're unsure of any of these details, you may need to ask your hosting provider.</p>
  84. <?php if (isset($install->errors["mysql"])): ?><div class='warning msg'><?php echo $install->errors["mysql"]; ?></div><?php endif; ?>
  85. <ul class='form'>
  86. <li><label>MySQL host address</label> <input id='mysqlHost' name='mysqlHost' tabindex='3' type='text' class='text' value='<?php echo isset($_POST["mysqlHost"]) ? $_POST["mysqlHost"] : "localhost"; ?>'/></li>
  87. <li><label>MySQL username</label> <input id='mysqlUser' name='mysqlUser' tabindex='4' type='text' class='text' value='<?php echo @$_POST["mysqlUser"]; ?>'/></li>
  88. <li><label>MySQL password</label> <input id='mysqlPass' name='mysqlPass' tabindex='5' type='password' class='text' value='<?php echo @$_POST["mysqlPass"]; ?>'/></li>
  89. <li><label>MySQL database</label> <input id='mysqlDB' name='mysqlDB' tabindex='6' type='text' class='text' value='<?php echo @$_POST["mysqlDB"]; ?>'/></li>
  90. </ul>
  91. <hr/>
  92. <p>esoTalk will use the following information to set up your administrator account on your forum.</p>
  93. <ul class='form'>
  94. <li><label>Administrator username</label> <input id='adminUser' name='adminUser' tabindex='7' type='text' class='text' value='<?php echo @$_POST["adminUser"]; ?>'/>
  95. <?php if (isset($install->errors["adminUser"])): ?><div class='warning msg'><?php echo $install->errors["adminUser"]; ?></div><?php endif; ?></li>
  96. <li><label>Administrator email</label> <input id='adminEmail' name='adminEmail' tabindex='8' type='text' class='text' value='<?php echo @$_POST["adminEmail"]; ?>'/>
  97. <?php if (isset($install->errors["adminEmail"])): ?><span class='warning msg'><?php echo $install->errors["adminEmail"]; ?></span><?php endif; ?></li>
  98. <li><label>Administrator password</label> <input id='adminPass' name='adminPass' tabindex='9' type='password' class='text' value='<?php echo @$_POST["adminPass"]; ?>'/>
  99. <?php if (isset($install->errors["adminPass"])): ?><span class='warning msg'><?php echo $install->errors["adminPass"]; ?></span><?php endif; ?></li>
  100. <li><label>Confirm password</label> <input id='adminConfirm' name='adminConfirm' tabindex='10' type='password' class='text' value='<?php echo @$_POST["adminConfirm"]; ?>'/>
  101. <?php if (isset($install->errors["adminConfirm"])): ?><span class='warning msg'><?php echo $install->errors["adminConfirm"]; ?></span><?php endif; ?></li>
  102. </ul>
  103. <script type='text/javascript'>
  104. // <![CDATA[
  105. if (!getById("forumTitle").value) makePlaceholder(getById("forumTitle"), "e.g. Simon's Krav Maga Forum");
  106. if (!getById("mysqlUser").value) makePlaceholder(getById("mysqlUser"), "simon");
  107. if (!getById("mysqlDB").value) makePlaceholder(getById("mysqlDB"), "esotalk");
  108. if (!getById("adminUser").value) makePlaceholder(getById("adminUser"), "Simon");
  109. if (!getById("adminEmail").value) makePlaceholder(getById("adminEmail"), "simon@example.com");
  110. // ]]>
  111. </script>
  112. <br/>
  113. <a href='#advanced' onclick='toggleAdvanced();return false' title='What, you&#39;re too cool for the normal settings?' tabindex='11'>Advanced options</a>
  114. <hr class='aboveToggle'/>
  115. <div id='advanced'>
  116. <?php if (isset($install->errors["tablePrefix"])): ?><p class='warning msg'><?php echo $install->errors["tablePrefix"]; ?></p><?php endif; ?>
  117. <ul class='form'>
  118. <li><label>MySQL table prefix</label> <input name='tablePrefix' id='tablePrefix' tabindex='12' type='text' class='text' value='<?php echo isset($_POST["tablePrefix"]) ? $_POST["tablePrefix"] : "et_"; ?>'/></li>
  119. <li><label>Base URL</label> <input name='baseURL' type='text' tabindex='13' class='text' value='<?php echo isset($_POST["baseURL"]) ? $_POST["baseURL"] : $install->suggestBaseUrl(); ?>'/></li>
  120. <li><label>Use friendly URLs</label> <input name='friendlyURLs' type='checkbox' tabindex='14' class='checkbox' value='1' checked='<?php echo (!empty($_POST["friendlyURLs"]) or $install->suggestFriendlyUrls()) ? "checked" : ""; ?>'/></li>
  121. </ul>
  122. <hr/>
  123. <input type='hidden' name='showAdvanced' id='showAdvanced' value='<?php echo $_POST["showAdvanced"]; ?>'/>
  124. <script type='text/javascript'>
  125. // <![CDATA[
  126. function toggleAdvanced() {
  127. toggle(getById("advanced"), {animation: "verticalSlide"});
  128. getById("showAdvanced").value = getById("advanced").showing ? "1" : "";
  129. if (getById("advanced").showing) {
  130. animateScroll(getById("advanced").offsetTop + getById("advanced").offsetHeight + getClientDimensions()[1]);
  131. getById("tablePrefix").focus();
  132. }
  133. }
  134. <?php if (empty($_POST["showAdvanced"])): ?>hide(getById("advanced"));<?php endif; ?>
  135. // ]]>
  136. </script>
  137. </div>
  138. <p id='footer' style='margin:0'><input type='submit' tabindex='15' value='Next step &#155;' class='button'/></p>
  139. <?php break;
  140. // Show an installation error.
  141. case "install": ?>
  142. <h1><img src='logo.gif' alt=''/> Uh oh! It's a fatal error...</h1>
  143. <p class='warning msg'>The esoTalk installer encountered an error.</p>
  144. <p>The installer has encountered a nasty error which is making it impossible to install esoTalk on your server. But don't feel down - <strong>here are a few things you can try</strong>:</p>
  145. <ul>
  146. <li><strong>Try again.</strong> Everyone makes mistakes - maybe the computer made one this time!</li>
  147. <li><strong>Go back and check your settings.</strong> In particular, make sure your database information is correct.</li>
  148. <li><strong>Get help.</strong> Go on the <a href='http://forum.esotalk.com' title='Don&#039;t worry, we&#039;re friendly!'>esoTalk support forum</a> and <a href='http://forum.esotalk.com/search/tag:installation'>search</a> to see if anyone else is having the same problem as you are. If not, start a new conversation about your problem, including the error details below.</li>
  149. </ul>
  150. <a href='#' onclick='toggleError();return false'>Show error information</a>
  151. <hr class='aboveToggle'/>
  152. <div id='error'>
  153. <?php echo $install->errors[1]; ?>
  154. <hr/>
  155. </div>
  156. <script type='text/javascript'>
  157. // <![CDATA[
  158. function toggleError() {
  159. toggle(getById("error"), {animation: "verticalSlide"});
  160. }
  161. hide(getById("error"));
  162. // ]]>
  163. </script>
  164. <p id='footer' style='margin:0'>
  165. <input type='submit' class='button' value='&#139; Go back' name='back'/>
  166. <input type='submit' class='button' value='Try again'/>
  167. </p>
  168. <?php break;
  169. // Finish!
  170. case "finish": ?>
  171. <h1><img src='logo.gif' alt=''/> Congratulations!</h1>
  172. <p>esoTalk has been installed, and your forum should be up and ready to go.</p>
  173. <p>It's highly recommended that you <strong>remove the <code>install</code> folder</strong> to prevent anyone from hacking your forum.</p>
  174. <a href='javascript:toggleAdvanced()'>Show advanced information</a>
  175. <hr class='aboveToggle'/>
  176. <div id='advanced'>
  177. <strong>Queries run</strong>
  178. <pre>
  179. <?php if (isset($_SESSION["queries"]) and is_array($_SESSION["queries"]))
  180. foreach ($_SESSION["queries"] as $query) echo sanitize($query) . ";<br/><br/>"; ?>
  181. </pre>
  182. <hr/>
  183. </div>
  184. <script type='text/javascript'>
  185. // <![CDATA[
  186. function toggleAdvanced() {
  187. toggle(getById("advanced"), {animation: "verticalSlide"});
  188. }
  189. hide(getById("advanced"));
  190. // ]]>
  191. </script>
  192. <p style='text-align:center' id='footer'><input type='submit' class='button' value='Take me to my forum!' name='finish'/></p>
  193. <?php break;
  194. }
  195. ?>
  196. </div>
  197. </form>
  198. </body>
  199. </html>