XPressME Integration Kit

Trac

source: branches/Ver2.2/xpressme_integration_kit/include/add_xpress_process.php @ 493

Last change on this file since 493 was 493, checked in by toemon, 15 years ago

Ver2.2ブランチ Ver2.2.0リリース

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