PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/INSTALL/cm-config.php

http://pacercms.googlecode.com/
PHP | 244 lines | 213 code | 27 blank | 4 comment | 8 complexity | b83d6bdda5e4ce1520440f7a907751fa MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. define('CM_INSTALLING', true);
  3. if (!file_exists('../includes/config-sample.php'))
  4. die('Sorry, I need a <tt>config-sample.php</tt> file to work from. Please re-upload this file from your PacerCMS installation.');
  5. $configFile = file('../includes/config-sample.php');
  6. if (!is_writable('../includes/')) die("Sorry, I can't write to the <tt>./includes</tt> directory. You'll have to either change the permissions (<tt>chmod 777 includes/</tt>) on the directory or create your <tt>config.php</tt> manually.");
  7. if (isset($_GET['step']))
  8. $step = $_GET['step'];
  9. else
  10. $step = 0;
  11. header( 'Content-Type: text/html; charset=utf-8' );
  12. ?>
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  14. <html xmlns="http://www.w3.org/1999/xhtml">
  15. <head>
  16. <title>PacerCMS &rsaquo; Setup Configuration File</title>
  17. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  18. <style>
  19. body {
  20. font-family: "Lucida Grande", Helvetica, Verdana, sans-serif;
  21. font-size: 10pt;
  22. line-height: 16pt;
  23. text-align: left;
  24. margin: 0;
  25. margin-left: 10%;
  26. margin-right: 10%;
  27. padding: 0;
  28. color: rgb(0, 0, 0);
  29. }
  30. a, a:link, a:visited {
  31. text-decoration: none;
  32. }
  33. a:hover {
  34. text-decoration: underline;
  35. }
  36. img {
  37. border: 0;
  38. }
  39. h1 {
  40. font-size: 15pt;
  41. font-weight: bold;
  42. }
  43. #footer {text-align:right;font-size:80%;line-height:2em;border-top:solid 1px #eee;}
  44. </style>
  45. </head>
  46. <body>
  47. <h1><img src="../siteadmin/cm-images/header.png" alt="PacerCMS"></h1>
  48. <?php
  49. // Check if cm-config.php has been created
  50. if (file_exists('../includes/config.php'))
  51. die("<p>The file 'config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='cm-install.php'>installing now</a>.</p></body></html>");
  52. switch($step) {
  53. case 0:
  54. ?>
  55. <p>Welcome to PacerCMS. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
  56. <ol>
  57. <li>Database name</li>
  58. <li>Database username</li>
  59. <li>Database password</li>
  60. <li>Database host</li>
  61. <li>Template folder name</li>
  62. </ol>
  63. <p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>config-sample.php</code> in a text editor, fill in your information, and save it as <code>config.php</code>. </strong></p>
  64. <p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready, <a href="cm-config.php?step=1">let&#8217;s go</a>! </p>
  65. <?php
  66. break;
  67. case 1:
  68. ?>
  69. </p>
  70. <form method="post" action="cm-config.php?step=2">
  71. <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
  72. <table>
  73. <tr>
  74. <th scope="row">Database Platform</th>
  75. <td>
  76. <select name="dbplatform" type="text">
  77. <option value="mysql">MySQL</option>
  78. </select>
  79. </td>
  80. <td>The type of database platform (Note: Only tested with MySQL). </td>
  81. </tr>
  82. <tr>
  83. <th scope="row">Character Set</th>
  84. <td>
  85. <select name="dbcharset" type="text">
  86. <option value="utf8">Unicode (UTF-8)</option>
  87. <option value="latin1">ISO 8859-1 (Latin-1)</option>
  88. </select>
  89. </td>
  90. <td>The charachter set for database storage. </td>
  91. </tr>
  92. <tr>
  93. <th scope="row">Database Name</th>
  94. <td><input name="dbname" type="text" size="25" value="pacercms" /></td>
  95. <td>The name of the database you want to run PacerCMS in. </td>
  96. </tr>
  97. <tr>
  98. <th scope="row">User Name</th>
  99. <td><input name="uname" type="text" size="25" value="username" /></td>
  100. <td>Your database username</td>
  101. </tr>
  102. <tr>
  103. <th scope="row">Password</th>
  104. <td><input name="pwd" type="text" size="25" value="password" /></td>
  105. <td>...and password.</td>
  106. </tr>
  107. <tr>
  108. <th scope="row">Database Host</th>
  109. <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
  110. <td>99% chance you won't need to change this value.</td>
  111. </tr>
  112. <tr>
  113. <th scope="row">Template Folder</th>
  114. <td><input name="tplfld" type="text" size="25" value="default" /></td>
  115. <td>Type the name of your template folder. Use "<tt>default</tt>" for basic template.</td>
  116. </tr>
  117. <tr>
  118. <th scope="row">Language</th>
  119. <td>
  120. <select name="locale" type="text">
  121. <option value="en_US.UTF8">English (United States)</option>
  122. <option value="fr_FR.UTF8">French (France)</option>
  123. </select>
  124. </td>
  125. <td>Choose the default language for your site.</td>
  126. </tr>
  127. </table>
  128. <h2 class="step">
  129. <input name="submit" type="submit" value="Submit" />
  130. </h2>
  131. </form>
  132. <?php
  133. break;
  134. case 2:
  135. $dbplatform = trim($_POST['dbplatform']);
  136. $dbcharset = trim($_POST['dbcharset']);
  137. $dbname = trim($_POST['dbname']);
  138. $uname = trim($_POST['uname']);
  139. $passwrd = trim($_POST['pwd']);
  140. $dbhost = trim($_POST['dbhost']);
  141. $tplfld = trim($_POST['tplfld']);
  142. $locale = trim($_POST['locale']);
  143. define('DB_PLATFORM', $dbplatform);
  144. define('DB_CHARSET', $dbcharset);
  145. define('DB_DATABASE', $dbname);
  146. define('DB_USERNAME', $uname);
  147. define('DB_PASSWORD', $passwrd);
  148. define('DB_HOSTNAME', $dbhost);
  149. define('TEMPLATES_FOLDER', $tplfld);
  150. define('LOCALE', $locale);
  151. // Database Connection
  152. $dbTest = mysql_pconnect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD) or die("Your connection to the server was refused.");
  153. mysql_select_db(DB_DATABASE, $dbTest) or die("You connected to the server, but your connection to the database was refused.");
  154. // We'll fail here if the values are no good.
  155. $handle = fopen('../includes/config.php', 'w');
  156. echo "<blockquote><code>";
  157. foreach ($configFile as $line_num => $line)
  158. {
  159. switch (substr($line,0,19))
  160. {
  161. case 'define("DB_PLATFORM':
  162. $line = str_replace("mysql", $dbplatform, $line);
  163. fwrite($handle, $line);
  164. echo $line . "<br/>";
  165. break;
  166. case 'define("DB_CHARSET"':
  167. $line = str_replace("utf8", $dbcharset, $line);
  168. fwrite($handle, $line);
  169. echo $line . "<br/>";
  170. break;
  171. case 'define("DB_HOSTNAME':
  172. $line = str_replace("localhost", $dbhost, $line);
  173. fwrite($handle, $line);
  174. echo $line . "<br/>";
  175. break;
  176. case 'define("DB_DATABASE':
  177. $line = str_replace("pacercms", $dbname, $line);
  178. fwrite($handle, $line);
  179. echo $line . "<br/>";
  180. break;
  181. case 'define("DB_USERNAME':
  182. $line = str_replace("username", $uname, $line);
  183. fwrite($handle, $line);
  184. echo $line . "<br>";
  185. break;
  186. case 'define("DB_PASSWORD':
  187. $line = str_replace("password", $passwrd, $line);
  188. fwrite($handle, $line);
  189. echo $line . "<br/>";
  190. break;
  191. case 'define("TEMPLATES_F':
  192. $line = str_replace("default", $tplfld, $line);
  193. fwrite($handle, $line);
  194. echo $line . "<br/>";
  195. break;
  196. case 'define("LOCALE", "e':
  197. $line = str_replace("en_US.UTF8", $locale, $line);
  198. fwrite($handle, $line);
  199. echo $line . "<br/>";
  200. break;
  201. default:
  202. fwrite($handle, $line);
  203. echo $line . "<br/>";
  204. }
  205. }
  206. fclose($handle);
  207. chmod('../includes/config.php', 0666);
  208. echo "</code></blockquote>";
  209. ?>
  210. <p>PacerCMS can now communicate with your database. If you are ready, time now to <a href="cm-install.php">run the install!</a></p>
  211. <?php
  212. break;
  213. }
  214. ?>
  215. <p id="footer">Install scripts modeled after <a href="http://wordpress.org">WordPress</a>'s simple but effective methods.</p>
  216. </body>
  217. </html>