1.1 --- a/public_html/admin/install/toinnodb.php Sun Sep 20 19:11:47 2009 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,116 +0,0 @@
1.4 -<?php
1.5 -
1.6 -/* Reminder: always indent with 4 spaces (no tabs). */
1.7 -// +---------------------------------------------------------------------------+
1.8 -// | Geeklog 1.6 |
1.9 -// +---------------------------------------------------------------------------+
1.10 -// | toinnodb.php |
1.11 -// | |
1.12 -// | Change Geeklog tables from MyISAM to InnoDB. |
1.13 -// +---------------------------------------------------------------------------+
1.14 -// | Copyright (C) 2004-2009 by the following authors: |
1.15 -// | |
1.16 -// | Authors: Dirk Haun - dirk AT haun-online DOT de |
1.17 -// +---------------------------------------------------------------------------+
1.18 -// | |
1.19 -// | This program is free software; you can redistribute it and/or |
1.20 -// | modify it under the terms of the GNU General Public License |
1.21 -// | as published by the Free Software Foundation; either version 2 |
1.22 -// | of the License, or (at your option) any later version. |
1.23 -// | |
1.24 -// | This program is distributed in the hope that it will be useful, |
1.25 -// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
1.26 -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1.27 -// | GNU General Public License for more details. |
1.28 -// | |
1.29 -// | You should have received a copy of the GNU General Public License |
1.30 -// | along with this program; if not, write to the Free Software Foundation, |
1.31 -// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1.32 -// | |
1.33 -// +---------------------------------------------------------------------------+
1.34 -
1.35 -require_once '../../lib-common.php';
1.36 -
1.37 -// bail if user isn't a Root user
1.38 -if (!SEC_inGroup('Root')) {
1.39 - $display = COM_siteHeader('menu', $MESSAGE[30])
1.40 - . COM_showMessageText($LANG20[6], $MESSAGE[30])
1.41 - . COM_siteFooter();
1.42 - COM_accessLog('User ' . COM_getDisplayName() . ' tried to illegally access the optimize database screen.');
1.43 - COM_output($display);
1.44 - exit;
1.45 -}
1.46 -
1.47 -/**
1.48 -* Check for InnoDB table support (usually as of MySQL 4.0, but may be
1.49 -* available in earlier versions, e.g. "Max" or custom builds).
1.50 -*
1.51 -* @return true = InnoDB tables supported, false = not supported
1.52 -*
1.53 -*/
1.54 -function innodb_supported()
1.55 -{
1.56 - global $_DB_dbms;
1.57 -
1.58 - $retval = false;
1.59 -
1.60 - if ($_DB_dbms == 'mysql') {
1.61 - $result = DB_query("SHOW VARIABLES LIKE 'have_innodb'");
1.62 - $A = DB_fetchArray($result, true);
1.63 -
1.64 - if (strcasecmp($A[1], 'yes') == 0) {
1.65 - $retval = true;
1.66 - }
1.67 - }
1.68 -
1.69 - return $retval;
1.70 -}
1.71 -
1.72 -
1.73 -// MAIN
1.74 -
1.75 -echo COM_siteHeader('menu', 'Changing tables to InnoDB');
1.76 -echo COM_startBlock('Changing tables to InnoDB');
1.77 -
1.78 -if (innodb_supported()) {
1.79 -
1.80 - echo '<p>This may take a while ...</p>' . LB;
1.81 - flush();
1.82 -
1.83 - $opt_time = new timerobject();
1.84 - $opt_time->startTimer();
1.85 -
1.86 - DB_displayError(true);
1.87 -
1.88 - $result = DB_query("SHOW TABLES");
1.89 - $numTables = DB_numRows($result);
1.90 - for ($i = 0; $i < $numTables; $i++) {
1.91 - $A = DB_fetchArray($result, true);
1.92 - if (in_array($A[0], $_TABLES)) {
1.93 - $make_innodb = DB_query("ALTER TABLE $A[0] TYPE=InnoDB", 1);
1.94 - if ($make_innodb === false) {
1.95 - echo '<p>SQL error for table "' . $A[0] . '" (ignored): '
1.96 - . DB_error() . '</p>' . LB;
1.97 - flush();
1.98 - }
1.99 - }
1.100 - }
1.101 -
1.102 - DB_delete($_TABLES['vars'], 'name', 'database_engine');
1.103 - DB_query("INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('database_engine', 'InnoDB')");
1.104 -
1.105 - $exectime = $opt_time->stopTimer();
1.106 -
1.107 - echo '<p>Changing ' . count($_TABLES) . ' tables to InnoDB took '
1.108 - . $exectime . ' seconds.<p>' . LB;
1.109 -
1.110 -} else {
1.111 -
1.112 - echo '<p>Sorry, your database does not support InnoDB tables.</p>' . LB;
1.113 -
1.114 -}
1.115 -
1.116 -echo COM_endBlock();
1.117 -echo COM_siteFooter();
1.118 -
1.119 -?>