XPressME Integration Kit

Trac

source: trunk/xpressme_integration_kit/include/add_xpress_process.php @ 524

Last change on this file since 524 was 524, checked in by toemon, 14 years ago

WP3でMultiBlogに設定した際、home urlが改変されるバグ修正 Fixes #291
その他、デフォルトテーマの修正

File size: 4.5 KB
Line 
1<?php
2// used wptouch plugin & iPhone access check (thx uemu)
3function is_iphone_with_wptouch(){
4        global $wptouch_plugin;
5        if (is_object($wptouch_plugin)) return $wptouch_plugin->applemobile;
6        return false;
7}
8
9function safe_site_url(){
10        global $xoops_config,$blog_id,$blogname;
11       
12        if (is_xpress_index_page_call()){
13                $siteurl = get_option('siteurl');
14                $home = get_option('home');
15                $module_url = $xoops_config->module_url;
16                $module_name = $xoops_config->module_name;
17                $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
18                $guess_url = preg_replace('|/' . $module_name . '/.*|i', '/' . $module_name, $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
19                $blog_sub_path = '';
20                if (defined('MULTISITE') && MULTISITE){
21                        if ($blog_id > 1){
22                                $blog_path = '/cube_mu/modules/xpress3/toy/';
23                                $blog_sub_path = '/' .$blogname;
24                        }
25                }
26                $guess_url .= $blog_sub_path;
27
28                if(strcmp($siteurl,$module_url.$blog_sub_path) !== 0) {
29                        if (!@fclose(@fopen($siteurl . '/xoops_version.php', "r"))){
30                                update_option('siteurl' , $module_url.$blog_sub_path);
31                        }
32                }
33
34                if(strcmp($guess_url,$home) !== 0) {
35                        if (@fclose(@fopen($guess_url . '/xoops_version.php', "r"))){
36                                update_option('home' , $guess_url);
37                        }
38                }
39        }
40}
41
42require_once( dirname( __FILE__ ).'/request_url.php');
43if (is_xpress_index_page_call()){
44        //$_SERVER['REQUEST_METHOD'] = 'POST' is
45        //When notifying by a private message, Notification_reserve_send();
46        //it is evaded that the data base becomes read-only as a result of the check on the referrer and the method.
47        $request_method =  (isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : '';
48        $_SERVER['REQUEST_METHOD'] = 'POST';
49        require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php.
50        $_SERVER['REQUEST_METHOD'] = $request_method;
51       
52        unset($offset);         //This Trap is provides the case where $offset is defined on the XOOPS side.
53        require_once(ABSPATH.'wp-settings.php');
54       
55        //When it is not possible to connect it correctly at site home URL on the WordPress side,
56        //URL is corrected based on accessed URL.
57        safe_site_url();
58
59        if (!is_object($xoopsUser)){    // before login auth cookie clear
60                wp_logout();
61        }
62        wp();
63       
64        //for Event notification update on single post to which link is changed by permalink
65        if ( is_404() ) {
66                if (!empty($_POST['not_redirect'])) {
67                        include '../../mainfile.php';
68                        require_once XOOPS_ROOT_PATH.'/include/notification_update.php';
69                        exit();
70                }
71        }
72       
73        if (!function_exists('is_wordpress_style')){    // When the XPressME plug-in is invalid
74                require_once dirname( __FILE__ ).'/xpress_active_plugin.php' ;
75                xpress_pulugin_activation('xpressme/xpressme.php');
76                // reloaded
77                header('Location: ' . $xoops_config->module_url . '/');
78               
79                $err_str = "The activation of the XPressME plugin was executed.<br />\n";
80                $err_str .= "Because the XPressME plugin was invalid.<br />\n";
81                $err_str .= "Please do the rereading seeing on the page.\n";                   
82                die($err_str);
83        }
84       
85        Notification_reserve_send();
86        ob_start();     
87                if (version_compare($xoops_config->wp_version,'2.2', '<'))
88                        require_once dirname( __FILE__ ).'/old_template-loader.php' ;
89                else
90                        require_once( ABSPATH . WPINC . '/template-loader.php' );
91                $wp_output = ob_get_contents();
92        ob_end_clean();
93
94        //Rendering Select
95        if(
96                is_wordpress_style()            // When the display mode is WordPress style
97                || is_feed()                            // It judges it here because it does in is_index_page() through feed to which the permalink is set.
98                || is_iphone_with_wptouch()     // When iPhone access & used wptouch plugin (thx uemu)
99        ){
100                        echo $wp_output;
101        } else {
102                        require_once( dirname( __FILE__ ).'/xpress_render.php' );
103                        xpress_render($wp_output);
104        }
105
106        //When there is no block cache, and an optional block is different, cache is refreshed.
107        //When adding, and changing and deleting Post & Comment, block cache is refreshed by add_action at any time.
108        // This Function in xpressme plugin
109        require_once( dirname( __FILE__ ).'/xpress_block_render.php' );
110        xpress_unnecessary_block_cache_delete($xoops_config->module_name);
111        if (is_home()) xpress_block_cache_refresh($xoops_config->module_name);
112        exit();         // The return to wp-blog-header.php is stolen here
113}
114if (is_admin_post_call()) require_once $xoops_config->xoops_mainfile_path;              // for Notification_triggerEvent
115if (is_xpress_comments_post_call()) require_once $xoops_config->xoops_mainfile_path;    // for Notification_triggerEvent
116?>
Note: See TracBrowser for help on using the repository browser.