[MOD] Cache Guests Pages

แนะนำ Mod ต่างๆ ของ PHPBB3 แนะนำความสามารถ ของ mod การติดตั้ง การเข้ากันได้กับเวอร์ชั่น

Moderator: mindphp

buay
PHP Super Member
PHP Super Member
โพสต์: 250
ลงทะเบียนเมื่อ: 02/06/2014 9:55 am

[MOD] Cache Guests Pages

โพสต์ที่ยังไม่ได้อ่าน โดย buay »

9-7-2557 11-09-30.png
9-7-2557 11-09-30.png (31.82 KiB) Viewed 4659 times
รายละเอียด : เนื้อหนาของหน้าเว็บจะถูกเก็บไว้ในไฟล์แคช เมื่อมีผู้ใช้เข้ามาชมก็จะโหลดจากแคชในการแสดงข้อมูล แต่แคชนี้จะเพิ่มขึ้นตามสัดส่วนการใช้งานของผู้เข้าใช้
พัฒนาโดย : Kot Matroskin
Version : 1.1.2
ดาวน์โหลดได้ที่ : https://www.mindphp.com/download/files/117-1 ... 2-zip.html

ไฟล์ที่ใช้ในการติดตั้ง
>>.htaccess,
>>cron.php,
>>index.php,
>>posting.php,
>>viewforum.php,
>>viewtopic.php,
>>includes/functions.php,
>>includes/functions_admin.php,
>>includes/mcp/mcp_main.php,
>>styles/prosilver/template/overall_footer.html

วิธีติดตั้ง

เปิดไฟล์ : .htaccess,

ค้นหา

โค้ด: เลือกทั้งหมด

#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
 
เติมหลัง

โค้ด: เลือกทั้งหมด

#</IfModule>

#
# Uncomment the statement below if your PHP running as a CGI
# and you have no access to If-Modified-Since/If-None-Match request headers
#
#<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}]
#RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]
 
เปิดไฟล์ : cron.php,

ค้นหา

โค้ด: เลือกทั้งหมด

        $cache->tidy();
 
เติมหลัง

โค้ด: เลือกทั้งหมด


    break;

    case 'cgp_tidy_cache':

        if (!class_exists('CGP'))
        {
            include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
        }

        if (time() - $config['cgp_cache_gc'] <= $config['cgp_cache_last_gc'] || !method_exists(CGP::$cache, 'tidy'))
        {
            break;
        }

        CGP::$cache->tidy();
 
เปิดไฟล์ : index.php,

ค้นหา

โค้ด: เลือกทั้งหมด

$auth->acl($user->data);
 
เติมหลัง

โค้ด: เลือกทั้งหมด


//-- BEGIN Cache page content for guests
if (!class_exists('CGP'))
{
    include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
}

if (defined('CGP_ENABLED'))
{
    if (CGP::is_cacheable_user($user))
    {
        define('CGP_KEY', '_index' . CGP::user_type_suffix($user));

        CGP::display_if_cached(CGP_KEY);
    }
}
//-- END Cache page content for guests

 
เปิดไฟล์ : posting.php,

ค้นหา

โค้ด: เลือกทั้งหมด

include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
 
เติมหลัง

โค้ด: เลือกทั้งหมด

//-- BEGIN Cache page content for guests
if (!class_exists('CGP'))
{
    include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
}
//-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

            $meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id");
 
เติมหลัง

โค้ด: เลือกทั้งหมด

            //-- BEGIN Cache page content for guests
            if (defined('CGP_ENABLED')) CGP::destroy_topic_cache($topic_id, $post_data);
            //-- END Cache page content for guests
            
ค้นหา

โค้ด: เลือกทั้งหมด

                $captcha->reset();
            }
 
เติมหลัง

โค้ด: เลือกทั้งหมด


            //-- BEGIN Cache page content for guests
            if (defined('CGP_ENABLED')) CGP::destroy_topic_cache($topic_id, $post_data);
            //-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

                $message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>');
            }
 
เติมหลัง

โค้ด: เลือกทั้งหมด


            //-- BEGIN Cache page content for guests
            if (defined('CGP_ENABLED')) CGP::destroy_topic_cache($topic_id, $post_data);
            //-- END Cache page content for guests
 
เปิดไฟล์ : viewforum.php,

ค้นหา

