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.

573 lines
28 KiB

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