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.

999 lines
58 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: ./update.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/update.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 01-Mar-05, 20:47
  15. // Modified: $Date: 2015-02-16 20:53:19 +0000 (Mon, 16 Feb 2015) $
  16. // $Author: karnesky $
  17. // $Revision: 1405 $
  18. // This file will update any refbase MySQL database installation from v0.8.0 or greater to v0.9.6.
  19. // (Note that this script currently doesn't offer any conversion from 'latin1' to 'utf8')
  20. // CAUTION: YOU MUST REMOVE THIS SCRIPT FROM YOUR WEB DIRECTORY AFTER THE UPDATE!!
  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($_REQUEST['adminUserName']))
  42. $adminUserName = $_REQUEST['adminUserName'];
  43. else
  44. $adminUserName = "";
  45. if (isset($_REQUEST['adminPassword']))
  46. $adminPassword = $_REQUEST['adminPassword'];
  47. else
  48. $adminPassword = "";
  49. // --------------------------------------------------------------------
  50. // Check the correct parameters have been passed:
  51. if (empty($adminUserName) AND empty($adminPassword))
  52. {
  53. // if 'update.php' was called without any valid parameters:
  54. // Display an update form:
  55. if (isset($_SESSION['errors']))
  56. {
  57. $errors = $_SESSION['errors'];
  58. // Note: though we clear the session variable, the current error message is still available to this script via '$errors':
  59. deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  60. }
  61. else
  62. $errors = array(); // initialize the '$errors' variable in order to prevent 'Undefined variable...' messages
  63. if (isset($_SESSION['formVars']))
  64. {
  65. $formVars = $_SESSION['formVars'];
  66. // Note: though we clear the session variable, the current form variables are still available to this script via '$formVars':
  67. deleteSessionVariable("formVars");
  68. }
  69. else
  70. {
  71. // Reset the '$formVars' variable (since we're providing the default values):
  72. $formVars = array();
  73. // provide the default values:
  74. $formVars["adminUserName"] = "root";
  75. $formVars["adminPassword"] = "";
  76. }
  77. // If there's no stored message available:
  78. if (!isset($_SESSION['HeaderString']))
  79. {
  80. if (empty($errors)) // provide the default message:
  81. $HeaderString = "To update refbase v0.8.0 or greater please fill out the form below and click the Update button:";
  82. else // -> there were errors when validating the fields
  83. $HeaderString = "There were validation errors regarding the details you entered. Please check the comments above the respective fields:";
  84. }
  85. else
  86. {
  87. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  88. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  89. deleteSessionVariable("HeaderString");
  90. }
  91. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  92. // ('' will produce the default 'Web' output style)
  93. if (isset($_REQUEST['viewType']))
  94. $viewType = $_REQUEST['viewType'];
  95. else
  96. $viewType = "";
  97. // Show the login status:
  98. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  99. // DISPLAY header:
  100. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  101. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Update", "index,follow", "Update form for the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  102. showPageHeader($HeaderString);
  103. // Start <form> and <table> holding the form elements:
  104. ?>
  105. <form action="update.php" method="POST">
  106. <input type="hidden" name="formType" value="update">
  107. <input type="hidden" name="submit" value="Update"><?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 "Update" button) ?>
  108. <table align="center" border="0" cellpadding="0" cellspacing="12" width="95%" summary="This table holds the update form">
  109. <tr>
  110. <td colspan="3"><h3>refbase Update</h3></td>
  111. </tr>
  112. <tr>
  113. <td width="190" valign="top"><b>Important Notes:</b></td>
  114. <td valign="top" colspan="2">
  115. It's important that you make a <span class="warning">backup</span> copy of your original files <em>db.inc.php</em> and <em>ini.inc.php</em> (which are located within the <em>initialize</em> subdirectory of your refbase base directory). We also strongly recommend to <a href="http://backup.refbase.net/" target="top" title="Instructions how to backup your refbase MySQL database">backup</a> your existing refbase MySQL database before proceeding.
  116. <br>
  117. <br>
  118. Before executing this script, you <span class="warning">must edit</span> the updated include file <span class="warning"><em>initialize/db.inc.php</em></span> in a text editor and re-enter the values from your old <em>db.inc.php</em> file for the variables <em>$databaseName</em>, <em>$username</em> and <em>$password</em>. Then, proceed with this form:
  119. </td>
  120. </tr>
  121. <tr>
  122. <td valign="top"><b>MySQL Admin User:</b></td>
  123. <td valign="top"><?php echo fieldError("adminUserName", $errors); ?>
  124. <input type="text" name="adminUserName" value="<?php echo encodeHTML($formVars["adminUserName"]); ?>" size="30">
  125. </td>
  126. <td valign="top">Give the name of an administrative user that has full access to your MySQL database. Often, this is the <em>root</em> user.</td>
  127. </tr>
  128. <tr>
  129. <td valign="top"><b>MySQL Admin Password:</b></td>
  130. <td valign="top"><?php
  131. // the form won't remember the password, so we'll ask the user to re-type it...
  132. if (!empty($errors) AND !isset($errors["adminPassword"])) // ...if there were some validation errors but not with the password field
  133. echo "\n\t\t\t<b>Please type your password again:</b>\n\t\t\t<br>";
  134. else
  135. echo fieldError("adminPassword", $errors);
  136. ?>
  137. <input type="password" name="adminPassword" size="30">
  138. </td>
  139. <td valign="top">Please enter the password for the administrative user you've specified above.</td>
  140. </tr>
  141. <tr>
  142. <td valign="top">&nbsp;</td>
  143. <td valign="top" align="right">
  144. <input type="submit" name="submit" value="Update">
  145. </td>
  146. <td valign="top">&nbsp;</td>
  147. </tr>
  148. </table>
  149. </form><?php
  150. // --------------------------------------------------------------------
  151. // DISPLAY THE HTML FOOTER:
  152. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  153. showPageFooter($HeaderString);
  154. displayHTMLfoot();
  155. // --------------------------------------------------------------------
  156. }
  157. else // some parameters have been passed, so let's validate the fields:
  158. {
  159. // --------------------------------------------------------------------
  160. // Clear any errors that might have been found previously:
  161. $errors = array();
  162. // Write the (POST) form variables into an array:
  163. foreach($_POST as $varname => $value)
  164. $formVars[$varname] = $value;
  165. // Validate the 'adminUserName' field:
  166. if (empty($formVars["adminUserName"]))
  167. // The 'adminUserName' field cannot be a null string
  168. $errors["adminUserName"] = "This field cannot be blank:";
  169. // Validate the 'adminPassword' field:
  170. if (empty($formVars["adminPassword"]))
  171. // The 'adminPassword' field cannot be a null string
  172. $errors["adminPassword"] = "This field cannot be blank:";
  173. // --------------------------------------------------------------------
  174. // Now the script has finished the validation, check if there were any errors:
  175. if (count($errors) > 0)
  176. {
  177. // Write back session variables:
  178. saveSessionVariable("errors", $errors); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  179. saveSessionVariable("formVars", $formVars);
  180. // There are errors. Relocate back to the update form:
  181. header("Location: update.php");
  182. exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  183. }
  184. // --------------------------------------------------------------------
  185. // If we made it here, then the data is considered valid!
  186. // (0) CLOSE EXISTING CONNECTION
  187. // we have to close the existing connection since we need to establish a new connection with admin permissions
  188. disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php'
  189. // (1) OPEN ADMIN CONNECTION, (2) SELECT DATABASE
  190. connectToMySQLDatabaseAsAdmin($adminUserName, $adminPassword); // function 'connectToMySQLDatabaseAsAdmin()' is defined in 'install.inc.php'
  191. // --------------------------------------------------------------------
  192. // (2) RUN the SQL queries on the database through the admin connection:
  193. // NOTE: many simple, brain-dead UPDATE queries follow below
  194. // (we should probably have a SQL function and/or make this an array and process that)
  195. $resultArray = array();
  196. // Alter table specification for table 'deleted'
  197. // TODO: create a new function 'changeColumn()' that only modifies the column spec if the new column spec is different from the old one
  198. $query = "ALTER table " . $tableDeleted . " MODIFY edition varchar(50) default NULL";
  199. $result = queryMySQLDatabase($query);
  200. $resultArray["Table 'deleted': altered table specification. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0); // get the number of rows that were modified (or return 0 if an error occurred)
  201. $query = "ALTER table " . $tableDeleted . " MODIFY thesis enum('Bachelor''s thesis','Honours thesis','Master''s thesis','Ph.D. thesis','Diploma thesis','Doctoral thesis','Habilitation thesis') default NULL";
  202. $result = queryMySQLDatabase($query);
  203. $resultArray["Table 'deleted': altered table specification. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  204. // Alter table specification for table 'refs'
  205. $query = "ALTER table " . $tableRefs . " MODIFY edition varchar(50) default NULL";
  206. $result = queryMySQLDatabase($query);
  207. $resultArray["Table 'refs': altered table specification. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  208. $query = "ALTER table " . $tableRefs . " MODIFY thesis enum('Bachelor''s thesis','Honours thesis','Master''s thesis','Ph.D. thesis','Diploma thesis','Doctoral thesis','Habilitation thesis') default NULL";
  209. $result = queryMySQLDatabase($query);
  210. $resultArray["Table 'refs': altered table specification. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  211. // Add field 'version' to table 'deleted'
  212. $properties = "MEDIUMINT(8) UNSIGNED DEFAULT 1 AFTER modified_by";
  213. $resultArray["Table 'deleted': added field 'version'"] = addColumnIfNotExists("version", $tableDeleted, $properties); // function 'addColumnIfNotExists()' is defined in 'install.inc.php'
  214. // Add field 'version' to table 'refs'
  215. $properties = "MEDIUMINT(8) UNSIGNED DEFAULT 1 AFTER modified_by";
  216. $resultArray["Table 'refs': added field 'version'"] = addColumnIfNotExists("version", $tableRefs, $properties);
  217. // Update table 'refs'
  218. $query = "UPDATE " . $tableRefs . " SET thesis = NULL WHERE thesis = ''"; // this fix is required to ensure correct sorting when outputting citations with '$citeOrder="type"' or '$citeOrder="type-year"'
  219. $result = queryMySQLDatabase($query);
  220. $resultArray["Table 'refs': updated 'thesis' field (replaced empty string with NULL). Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  221. $query = "UPDATE " . $tableRefs . " SET type = 'Conference Article' WHERE type RLIKE '^(Unsupported: )?Conference Proceeding$'"; // this may not be perfect since some items of type "Conference Proceeding" may be actually a "Conference Volume"
  222. $result = queryMySQLDatabase($query);
  223. $resultArray["Table 'refs': updated 'type' field ('Conference Proceeding' => 'Conference Article'). Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  224. $query = "UPDATE " . $tableRefs . " SET type = 'Miscellaneous' WHERE type RLIKE '^(Unsupported: )?Generic$'";
  225. $result = queryMySQLDatabase($query);
  226. $resultArray["Table 'refs': updated 'type' field ('Generic' => 'Miscellaneous'). Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  227. $query = "UPDATE " . $tableRefs . " SET type = 'Newspaper Article' WHERE type RLIKE '^(Unsupported: )?Newspaper$'"; // this may not be perfect since some items of type "Newspaper" may be actually a "Newspaper Volume"
  228. $result = queryMySQLDatabase($query);
  229. $resultArray["Table 'refs': updated 'type' field ('Newspaper' => 'Newspaper Article'). Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  230. $query = "UPDATE " . $tableRefs . " SET type = 'Software' WHERE type RLIKE '^(Unsupported: )?Computer Program$'";
  231. $result = queryMySQLDatabase($query);
  232. $resultArray["Table 'refs': updated 'type' field ('Computer Program' => 'Software'). Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  233. $query = "UPDATE " . $tableRefs . " SET type = REPLACE(type,'Unsupported: ','') WHERE type RLIKE '^Unsupported: (Abstract|Conference (Article|Volume)|Magazine Article|Manual|Miscellaneous|Newspaper Article|Patent|Report|Software)$'";
  234. $result = queryMySQLDatabase($query);
  235. $resultArray["Table 'refs': updated 'type' field (removed 'Unsupported' label for all newly supported types). Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  236. // Add new utilities to table 'depends'
  237. $values = "(NULL, 'pdftotext', 'true', NULL)";
  238. $resultArray["Table 'depends': inserted entry for 'pdftotext' utility"] = insertIfNotExists(array("depends_external" => "pdftotext"), $tableDepends, $values);
  239. // Create new MySQL table 'user_options'
  240. $properties = "(option_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, "
  241. . "user_id MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0', "
  242. . "export_cite_keys ENUM('yes','no') NOT NULL DEFAULT 'yes', "
  243. . "autogenerate_cite_keys ENUM('yes','no') NOT NULL DEFAULT 'yes', "
  244. . "prefer_autogenerated_cite_keys ENUM('no','yes') NOT NULL DEFAULT 'no', "
  245. . "use_custom_cite_key_format ENUM('no','yes') NOT NULL DEFAULT 'no', "
  246. . "cite_key_format VARCHAR(255) DEFAULT NULL, "
  247. . "uniquify_duplicate_cite_keys ENUM('yes','no') NOT NULL DEFAULT 'yes', "
  248. . "nonascii_chars_in_cite_keys ENUM('transliterate','strip','keep') DEFAULT NULL, "
  249. . "use_custom_text_citation_format ENUM('no','yes') NOT NULL DEFAULT 'no', "
  250. . "text_citation_format VARCHAR(255) DEFAULT NULL, "
  251. . "records_per_page SMALLINT(5) UNSIGNED DEFAULT NULL, "
  252. . "show_auto_completions ENUM('yes','no') NOT NULL DEFAULT 'yes', "
  253. . "main_fields TEXT, "
  254. . "INDEX (user_id))";
  255. $resultArray["Created table 'user_options'"] = addTableIfNotExists($tableUserOptions, $properties); // function 'addTableIfNotExists()' is defined in 'install.inc.php'
  256. // Insert default user options for anyone who's not logged in
  257. $values = "(NULL, 0, 'yes', 'yes', 'no', 'no', '<:authors:><:year:>', 'yes', NULL, 'no', '<:authors[2| & | et al.]:>< :year:>< {:recordIdentifier:}>', NULL, 'author, title, publication, keywords, abstract')";
  258. $resultArray["Table 'user_options': inserted default options for anyone who's not logged in"] = insertIfNotExists(array("user_id" => 0), $tableUserOptions, $values); // function 'insertIfNotExists()' is defined in 'install.inc.php'
  259. // Insert default user options for all users
  260. // First, check how many users are contained in table 'users':
  261. $query = "SELECT user_id, first_name, last_name FROM " . $tableUsers;
  262. $result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php'
  263. $rowsFound = @ mysql_num_rows($result);
  264. if ($rowsFound > 0) // If there were rows (= user IDs) found ...
  265. {
  266. while ($row = @ mysql_fetch_array($result))
  267. {
  268. $values = "(NULL, " . $row['user_id'] . ", 'yes', 'yes', 'no', 'yes', '<:authors[2|+|++]:><:year:>', 'yes', 'transliterate', 'no', '<:authors[2| & | et al.]:>< :year:>< {:recordIdentifier:}>', NULL, 'author, title, publication, keywords, abstract')";
  269. $resultArray["Table 'user_options': inserted default options for user " . $row['user_id'] . " (" . $row['first_name'] . " " . $row['last_name'] . ")"] = insertIfNotExists(array("user_id" => $row['user_id']), $tableUserOptions, $values);
  270. }
  271. }
  272. // Add field 'records_per_page' to table 'user_options'
  273. $properties = "SMALLINT(5) UNSIGNED DEFAULT NULL AFTER text_citation_format";
  274. $resultArray["Table 'user_options': added field 'records_per_page'"] = addColumnIfNotExists("records_per_page", $tableUserOptions, $properties);
  275. // Add field 'show_auto_completions' to table 'user_options'
  276. $properties = "ENUM('yes','no') NOT NULL DEFAULT 'yes' AFTER records_per_page";
  277. $resultArray["Table 'user_options': added field 'show_auto_completions'"] = addColumnIfNotExists("show_auto_completions", $tableUserOptions, $properties);
  278. // Add field 'main_fields' to table 'user_options'
  279. $properties = "TEXT AFTER show_auto_completions";
  280. $resultArray["Table 'user_options': added field 'main_fields'"] = addColumnIfNotExists("main_fields", $tableUserOptions, $properties);
  281. // Add field 'allow_browse_view' to table 'user_permissions'
  282. $properties = "ENUM('yes','no') NOT NULL DEFAULT 'yes' AFTER allow_print_view";
  283. $resultArray["Table 'user_permissions': added field 'allow_browse_view'"] = addColumnIfNotExists("allow_browse_view", $tableUserPermissions, $properties);
  284. // Add field 'allow_list_view' to table 'user_permissions'
  285. $properties = "ENUM('yes','no') NOT NULL DEFAULT 'yes' AFTER allow_upload";
  286. $resultArray["Table 'user_permissions': added field 'allow_list_view'"] = addColumnIfNotExists("allow_list_view", $tableUserPermissions, $properties);
  287. // Disable the Browse view feature (which isn't done yet) for all users
  288. $query= "UPDATE " . $tableUserPermissions . " SET allow_browse_view = 'no'";
  289. $result = queryMySQLDatabase($query);
  290. $resultArray["Table 'user_permissions': disabled the Browse view feature (which isn't done yet). Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  291. // Enable the Export feature for anyone who's not logged in ('$userID = 0'):
  292. $query= "UPDATE " . $tableUserPermissions . " SET allow_export = 'yes', allow_batch_export = 'yes' WHERE user_id = 0";
  293. $result = queryMySQLDatabase($query);
  294. $resultArray["Table 'user_permissions': enabled the export feature for anyone who's not logged in. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  295. // Update table 'styles'
  296. $query = "UPDATE " . $tableStyles . " SET style_spec = REPLACE(style_spec,'cite_','styles/cite_') WHERE style_spec RLIKE '^cite_'";
  297. $result = queryMySQLDatabase($query);
  298. $resultArray["Table 'styles': updated 'style_spec' field. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  299. $values = "(NULL, 'Ann Glaciol', 'true', 'styles/cite_AnnGlaciol_JGlaciol.php', 'B010', '1')";
  300. $resultArray["Table 'styles': inserted style 'Ann Glaciol'"] = insertIfNotExists(array("style_name" => "Ann Glaciol"), $tableStyles, $values);
  301. $values = "(NULL, 'J Glaciol', 'true', 'styles/cite_AnnGlaciol_JGlaciol.php', 'B030', '1')";
  302. $resultArray["Table 'styles': inserted style 'J Glaciol'"] = insertIfNotExists(array("style_name" => "J Glaciol"), $tableStyles, $values);
  303. $values = "(NULL, 'APA', 'true', 'styles/cite_APA.php', 'A010', '1')";
  304. $resultArray["Table 'styles': inserted style 'APA'"] = insertIfNotExists(array("style_name" => "APA"), $tableStyles, $values);
  305. $values = "(NULL, 'AMA', 'true', 'styles/cite_AMA.php', 'A020', '1')";
  306. $resultArray["Table 'styles': inserted style 'AMA'"] = insertIfNotExists(array("style_name" => "AMA"), $tableStyles, $values);
  307. $values = "(NULL, 'MLA', 'true', 'styles/cite_MLA.php', 'A030', '1')";
  308. $resultArray["Table 'styles': inserted style 'MLA'"] = insertIfNotExists(array("style_name" => "MLA"), $tableStyles, $values);
  309. $values = "(NULL, 'Chicago', 'true', 'styles/cite_Chicago.php', 'A070', '1')";
  310. $resultArray["Table 'styles': inserted style 'Chicago'"] = insertIfNotExists(array("style_name" => "Chicago"), $tableStyles, $values);
  311. $values = "(NULL, 'Harvard 1', 'true', 'styles/cite_Harvard_1.php', 'A090', '1')";
  312. $resultArray["Table 'styles': inserted style 'Harvard 1'"] = insertIfNotExists(array("style_name" => "Harvard 1"), $tableStyles, $values);
  313. $values = "(NULL, 'Harvard 2', 'true', 'styles/cite_Harvard_2.php', 'A093', '1')";
  314. $resultArray["Table 'styles': inserted style 'Harvard 2'"] = insertIfNotExists(array("style_name" => "Harvard 2"), $tableStyles, $values);
  315. $values = "(NULL, 'Harvard 3', 'true', 'styles/cite_Harvard_3.php', 'A096', '1')";
  316. $resultArray["Table 'styles': inserted style 'Harvard 3'"] = insertIfNotExists(array("style_name" => "Harvard 3"), $tableStyles, $values);
  317. $values = "(NULL, 'Vancouver', 'true', 'styles/cite_Vancouver.php', 'A110', '1')";
  318. $resultArray["Table 'styles': inserted style 'Vancouver'"] = insertIfNotExists(array("style_name" => "Vancouver"), $tableStyles, $values);
  319. $query = "UPDATE " . $tableStyles . " SET order_by = 'B010' WHERE style_name = 'Ann Glaciol'";
  320. $result = queryMySQLDatabase($query);
  321. $resultArray["Table 'styles': updated 'Ann Glaciol' style. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  322. $query = "UPDATE " . $tableStyles . " SET order_by = 'B020' WHERE style_name = 'Deep Sea Res'";
  323. $result = queryMySQLDatabase($query);
  324. $resultArray["Table 'styles': updated 'Deep Sea Res' style. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  325. $query = "UPDATE " . $tableStyles . " SET order_by = 'B030' WHERE style_name = 'J Glaciol'";
  326. $result = queryMySQLDatabase($query);
  327. $resultArray["Table 'styles': updated 'J Glaciol' style. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  328. $query = "UPDATE " . $tableStyles . " SET order_by = 'B040' WHERE style_name = 'Mar Biol'";
  329. $result = queryMySQLDatabase($query);
  330. $resultArray["Table 'styles': updated 'Mar Biol' style. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  331. $query = "UPDATE " . $tableStyles . " SET order_by = 'B050' WHERE style_name = 'MEPS'";
  332. $result = queryMySQLDatabase($query);
  333. $resultArray["Table 'styles': updated 'MEPS' style. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  334. $query = "UPDATE " . $tableStyles . " SET order_by = 'B060' WHERE style_name = 'Polar Biol'";
  335. $result = queryMySQLDatabase($query);
  336. $resultArray["Table 'styles': updated 'Polar Biol' style. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  337. $query = "UPDATE " . $tableStyles . " SET order_by = 'C010' WHERE style_name = 'Text Citation'";
  338. $result = queryMySQLDatabase($query);
  339. $resultArray["Table 'styles': updated 'Text Citation' style. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  340. // Update table 'types'
  341. $query = "UPDATE " . $tableTypes . " SET order_by = '01' WHERE type_name = 'Journal Article'";
  342. $result = queryMySQLDatabase($query);
  343. $resultArray["Table 'types': updated 'Journal Article' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  344. $query = "UPDATE " . $tableTypes . " SET order_by = '02' WHERE type_name = 'Abstract'";
  345. $result = queryMySQLDatabase($query);
  346. $resultArray["Table 'types': updated 'Abstract' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  347. $query = "UPDATE " . $tableTypes . " SET order_by = '03' WHERE type_name = 'Book Chapter'";
  348. $result = queryMySQLDatabase($query);
  349. $resultArray["Table 'types': updated 'Book Chapter' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  350. $query = "UPDATE " . $tableTypes . " SET order_by = '04' WHERE type_name = 'Book Whole'";
  351. $result = queryMySQLDatabase($query);
  352. $resultArray["Table 'types': updated 'Book Whole' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  353. $query = "UPDATE " . $tableTypes . " SET order_by = '05' WHERE type_name = 'Conference Article'";
  354. $result = queryMySQLDatabase($query);
  355. $resultArray["Table 'types': updated 'Conference Article' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  356. $query = "UPDATE " . $tableTypes . " SET order_by = '06' WHERE type_name = 'Conference Volume'";
  357. $result = queryMySQLDatabase($query);
  358. $resultArray["Table 'types': updated 'Conference Volume' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  359. $query = "UPDATE " . $tableTypes . " SET order_by = '07' WHERE type_name = 'Journal'";
  360. $result = queryMySQLDatabase($query);
  361. $resultArray["Table 'types': updated 'Journal' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  362. $query = "UPDATE " . $tableTypes . " SET order_by = '08' WHERE type_name = 'Magazine Article'";
  363. $result = queryMySQLDatabase($query);
  364. $resultArray["Table 'types': updated 'Magazine Article' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  365. $query = "UPDATE " . $tableTypes . " SET order_by = '09' WHERE type_name = 'Manual'";
  366. $result = queryMySQLDatabase($query);
  367. $resultArray["Table 'types': updated 'Manual' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  368. $query = "UPDATE " . $tableTypes . " SET order_by = '10' WHERE type_name = 'Manuscript'";
  369. $result = queryMySQLDatabase($query);
  370. $resultArray["Table 'types': updated 'Manuscript' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  371. $query = "UPDATE " . $tableTypes . " SET order_by = '11' WHERE type_name = 'Map'";
  372. $result = queryMySQLDatabase($query);
  373. $resultArray["Table 'types': updated 'Map' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  374. $query = "UPDATE " . $tableTypes . " SET order_by = '12' WHERE type_name = 'Miscellaneous'";
  375. $result = queryMySQLDatabase($query);
  376. $resultArray["Table 'types': updated 'Miscellaneous' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  377. $query = "UPDATE " . $tableTypes . " SET order_by = '13' WHERE type_name = 'Newspaper Article'";
  378. $result = queryMySQLDatabase($query);
  379. $resultArray["Table 'types': updated 'Newspaper Article' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  380. $query = "UPDATE " . $tableTypes . " SET order_by = '14' WHERE type_name = 'Patent'";
  381. $result = queryMySQLDatabase($query);
  382. $resultArray["Table 'types': updated 'Patent' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  383. $query = "UPDATE " . $tableTypes . " SET order_by = '15' WHERE type_name = 'Report'";
  384. $result = queryMySQLDatabase($query);
  385. $resultArray["Table 'types': updated 'Report' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  386. $query = "UPDATE " . $tableTypes . " SET order_by = '16' WHERE type_name = 'Software'";
  387. $result = queryMySQLDatabase($query);
  388. $resultArray["Table 'types': updated 'Software' type. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  389. $values = "(NULL, 'Abstract', 'true', 2, '02')";
  390. $resultArray["Table 'types': inserted type 'Abstract'"] = insertIfNotExists(array("type_name" => "Abstract"), $tableTypes, $values);
  391. $values = "(NULL, 'Conference Article', 'true', 2, '05')";
  392. $resultArray["Table 'types': inserted type 'Conference Article'"] = insertIfNotExists(array("type_name" => "Conference Article"), $tableTypes, $values);
  393. $values = "(NULL, 'Conference Volume', 'true', 3, '06')";
  394. $resultArray["Table 'types': inserted type 'Conference Volume'"] = insertIfNotExists(array("type_name" => "Conference Volume"), $tableTypes, $values);
  395. $values = "(NULL, 'Magazine Article', 'true', 1, '08')";
  396. $resultArray["Table 'types': inserted type 'Magazine Article'"] = insertIfNotExists(array("type_name" => "Magazine Article"), $tableTypes, $values);
  397. $values = "(NULL, 'Manual', 'true', 3, '09')";
  398. $resultArray["Table 'types': inserted type 'Manual'"] = insertIfNotExists(array("type_name" => "Manual"), $tableTypes, $values);
  399. $values = "(NULL, 'Miscellaneous', 'true', 3, '12')";
  400. $resultArray["Table 'types': inserted type 'Miscellaneous'"] = insertIfNotExists(array("type_name" => "Miscellaneous"), $tableTypes, $values);
  401. $values = "(NULL, 'Newspaper Article', 'true', 1, '13')";
  402. $resultArray["Table 'types': inserted type 'Newspaper Article'"] = insertIfNotExists(array("type_name" => "Newspaper Article"), $tableTypes, $values);
  403. $values = "(NULL, 'Patent', 'true', 3, '14')";
  404. $resultArray["Table 'types': inserted type 'Patent'"] = insertIfNotExists(array("type_name" => "Patent"), $tableTypes, $values);
  405. $values = "(NULL, 'Report', 'true', 3, '15')";
  406. $resultArray["Table 'types': inserted type 'Report'"] = insertIfNotExists(array("type_name" => "Report"), $tableTypes, $values);
  407. $values = "(NULL, 'Software', 'true', 3, '16')";
  408. $resultArray["Table 'types': inserted type 'Software'"] = insertIfNotExists(array("type_name" => "Software"), $tableTypes, $values);
  409. // Add new language options to table 'languages'
  410. $values = "(NULL, 'fr', 'true', '3')";
  411. $resultArray["Table 'languages': inserted French language option"] = insertIfNotExists(array("language_name" => "fr"), $tableLanguages, $values);
  412. $values = "(NULL, 'es', 'false', '4')";
  413. $resultArray["Table 'languages': inserted Spanish language option"] = insertIfNotExists(array("language_name" => "es"), $tableLanguages, $values);
  414. $values = "(NULL, 'cn', 'true', '5')";
  415. $resultArray["Table 'languages': inserted Chinese language option"] = insertIfNotExists(array("language_name" => "cn"), $tableLanguages, $values);
  416. $values = "(NULL, 'ru', 'true', '6')";
  417. $resultArray["Table 'languages': inserted Russian language option"] = insertIfNotExists(array("language_name" => "ru"), $tableLanguages, $values);
  418. $values = "(NULL, 'ja', 'true', '7')";
  419. $resultArray["Table 'languages': inserted Japanese language option"] = insertIfNotExists(array("language_name" => "ja"), $tableLanguages, $values);
  420. // Enable disabled localizations
  421. $query = "UPDATE " . $tableLanguages . " SET language_enabled = 'true' WHERE language_name = 'de'";
  422. $result = queryMySQLDatabase($query);
  423. $resultArray["Table 'languages': enabled German language option. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  424. // Alter table specification for table 'formats'
  425. $query = "ALTER table " . $tableFormats . " MODIFY format_type enum('export','import','cite') NOT NULL default 'export'";
  426. $result = queryMySQLDatabase($query);
  427. $resultArray["Table 'formats': altered table specification. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  428. // Update existing formats in table 'formats'
  429. $query = "UPDATE " . $tableFormats . " SET format_name = 'BibTeX' WHERE format_name = 'Bibtex'";
  430. $result = queryMySQLDatabase($query);
  431. $resultArray["Table 'formats': renamed format name 'Bibtex' to 'BibTeX'. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  432. // Update existing import formats in table 'formats'
  433. $query = "UPDATE " . $tableFormats . " SET format_spec = 'bibutils/import_bib2refbase.php', order_by = 'A010' WHERE format_name = 'BibTeX' AND format_type = 'import'";
  434. $result = queryMySQLDatabase($query);
  435. $resultArray["Table 'formats': updated 'BibTeX' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  436. $query = "UPDATE " . $tableFormats . " SET order_by = 'A020' WHERE format_name = 'Copac' AND format_type = 'import'";
  437. $result = queryMySQLDatabase($query);
  438. $resultArray["Table 'formats': updated 'Copac' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  439. $query = "UPDATE " . $tableFormats . " SET order_by = 'A030' WHERE format_name = 'CSA' AND format_type = 'import'";
  440. $result = queryMySQLDatabase($query);
  441. $resultArray["Table 'formats': updated 'CSA' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  442. $query = "UPDATE " . $tableFormats . " SET format_spec = 'bibutils/import_end2refbase.php', order_by = 'A040' WHERE format_name = 'Endnote' AND format_type = 'import'";
  443. $result = queryMySQLDatabase($query);
  444. $resultArray["Table 'formats': updated 'Endnote' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  445. $query = "UPDATE " . $tableFormats . " SET order_by = 'A045' WHERE format_name = 'Endnote XML' AND format_type = 'import'";
  446. $result = queryMySQLDatabase($query);
  447. $resultArray["Table 'formats': updated 'Endnote XML' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  448. $query = "UPDATE " . $tableFormats . " SET format_name = 'ISI', format_spec = 'import_isi2refbase.php', order_by = 'A050', depends_id = 1 WHERE (format_name = 'RIS (ISI)' OR format_name = 'ISI') AND format_type = 'import'";
  449. $result = queryMySQLDatabase($query);
  450. $resultArray["Table 'formats': updated 'ISI' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  451. $query = "UPDATE " . $tableFormats . " SET order_by = 'A060' WHERE format_name = 'Pubmed Medline' AND format_type = 'import'";
  452. $result = queryMySQLDatabase($query);
  453. $resultArray["Table 'formats': updated 'Pubmed Medline' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  454. $query = "UPDATE " . $tableFormats . " SET format_spec = 'bibutils/import_med2refbase.php', order_by = 'A065' WHERE format_name = 'Pubmed XML' AND format_type = 'import'";
  455. $result = queryMySQLDatabase($query);
  456. $resultArray["Table 'formats': updated 'Pubmed XML' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  457. $query = "UPDATE " . $tableFormats . " SET order_by = 'A070' WHERE format_name = 'RefWorks' AND format_type = 'import'";
  458. $result = queryMySQLDatabase($query);
  459. $resultArray["Table 'formats': updated 'RefWorks' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  460. $query = "UPDATE " . $tableFormats . " SET format_spec = 'import_ris2refbase.php', order_by = 'A080', depends_id = 1 WHERE format_name = 'RIS' AND format_type = 'import'";
  461. $result = queryMySQLDatabase($query);
  462. $resultArray["Table 'formats': updated 'RIS' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  463. $query = "UPDATE " . $tableFormats . " SET order_by = 'A090' WHERE format_name = 'SciFinder' AND format_type = 'import'";
  464. $result = queryMySQLDatabase($query);
  465. $resultArray["Table 'formats': updated 'SciFinder' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  466. $query = "UPDATE " . $tableFormats . " SET order_by = 'A100' WHERE format_name = 'Text (Tab-Delimited)' AND format_type = 'import'";
  467. $result = queryMySQLDatabase($query);
  468. $resultArray["Table 'formats': updated 'Text (Tab-Delimited)' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  469. $query = "UPDATE " . $tableFormats . " SET order_by = 'A150' WHERE format_name = 'CrossRef XML' AND format_type = 'import'";
  470. $result = queryMySQLDatabase($query);
  471. $resultArray["Table 'formats': updated 'CrossRef XML' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  472. $query = "UPDATE " . $tableFormats . " SET format_spec = 'bibutils/import_modsxml2refbase.php', order_by = 'A160', depends_id = 2 WHERE format_name = 'MODS XML' AND format_type = 'import'";
  473. $result = queryMySQLDatabase($query);
  474. $resultArray["Table 'formats': updated 'MODS XML' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  475. $query = "UPDATE " . $tableFormats . " SET order_by = 'A170' WHERE format_name = 'OAI_DC XML' AND format_type = 'import'";
  476. $result = queryMySQLDatabase($query);
  477. $resultArray["Table 'formats': updated 'OAI_DC XML' import format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  478. // Add new import formats in table 'formats'
  479. $values = "(NULL, 'Copac', 'import', 'true', 'bibutils/import_copac2refbase.php', 'A020', 2)";
  480. $resultArray["Table 'formats': inserted 'Copac' import format"] = insertIfNotExists(array("format_name" => "Copac", "format_type" => "import"), $tableFormats, $values);
  481. $values = "(NULL, 'CSA', 'import', 'true', 'import_csa2refbase.php', 'A030', 1)";
  482. $resultArray["Table 'formats': inserted 'CSA' import format"] = insertIfNotExists(array("format_name" => "CSA", "format_type" => "import"), $tableFormats, $values);
  483. $values = "(NULL, 'Endnote XML', 'import', 'true', 'bibutils/import_endx2refbase.php', 'A045', 2)";
  484. $resultArray["Table 'formats': inserted 'Endnote XML' import format"] = insertIfNotExists(array("format_name" => "Endnote XML", "format_type" => "import"), $tableFormats, $values);
  485. $values = "(NULL, 'Pubmed Medline', 'import', 'true', 'import_medline2refbase.php', 'A060', 1)";
  486. $resultArray["Table 'formats': inserted 'Pubmed Medline' import format"] = insertIfNotExists(array("format_name" => "Pubmed Medline", "format_type" => "import"), $tableFormats, $values);
  487. $values = "(NULL, 'RefWorks', 'import', 'true', 'import_refworks2refbase.php', 'A070', 1)";
  488. $resultArray["Table 'formats': inserted 'RefWorks' import format"] = insertIfNotExists(array("format_name" => "RefWorks", "format_type" => "import"), $tableFormats, $values);
  489. $values = "(NULL, 'SciFinder', 'import', 'true', 'import_scifinder2refbase.php', 'A090', 1)";
  490. $resultArray["Table 'formats': inserted 'SciFinder' import format"] = insertIfNotExists(array("format_name" => "SciFinder", "format_type" => "import"), $tableFormats, $values);
  491. $values = "(NULL, 'Text (Tab-Delimited)', 'import', 'true', 'import_tabdelim2refbase.php', 'A100', 1)";
  492. $resultArray["Table 'formats': inserted 'Text (Tab-Delimited)' import format"] = insertIfNotExists(array("format_name" => "Text (Tab-Delimited)", "format_type" => "import"), $tableFormats, $values);
  493. $values = "(NULL, 'arXiv XML', 'import', 'true', 'import_arxiv2refbase.php', 'A130', 1)";
  494. $resultArray["Table 'formats': inserted 'arXiv XML' import format"] = insertIfNotExists(array("format_name" => "arXiv XML", "format_type" => "import"), $tableFormats, $values);
  495. $values = "(NULL, 'CrossRef XML', 'import', 'true', 'import_crossref2refbase.php', 'A150', 1)";
  496. $resultArray["Table 'formats': inserted 'CrossRef XML' import format"] = insertIfNotExists(array("format_name" => "CrossRef XML", "format_type" => "import"), $tableFormats, $values);
  497. // Update existing export formats in table 'formats'
  498. $query = "UPDATE " . $tableFormats . " SET order_by = 'B010' WHERE format_name = 'BibTeX' AND format_type = 'export'";
  499. $result = queryMySQLDatabase($query);
  500. $resultArray["Table 'formats': updated 'BibTeX' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  501. $query = "UPDATE " . $tableFormats . " SET order_by = 'B040' WHERE format_name = 'Endnote' AND format_type = 'export'";
  502. $result = queryMySQLDatabase($query);
  503. $resultArray["Table 'formats': updated 'Endnote' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  504. $query = "UPDATE " . $tableFormats . " SET order_by = 'B050' WHERE format_name = 'ISI' AND format_type = 'export'";
  505. $result = queryMySQLDatabase($query);
  506. $resultArray["Table 'formats': updated 'ISI' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  507. $query = "UPDATE " . $tableFormats . " SET order_by = 'B080' WHERE format_name = 'RIS' AND format_type = 'export'";
  508. $result = queryMySQLDatabase($query);
  509. $resultArray["Table 'formats': updated 'RIS' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  510. $query = "UPDATE " . $tableFormats . " SET order_by = 'B105' WHERE format_name = 'Text (CSV)' AND format_type = 'export'";
  511. $result = queryMySQLDatabase($query);
  512. $resultArray["Table 'formats': updated 'Text (CSV)' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  513. $query = "UPDATE " . $tableFormats . " SET format_name = 'Atom XML', format_enabled = 'true', format_spec ='export_atomxml.php', order_by = 'B140' WHERE format_name = 'OpenSearch RSS' AND format_type = 'export'";
  514. $result = queryMySQLDatabase($query);
  515. $resultArray["Table 'formats': updated 'OpenSearch RSS' export format, and renamed it to 'Atom XML'. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  516. $query = "UPDATE " . $tableFormats . " SET order_by = 'B160' WHERE format_name = 'MODS XML' AND format_type = 'export'";
  517. $result = queryMySQLDatabase($query);
  518. $resultArray["Table 'formats': updated 'MODS XML' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  519. $query = "UPDATE " . $tableFormats . " SET order_by = 'B170' WHERE format_name = 'OAI_DC XML' AND format_type = 'export'";
  520. $result = queryMySQLDatabase($query);
  521. $resultArray["Table 'formats': updated 'OAI_DC XML' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  522. $query = "UPDATE " . $tableFormats . " SET order_by = 'B180' WHERE format_name = 'ODF XML' AND format_type = 'export'";
  523. $result = queryMySQLDatabase($query);
  524. $resultArray["Table 'formats': updated 'ODF XML' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  525. $query = "UPDATE " . $tableFormats . " SET format_name = 'SRW_MODS XML', order_by = 'B195' WHERE format_name = 'SRW XML' AND format_type = 'export'";
  526. $result = queryMySQLDatabase($query);
  527. $resultArray["Table 'formats': updated 'SRW XML' export format, and renamed it to 'SRW_MODS XML'. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  528. $query = "UPDATE " . $tableFormats . " SET order_by = 'B200' WHERE format_name = 'Word XML' AND format_type = 'export'";
  529. $result = queryMySQLDatabase($query);
  530. $resultArray["Table 'formats': updated 'Word XML' export format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  531. // Add new export formats in table 'formats'
  532. $values = "(NULL, 'ADS', 'export', 'true', 'bibutils/export_xml2ads.php', 'B005', 2)";
  533. $resultArray["Table 'formats': inserted 'ADS' export format"] = insertIfNotExists(array("format_name" => "ADS", "format_type" => "export"), $tableFormats, $values);
  534. $values = "(NULL, 'ISI', 'export', 'true', 'bibutils/export_xml2isi.php', 'B050', 2)";
  535. $resultArray["Table 'formats': inserted 'ISI' export format"] = insertIfNotExists(array("format_name" => "ISI", "format_type" => "export"), $tableFormats, $values);
  536. $values = "(NULL, 'Atom XML', 'export', 'true', 'export_atomxml.php', 'B140', 1)";
  537. $resultArray["Table 'formats': inserted 'Atom XML' export format"] = insertIfNotExists(array("format_name" => "Atom XML", "format_type" => "export"), $tableFormats, $values);
  538. $values = "(NULL, 'OAI_DC XML', 'export', 'true', 'export_oaidcxml.php', 'B170', 1)";
  539. $resultArray["Table 'formats': inserted 'OAI_DC XML' export format"] = insertIfNotExists(array("format_name" => "OAI_DC XML", "format_type" => "export"), $tableFormats, $values);
  540. $values = "(NULL, 'ODF XML', 'export', 'true', 'export_odfxml.php', 'B180', 1)";
  541. $resultArray["Table 'formats': inserted 'ODF XML' export format"] = insertIfNotExists(array("format_name" => "ODF XML", "format_type" => "export"), $tableFormats, $values);
  542. $values = "(NULL, 'SRW_DC XML', 'export', 'true', 'export_srwxml.php', 'B190', 1)";
  543. $resultArray["Table 'formats': inserted 'SRW_DC XML' export format"] = insertIfNotExists(array("format_name" => "SRW_DC XML", "format_type" => "export"), $tableFormats, $values);
  544. $values = "(NULL, 'SRW_MODS XML', 'export', 'true', 'export_srwxml.php', 'B195', 1)";
  545. $resultArray["Table 'formats': inserted 'SRW_MODS XML' export format"] = insertIfNotExists(array("format_name" => "SRW_MODS XML", "format_type" => "export"), $tableFormats, $values);
  546. $values = "(NULL, 'Word XML', 'export', 'true', 'bibutils/export_xml2word.php', 'B200', 2)";
  547. $resultArray["Table 'formats': inserted 'Word XML' export format"] = insertIfNotExists(array("format_name" => "Word XML", "format_type" => "export"), $tableFormats, $values);
  548. // Update existing citation formats in table 'formats'
  549. $query = "UPDATE " . $tableFormats . " SET order_by = 'C010' WHERE format_name = 'html' AND format_type = 'cite'";
  550. $result = queryMySQLDatabase($query);
  551. $resultArray["Table 'formats': updated 'html' citation format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  552. $query = "UPDATE " . $tableFormats . " SET order_by = 'C020' WHERE format_name = 'RTF' AND format_type = 'cite'";
  553. $result = queryMySQLDatabase($query);
  554. $resultArray["Table 'formats': updated 'RTF' citation format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  555. $query = "UPDATE " . $tableFormats . " SET order_by = 'C030' WHERE format_name = 'PDF' AND format_type = 'cite'";
  556. $result = queryMySQLDatabase($query);
  557. $resultArray["Table 'formats': updated 'PDF' citation format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  558. $query = "UPDATE " . $tableFormats . " SET order_by = 'C040' WHERE format_name = 'LaTeX' AND format_type = 'cite'";
  559. $result = queryMySQLDatabase($query);
  560. $resultArray["Table 'formats': updated 'LaTeX' citation format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  561. $query = "UPDATE " . $tableFormats . " SET order_by = 'C045' WHERE format_name = 'LaTeX .bbl' AND format_type = 'cite'";
  562. $result = queryMySQLDatabase($query);
  563. $resultArray["Table 'formats': updated 'LaTeX .bbl' citation format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  564. $query = "UPDATE " . $tableFormats . " SET order_by = 'C050' WHERE format_name = 'Markdown' AND format_type = 'cite'";
  565. $result = queryMySQLDatabase($query);
  566. $resultArray["Table 'formats': updated 'Markdown' citation format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  567. $query = "UPDATE " . $tableFormats . " SET order_by = 'C060' WHERE format_name = 'ASCII' AND format_type = 'cite'";
  568. $result = queryMySQLDatabase($query);
  569. $resultArray["Table 'formats': updated 'ASCII' citation format. Affected rows"] = ($result ? mysql_affected_rows($connection) : 0);
  570. // Add new citation formats in table 'formats'
  571. $values = "(NULL, 'html', 'cite', 'true', 'formats/cite_html.php', 'C010', 1)";
  572. $resultArray["Table 'formats': inserted 'html' citation format"] = insertIfNotExists(array("format_name" => "html", "format_type" => "cite"), $tableFormats, $values);
  573. $values = "(NULL, 'RTF', 'cite', 'true', 'formats/cite_rtf.php', 'C020', 1)";
  574. $resultArray["Table 'formats': inserted 'RTF' citation format"] = insertIfNotExists(array("format_name" => "RTF", "format_type" => "cite"), $tableFormats, $values);
  575. $values = "(NULL, 'PDF', 'cite', 'true', 'formats/cite_pdf.php', 'C030', 1)";
  576. $resultArray["Table 'formats': inserted 'PDF' citation format"] = insertIfNotExists(array("format_name" => "PDF", "format_type" => "cite"), $tableFormats, $values);
  577. $values = "(NULL, 'LaTeX', 'cite', 'true', 'formats/cite_latex.php', 'C040', 1)";
  578. $resultArray["Table 'formats': inserted 'LaTeX' citation format"] = insertIfNotExists(array("format_name" => "LaTeX", "format_type" => "cite"), $tableFormats, $values);
  579. $values = "(NULL, 'LaTeX .bbl', 'cite', 'true', 'formats/cite_latex_bbl.php', 'C045', 1)";
  580. $resultArray["Table 'formats': inserted 'LaTeX .bbl' citation format"] = insertIfNotExists(array("format_name" => "LaTeX .bbl", "format_type" => "cite"), $tableFormats, $values);
  581. $values = "(NULL, 'Markdown', 'cite', 'true', 'formats/cite_markdown.php', 'C050', 1)";
  582. $resultArray["Table 'formats': inserted 'Markdown' citation format"] = insertIfNotExists(array("format_name" => "Markdown", "format_type" => "cite"), $tableFormats, $values);
  583. $values = "(NULL, 'ASCII', 'cite', 'true', 'formats/cite_ascii.php', 'C060', 1)";
  584. $resultArray["Table 'formats': inserted 'ASCII' citation format"] = insertIfNotExists(array("format_name" => "ASCII", "format_type" => "cite"), $tableFormats, $values);
  585. // Enable some of the existing export formats (which were previously disabled by default) for anyone who's not logged in ('$userID = 0'):
  586. // Fetch IDs for all formats that shall be enabled:
  587. $formatIDArray = array();
  588. $query = "SELECT format_id, format_name FROM " . $tableFormats . " WHERE (format_name RLIKE '^(BibTeX|Endnote|RIS)$' AND format_type = 'export')";
  589. $result = queryMySQLDatabase($query);
  590. $rowsFound = @ mysql_num_rows($result);
  591. if ($rowsFound > 0)
  592. {
  593. while ($row = @ mysql_fetch_array($result))
  594. $formatIDArray[$row['format_id']] = $row['format_name'];
  595. }
  596. foreach ($formatIDArray as $formatID => $formatName)
  597. {
  598. $values = "(NULL, " . $formatID . ", 0, 'true')";
  599. $resultArray["Table 'user_formats': enabled format '" . $formatName . "' for anyone who's not logged in"] = insertIfNotExists(array("format_id" => $formatID), $tableUserFormats, $values, "0");
  600. }
  601. // Enable some of the newly created export/citation formats, citation styles & resource types for all users:
  602. // Fetch IDs for all formats that shall be enabled:
  603. $formatIDArray = array();
  604. $query = "SELECT format_id, format_name FROM " . $tableFormats . " WHERE (format_name RLIKE '^(ISI|ODF XML|Word XML)$' AND format_type = 'export') OR (format_name RLIKE '^(html|RTF|PDF|LaTeX)$' AND format_type = 'cite')";
  605. $result = queryMySQLDatabase($query);
  606. $rowsFound = @ mysql_num_rows($result);
  607. if ($rowsFound > 0)
  608. {
  609. while ($row = @ mysql_fetch_array($result))
  610. $formatIDArray[$row['format_id']] = $row['format_name'];
  611. }
  612. // Fetch IDs for all styles that shall be enabled:
  613. $styleIDArray = array();
  614. $query = "SELECT style_id, style_name FROM " . $tableStyles . " WHERE style_name RLIKE '^(AMA|APA|Chicago|Harvard( [0-9]+)?|J Glaciol|MLA|Vancouver)$'";
  615. $result = queryMySQLDatabase($query);
  616. $rowsFound = @ mysql_num_rows($result);
  617. if ($rowsFound > 0)
  618. {
  619. while ($row = @ mysql_fetch_array($result))
  620. $styleIDArray[$row['style_id']] = $row['style_name'];
  621. }
  622. // Fetch IDs for all types that shall be enabled:
  623. $typeIDArray = array();
  624. $query = "SELECT type_id, type_name FROM " . $tableTypes . " WHERE type_name RLIKE '^(Abstract|Conference Article|Conference Volume|Magazine Article|Manual|Miscellaneous|Newspaper Article|Patent|Report|Software)$'";
  625. $result = queryMySQLDatabase($query);
  626. $rowsFound = @ mysql_num_rows($result);
  627. if ($rowsFound > 0)
  628. {
  629. while ($row = @ mysql_fetch_array($result))
  630. $typeIDArray[$row['type_id']] = $row['type_name'];
  631. }
  632. // Enable formats, styles & types for anyone who's not logged in ('$userID = 0'):
  633. foreach ($formatIDArray as $formatID => $formatName)
  634. {
  635. $values = "(NULL, " . $formatID . ", 0, 'true')";
  636. $resultArray["Table 'user_formats': enabled format '" . $formatName . "' for anyone who's not logged in"] = insertIfNotExists(array("format_id" => $formatID), $tableUserFormats, $values, "0");
  637. }
  638. foreach ($styleIDArray as $styleID => $styleName)
  639. {
  640. $values = "(NULL, " . $styleID . ", 0, 'true')";
  641. $resultArray["Table 'user_styles': enabled style '" . $styleName . "' for anyone who's not logged in"] = insertIfNotExists(array("style_id" => $styleID), $tableUserStyles, $values, "0");
  642. }
  643. foreach ($typeIDArray as $typeID => $typeName)
  644. {
  645. $values = "(NULL, " . $typeID . ", 0, 'true')";
  646. $resultArray["Table 'user_types': enabled type '" . $typeName . "' for anyone who's not logged in"] = insertIfNotExists(array("type_id" => $typeID), $tableUserTypes, $values, "0");
  647. }
  648. // Enable formats, styles & types for all users:
  649. // First, check how many users are contained in table 'users':
  650. $query = "SELECT user_id, first_name, last_name FROM " . $tableUsers;
  651. $result = queryMySQLDatabase($query);
  652. $rowsFound = @ mysql_num_rows($result);
  653. if ($rowsFound > 0) // If there were rows (= user IDs) found ...
  654. {
  655. while ($row = @ mysql_fetch_array($result))
  656. {
  657. foreach ($formatIDArray as $formatID => $formatName)
  658. {
  659. $values = "(NULL, " . $formatID . ", " . $row['user_id'] . ", 'true')";
  660. $resultArray["Table 'user_formats': enabled format '" . $formatName . "' for user " . $row['user_id'] . " (" . $row['first_name'] . " " . $row['last_name'] . ")"] = insertIfNotExists(array("format_id" => $formatID), $tableUserFormats, $values, $row['user_id']);
  661. }
  662. foreach ($styleIDArray as $styleID => $styleName)
  663. {
  664. $values = "(NULL, " . $styleID . ", " . $row['user_id'] . ", 'true')";
  665. $resultArray["Table 'user_styles': enabled style '" . $styleName . "' for user " . $row['user_id'] . " (" . $row['first_name'] . " " . $row['last_name'] . ")"] = insertIfNotExists(array("style_id" => $styleID), $tableUserStyles, $values, $row['user_id']);
  666. }
  667. foreach ($typeIDArray as $typeID => $typeName)
  668. {
  669. $values = "(NULL, " . $typeID . ", " . $row['user_id'] . ", 'true')";
  670. $resultArray["Table 'user_types': enabled type '" . $typeName . "' for user " . $row['user_id'] . " (" . $row['first_name'] . " " . $row['last_name'] . ")"] = insertIfNotExists(array("type_id" => $typeID), $tableUserTypes, $values, $row['user_id']);
  671. }
  672. }
  673. }
  674. // (3) ERRORS
  675. // Check whether any tables/rows were affected by the performed SQL queries:
  676. unset($resultArray["Table 'deleted': altered table specification. Affected rows"]); // currently, we simply remove again the results of the 'ALTER TABLE' queries since they will always affect every row in that table
  677. unset($resultArray["Table 'refs': altered table specification. Affected rows"]);
  678. unset($resultArray["Table 'formats': altered table specification. Affected rows"]);
  679. foreach($resultArray as $varname => $value)
  680. if (($value == "0") OR ($value == "false"))
  681. unset($resultArray[$varname]); // remove any action that didn't affect any table or rows
  682. if (empty($resultArray))
  683. {
  684. $HeaderString = "Nothing was changed! Your refbase installation is up-to-date.";
  685. // Write back session variables:
  686. saveSessionVariable("HeaderString", $HeaderString);
  687. }
  688. // (4) CLOSE ADMIN CONNECTION
  689. disconnectFromMySQLDatabase();
  690. // --------------------------------------------------------------------
  691. // Provide a feedback page:
  692. // If there's no stored message available:
  693. if (!isset($_SESSION['HeaderString'])) // provide a default message:
  694. {
  695. $HeaderString = "Update of the Web Reference Database was successful!";
  696. }
  697. else
  698. {
  699. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  700. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  701. deleteSessionVariable("HeaderString");
  702. }
  703. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  704. // ('' will produce the default 'Web' output style)
  705. if (isset($_REQUEST['viewType']))
  706. $viewType = $_REQUEST['viewType'];
  707. else
  708. $viewType = "";
  709. // Show the login status:
  710. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  711. // DISPLAY header:
  712. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  713. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Update Feedback", "index,follow", "Update feedback for the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  714. showPageHeader($HeaderString);
  715. // Start a <table>:
  716. ?>
  717. <table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds the update feedback info"><?php
  718. if (!empty($resultArray)) // if something was changed, add a welcome title:
  719. {
  720. ?>
  721. <tr>
  722. <td colspan="2"><h3>Welcome to refbase v0.9.6!</h3></td>
  723. </tr><?php
  724. }
  725. // following note will be always displayed no matter if something was changed or not:
  726. ?>
  727. <tr>
  728. <td valign="top"><b>Important Note:</b></td>
  729. <td>
  730. The files <em>update.php</em> and <em>update.sql</em> (as well as <em>install.php</em> and <em>install.sql</em>) are only provided for update/installation purposes and are not needed anymore. Due to security considerations you should <span class="warning">remove these files</span> from your web directory NOW!!
  731. </td>
  732. </tr><?php
  733. if (!empty($resultArray)) // if something was changed, add some configuration info:
  734. {
  735. ?>
  736. <tr>
  737. <td valign="top"><b>Configure refbase:</b></td>
  738. <td>
  739. In order to re-establish your existing settings, please open file <em>initialize/ini.inc.php</em> in a text editor and restore all values from your old <em>ini.inc.php</em> file. The new include file contains new settings which you should check out and adopt to your needs if needed. Please see the comments within the file for further information.
  740. </td>
  741. </tr>
  742. <tr>
  743. <td valign="top"><b>Log:</b></td>
  744. <td>
  745. Following update actions were performed successfully:
  746. </td>
  747. </tr>
  748. <tr>
  749. <td valign="top">&nbsp;</td>
  750. <td>
  751. <pre><?php
  752. foreach($resultArray as $varname => $value)
  753. {
  754. if ($value == "true")
  755. echo $varname . ".\n";
  756. else
  757. echo $varname . ": " . $value . "\n";
  758. }
  759. ?>
  760. </pre>
  761. </td>
  762. </tr><?php
  763. }
  764. ?>
  765. </table><?php
  766. // --------------------------------------------------------------------
  767. // DISPLAY THE HTML FOOTER:
  768. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  769. showPageFooter($HeaderString);
  770. displayHTMLfoot();
  771. // --------------------------------------------------------------------
  772. }
  773. ?>