OSDN Git Service

FIX:アップグレードスクリプトがNucleus3.6上で動作するように修正
authorreine <reine@users.sourceforge.jp>
Fri, 22 Jun 2012 15:39:54 +0000 (00:39 +0900)
committerreine <reine@users.sourceforge.jp>
Fri, 22 Jun 2012 15:39:54 +0000 (00:39 +0900)
全アップグレードスクリプトのデータベースハンドラの変更を元に戻した。
(完全にRevertとも言えないのでFIXとしています)

18 files changed:
nucleus/upgrades/index.php
nucleus/upgrades/upgrade.functions.php
nucleus/upgrades/upgrade.php
nucleus/upgrades/upgrade0.95.php
nucleus/upgrades/upgrade0.96.php
nucleus/upgrades/upgrade1.0.php
nucleus/upgrades/upgrade1.1.php
nucleus/upgrades/upgrade1.5.php
nucleus/upgrades/upgrade2.0.php
nucleus/upgrades/upgrade2.5.php
nucleus/upgrades/upgrade3.0.php
nucleus/upgrades/upgrade3.1.php
nucleus/upgrades/upgrade3.2.php
nucleus/upgrades/upgrade3.3.php
nucleus/upgrades/upgrade3.4.php
nucleus/upgrades/upgrade3.5.php
nucleus/upgrades/upgrade3.6.php
nucleus/upgrades/upgrade4.0.php

index 74720cc..c806652 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: index.php 1690 2012-03-08 22:45:08Z ftruscot $
  *
  */
        <p> A manual addition needs to be made to <em>config.php</em>, in order to get the media functions to work. Here's what to add: </p>
        <pre>
        // path to media dir
-       $DIR_MEDIA = '<strong><?php echo i18n;;hsc($guess)?></strong>';
+       $DIR_MEDIA = '<strong><?php echo htmlspecialchars($guess)?></strong>';
        </pre>
 
        <p> Also, it will be necessary to create that directory yourself. If you want to make file upload possible, you should set the permissions of the media/ directory to 777 (see the documentation/tips.html in Nucleus 0.96+ for a quick guide on setting permissions). </p>
        <p> A manual addition needs to be made to <i>config.php</i>, in order to get imported skins to work correctly. Here's what to add: </p>
        <pre>
        // extra skin files for imported skins
-       $DIR_SKINS = '<strong><?php echo i18n;;hsc($guess)?></strong>';
+       $DIR_SKINS = '<strong><?php echo htmlspecialchars($guess)?></strong>';
        </pre>
 
        <p> Also, it will be necessary to create this directory yourself. Downloaded skins can then be expanded into that directory and be imported from inside the Nucleus admin area. </p>
index 0e2f667..41d8d4f 100644 (file)
@@ -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,7 +12,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade.functions.php 1889 2012-06-17 08:46:45Z sakamocchi $
  */
 
                        break;
                }
 
-               $result = DB::getResult($query);
-               $installed = ( $result !== FALSE ) && ($result->rowCount() >= $minrows);
-
+               $result = mysql_query($query);
+               $installed = ( $result != 0 ) && (mysql_num_rows($result) >= $minrows);
+               
                return $installed;
        }
 
                echo "<li> $friendly &mdash; ";
 
                # execute the query
-               $result = @DB::execute($query);
+               $result = @mysql_query($query);
 
                // begin if: error executing query
                if ( $result === FALSE )
                {
                        echo '<span class="warning"> FAILED </span> <br />';
-                       $err = DB::getError();
-                       echo 'Error: <code>', $err[2], '</code>';
+                       echo 'Error: <code>', mysql_error(), '</code>';
                        $upgrade_failures++;
                }
                // else: query was successful
                $indices = array();
 
                $query = 'SHOW INDEX FROM ' . sql_table($table);
-               $result = @DB::getResult($query);
+               $result = @mysql_query($query);
 
                // begin loop: each result object