โค้ด: เลือกทั้งหมด

$sort_dir    = request_var('sd', $default_sort_dir);
 
เติมหลัง

โค้ด: เลือกทั้งหมด


//-- BEGIN Cache page content for guests
if (!class_exists('CGP'))
{
    include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
}

if (defined('CGP_ENABLED'))
{
    // process typical cases only to prevent cache size exploding
    if (CGP::is_cacheable_user($user) && 
        $forum_id &&
        $sort_days == $default_sort_days &&
        $sort_key == $default_sort_key &&
        $sort_dir == $default_sort_dir)
    {
        define('CGP_KEY', "_vf_f{$forum_id}_s{$start}" . CGP::user_type_suffix($user));

        CGP::display_if_cached(CGP_KEY);
    }
}
//-- END Cache page content for guests
 
เปิดไฟล์ : viewtopic.php,

ค้นหา

โค้ด: เลือกทั้งหมด

    $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
}
 
เติมหลัง

โค้ด: เลือกทั้งหมด


//-- BEGIN Cache page content for guests
if (!class_exists('CGP'))
{
    include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
}

if (defined('CGP_ENABLED'))
{
    // process typical cases only to prevent cache size exploding
    if (CGP::is_cacheable_user($user) && 
        $topic_id && !$view && !$update &&
        $sort_days == $default_sort_days &&
        $sort_key == $default_sort_key &&
        $sort_dir == $default_sort_dir)
    {
        define('CGP_KEY', "_vt_t{$topic_id}_s{$start}" . CGP::user_type_suffix($user));

        CGP::display_if_cached(CGP_KEY);
    }
}
//-- END Cache page content for guests
 
เปิดไฟล์ : includes/functions.php,

ค้นหา

โค้ด: เลือกทั้งหมด

            ob_start('ob_gzhandler');
        }
 
เติมหลัง

โค้ด: เลือกทั้งหมด

    }
    elseif (defined('CGP_KEY') && !headers_sent() && ob_get_level() <= 1 && ob_get_length() == 0)
    {
        // we have to use output buffer for saving cached content
        ob_start();
 
ค้นหา

โค้ด: เลือกทั้งหมด

    global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;
 
เติมหลัง

โค้ด: เลือกทั้งหมด

    //-- BEGIN Cache page content for guests
    global $acm_type;
    //-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

            $cron_type = 'tidy_sessions';
 
เติมหลัง

โค้ด: เลือกทั้งหมด

        }
        // Perform custom cache tidy if not system cache used
        else if ($acm_type != 'file' && $config['cgp_force_fcache'] && 
            $time_now - $config['cgp_cache_gc'] > $config['cgp_cache_last_gc'])
        {
            // Tidy the cache
            $cron_type = 'cgp_tidy_cache';
 
ค้นหา

โค้ด: เลือกทั้งหมด

    $template->display('body');
 
เติมหลัง

โค้ด: เลือกทั้งหมด


    //-- BEGIN Cache page content for guests
    if (defined('CGP_KEY') && (!isset($cron_type) || !$cron_type)) // don't cache pages with cron calls
    {
        if (!class_exists('CGP'))
        {
            include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
        }
        
        if (isset($config['cgp_ttl'])) // should be defined as well as CGP_KEY... but why not to check before using?
        {
            CGP::cache_content_page(CGP_KEY, $config['cgp_ttl']);
        }
        else
        {
            CGP::cache_content_page(CGP_KEY);
        }
    }
    //-- END Cache page content for guests
 
เปิดไฟล์ : includes/functions_admin.php,

ค้นหา เติมหลัง

โค้ด: เลือกทั้งหมด


//-- BEGIN Cache page content for guests
if (!class_exists('CGP'))
{
    include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
}
//-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

        $topic_ids = array($topic_ids);
    }
 
เติมหลัง

โค้ด: เลือกทั้งหมด


    //-- BEGIN Cache page content for guests
    if (defined('CGP_ENABLED')) 
    {
        foreach ($topic_ids as $t_id)
        {
            CGP::destroy_topic_cache($t_id);
        }
        
        foreach ($forum_ids as $f_id)
        {
            CGP::destroy_forum_cache($f_id);
        }
    }
    //-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

        $topic_ids[] = (int) $row['topic_id'];
    }
    $db->sql_freeresult($result);
 
