• The added line is THIS COLOR.
  • The deleted line is THIS COLOR.
&tag(P_BLOG);

[[P_BLOG]]本体の改造。

*負荷軽減 [#xb976343]
**Plug-in 読込み処理を1回だけに [#be0313e8]

include/func_base.inc.php

 /*
  * Load Plug-in Modules
  */
 function include_plugin($mode)
 {
     global $cd, $cfg, $plugin;
 +   static $done;
 +
 +   if ($done) return;
 +
     if ($handlerDir = @opendir($cd . '/include/user_include/plugins')) {
         while ($filename = readdir($handlerDir)) {
             if ($filename != '.' && $filename != '..' && preg_match('/^plg_.+\.inc\.php$/', $filename)) {
                 include_once $cd . '/include/user_include/plugins/' . $filename;
             }
         }
     }
 +
 +   $done = true;
 }
#geshi(PHP){{
/*
 * Load Plug-in Modules
 */
function include_plugin($mode)
{
    global $cd, $cfg, $plugin;
+   static $done;
+
+   if ($done) return;
+
    if ($handlerDir = @opendir($cd . '/include/user_include/plugins')) {
        while ($filename = readdir($handlerDir)) {
            if ($filename != '.' && $filename != '..' && preg_match('/^plg_.+\.inc\.php$/', $filename)) {
                include_once $cd . '/include/user_include/plugins/' . $filename;
            }
        }
    }
+
+   $done = true;
}
}}

**SQL へのアクセスを減らす [#e1b06084]

include/func_base.inc.php

 /**
  * MySQL Connection
  */
 function db_connect() 
 {
     global $dbname, $host, $user, $password;
 +   static $link = FALSE;
 +
 +   if ($link) return $link;
 +
     $link = @mysql_connect($host, $user, $password);
     if ($link && mysql_select_db($dbname)) {
         return $link;
     } else {
 +       $link = FALSE;
         if (file_exists('./SETUP/')) {
             $update_dir = '<p class="ref">Go to <a href="./SETUP/">SETUP</a> directory.</p>';
         } else {
             $update_dir = '<p>No SETUP directory found.</p>';
         }        
#geshi(PHP){{
/**
 * MySQL Connection
 */
function db_connect() 
{
    global $dbname, $host, $user, $password;
+   static $link = FALSE;
+
+   if ($link) return $link;
+
    $link = @mysql_connect($host, $user, $password);
    if ($link && mysql_select_db($dbname)) {
        return $link;
    } else {
+       $link = FALSE;
        if (file_exists('./SETUP/')) {
            $update_dir = '<p class="ref">Go to <a href="./SETUP/">SETUP</a> directory.</p>';
        } else {
            $update_dir = '<p>No SETUP directory found.</p>';
        }        
}}

 //================================================================
 // CONFIG
 //================================================================
 
 function init_config()
 {
     global $config_table, $cd;
 +   static $cfg;
 +
 +   if (isset($cfg)) return $cfg;
 +
     $cfg = array();
     $sql = 'SELECT * FROM `' . $config_table . '`';
     $res = mysql_query($sql);
     if ($res) {
         while ($row = mysql_fetch_assoc($res)) {
             $cfg[$row['config_key']] = $row['config_value'];
         }
     } else {
 +       unset($cfg);
         if (file_exists('./SETUP/')) {
             $update_dir = '<p class="ref">Go to <a href="./SETUP/">SETUP</a> directory.</p>';
         } else {
             $update_dir = '<p>No SETUP directory found.</p>';
         }        
#geshi(PHP){{
//================================================================
// CONFIG
//================================================================

function init_config()
{
    global $config_table, $cd;
+   static $cfg;
+
+   if (isset($cfg)) return $cfg;
+
    $cfg = array();
    $sql = 'SELECT * FROM `' . $config_table . '`';
    $res = mysql_query($sql);
    if ($res) {
        while ($row = mysql_fetch_assoc($res)) {
            $cfg[$row['config_key']] = $row['config_value'];
        }
    } else {
+       unset($cfg);
        if (file_exists('./SETUP/')) {
            $update_dir = '<p class="ref">Go to <a href="./SETUP/">SETUP</a> directory.</p>';
        } else {
            $update_dir = '<p>No SETUP directory found.</p>';
        }        
}}

定量的な検証はしていないので、どの程度早くなるかは気持ちの問題が大きいような・・・。