OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@1025 1ca29...
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 4 Jul 2009 14:22:36 +0000 (14:22 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 4 Jul 2009 14:22:36 +0000 (14:22 +0000)
utf8/install.php
utf8/nucleus/documentation/history.html
utf8/nucleus/libs/sql/mysql.php
utf8/nucleus/libs/sql/pdo.php

index 0da4ff3..4de48d2 100755 (executable)
@@ -608,11 +608,11 @@ function doInstall() {
                          .     $collation;\r
        }\r
 // </add for garble measure>*/\r
                          .     $collation;\r
        }\r
 // </add for garble measure>*/\r
-               sql_query($sql) or _doError(_ERROR16 . ': ' . sql_error());\r
+               sql_query($sql,$MYSQL_CONN) or _doError(_ERROR16 . ': ' . sql_error($MYSQL_CONN));\r
        }\r
 \r
        // 4. try to select database\r
        }\r
 \r
        // 4. try to select database\r
-       sql_select_db($mysql_database) or _doError(_ERROR17);\r
+       sql_select_db($mysql_database,$MYSQL_CONN) or _doError(_ERROR17);\r
 \r
        // 5. execute queries\r
        $filename = 'install.sql';\r
 \r
        // 5. execute queries\r
        $filename = 'install.sql';\r
@@ -687,7 +687,7 @@ function doInstall() {
                        }\r
 // </add for garble measure>*/\r
 \r
                        }\r
 // </add for garble measure>*/\r
 \r
-                       sql_query($query) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . sql_error() );\r
+                       sql_query($query,$MYSQL_CONN) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . sql_error($MYSQL_CONN) );\r
                }\r
        }\r
 \r
                }\r
        }\r
 \r
@@ -709,7 +709,7 @@ function doInstall() {
                         . " '" . $itm_body . "',"\r
                         . " '" . $itm_more . "',"\r
                         . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";\r
                         . " '" . $itm_body . "',"\r
                         . " '" . $itm_more . "',"\r
                         . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";\r
-       sql_query($newpost) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . sql_error() );\r
+       sql_query($newpost,$MYSQL_CONN) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . sql_error($MYSQL_CONN) );\r
 \r
        // 6. update global settings\r
        updateConfig('IndexURL',   $config_indexurl);\r
 \r
        // 6. update global settings\r
        updateConfig('IndexURL',   $config_indexurl);\r
