You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

570 lines
28 KiB

  1. <?php
  2. // Project: Web Reference Database (refbase) <http://www.refbase.net>
  3. // Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
  4. // original author(s).
  5. //
  6. // This code is distributed in the hope that it will be useful,
  7. // but WITHOUT ANY WARRANTY. Please see the GNU General Public
  8. // License for more details.
  9. //
  10. // File: ./install.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/install.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 07-Jan-04, 22:00
  15. // Modified: $Date: 2015-02-16 20:53:19 +0000 (Mon, 16 Feb 2015) $
  16. // $Author: karnesky $
  17. // $Revision: 1405 $
  18. // This file will install the literature database for you. Note that you must have
  19. // an existing PHP and MySQL installation. Please see the readme for further information.
  20. // CAUTION: YOU MUST REMOVE THIS SCRIPT FROM YOUR WEB DIRECTORY AFTER INSTALLATION!!
  21. // Incorporate some include files:
  22. include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
  23. include 'includes/header.inc.php'; // include header
  24. include 'includes/footer.inc.php'; // include footer
  25. include 'includes/include.inc.php'; // include common functions
  26. include 'includes/install.inc.php'; // include install/update functions
  27. include 'initialize/ini.inc.php'; // include common variables
  28. // --------------------------------------------------------------------
  29. // START A SESSION:
  30. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  31. start_session(false);
  32. // --------------------------------------------------------------------
  33. // Initialize preferred display language:
  34. // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
  35. include 'includes/locales.inc.php'; // include the locales
  36. // --------------------------------------------------------------------
  37. // This specifies the name of the database that handles the MySQL user access privileges.
  38. // Unless you've fiddled with it, you shouldn't change the default value ('mysql'):
  39. $adminDatabaseName = 'mysql';
  40. // Extract any parameters passed to the script:
  41. if (isset($_POST['adminUserName']))
  42. $adminUserName = $_POST['adminUserName'];
  43. else
  44. $adminUserName = "";
  45. if (isset($_POST['adminPassword']))
  46. $adminPassword = $_POST['adminPassword'];
  47. else
  48. $adminPassword = "";
  49. if (isset($_POST['pathToMYSQL']))
  50. $pathToMYSQL = $_POST['pathToMYSQL'];
  51. else
  52. $pathToMYSQL = "";
  53. if (isset($_POST['databaseStructureFile']))
  54. $databaseStructureFile = $_POST['databaseStructureFile'];
  55. else
  56. $databaseStructureFile = "";
  57. if (isset($_POST['pathToBibutils']))
  58. $pathToBibutils = $_POST['pathToBibutils'];
  59. else
  60. $pathToBibutils = "";
  61. if (isset($_POST['defaultCharacterSet']))
  62. $defaultCharacterSet = $_POST['defaultCharacterSet'];
  63. else
  64. $defaultCharacterSet = "";
  65. // --------------------------------------------------------------------
  66. // Check the correct parameters have been passed:
  67. if (empty($adminUserName) AND empty($adminPassword) AND empty($pathToMYSQL) AND empty($databaseStructureFile))
  68. {
  69. // if 'install.php' was called without any valid parameters:
  70. //Display an installation form:
  71. if (isset($_SESSION['errors']))
  72. {
  73. $errors = $_SESSION['errors'];
  74. // Note: though we clear the session variable, the current error message is still available to this script via '$errors':
  75. deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  76. }
  77. else
  78. $errors = array(); // initialize the '$errors' variable in order to prevent 'Undefined variable...' messages
  79. if (isset($_SESSION['formVars']))
  80. {
  81. $formVars = $_SESSION['formVars'];
  82. // Note: though we clear the session variable, the current form variables are still available to this script via '$formVars':
  83. deleteSessionVariable("formVars"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  84. }
  85. else
  86. {
  87. // Reset the '$formVars' variable (since we're providing the default values):
  88. $formVars = array();
  89. $pathSeparator = PATH_SEPARATOR;
  90. $pathItems = explode($pathSeparator, getenv("PATH"));
  91. // Provide default values for the form fields:
  92. $formVars["adminUserName"] = "root";
  93. $formVars["adminPassword"] = "";
  94. $formVars["databaseStructureFile"] = "./install.sql";
  95. // Try to find the 'mysql' command line interpreter:
  96. $mysqlLocations = array_unique(array_merge($pathItems, array("/Program Files/MySQL/bin", "/wamp/mysql/bin", "/Program Files/xampp/mysql/bin", "/www/xampp/mysql/bin", "/xampp/mysql/bin", "/apachefriends/xampp/mysql/bin", "/usr/local/mysql/bin", "/usr/local/bin/mysql/bin", "/usr/bin/mysql/bin", "/usr/mysql/bin", "/opt/local/bin/", "/opt/local/lib/mysql4/bin/", "/opt/local/lib/mysql5/bin/")));
  97. $mysqlNames = array("mysql", "mysql.exe");
  98. $formVars["pathToMYSQL"] = locateFile($mysqlLocations, $mysqlNames, false); // function 'locateFile()' is defined in 'install.inc.php'
  99. // Try to find the Bibutils programs:
  100. $bibutilsLocations = array_unique(array_merge($pathItems, array("/usr/bin", "/usr/local/bin", "/opt/local/bin/", ".", "./refbase", "./bibutils")));
  101. // We'll only check for one program to save time (and because, we currently don't allow the script to have a subset of the functionality provided by Bibutils)
  102. $bibutilsNames = array("xml2bib", "xml2bib.exe");
  103. $formVars["pathToBibutils"] = locateFile($bibutilsLocations, $bibutilsNames, true);
  104. $formVars["defaultCharacterSet"] = "latin1";
  105. }
  106. // If there's no stored message available:
  107. if (!isset($_SESSION['HeaderString']))
  108. {
  109. if (empty($errors)) // provide the default message:
  110. $HeaderString = "To install the refbase package please fill out the form below and click the <em>Install</em> button:";
  111. else // -> there were errors when validating the fields
  112. $HeaderString = "There were validation errors regarding the details you entered. Please check the comments above the respective fields:";
  113. }
  114. else
  115. {
  116. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  117. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  118. deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  119. }
  120. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  121. // ('' will produce the default 'Web' output style)
  122. if (isset($_REQUEST['viewType']))
  123. $viewType = $_REQUEST['viewType'];
  124. else
  125. $viewType = "";
  126. // For the default character set, make sure that the correct popup menu entry is selected upon reload:
  127. if ($formVars["defaultCharacterSet"] == "utf8")
  128. {
  129. $latin1CharacterSetSelected = "";
  130. $unicodeCharacterSetSelected = " selected";
  131. }
  132. else // $formVars["defaultCharacterSet"] is 'latin1' or ''
  133. {
  134. $latin1CharacterSetSelected = " selected";
  135. $unicodeCharacterSetSelected = "";
  136. }
  137. // Show the login status:
  138. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  139. // DISPLAY header:
  140. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  141. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Installation", "index,follow", "Installation form for the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  142. showPageHeader($HeaderString);
  143. // Start <form> and <table> holding the form elements:
  144. ?>
  145. <form action="install.php" method="POST">
  146. <input type="hidden" name="formType" value="install">
  147. <input type="hidden" name="submit" value="Install"><?php // provide a default value for the 'submit' form tag. Otherwise, some browsers may not recognize the correct output format when a user hits <enter> within a form field (instead of clicking the "Install" button) ?>
  148. <table align="center" border="0" cellpadding="0" cellspacing="12" width="95%" summary="This table holds the installation form">
  149. <tr>
  150. <td colspan="3"><h3>refbase Installation</h3></td>
  151. </tr>
  152. <tr>
  153. <td width="190" valign="top"><b>Important note:</b></td>
  154. <td valign="top" colspan="2">
  155. Before executing this script, it is highly recommended to <span class="warning">open the include file <em>initialize/db.inc.php</em></span> in a text editor and edit the values of the variables <em>$databaseName</em>, <em>$username</em> and <em>$password</em> to suit your setup! Then, proceed with this form:
  156. </td>
  157. </tr>
  158. <tr>
  159. <td valign="top"><b>MySQL admin user:</b></td>
  160. <td valign="top"><?php echo fieldError("adminUserName", $errors); ?>
  161. <input type="text" name="adminUserName" value="<?php echo $formVars["adminUserName"]; ?>" size="30">
  162. </td>
  163. <td valign="top">Give the name of an administrative user that has full access to the MySQL admin database. Often, this is the <em>root</em> user.</td>
  164. </tr>
  165. <tr>
  166. <td valign="top"><b>MySQL admin password:</b></td>
  167. <td valign="top"><?php
  168. // the form won't remember the password, so we'll ask the user to re-type it...
  169. if (!empty($errors) AND !isset($errors["adminPassword"])) // ...if there were some validation errors but not with the password field
  170. echo "\n\t\t\t<b>Please type your password again:</b>\n\t\t\t<br>";
  171. else
  172. echo fieldError("adminPassword", $errors);
  173. ?>
  174. <input type="password" name="adminPassword" size="30">
  175. </td>
  176. <td valign="top">Please enter the password for the administrative user you've specified above.</td>
  177. </tr>
  178. <tr>
  179. <td valign="top"><b>Path to the MySQL application:</b></td>
  180. <td valign="top"><?php echo fieldError("pathToMYSQL", $errors); ?>
  181. <input type="text" name="pathToMYSQL" value="<?php echo $formVars["pathToMYSQL"]; ?>" size="30">
  182. </td>
  183. <td valign="top">Specify the full path to the <em>mysql</em> command line interpreter. The install script attempts to locate the <em>mysql</em> program for you. If the field is empty, please enter the full path manually.</td>
  184. </tr>
  185. <tr>
  186. <td valign="top"><b>Path to the database structure file:</b></td>
  187. <td valign="top"><?php echo fieldError("databaseStructureFile", $errors); ?>
  188. <input type="text" name="databaseStructureFile" value="<?php echo $formVars["databaseStructureFile"]; ?>" size="30">
  189. </td>
  190. <td valign="top">Enter the full path to the SQL dump file containing the database structure &amp; data. Keep the default value, if you're installing refbase for the first time.</td>
  191. </tr>
  192. <tr>
  193. <td valign="top"><b>Path to the Bibutils directory [optional]:</b></td>
  194. <td valign="top"><?php echo fieldError("pathToBibutils", $errors); ?>
  195. <input type="text" name="pathToBibutils" value="<?php echo $formVars["pathToBibutils"]; ?>" size="30">
  196. </td>
  197. <td valign="top"><a href="http://bibutils.refbase.net/" target="top" title="more info about the refbase integration with Bibutils"><em>Bibutils</em></a> provides additional import and export funtionality to refbase (e.g. support for Endnote &amp; BibTeX). It is optional, but highly recommended. The install script attempts to locate <em>Bibutils</em> for you. If you can't access <em>Bibutils</em> from your path, please fill this value in manually (and, if you think other people might have <em>Bibutils</em> installed to the same path, <a href="http://support.refbase.net/" target="top" title="refbase forums &amp; mailinglists">report</a> it to the refbase developers). The path must end with a slash!</td>
  198. </tr>
  199. <tr>
  200. <td valign="top"><b>Default character set:</b></td>
  201. <td valign="top"><?php echo fieldError("defaultCharacterSet", $errors); ?>
  202. <select name="defaultCharacterSet">
  203. <option<?php echo $latin1CharacterSetSelected; ?>>latin1</option>
  204. <option<?php echo $unicodeCharacterSetSelected; ?>>utf8</option>
  205. </select>
  206. </td>
  207. <td valign="top">Specify the default character set for the MySQL database used by refbase. Note that <em>utf8</em> (Unicode) requires MySQL 4.1.x or greater, otherwise <em>latin1</em> (i.e., ISO-8859-1 West European) will be used by default.</td>
  208. </tr>
  209. <tr>
  210. <td valign="top">&nbsp;</td>
  211. <td valign="top" align="right">
  212. <input type="submit" name="submit" value="Install">
  213. </td>
  214. <td valign="top"><span class="warning">CAUTION:</span> Note that, if there's already an existing refbase database with the name specified in <em>$databaseName</em>, clicking the <em>Install</em> button will overwrite ALL data in that database! If you'd like to install the refbase tables into another existing database, you must ensure that there are no table name conflicts (<a href="http://install.refbase.net/" target="top" title="howto install refbase over an existing database">more info</a>).</td>
  215. </tr>
  216. </table>
  217. </form><?php
  218. // --------------------------------------------------------------------
  219. // DISPLAY THE HTML FOOTER:
  220. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  221. showPageFooter($HeaderString);
  222. displayHTMLfoot();
  223. // --------------------------------------------------------------------
  224. }
  225. else // some parameters have been passed, so let's validate the fields:
  226. {
  227. // --------------------------------------------------------------------
  228. // Clear any errors that might have been found previously:
  229. $errors = array();
  230. // Write the (POST) form variables into an array:
  231. foreach($_POST as $varname => $value)
  232. $formVars[$varname] = $value;
  233. // Validate the 'adminUserName' field:
  234. if (empty($formVars["adminUserName"]))
  235. // The 'adminUserName' field cannot be a null string
  236. $errors["adminUserName"] = "This field cannot be blank:";
  237. // Validate the 'adminPassword' field:
  238. if (empty($formVars["adminPassword"]))
  239. // The 'adminPassword' field cannot be a null string
  240. $errors["adminPassword"] = "This field cannot be blank:";
  241. // Validate the 'pathToMYSQL' field:
  242. if (empty($formVars["pathToMYSQL"]))
  243. // The 'pathToMYSQL' field cannot be a null string
  244. $errors["pathToMYSQL"] = "This field cannot be blank:";
  245. elseif (preg_match("/[;|]/", $formVars["pathToMYSQL"]))
  246. // For security reasons, the 'pathToMYSQL' field cannot contain the characters ';' or '|' (which would tie multiple shell commands together)
  247. $errors["pathToMYSQL"] = "Due to security reasons this field cannot contain the characters ';' or '|':";
  248. elseif (is_dir($formVars["pathToMYSQL"]))
  249. // Check if the specified path resolves to a directory
  250. $errors["pathToMYSQL"] = "You cannot specify a directory! Please give the path to the mysql command:";
  251. elseif (!is_readable($formVars["pathToMYSQL"]))
  252. // Check if the specified path resolves to the mysql application
  253. $errors["pathToMYSQL"] = "Your path specification is invalid (command not found):";
  254. // Note: Currently, the checks for whether the function is executable or whether it is mysql have been commented out,
  255. // since they don't seem to work on windows! (see <http://sourceforge.net/forum/forum.php?thread_id=1021143&forum_id=218758>)
  256. // elseif (!is_executable($formVars["pathToMYSQL"]))
  257. // // Check if the given file is executable
  258. // $errors["pathToMYSQL"] = "This file does not appear to be an executable command:";
  259. // elseif (!preg_match("#(^|.*/)mysql$#", $formVars["pathToMYSQL"]))
  260. // // Make sure that the given file is 'mysql'
  261. // $errors["pathToMYSQL"] = "This does not appear to be the 'mysql' command line interpreter:";
  262. // Validate the 'databaseStructureFile' field:
  263. if (empty($formVars["databaseStructureFile"]))
  264. // The 'databaseStructureFile' field cannot be a null string
  265. $errors["databaseStructureFile"] = "This field cannot be blank:";
  266. elseif (preg_match("/[;|]/", $formVars["databaseStructureFile"]))
  267. // For security reasons, the 'databaseStructureFile' field cannot contain the characters ';' or '|' (which would tie multiple shell commands together)
  268. $errors["databaseStructureFile"] = "Due to security reasons this field cannot contain the characters ';' or '|':";
  269. elseif (is_dir($formVars["databaseStructureFile"]))
  270. // Check if the specified path resolves to a directory
  271. $errors["databaseStructureFile"] = "You cannot specify a directory! Please give the path to the database structure file:";
  272. elseif (!is_readable($formVars["databaseStructureFile"]))
  273. // Check if the specified path resolves to the database structure file
  274. $errors["databaseStructureFile"] = "Your path specification is invalid (file not found):";
  275. // Validate the 'pathToBibutils' field:
  276. if (!empty($formVars["pathToBibutils"])) // we'll only validate the 'pathToBibutils' field if it isn't empty (installation of Bibutils is optional)
  277. {
  278. if (preg_match("/[;|]/", $formVars["pathToBibutils"]))
  279. // For security reasons, the 'pathToBibutils' field cannot contain the characters ';' or '|' (which would tie multiple shell commands together)
  280. $errors["pathToBibutils"] = "Due to security reasons this field cannot contain the characters ';' or '|':";
  281. elseif (!is_readable($formVars["pathToBibutils"]))
  282. // Check if the specified path resolves to an existing directory
  283. $errors["pathToBibutils"] = "Your path specification is invalid (directory not found):";
  284. elseif (!is_dir($formVars["pathToBibutils"]))
  285. // Check if the specified path resolves to a directory (and not a file)
  286. $errors["pathToBibutils"] = "You must specify a directory! Please give the path to the directory containing the Bibutils utilities:";
  287. }
  288. // Validate the 'defaultCharacterSet' field:
  289. // Note: Currently we're not generating an error & rooting back to the install form, if the user did choose 'utf8' but has some MySQL version < 4.1 installed.
  290. // In this case, we'll simply ignore the setting and 'latin1' will be used by default.
  291. // --------------------------------------------------------------------
  292. // Now the script has finished the validation, check if there were any errors:
  293. if (count($errors) > 0)
  294. {
  295. // Write back session variables:
  296. saveSessionVariable("errors", $errors); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  297. saveSessionVariable("formVars", $formVars);
  298. // There are errors. Relocate back to the installation form:
  299. header("Location: install.php");
  300. exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  301. }
  302. // --------------------------------------------------------------------
  303. // If we made it here, then the data is considered valid!
  304. // (1) Open the database connection and use the mysql database:
  305. if (!($connection = @ mysql_connect($hostName,$adminUserName,$adminPassword)))
  306. if (mysql_errno() != 0) // this works around a stupid(?) behaviour of the Roxen webserver that returns 'errno: 0' on success! ?:-(
  307. showErrorMsg("The following error occurred while trying to connect to the host:", "");
  308. if (!(mysql_select_db($adminDatabaseName, $connection)))
  309. if (mysql_errno() != 0) // this works around a stupid(?) behaviour of the Roxen webserver that returns 'errno: 0' on success! ?:-(
  310. showErrorMsg("The following error occurred while trying to connect to the database:", "");
  311. // First, check if we're a dealing with MySQL version 4.1.x or greater:
  312. // (MySQL 4.1.x is required if the refbase MySQL database/tables shall be installed using Unicode/UTF-8 as default character set)
  313. $mysqlVersion = getMySQLversion(); // function 'getMySQLversion()' is defined in 'include.inc.php'
  314. // --------------------------------------------------------------------
  315. // Prepare the install queries and proceed with the actual installation procedure:
  316. // Build the database queries required for installation:
  317. $queryGrantStatement = "GRANT SELECT,INSERT,UPDATE,DELETE ON " . $databaseName . ".* TO " . quote_smart($username) . "@" . quote_smart($hostName) . " IDENTIFIED BY " . quote_smart($password);
  318. $queryCreateDB = "CREATE DATABASE IF NOT EXISTS " . $databaseName; // by default, 'latin1' will be used as default character set
  319. if ($mysqlVersion >= 4.1) // if MySQL 4.1.x (or greater) is installed...
  320. {
  321. $queryCreateDB = $queryCreateDB . " DEFAULT CHARACTER SET " . $defaultCharacterSet; // ...add the default character set chosen by the user
  322. if ($defaultCharacterSet == "utf8") // ...in case of UTF-8, adjust the path to the default database structure file if necessary
  323. if ($databaseStructureFile == "./install.sql")
  324. $databaseStructureFile = "./install_utf8.sql";
  325. }
  326. if (!empty($pathToBibutils)) // we'll only update the Bibutils path if '$pathToBibutils' isn't empty (installation of Bibutils is optional)
  327. $queryUpdateDependsTable = "UPDATE " . $databaseName . "." . $tableDepends . " SET depends_path = " . quote_smart($pathToBibutils) . " WHERE depends_external = \"bibutils\""; // update the Bibutils path spec
  328. else // we set the 'depends_enabled' field in table 'depends' to 'false' to indicate that Bibutils isn't installed
  329. $queryUpdateDependsTable = "UPDATE " . $databaseName . "." . $tableDepends . " SET depends_enabled = \"false\" WHERE depends_external = \"bibutils\""; // disable Bibutils functionality
  330. // (2) Run the INSTALL queries on the mysql database through the connection:
  331. if (!($result = @ mysql_query ($queryGrantStatement, $connection)))
  332. if (mysql_errno() != 0) // this works around a stupid(?) behaviour of the Roxen webserver that returns 'errno: 0' on success! ?:-(
  333. showErrorMsg("The following error occurred while trying to query the database:", "");
  334. if (!($result = @ mysql_query ($queryCreateDB, $connection)))
  335. if (mysql_errno() != 0) // this works around a stupid(?) behaviour of the Roxen webserver that returns 'errno: 0' on success! ?:-(
  336. showErrorMsg("The following error occurred while trying to query the database:", "");
  337. // IMPORT the literature database structure from file:
  338. exec($pathToMYSQL . " -h " . $hostName . " -u " . $adminUserName . " -p" . $adminPassword . " --database=" . $databaseName . " < " . $databaseStructureFile . " 2>&1", $resultArray);
  339. // User note from <http://de2.php.net/manual/en/ref.exec.php> regarding the use of PHP's 'exec()' command:
  340. // From 'eremy at ntb dot co dot nz' (28-Sep-2003 03:18):
  341. // If an error occurs in the code you're trying to exec(), it can be challenging to figure out what's going
  342. // wrong, since php echoes back the stdout stream rather than the stderr stream where all the useful error
  343. // reporting's done. The solution is to add the code "2>&1" to the end of your shell command, which redirects
  344. // stderr to stdout, which you can then easily print using something like print `shellcommand 2>&1`.
  345. // run the UPDATE query on the depends table of the (just imported) literature database:
  346. if (!($result = @ mysql_query ($queryUpdateDependsTable, $connection)))
  347. if (mysql_errno() != 0) // this works around a stupid(?) behaviour of the Roxen webserver that returns 'errno: 0' on success! ?:-(
  348. showErrorMsg("The following error occurred while trying to query the database:", "");
  349. // (5) Close the database connection:
  350. if (!(mysql_close($connection)))
  351. if (mysql_errno() != 0) // this works around a stupid(?) behaviour of the Roxen webserver that returns 'errno: 0' on success! ?:-(
  352. showErrorMsg("The following error occurred while trying to disconnect from the database:", "");
  353. $resultLines = ""; // initialize variable
  354. // Read out the execution result array:
  355. if (!empty($resultArray)) // if there were any execution errors
  356. {
  357. reset($resultArray); // reset the internal array pointer to the first element
  358. while (list ($key, $val) = each ($resultArray))
  359. $resultLines .= "\n" . trim($val); // append each of the array elements to a string
  360. }
  361. // --------------------------------------------------------------------
  362. // Provide a feedback page:
  363. // If there's no stored message available:
  364. if (!isset($_SESSION['HeaderString'])) // provide one of the default messages:
  365. {
  366. if (!empty($resultArray)) // if there were any execution errors
  367. $HeaderString = "The following error occurred while trying to import the SQL data into the database:";
  368. else // assume that the installation was successful
  369. $HeaderString = "Installation of the Web Reference Database was successful!";
  370. }
  371. else
  372. {
  373. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  374. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  375. deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  376. }
  377. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  378. // ('' will produce the default 'Web' output style)
  379. if (isset($_REQUEST['viewType']))
  380. $viewType = $_REQUEST['viewType'];
  381. else
  382. $viewType = "";
  383. // Show the login status:
  384. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  385. // DISPLAY header:
  386. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  387. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Installation Feedback", "index,follow", "Installation feedback for the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  388. showPageHeader($HeaderString);
  389. // Start a <table>:
  390. ?>
  391. <table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds the installation feedback info"><?php
  392. if (!empty($resultArray)) // if there were any execution errors:
  393. {
  394. ?>
  395. <tr>
  396. <td valign="top"><b>Error:</b></td>
  397. <td><?php echo encodeHTML($resultLines); ?></td>
  398. </tr>
  399. <tr>
  400. <td valign="top">&nbsp;</td>
  401. <td>
  402. <b>Please make sure that you've specified the correct path to the MySQL database structure file!</b>
  403. </td>
  404. </tr>
  405. <tr>
  406. <td valign="top">&nbsp;</td>
  407. <td>
  408. <a href="install.php">Go Back</a>
  409. </td>
  410. </tr><?php
  411. }
  412. else // no execution errors -> inform the user about successful database installation:
  413. {
  414. ?>
  415. <tr>
  416. <td colspan="2"><h3>Welcome to refbase!</h3></td>
  417. </tr>
  418. <tr>
  419. <td valign="top"><b>Important Note:</b></td>
  420. <td>
  421. The <em>install.php</em> script is only provided for installation purposes and is not needed anymore. Due to security considerations you should <span class="warning">remove this script</span> from your web directory NOW!!
  422. </td>
  423. </tr>
  424. <tr>
  425. <td valign="top"><b>Setup users:</b></td>
  426. <td>
  427. Here's how to setup the admin user account for your newly created literature database:
  428. <ul type="circle">
  429. <li>Goto <a href="index.php" target="_blank" title="Open the main page in a new window"><?php echo encodeHTML($officialDatabaseName); ?></a></li>
  430. <li>Login with email address = <em>user@refbase.net</em> &amp; password = <em>start</em></li>
  431. <li>Click on <em>Add User</em> and enter the name, institutional abbreviation, email address and password of the admin user</li>
  432. <li>Open the file <em>ini.inc.php</em> in a text editor and change the value of the <em>$adminLoginEmail</em> variable to the email address you've specified for the admin user</li>
  433. <li>Log out, then login again using the email address and password of your newly created admin account</li>
  434. </ul>
  435. If you want to add additional users use the <em>Add User</em> link and enter the user's name, institutional abbreviation, email address and password.
  436. </td>
  437. </tr>
  438. <tr>
  439. <td valign="top"><b>Configure refbase:</b></td>
  440. <td>
  441. In order to customize your literature database, please open again <em>ini.inc.php</em> in a text editor. This include file contains variables that are common to all scripts and whose values can/must be adopted to your needs. Please see the comments within the file for further information.
  442. </td>
  443. </tr><?php
  444. }
  445. ?>
  446. </table><?php
  447. // --------------------------------------------------------------------
  448. // DISPLAY THE HTML FOOTER:
  449. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  450. showPageFooter($HeaderString);
  451. displayHTMLfoot();
  452. // --------------------------------------------------------------------
  453. }
  454. ?>