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