XPressME Integration Kit

Trac

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

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

mySQL接続上限警告 対策 Fixes#315

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