@@ -736,7 +736,7 @@ function doInstall() {
                   . " WHERE"\r
                   . " mnumber       = 1";\r
 \r
                   . " WHERE"\r
                   . " mnumber       = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR19 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR19 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        // 8. update weblog settings\r
        $query = 'UPDATE ' . tableName('nucleus_blog')\r
 \r
        // 8. update weblog settings\r
        $query = 'UPDATE ' . tableName('nucleus_blog')\r
@@ -746,7 +746,7 @@ function doInstall() {
                   . " WHERE"\r
                   . " bnumber    = 1";\r
 \r
                   . " WHERE"\r
                   . " bnumber    = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR20 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        // 8-2. update category settings\r
        if ($charset == 'ujis') {\r
 \r
        // 8-2. update category settings\r
        if ($charset == 'ujis') {\r
@@ -762,14 +762,14 @@ function doInstall() {
                   . " WHERE"\r
                   . " catid      = 1";\r
 \r
                   . " WHERE"\r
                   . " catid      = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR20 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        // 9. update item date\r
        $query = 'UPDATE ' . tableName('nucleus_item')\r
                   . " SET   itime   = '" . date('Y-m-d H:i:s', time() ) ."'"\r
                   . " WHERE inumber = 1";\r
 \r
 \r
        // 9. update item date\r
        $query = 'UPDATE ' . tableName('nucleus_item')\r
                   . " SET   itime   = '" . date('Y-m-d H:i:s', time() ) ."'"\r
                   . " WHERE inumber = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR21 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR21 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        global $aConfPlugsToInstall, $aConfSkinsToImport;\r
        $aSkinErrors = array();\r
 \r
        global $aConfPlugsToInstall, $aConfSkinsToImport;\r
        $aSkinErrors = array();\r
@@ -795,7 +795,7 @@ function doInstall() {
                $DIR_LIBS    = $DIR_NUCLEUS . 'libs/';\r
 \r
                // close database connection (needs to be closed if we want to include globalfunctions.php)\r
                $DIR_LIBS    = $DIR_NUCLEUS . 'libs/';\r
 \r
                // close database connection (needs to be closed if we want to include globalfunctions.php)\r
-               sql_close();\r
+               sql_close($MYSQL_CONN);\r
 \r
                $manager = '';\r
                include_once($DIR_LIBS . 'globalfunctions.php');\r
 \r
                $manager = '';\r
                include_once($DIR_LIBS . 'globalfunctions.php');\r
@@ -827,8 +827,9 @@ function doInstall() {
                $config_data .= "       \$MYSQL_PREFIX   = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";\r
                $config_data .= "       // new in 3.50. first element is db handler, the second is the db driver used by the handler\n";\r
                $config_data .= "       // default is \$MYSQL_HANDLER = array('mysql','mysql');\n";\r
                $config_data .= "       \$MYSQL_PREFIX   = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";\r
                $config_data .= "       // new in 3.50. first element is db handler, the second is the db driver used by the handler\n";\r
                $config_data .= "       // default is \$MYSQL_HANDLER = array('mysql','mysql');\n";\r
-               $config_data .= "       \$MYSQL_HANDLER = array('mysql','mysql');\n";\r
+               $config_data .= "       //\$MYSQL_HANDLER = array('mysql','mysql');\n";\r
                $config_data .= "       //\$MYSQL_HANDLER = array('pdo','mysql');\n";\r
                $config_data .= "       //\$MYSQL_HANDLER = array('pdo','mysql');\n";\r
+               $config_data .= "       \$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";\r
                $config_data .= "\n";\r
                $config_data .= "       // main nucleus directory\n";\r
                $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";\r
                $config_data .= "\n";\r
                $config_data .= "       // main nucleus directory\n";\r
                $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";\r
@@ -1101,6 +1102,7 @@ function doCheckFiles() {
 }\r
 \r
 function updateConfig($name, $val) {\r
 }\r
 \r
 function updateConfig($name, $val) {\r
+       global $MYSQL_CONN;\r
        $name = addslashes($name);\r
        $val  = trim(addslashes($val) );\r
 \r
        $name = addslashes($name);\r
        $val  = trim(addslashes($val) );\r
 \r
@@ -1108,8 +1110,8 @@ function updateConfig($name, $val) {
                   . " SET   value = '$val'"\r
                   . " WHERE name  = '$name'";\r
 \r
                   . " SET   value = '$val'"\r
                   . " WHERE name  = '$name'";\r
 \r
-       sql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );\r
-       return sql_insert_id();\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR26 . ': ' . mysql_error($MYSQL_CONN) );\r
+       return sql_insert_id($MYSQL_CONN);\r
 }\r
 \r
 function replaceDoubleBackslash($input) {\r
 }\r
 \r
 function replaceDoubleBackslash($input) {\r
index 877e35b..a3cb26e 100755 (executable)
@@ -57,6 +57,7 @@
        <li>\r
                <strong>Nucleus v3.5 (SVN)</strong>\r
                <ul>\r
        <li>\r
                <strong>Nucleus v3.5 (SVN)</strong>\r
                <ul>\r
+                       <li>CHANGED: modified install.php and sql_* handlers to allow installation using PDO. Activation is manual and not intended for public consumption in 3.50. Only tested for pdo-mysql handler. (ftruscot)</li>\r
                        <li>ADDED/CHANGED: extended sql_* api to cover all mysql_* functions used in core. Functions loaded from nucleus/libs/sql/ folder. See <a href="http://wakka.xiffy.nl/planning:3.50#mysql_api_warning" title="sql API">here</a>. (ftruscot)</li>\r
                        <li>FIXED: atom.phpとxml-rss2.phpで_CHARSETをチェックして文字コード変換(<a href="http://japan.nucleuscms.org/bb/viewtopic.php?t=4376" target="_blank" class="postlink">Nicleus3.41 へアップグレード後 xml-rss2.php でエラー</a>)(きゃしゃ)</li>\r
                        <li>CHANGED: SEARCH.php改良(<a href="http://japan.nucleuscms.org/bb/viewtopic.php?t=4370" target="_blank" class="postlink">&lt;%relevance%&gt;対応SEARCH.php</a>、<a href="http://japan.nucleuscms.org/bb/viewtopic.php?t=3824" target="_blank" class="postlink">検索結果の正確さ</a>)(きゃしゃ)</li>\r
                        <li>ADDED/CHANGED: extended sql_* api to cover all mysql_* functions used in core. Functions loaded from nucleus/libs/sql/ folder. See <a href="http://wakka.xiffy.nl/planning:3.50#mysql_api_warning" title="sql API">here</a>. (ftruscot)</li>\r
                        <li>FIXED: atom.phpとxml-rss2.phpで_CHARSETをチェックして文字コード変換(<a href="http://japan.nucleuscms.org/bb/viewtopic.php?t=4376" target="_blank" class="postlink">Nicleus3.41 へアップグレード後 xml-rss2.php でエラー</a>)(きゃしゃ)</li>\r
                        <li>CHANGED: SEARCH.php改良(<a href="http://japan.nucleuscms.org/bb/viewtopic.php?t=4370" target="_blank" class="postlink">&lt;%relevance%&gt;対応SEARCH.php</a>、<a href="http://japan.nucleuscms.org/bb/viewtopic.php?t=3824" target="_blank" class="postlink">検索結果の正確さ</a>)(きゃしゃ)</li>\r
index 3338d54..a3d5a55 100644 (file)
@@ -135,6 +135,15 @@ if (function_exists('mysql_query') && !function_exists('sql_fetch_assoc'))
        }
        
        /**
        }
        
        /**
+         * executes an PDO::quote() like escape, ie adds quotes arround the string and escapes chars as needed 
+         */
+       function sql_quote_string($val,$conn = false) {
+               global $MYSQL_CONN;
+               if (!$conn) $conn = $MYSQL_CONN;
+               return "'".mysql_real_escape_string($val,$conn)."'";
+       }
+       
+       /**
          * executes an SQL insert id
          */
        function sql_insert_id($conn = false)
          * executes an SQL insert id
          */
        function sql_insert_id($conn = false)
index 8e21424..06fe2e3 100644 (file)
@@ -67,7 +67,7 @@ if (!function_exists('sql_fetch_assoc'))
                                                
                } catch (PDOException $e) {
                        $DBH =NULL;
                                                
                } catch (PDOException $e) {
                        $DBH =NULL;
-                       startUpError('<p>Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
+                       startUpError('<p>a1 Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
                }
 //echo '<hr />DBH: '.print_r($DBH,true).'<hr />';              
                return $DBH;
                }
 //echo '<hr />DBH: '.print_r($DBH,true).'<hr />';              
                return $DBH;
@@ -103,7 +103,7 @@ if (!function_exists('sql_fetch_assoc'))
 // </add for garble measure>*/
                } catch (PDOException $e) {
                        $SQL_DBH = NULL;
 // </add for garble measure>*/
                } catch (PDOException $e) {
                        $SQL_DBH = NULL;
-                       startUpError('<p>Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
+                       startUpError('<p>a2 Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
                }
 //             echo '<hr />DBH: '.print_r($SQL_DBH,true).'<hr />';             
                $MYSQL_CONN &= $SQL_DBH;
                }
 //             echo '<hr />DBH: '.print_r($SQL_DBH,true).'<hr />';             
                $MYSQL_CONN &= $SQL_DBH;
@@ -168,6 +168,8 @@ if (!function_exists('sql_fetch_assoc'))
        function sql_select_db($db,&$dbh=NULL)
        {
                global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_CONN, $MYSQL_HANDLER, $SQL_DBH;
        function sql_select_db($db,&$dbh=NULL)
        {
                global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_CONN, $MYSQL_HANDLER, $SQL_DBH;
+//echo '<hr />'.print_r($dbh,true).'<hr />';
+//exit;
                if (is_null($dbh)) { 
                        try {
                                $SQL_DBH = NULL;
                if (is_null($dbh)) { 
                        try {
                                $SQL_DBH = NULL;
@@ -179,7 +181,7 @@ if (!function_exists('sql_fetch_assoc'))
                                $SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.trim($host).$port.';dbname='.$db, $MYSQL_USER, $MYSQL_PASSWORD);
                                return 1;
                        } catch (PDOException $e) {
                                $SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.trim($host).$port.';dbname='.$db, $MYSQL_USER, $MYSQL_PASSWORD);
                                return 1;
                        } catch (PDOException $e) {
-                               startUpError('<p>Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
+                               startUpError('<p>a3 Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
                                return 0;
                        }
                }
                                return 0;
                        }
                }
@@ -198,6 +200,17 @@ if (!function_exists('sql_fetch_assoc'))
        }
        
        /**
        }
        
        /**
+         * executes an PDO::quote() like escape, ie adds quotes arround the string and escapes chars as needed 
+         */
+       function sql_quote_string($val,$dbh=NULL) {
+               global $SQL_DBH;
+               if (is_null($dbh))
+                       return $SQL_DBH->quote($val);
+               else
+                       return $dbh->quote($val);
+       }
+       
+       /**
          * executes an SQL insert id
          */
        function sql_insert_id($dbh=NULL)
          * executes an SQL insert id
          */
        function sql_insert_id($dbh=NULL)