X-Git-Url: http://git.osdn.net/view?p=nucleus-jp%2Fnucleus-next.git;a=blobdiff_plain;f=nucleus%2Fupgrades%2Fupgrade.functions.php;h=45b7e1495ccdd78dd11b51e8a3c68213405c14bc;hp=6ea18c34cf4ffa920e6e202665db4b1e3dec3cf3;hb=c90b0980cfa3e79cd4bc7eed551a64a5e2b02a5c;hpb=b7e5335177b8724f95d0f9b7e08550f4d9ec91b4 diff --git a/nucleus/upgrades/upgrade.functions.php b/nucleus/upgrades/upgrade.functions.php index 6ea18c3..45b7e14 100644 --- a/nucleus/upgrades/upgrade.functions.php +++ b/nucleus/upgrades/upgrade.functions.php @@ -2,7 +2,7 @@ /** * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) - * Copyright (C) 2002-2009 The Nucleus Group + * Copyright (C) 2002-2012 The Nucleus Group * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -12,8 +12,8 @@ */ /** * @license http://nucleuscms.org/license.txt GNU General Public License - * @copyright Copyright (C) 2002-2009 The Nucleus Group - * @version $Id: upgrade.functions.php 1592 2011-10-29 22:24:24Z gregorlove $ + * @copyright Copyright (C) 2002-2012 The Nucleus Group + * @version $Id: upgrade.functions.php 1889 2012-06-17 08:46:45Z sakamocchi $ */ /** @@ -21,7 +21,7 @@ */ /************************************************************* - * NOTE: With upgrade to 3.6, need to set this to use sql_* API + * NOTE: With upgrade to 4.0, need to set this to use DB::* API **************************************************************/ include('../../config.php'); @@ -140,11 +140,22 @@ $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 360 LIMIT 1'; $minrows = 1; break; + + case '400': + $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 400 LIMIT 1'; + $minrows = 1; + break; } +<<<<<<< HEAD + $result = DB::getResult($query); + $installed = ( $result !== FALSE ) && ($result->rowCount() >= $minrows); + +======= $result = mysql_query($query); $installed = ( $result != 0 ) && (mysql_num_rows($result) >= $minrows); - + +>>>>>>> skinnable-master return $installed; } @@ -163,7 +174,6 @@ return getNucleusVersion(); } - /** * Show the login form * @param string $action @@ -171,59 +181,48 @@ function upgrade_showLogin($action) { upgrade_head(); -?> -

Log In

-

Please enter your login name and password.

- -
- -

- -
- - Log In \n"; + echo "

Please enter your login name and password.

\n"; + + echo "
\n"; + echo "\n"; + echo "

\n"; + echo "\n"; + echo "
\n"; + upgrade_foot(); exit; - } // end function upgrade_showLogin() - + } /** * Display the HTML header */ function upgrade_head() { -?> - - - - Nucleus Upgrade - it - if ( file_exists('../styles/manual.css') ) - { -?> - -\n"; + echo "\n"; + echo "\n"; + echo " Nucleus Upgrade \n"; + + if ( file_exists('../documentation/styles/manual.css') ) + { + echo "\n"; + } + else + { + echo "\n"; + } + + echo "\n"; + echo "\n"; } - // else: include some CSS - else - { -?> - - - - - - $friendly — "; # execute the query - $result = @mysql_query($query); + $result = @DB::execute($query); // begin if: error executing query if ( $result === FALSE ) { echo ' FAILED
'; - echo 'Error: ', mysql_error(), ''; + $err = DB::getError(); + echo 'Error: ', $err[2], ''; $upgrade_failures++; } // else: query was successful @@ -344,10 +344,8 @@ // begin if: no upgrade failures; update the database version in the config table if ( $upgrade_failures == 0 ) { - $query = 'UPDATE `%s` ' . - 'SET `value` = "%s" ' . - 'WHERE `name` = "DatabaseVersion"'; - + $query = 'UPDATE %s SET value = "%s" WHERE name = "DatabaseVersion";'; + $query = sprintf($query, sql_table('config'), $version); upgrade_query($message, $query); } @@ -372,20 +370,20 @@ // get info for indices from database $indices = array(); - $query = 'SHOW INDEX FROM `' . sql_table($table) . '`'; - $result = @mysql_query($query); + $query = 'SHOW INDEX FROM ' . sql_table($table); + $result = @DB::getResult($query); // begin loop: each result object - while ( $object = mysql_fetch_object($result) ) + foreach ( $result as $row ) { // begin if: key has not been added to the indeces array yet - if ( !isset($indices[$object->Key_name]) ) + if ( !isset($indices[$row['Key_name']]) ) { - $indices[$object->Key_name] = array(); + $indices[$row['Key_name']] = array(); } // end if - array_push($indices[$object->Key_name], $object->Column_name); + array_push($indices[$row['Key_name']], $row['Column_name']); } // compare each index with parameter @@ -412,11 +410,11 @@ */ function upgrade_checkIfTableExists($table) { - $query = 'SHOW TABLES LIKE `' . sql_table($table) . '`'; - $result = @mysql_query($query); + $query = 'SHOW TABLES LIKE ' . sql_table($table); + $result = DB::getResult($query); // begin if: query executed successfully and one row was returned - if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) ) + if ( ($result !== FALSE) && ($result->rowCount() == 1) ) { return TRUE; } @@ -437,11 +435,11 @@ */ function upgrade_checkIfCVExists($value) { - $query = 'SELECT `name` FROM `' . sql_table('config') . '` WHERE `name` = "' . $value . '"'; - $result = @mysql_query($query); + $query = 'SELECT name FROM ' . sql_table('config') . ' WHERE name = "' . $value . '"'; + $result = DB::getResult($query); // begin if: query executed successfully and one row was returned - if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) ) + if ( ($result !== FALSE) && ($result->rowCount() == 1) ) { return TRUE; } @@ -463,11 +461,11 @@ */ function upgrade_checkIfColumnExists($table, $column) { - $query = 'DESC `' . sql_table($table) . '` `' . $column . '`'; - $result = @mysql_query($query); + $query = 'DESC ' . sql_table($table) . ' ' . $column; + $result = DB::getResult($query); // begin if: query executed successfully and one row was returned - if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) ) + if ( ($result !== FALSE) && ($result->rowCount() == 1) ) { return TRUE; }