-               foreach ( $result as $row )
+               while ( $object = mysql_fetch_object($result) )
                {
 
                        // begin if: key has not been added to the indeces array yet
-                       if ( !isset($indices[$row['Key_name']]) )
+                       if ( !isset($indices[$object->Key_name]) )
                        {
-                               $indices[$row['Key_name']] = array();
+                               $indices[$object->Key_name] = array();
                        } // end if
 
-                       array_push($indices[$row['Key_name']], $row['Column_name']);
+                       array_push($indices[$object->Key_name], $object->Column_name);
                }
 
                // compare each index with parameter
        function upgrade_checkIfTableExists($table)
        {
                $query = 'SHOW TABLES LIKE ' . sql_table($table);
-               $result = DB::getResult($query);
+               $result = @mysql_query($query);
 
                // begin if: query executed successfully and one row was returned
-               if ( ($result !== FALSE) && ($result->rowCount() == 1) )
+               if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) )
                {
                        return TRUE;
                }
        function upgrade_checkIfCVExists($value)
        {
                $query = 'SELECT name FROM ' . sql_table('config') . ' WHERE name = "' . $value . '"';
-               $result = DB::getResult($query);
+               $result = @mysql_query($query);
 
                // begin if: query executed successfully and one row was returned
-               if ( ($result !== FALSE) && ($result->rowCount() == 1) )
+               if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) )
                {
                        return TRUE;
                }
        function upgrade_checkIfColumnExists($table, $column)
        {
                $query = 'DESC ' . sql_table($table) . ' ' . $column;
-               $result = DB::getResult($query);
+               $result = @mysql_query($query);
 
                // begin if: query executed successfully and one row was returned
-               if ( ($result !== FALSE) && ($result->rowCount() == 1) )
+               if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) )
                {
                        return TRUE;
                }
index 12d39bd..7713d6b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade.php 1690 2012-03-08 22:45:08Z ftruscot $
  */
 
index d6a8e53..c1fb02d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade0.95.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
index 47b967b..8099dfe 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade0.96.php 1809 2012-05-01 14:48:30Z sakamocchi $
  */
 