เติมหลัง

โค้ด: เลือกทั้งหมด


    //-- BEGIN Cache page content for guests
    if (defined('CGP_ENABLED')) 
    {
        foreach ($topic_ids as $t_id)
        {
            CGP::destroy_topic_cache($t_id);
        }
    }
    //-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

        return $return;
    }
 
เติมหลัง

โค้ด: เลือกทั้งหมด


    //-- BEGIN Cache page content for guests
    if (defined('CGP_ENABLED')) 
    {
        foreach ($topic_ids as $t_id)
        {
            CGP::destroy_topic_cache($t_id);
        }
    }
    //-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

    if (sizeof($moved_topic_ids))
    {
 
เติมหลัง

โค้ด: เลือกทั้งหมด

        //-- BEGIN Cache page content for guests
        if (defined('CGP_ENABLED')) 
        {
            foreach ($forum_ids as $f_id)
            {
                CGP::destroy_forum_cache($f_id);
            }
        }
        //-- END Cache page content for guests
    
ค้นหา

โค้ด: เลือกทั้งหมด

    $db->sql_freeresult($result);
 
เติมหลัง

โค้ด: เลือกทั้งหมด


    //-- BEGIN Cache page content for guests
    if (defined('CGP_ENABLED')) 
    {
        foreach ($topic_ids as $t_id)
        {
            CGP::destroy_topic_cache($t_id);
        }
    }
    //-- END Cache page content for guests
 
เปิดไฟล์ : includes/mcp/mcp_main.php,

ค้นหา เติมหลัง

โค้ด: เลือกทั้งหมด


//-- BEGIN Cache page content for guests
if (!class_exists('CGP'))
{
    include($phpbb_root_path . 'includes/cache_guests_pages.' . $phpEx);
}
//-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

        $data = ($action == 'lock' || $action == 'unlock') ? get_topic_data($ids) : get_post_data($ids);
 
เติมหลัง

โค้ด: เลือกทั้งหมด


        //-- BEGIN Cache page content for guests
        // no need to refresh topic cache for posts locking
        if (defined('CGP_ENABLED') && ($action == 'lock' || $action == 'unlock')) 
        {
            foreach ($ids as $t_id)
            {
                CGP::destroy_topic_cache($t_id, $data[$t_id]);
            }
        }
        //-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

                add_log('mod', $forum_id, $topic_id, 'LOG_TOPIC_TYPE_CHANGED', $row['topic_title']);
 
เติมหลัง

โค้ด: เลือกทั้งหมด

                
                //-- BEGIN Cache page content for guests
                if (defined('CGP_ENABLED'))
                {
                    CGP::destroy_topic_cache($topic_id, $row);
                }
                //-- END Cache page content for guests
 
ค้นหา

โค้ด: เลือกทั้งหมด

        $sync_sql[$to_forum_id][]    = 'forum_topics_real = forum_topics_real + ' . sizeof($new_topic_id_list);

        foreach ($sync_sql as $forum_id_key => $array)
        {
            $sql = 'UPDATE ' . FORUMS_TABLE . '
                SET ' . implode(', ', $array) . '
                WHERE forum_id = ' . $forum_id_key;
            $db->sql_query($sql);
        }
 
เติมหลัง

โค้ด: เลือกทั้งหมด


        //-- BEGIN Cache page content for guests
        if (defined('CGP_ENABLED')) 
        {
            CGP::destroy_forum_cache($to_forum_id);
        }
        //-- END Cache page content for guests
 
เปิดไฟล์ : styles/prosilver/template/overall_footer.html

ค้นหา

โค้ด: เลือกทั้งหมด

        <!-- IF DEBUG_OUTPUT --><br />{DEBUG_OUTPUT}<!-- ENDIF -->
 
ค้นหาในบรรทัด

โค้ด: เลือกทั้งหมด

        <!-- IF DEBUG_OUTPUT --><br />{DEBUG_OUTPUT}<!-- 
เติมหลัง

โค้ด: เลือกทั้งหมด

CGP DEBUG OUTPUT --><!-- 
*จากนั้นให้ทำการ คัดลอกไฟล์ทั้งหมดที่มี ในโฟลเดอร์ root ไปวางทับ
และทำการรันในหน้า install/index.php เพื่อทำการ install
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 32