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.

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