@@ -74,15 +74,17 @@ function upgrade_do96() {
        // 6. add 'imagepopup' skincontents in skin 'default'
        
        $query = 'SELECT sdnumber FROM '.sql_table('skin_desc')." WHERE sdname='default'";
-       $res = DB::getValue($query);
-       $query = 'INSERT INTO '.sql_table('skin')." VALUES (" . $res . ", 'imagepopup', '<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n  <title><%imagetext%></title>\r\n  <style type=\"text/css\">\r\n   img { border: none; }\r\n  </style>\r\n</head>\r\n<body>\r\n  <a href=\"javascript:window.close();\"><%image%></a>\r\n</body>\r\n</html>');";
+       $res = sql_query($query);
+       $obj = mysql_fetch_object($res);
+       $skinid = $obj->sdnumber;
+       $query = 'INSERT INTO '.sql_table('skin')." VALUES (" . $skinid . ", 'imagepopup', '<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n  <title><%imagetext%></title>\r\n  <style type=\"text/css\">\r\n   img { border: none; }\r\n  </style>\r\n</head>\r\n<body>\r\n  <a href=\"javascript:window.close();\"><%image%></a>\r\n</body>\r\n</html>');";
        upgrade_query("Adding 'imagepopup' skinparts",$query);
        
        // 7. add POPUP_CODE, MEDIA_CODE, IMAGE_CODE to ALL templates
        $query = 'SELECT tdnumber FROM '.sql_table('template_desc');
-       $res = DB::getResult($query);   // get all template ids
-       foreach ( $res as $row ) {
-               $tid = $row['tdnumber'];        // template id
+       $res = sql_query($query);       // get all template ids
+       while ($obj = mysql_fetch_object($res)) {
+               $tid = $obj->tdnumber;  // template id
        
                $query = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'POPUP_CODE', '<%popuplink%>');";
                $query2 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'MEDIA_CODE', '<%media%>');";
index e38b1ac..5cb0b81 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade1.0.php 1809 2012-05-01 14:48:30Z sakamocchi $
  */
 
@@ -51,11 +51,11 @@ function upgrade_do100() {
                if ($res) {
                        // 5. for all members: hash their password and also copy it to mcookiekey
                        $query = 'SELECT * FROM '.sql_table('member');
-                       $res = DB::getResult($query);
-                       foreach ( $res as $current ) {
-                               $hashedpw = md5($current['mpassword']);
-                               $updquery = 'UPDATE '.sql_table('member')." SET mpassword='$hashedpw' WHERE mnumber=" . $current['mnumber'];
-                               upgrade_query("Encrypting password for member " . $current['mnumber'], $updquery);
+                       $res = mysql_query($query);
+                       while ($current = mysql_fetch_object($res)) {
+                               $hashedpw = md5($current->mpassword);
+                               $updquery = 'UPDATE '.sql_table('member')." SET mpassword='$hashedpw' WHERE mnumber=" . $current->mnumber;
+                               upgrade_query("Encrypting password for member " . $current->mnumber,$updquery);
                        }
                }
        }else{
index 4c73869..f324ea2 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade1.1.php 1809 2012-05-01 14:48:30Z sakamocchi $
  */
 
@@ -71,9 +71,9 @@ function upgrade_do110() {
                // 4. add 'general' categories for all blogs, and update nucleus_item
                $catid = 1;     // generate catids ourself
                $query = 'SELECT bnumber FROM '.sql_table('blog');
-               $res = DB::getResult($query);
-               foreach ( $res as $current ) {
-                       $blogid = $current['bnumber'];
+               $res = mysql_query($query);
+               while ($current = mysql_fetch_object($res)) {
+                       $blogid = $current->bnumber;
                        
                        $query = 'INSERT INTO '.sql_table('category')." (catid, cblog, cname, cdesc) VALUES ($catid, $blogid, 'General', 'Items that do not fit in other categories')";
                        $r = upgrade_query("Adding category 'general' for blog " . $blogid, $query);
@@ -92,9 +92,9 @@ function upgrade_do110() {
                
                // 5. add template parts for category lists to all templates
                $query = 'SELECT tdnumber FROM '.sql_table('template_desc');
-               $res = DB::getResult($query);   // get all template ids
-               foreach ( $res as $row ) {
-                       $tid = $row['tdnumber'];        // template id
+               $res = sql_query($query);       // get all template ids
+               while ($obj = mysql_fetch_object($res)) {
+                       $tid = $obj->tdnumber;  // template id
                
                        $query = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'CATLIST_HEADER', '<ul><li><a href=\"<%blogurl%>\">All</a></li>');";
                        $query2 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'CATLIST_LISTITEM', '<li><a href=\"<%catlink%>\"><%catname%></a></li>');";
index eb684d4..0c58171 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade1.5.php 1889 2012-06-17 08:46:45Z sakamocchi $
  */
 
@@ -54,11 +54,11 @@ function upgrade_do150() {
                upgrade_query('Adding cblog column in table nucleus_comment',$query);
 
                $query = 'SELECT inumber, iblog FROM '.sql_table('item').', '.sql_table('comment').' WHERE inumber=citem AND cblog=0';
-               $res = DB::getResult($query);
+               $res = sql_query($query);
 
-               foreach ( $res as $row ) {
-                       $query = 'UPDATE '.sql_table('comment')." SET cblog='".$row['iblog']."' WHERE citem='".$row['inumber']."'";
-                       upgrade_query('Filling cblog column for item ' . $row['inumber'], $query);
+               while($o = mysql_fetch_object($res)) {
+                       $query = 'UPDATE '.sql_table('comment')." SET cblog='".$o->iblog."' WHERE citem='".$o->inumber."'";
+                       upgrade_query('Filling cblog column for item ' . $o->inumber, $query);
                }
        }       
        
@@ -72,9 +72,9 @@ function upgrade_do150() {
        
        // add 'EDITLINK' to all templates
        $query = 'SELECT tdnumber FROM '.sql_table('template_desc');
-       $res = DB::getResult($query);   // get all template ids
-       foreach ( $res as $row ) {
-               $tid = $row['tdnumber'];        // template id
+       $res = sql_query($query);       // get all template ids
+       while ($obj = mysql_fetch_object($res)) {
+               $tid = $obj->tdnumber;  // template id
        
                $query = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'EDITLINK', '<a href=\"<%editlink%>\" onclick=\"<%editpopupcode%>\">edit</a>');";
                upgrade_query("Adding editlink code to template $tid",$query);
@@ -82,22 +82,20 @@ function upgrade_do150() {
        }
        
        // in templates: update DATE_HEADER templates
-       $res = DB::getResult('SELECT * FROM '.sql_table('template').' WHERE tpartname=\'DATE_HEADER\'');
-       foreach ( $res as $row ) {
-               $newval = str_replace('<%daylink%>','<%%daylink%%>',$row['tcontent']);
-               $query = 'UPDATE '.sql_table('template').' SET tcontent='. DB::quoteValue($newval).' WHERE tdesc=' . $row['tdesc'] . ' AND tpartname=\'DATE_HEADER\'';
-               upgrade_query('Updating DATE_HEADER part in template ' . $row['tdesc'], $query);
+       $res = sql_query('SELECT * FROM '.sql_table('template').' WHERE tpartname=\'DATE_HEADER\'');
+       while ($o = mysql_fetch_object($res)) {
+               $newval = str_replace('<%daylink%>','<%%daylink%%>',$o->tcontent);
+               $query = 'UPDATE '.sql_table('template').' SET tcontent=\''. addslashes($newval).'\' WHERE tdesc=' . $o->tdesc . ' AND tpartname=\'DATE_HEADER\'';
+               upgrade_query('Updating DATE_HEADER part in template ' . $o->tdesc, $query);
        }
        
        // in templates: add 'comments'-templatevar to all non-empty ITEM templates     
-       $res = DB::getResult('SELECT * FROM '.sql_table('template').' WHERE tpartname=\'ITEM\'');
-       foreach ( $res as $row )
-       {
-               if ( i18n::strpos($row['tcontent'],'<%comments%>') === FALSE )
-               {
-                       $newval = $row['tcontent'] . '<%comments%>';
-                       $query = 'UPDATE '.sql_table('template').' SET tcontent='. DB::quoteValue($newval).' WHERE tdesc=' . $row['tdesc'] . ' AND tpartname=\'ITEM\'';
-                       upgrade_query('Updating ITEM part in template ' . $row['tdesc'], $query);
+       $res = sql_query('SELECT * FROM '.sql_table('template').' WHERE tpartname=\'ITEM\'');
+       while ($o = mysql_fetch_object($res)) {
+               if (!strstr($o->tcontent,'<%comments%>')) {
+                       $newval = $o->tcontent . '<%comments%>';
+                       $query = 'UPDATE '.sql_table('template').' SET tcontent=\''. addslashes($newval).'\' WHERE tdesc=' . $o->tdesc . ' AND tpartname=\'ITEM\'';
+                       upgrade_query('Updating ITEM part in template ' . $o->tdesc, $query);
                }
        }
 
index 6e4ef66..da5f254 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade2.0.php 1889 2012-06-17 08:46:45Z sakamocchi $
  */
 
index 747a507..9cade8a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade2.5.php 1889 2012-06-17 08:46:45Z sakamocchi $
  */
 
@@ -47,23 +47,23 @@ function upgrade_do250() {
                        $query = 'DELETE FROM ' . sql_table('plugin_option_desc');
                        upgrade_query('Flushing plugin option descriptions', $query);
                        $query = 'SELECT * FROM ' . sql_table('plugin_option') .' ORDER BY oid ASC';
-                       $res = DB::getResult($query);
+                       $res = sql_query($query);
                        $aValues = array();
-                       foreach ( $res as $row) {
+                       while ($o = mysql_fetch_object($res)) {
                                $query = 'INSERT INTO ' . sql_table('plugin_option_desc')
                                           .' (opid, oname, ocontext, odesc, otype)'
                                           ." VALUES ("
-                                                       .DB::quoteValue($row['opid']).','
-                                                       .DB::quoteValue($row['oname']) .','
+                                                       ."'".addslashes($o->opid)."',"
+                                                       ."'".addslashes($o->oname) ."',"
                                                        ."'global',"
-                                                       .DB::quoteValue($row['odesc']) .','
-                                                       .DB::quoteValue($row['otype']) .')';
-                               upgrade_query('Moving option description for '.i18n::hsc($row['oname']).' to ' . sql_table('plugin_option_desc'), $query);
+                                                       ."'".addslashes($o->odesc) ."',"
+                                                       ."'".addslashes($o->otype) ."')";
+                               upgrade_query('Moving option description for '.i18n::hsc($o->oname).' to ' . sql_table('plugin_option_desc'), $query);
        
                                // store new id
                                $aValues[] = array ( 
-                                                               'id' => DB::getInsertId(),
-                                                               'value' => $row['ovalue']
+                                                               'id' => mysql_insert_id(),
+                                                               'value' => $o->ovalue
                                                        );
                        }
                }
@@ -90,7 +90,7 @@ function upgrade_do250() {
                                foreach ($aValues as $aInfo) {
                                        $query = 'INSERT INTO ' . sql_table('plugin_option') 
                                                   .' (oid, ocontextid, ovalue)'
-                                                  ." VALUES (".$aInfo['id'].",'0',".DB::quoteValue($aInfo['value']).')';
+                                                  ." VALUES (".$aInfo['id'].",'0','".addslashes($aInfo['value'])."')";
                                        upgrade_query('Re-filling ' . sql_table('plugin_option') . ' ('.$aInfo['id'].')', $query);
                                }
                        }       
index 0b3e136..8d809bb 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade3.0.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
index c387ed2..7671dba 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade3.1.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
index 191719a..b0c224b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
index 076a8db..2666fb4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade3.3.php 1809 2012-05-01 14:48:30Z sakamocchi $
  */
 
@@ -35,7 +35,7 @@ function upgrade_do330() {
        }
 
        // check cmail column to separate to URL and cemail
-       DB::execute(
+       mysql_query(
                'UPDATE ' . sql_table('comment') . ' ' . 
                "SET cemail = cmail, cmail = '' " .
                "WHERE cmail LIKE '%@%'"
@@ -61,8 +61,8 @@ function upgrade_do330() {
 
        // check to see if user turn on Weblogs.com ping, if so, suggest to install the plugin
        $query = "SELECT bsendping FROM " . sql_table('blog') . " WHERE bsendping='1'"; 
-       $res = DB::getResult($query);
-       if ($res->rowCount() > 0) {
+       $res = mysql_query($query);
+       if (mysql_num_rows($res) > 0) {
                echo "<li>Note: The weblogs.com ping function is improved and moved into a plugin. To activate this function in v3.3, please go to plugin menu and install NP_Ping plugin. Also, NP_Ping is replacing NP_PingPong. If you have NP_PingPing installed, please also remove it.</li>";
        }
 }
index 8b97c51..47b7e85 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade3.4.php 1714 2012-03-31 06:32:09Z sakamocchi $
  */
 
index 847a574..93c3fb5 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade3.5.php 1714 2012-03-31 06:32:09Z sakamocchi $
  */
 
index 07b5820..bb0be06 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * 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
@@ -11,7 +11,7 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
  * @version $Id: upgrade3.6.php 1714 2012-03-31 06:32:09Z sakamocchi $
  */
 
index 76d2649..07a122b 100644 (file)
@@ -12,7 +12,7 @@
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2012 The Nucleus Group
- * @version $Id: upgrade2.0.php 1388 2009-07-18 06:31:28Z shizuki $
+ * @version $Id$
  */
 
 function upgrade_do400()
@@ -32,15 +32,19 @@ function upgrade_do400()
        /* change Language setting to Locale */
        if ( upgrade_checkIfCVExists('Language') )
        {
-               $language = DB::getValue("SELECT value FROM " . sql_table('config') . " WHERE name='Language'");
-               $locale = i18n::convert_old_language_file_name_to_locale($language);
-               if ( $locale )
+               $res = sql_query("SELECT value FROM " . sql_table('config') . " WHERE name='Language'");
+               if ( $res !== FALSE )
                {
-                       $query = 'INSERT INTO ' . sql_table('config') . " VALUES ('Locale','{$locale}')";
-                       upgrade_query('Creating Locale config value', $query);
-                       
-                       $query = 'DELETE FROM ' . sql_table('config') . " WHERE name='Language'";
-                       upgrade_query("Removing Language config value", $query);
+                       $row = sql_fetch_assoc($res);
+                       $locale = i18n_upg::convert_old_language_file_name_to_locale($row['value']);
+                       if ( $locale )
+                       {
+                               $query = 'INSERT INTO ' . sql_table('config') . " VALUES ('Locale','{$locale}')";
+                               upgrade_query('Creating Locale config value', $query);
+                               
+                               $query = 'DELETE FROM ' . sql_table('config') . " WHERE name='Language'";
+                               upgrade_query("Removing Language config value", $query);
+                       }
                }
        }
        
@@ -89,14 +93,14 @@ function upgrade_do400()
        }
        
        // all member default value set
-       $res = DB::getResult("SELECT * FROM " . sql_table('member'));
-       foreach ( $res as $row )
+       $result = sql_query("SELECT * FROM " . sql_table('member'));
+       while ( $row = mysql_fetch_assoc($result) )
        {
-               $locale = i18n::convert_old_language_file_name_to_locale($row['mlocale']);
+               $locale = i18n_upg::convert_old_language_file_name_to_locale($row['mlocale']);
                if ( $locale )
                {
                        $query = 'UPDATE $s SET mlocale=$s WHERE mnumber=$d';
-                       $query = sprintf($query, sql_table('member'), DB::quoteValue($locale), $row['mnumber']);
+                       $query = sprintf($query, sql_table('member'), addslashes($locale), $row['mnumber']);
                        upgrade_query('Changing mlocale value', $query);
                }
        }
@@ -107,3 +111,71 @@ function upgrade_do400()
        
 }
 
+class i18n_upg
+{
+       /**
+       * i18n::convert_old_language_file_name_to_locale()
+       * NOTE: this should be obsoleted near future.
+       *
+       * @static
+       * @param        string  $target_language        old translation file name
+       * @return       string  locale name as language_script_region
+       */
+       static public function convert_old_language_file_name_to_locale($target_language)
+       {
+               $target_locale = '';
+               foreach ( self::$lang_refs as $language => $locale )
+               {
+                       if ( $target_language == $language )
+                       {
+                               if ( preg_match('#^(.+)\.(.+)$#', $locale, $match) )
+                               {
+                                       $target_locale = $match[1];
+                               }
+                               else
+                               {
+                                       $target_locale = $locale;
+                               }
+                               break;
+                       }
+               }
+               return $target_locale;
+       }
+       
+       /**
+        * i18n::$lang_refs
+        * reference table to convert old and new way to name translation files.
+        * NOTE: this should be obsoleted as soon as possible.
+        *
+        * @static
+        */
+       static private $lang_refs = array(
+                       "english"               => "en_Latn_US",
+                       "english-utf8"  => "en_Latn_US.UTF-8",
+                       "bulgarian"     => "bg_Cyrl_BG",
+                       "finnish"               => "fi_Latn_FI",
+                       "catalan"               => "ca_Latn_ES",
+                       "french"                => "fr_Latn_FR",
+                       "russian"               => "ru_Cyrl_RU",
+                       "chinese"               => "zh_Hans_CN",
+                       "simchinese"    => "zh_Hans_CN",
+                       "chineseb5"     => "zh_Hant_TW",
+                       "traditional_chinese"   =>      "zh_Hant_TW",
+                       "galego"                => "gl_Latn_ES",
+                       "german"                => "de_Latn_DE",
+                       "korean-utf"    => "ko_Kore_KR.UTF-8",
+                       "korean-euc-kr" => "ko_Kore_KR.EUC-KR",
+                       "slovak"                => "sk_Latn_SK",
+                       "czech"         => "cs_Latn_CZ",
+                       "hungarian"     => "hu_Latn_HU",
+                       "latvian"               => "lv_Latn_LV",
+                       "nederlands"    => "nl_Latn_NL",
+                       "italiano"              => "it_Latn_IT",
+                       "persian"               => "fa_Arab_IR",
+                       "spanish"               => "es_Latn_ES",
+                       "spanish-utf8"  => "es_Latn_ES.UTF-8",
+                       "japanese-euc"  => "ja_Jpan_JP.EUC-JP",
+                       "japanese-utf8" => "ja_Jpan_JP.UTF-8",
+                       "portuguese_brazil"     => "pt_Latn_BR"
+                       );
+}