= 250 LIMIT 1'; $minrows = 1; break; case '300': $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 300 LIMIT 1'; $minrows = 1; break; case '310': $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 310 LIMIT 1'; $minrows = 1; break; case '320': $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 320 LIMIT 1'; $minrows = 1; break; case '330': $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 330 LIMIT 1'; $minrows = 1; break; case '340': $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 340 LIMIT 1'; $minrows = 1; break; case '350': $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 350 LIMIT 1'; $minrows = 1; break; case '360': $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; } $result = mysql_query($query); $installed = ( $result != 0 ) && (mysql_num_rows($result) >= $minrows); return $installed; } /** * Get the Nucleus version. If getNucleusVersion() doesn't exist, default to version 0.96 * @return int */ function upgrade_getNucleusVersion() { if ( !function_exists('getNucleusVersion') ) { return 96; } return getNucleusVersion(); } /** * Show the login form * @param string $action */ function upgrade_showLogin($action) { upgrade_head(); echo "

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; } /** * Display the HTML header */ function upgrade_head() { echo "\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"; } /** * Display the HTML footer */ function upgrade_foot() { echo ''; } /** * Display an error page * @param string $message */ function upgrade_error($message) { upgrade_head(); ?>

Error

The following message was returned:

Go Back

Executing Upgrades

Upgrade Completed!

Back to the Upgrades Overview

$friendly — "; # execute the query $result = @mysql_query($query); // begin if: error executing query if ( $result === FALSE ) { echo ' FAILED
'; echo 'Error: ', mysql_error(), ''; $upgrade_failures++; } // else: query was successful else { echo ' SUCCESS! '; } // end if echo '', "\n"; return $result; } /** * Tries to update database version, gives a message when failed * * @param $version * Schema version the database has been upgraded to */ function update_version($version) { global $upgrade_failures; $message = 'Updating DatabaseVersion in config table to ' . $version; // 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 = sprintf($query, sql_table('config'), $version); upgrade_query($message, $query); } // else: display 'not executed' message else { echo '
  • ', $message, ' — NOT EXECUTED Errors occurred during upgrade process.
  • '; } // end if } /** * * * @param string $table table to check (without prefix) * @param array $columns array of column names included * @return int */ function upgrade_checkIfIndexExists($table, $columns) { // get info for indices from database $indices = array(); $query = 'SHOW INDEX FROM ' . sql_table($table); $result = @mysql_query($query); // begin loop: each result object while ( $object = mysql_fetch_object($result) ) { // begin if: key has not been added to the indeces array yet if ( !isset($indices[$object->Key_name]) ) { $indices[$object->Key_name] = array(); } // end if array_push($indices[$object->Key_name], $object->Column_name); } // compare each index with parameter foreach ( $indices as $key_name => $index_columns ) { $diff = array_diff($index_columns, $columns); if ( count($diff) == 0 ) { return 1; } // end if } // end loop return 0; } /** * Checks to see if a given table exists * * @param string $table name of table to check existence of * @return bool TRUE if table exists, FALSE otherwise. */ function upgrade_checkIfTableExists($table) { $query = 'SHOW TABLES LIKE ' . sql_table($table); $result = @mysql_query($query); // begin if: query executed successfully and one row was returned if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) ) { return TRUE; } // else: query error or no results returned else { return FALSE; } // end if } /** * Checks to see if a given configuration value exists * * @param string $value config value to check for existance of (paramater must be MySQL escaped already) * @return bool TRUE if configuration value exists, FALSE otherwise. */ function upgrade_checkIfCVExists($value) { $query = 'SELECT name FROM ' . sql_table('config') . ' WHERE name = "' . $value . '"'; $result = @mysql_query($query); // begin if: query executed successfully and one row was returned if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) ) { return TRUE; } // else: query error or no results returned else { return FALSE; } // end if } /** * Checks to see if a given column exists * * @param string $table name of table to check for column in * @param string $column name of column to check for existance of * @return bool TRUE if column exists, FALSE otherwise. */ function upgrade_checkIfColumnExists($table, $column) { $query = 'DESC ' . sql_table($table) . ' ' . $column; $result = @mysql_query($query); // begin if: query executed successfully and one row was returned if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) ) { return TRUE; } // else: query error or no results returned else { return FALSE; } // end if }