4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5 * Copyright (C) 2002-2005 The Nucleus Group
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * (see nucleus/documentation/index.html#license for more info)
13 * Some functions common to all upgrade scripts
15 * $Id: upgrade.functions.php,v 1.6 2006-07-12 07:11:49 kimitake Exp $
16 * $NucleusJP: upgrade.functions.php,v 1.5 2005/03/19 07:20:50 kimitake Exp $
19 include('../../config.php');
21 // sql_table function did not exists in nucleus <= 2.0
22 if (!function_exists('sql_table'))
24 function sql_table($name) {
25 return 'nucleus_' . $name;
29 function upgrade_checkinstall($version) {
34 $query = 'SELECT bconvertbreaks FROM '.sql_table('blog').' LIMIT 1';
38 $query = 'SELECT cip FROM '.sql_table('comment').' LIMIT 1';
42 $query = 'SELECT mcookiekey FROM '.sql_table('member').' LIMIT 1';
46 $query = 'SELECT bnotifytype FROM '.sql_table('blog').' LIMIT 1';
50 $query = 'SELECT * FROM '.sql_table('plugin_option').' LIMIT 1';
54 $query = 'SELECT sdincpref FROM '.sql_table('skin_desc').' LIMIT 1';
59 $query = 'SELECT oid FROM '.sql_table('plugin_option_desc').' LIMIT 1';
64 $query = 'SELECT bincludesearch FROM ' . sql_table('blog') . ' LIMIT 1';
68 $query = 'SELECT * FROM '.sql_table('config').' WHERE name=\'DatabaseVersion\' and value >= 250 LIMIT 1';
72 $query = 'SELECT * FROM '.sql_table('config').' WHERE name=\'DatabaseVersion\' and value >= 300 LIMIT 1';
76 $query = 'SELECT * FROM '.sql_table('config').' WHERE name=\'DatabaseVersion\' and value >= 310 LIMIT 1';
80 $query = 'SELECT * FROM '.sql_table('config').' WHERE name=\'DatabaseVersion\' and value >= 320 LIMIT 1';
85 $res = mysql_query($query);
86 $installed = ($res != 0) && (mysql_num_rows($res) >= $minrows);
92 /** this function gets the nucleus version, even if the getNucleusVersion
93 * function does not exist yet
94 * return 96 for all versions < 100
96 function upgrade_getNucleusVersion() {
97 if (!function_exists('getNucleusVersion')) return 96;
98 return getNucleusVersion();
101 function upgrade_showLogin($type) {
104 <h1>まずはログインして下さい</h1>
105 <p>下記の情報を入力して下さい:</p>
107 <form method="post" action="<?php echo $type?>">
110 <li>名前: <input name="login" /></li>
111 <li>パスワード <input name="password" type="password" /></li>
115 <input name="action" value="login" type="hidden" />
116 <input type="submit" value="ログイン" />
120 <?php upgrade_foot();
124 function upgrade_head() {
126 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
127 <html xmlns="http://www.w3.org/1999/xhtml">
129 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
130 <title>Nucleus アップグレード</title>
132 @import url('../styles/manual.css');
144 function upgrade_foot() {
150 function upgrade_error($msg) {
161 <p><a href="index.php" onclick="history.back();">戻る</a></p>
168 function upgrade_start() {
169 global $upgrade_failures;
170 $upgrade_failures = 0;
178 function upgrade_end($msg = "") {
179 global $upgrade_failures;
180 if ($upgrade_failures > 0)
181 $msg = "いくつかのデータベース操作に失敗しました。もし以前にこのアップグレードスクリプトを実行していたのであれば、問題ないと思われます。";
188 <p><?php echo $msg?></p>
190 <p><a href="index.php">アップグレード最初のページ</a>にもどる</p>
198 * Tries to execute a query, gives a message when failed
200 * @param friendly name
203 function upgrade_query($friendly, $query) {
204 global $upgrade_failures;
206 echo "<li>$friendly ... ";
207 $res = mysql_query($query);
209 echo "<span style='color:red'>失敗</span>\n";
210 echo "<blockquote>失敗の理由: " . mysql_error() . " </blockquote>";
213 echo "<span style='color:green'>成功!</span><br />\n";
221 * table to check (without prefix)
223 * array of column names included
225 function upgrade_checkIfIndexExists($table, $aColumns) {
226 // get info for indices from database
229 $query = 'show index from ' . sql_table($table);
230 $res = mysql_query($query);
231 while ($o = mysql_fetch_object($res)) {
232 if (!$aIndices[$o->Key_name]) {
233 $aIndices[$o->Key_name] = array();
235 array_push($aIndices[$o->Key_name], $o->Column_name);
238 // compare each index with parameter
239 foreach ($aIndices as $keyName => $aIndexColumns) {
240 $aDiff = array_diff($aIndexColumns, $aColumns);
241 if (count($aDiff) == 0) return 1;