XPressME Integration Kit

Trac

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

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

Site URL,Home URLの自動修正を手動修正に変更 Fixes #312

File size: 6.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,$blog_id,$blogname;
11       
12        if (is_xpress_index_page_call()){
13               
14                if (!empty($_POST['submit_url_change'])) {
15                        if (!empty($_POST['site_url_set'])) {
16                                update_option('siteurl' , $_POST['site_url_set']);
17                        }
18                        if (!empty($_POST['home_url_set'])) {
19                                update_option('home' , $_POST['home_url_set']);
20                        }
21                }
22
23                $siteurl = get_option('siteurl');
24                $home = get_option('home');
25                $module_url = $xoops_config->module_url;
26                $module_name = $xoops_config->module_name;
27                $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
28                $guess_url = preg_replace('|/' . $module_name . '/.*|i', '/' . $module_name, $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
29                $blog_sub_path = '';
30                if(function_exists('is_multisite') && is_multisite()){
31                        if ($blog_id > 1){
32                                $blog_sub_path = '/' .$blogname;
33                        }
34                }
35                $guess_url .= $blog_sub_path;
36                $xoops_module_url = $module_url.$blog_sub_path;
37               
38                $site_url_error =  false;
39                if(strcmp($siteurl,$guess_url) !== 0) {
40                        if (!@fclose(@fopen($siteurl . '/xoops_version.php', "r"))){
41                                $site_url_error = true;
42                        }
43                }
44                $home_url_error = false;
45                if(strcmp($guess_url,$home) !== 0) {
46                        $home_url_error = true;
47                }
48                if ($site_url_error || $home_url_error){
49                        include $xoops_config->xoops_root_path ."/header.php";
50                        $form = '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n";
51                        $form .= '<table cellspacing="1" cellpadding="1" border="0">';
52                        $form .= '<tbody>';
53                        if ($site_url_error){
54                                $site_url_error_log = sprintf('Can not access WordPress Site URL(%s)',$siteurl);
55                                $form .= '<tr><td colspan="3"><font color="red"><b>' . $site_url_error_log . '</b></font></td></tr>';
56                                $form .= '<tr>';
57                                $form .= '<td width="16">&nbsp;</td>';
58                                $form .= '<td width="64">Site URL</td>';
59                                $form .= '<td><input name="site_url_set" type="text" size="64" maxlength="200" value="'  . $guess_url . '" /></td>';
60                                $form .= '</tr>';
61
62                        }
63                        if ($home_url_error){
64                                if ($site_url_error) $form .= '<tr><td colspan="3">&nbsp;</td></tr>';;
65                                $home_url_error_log = sprintf('WordPress Home URL(%s) is different from access URL. ',$home);
66                                $form .= '<tr><td colspan="3"><font color="red"><b>' . $home_url_error_log . '</b></font></td></tr>';
67                                $form .= '<tr>';
68                                $form .= '<td width="16">&nbsp;</td>';
69                                $form .= '<td width="64">Home URL</td>';
70                                $form .= '<td><input name="home_url_set" type="text" size="64" maxlength="200" value="'  . $guess_url . '" /></td>';
71                                $form .= '</tr>';
72                        }
73                        $form .= '</tbody>';
74                        $form .= '</table><br />';
75                        $form .= '<input type="submit" value= "Setting" name="submit_url_change" />' ."\n";
76                        echo $form;
77                        include $xoops_config->xoops_root_path . '/footer.php';
78                        exit();
79                }
80        }
81}
82
83require_once( dirname( __FILE__ ).'/request_url.php');
84if (is_xpress_index_page_call()){
85        //$_SERVER['REQUEST_METHOD'] = 'POST' is
86        //When notifying by a private message, Notification_reserve_send();
87        //it is evaded that the data base becomes read-only as a result of the check on the referrer and the method.
88        $request_method =  (isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : '';
89        $_SERVER['REQUEST_METHOD'] = 'POST';
90        require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php.
91        $_SERVER['REQUEST_METHOD'] = $request_method;
92       
93        unset($offset);         //This Trap is provides the case where $offset is defined on the XOOPS side.
94        require_once(ABSPATH.'wp-settings.php');
95       
96        //When it is not possible to connect it correctly at site home URL on the WordPress side,
97        //URL is corrected based on accessed URL.
98        global $xoopsUserIsAdmin;
99        if ($xoopsUserIsAdmin) safe_site_url();
100
101        if (!is_object($xoopsUser)){    // before login auth cookie clear
102                wp_logout();
103        }
104        wp();
105       
106        //for Event notification update on single post to which link is changed by permalink
107        if ( is_404() ) {
108                if (!empty($_POST['not_redirect'])) {
109                        include '../../mainfile.php';
110                        require_once XOOPS_ROOT_PATH.'/include/notification_update.php';
111                        exit();
112                }
113        }
114       
115        if (!function_exists('is_wordpress_style')){    // When the XPressME plug-in is invalid
116                require_once dirname( __FILE__ ).'/xpress_active_plugin.php' ;
117                xpress_pulugin_activation('xpressme/xpressme.php');
118                // reloaded
119                header('Location: ' . $xoops_config->module_url . '/');
120               
121                $err_str = "The activation of the XPressME plugin was executed.<br />\n";
122                $err_str .= "Because the XPressME plugin was invalid.<br />\n";
123                $err_str .= "Please do the rereading seeing on the page.\n";                   
124                die($err_str);
125        }
126       
127        Notification_reserve_send();
128        ob_start();     
129                if (version_compare($xoops_config->wp_version,'2.2', '<'))
130                        require_once dirname( __FILE__ ).'/old_template-loader.php' ;
131                else
132                        require_once( ABSPATH . WPINC . '/template-loader.php' );
133                $wp_output = ob_get_contents();
134        ob_end_clean();
135
136        //Rendering Select
137        if(
138                is_wordpress_style()            // When the display mode is WordPress style
139                || is_feed()                            // It judges it here because it does in is_index_page() through feed to which the permalink is set.
140                || is_iphone_with_wptouch()     // When iPhone access & used wptouch plugin (thx uemu)
141        ){
142                        echo $wp_output;
143        } else {
144                        require_once( dirname( __FILE__ ).'/xpress_render.php' );
145                        xpress_render($wp_output);
146        }
147
148        //When there is no block cache, and an optional block is different, cache is refreshed.
149        //When adding, and changing and deleting Post & Comment, block cache is refreshed by add_action at any time.
150        // This Function in xpressme plugin
151        require_once( dirname( __FILE__ ).'/xpress_block_render.php' );
152        xpress_unnecessary_block_cache_delete($xoops_config->module_name);
153        if (is_home()) xpress_block_cache_refresh($xoops_config->module_name);
154        exit();         // The return to wp-blog-header.php is stolen here
155}
156if (is_admin_post_call()) require_once $xoops_config->xoops_mainfile_path;              // for Notification_triggerEvent
157if (is_xpress_comments_post_call()) require_once $xoops_config->xoops_mainfile_path;    // for Notification_triggerEvent
158?>
Note: See TracBrowser for help on using the repository browser.