| [355] | 1 | <?php | 
|---|
| [410] | 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 |  | 
|---|
| [454] | 9 | function safe_site_url(){ | 
|---|
| [524] | 10 | global $xoops_config,$blog_id,$blogname; | 
|---|
| [454] | 11 |  | 
|---|
|  | 12 | if (is_xpress_index_page_call()){ | 
|---|
| [548] | 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 | } | 
|---|
| [549] | 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 | } | 
|---|
| [548] | 28 |  | 
|---|
| [454] | 29 | $siteurl = get_option('siteurl'); | 
|---|
|  | 30 | $home = get_option('home'); | 
|---|
|  | 31 | $module_url = $xoops_config->module_url; | 
|---|
| [475] | 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'] ); | 
|---|
| [524] | 35 | $blog_sub_path = ''; | 
|---|
| [534] | 36 | if(function_exists('is_multisite') && is_multisite()){ | 
|---|
| [567] | 37 | if ($blog_id > 0 && $blog_id != BLOG_ID_CURRENT_SITE){ | 
|---|
| [524] | 38 | $blog_sub_path = '/' .$blogname; | 
|---|
|  | 39 | } | 
|---|
|  | 40 | } | 
|---|
|  | 41 | $guess_url .= $blog_sub_path; | 
|---|
| [548] | 42 | $xoops_module_url = $module_url.$blog_sub_path; | 
|---|
|  | 43 |  | 
|---|
|  | 44 | $site_url_error =  false; | 
|---|
|  | 45 | if(strcmp($siteurl,$guess_url) !== 0) { | 
|---|
| [454] | 46 | if (!@fclose(@fopen($siteurl . '/xoops_version.php', "r"))){ | 
|---|
| [548] | 47 | $site_url_error = true; | 
|---|
| [454] | 48 | } | 
|---|
|  | 49 | } | 
|---|
| [548] | 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){ | 
|---|
| [549] | 60 | $site_url_error_log = __('Can not access WordPress address (URL).','xpressme'); | 
|---|
| [548] | 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"> </td>'; | 
|---|
| [549] | 64 | $form .= '<td width="64">'.__('WordPress address (URL)').'</td>'; | 
|---|
|  | 65 | $form .= '<td>'; | 
|---|
|  | 66 | $form .= $siteurl . '<br />'; | 
|---|
|  | 67 | $form .= ' to<br />'; | 
|---|
|  | 68 | $form .= '<input name="site_url_set" type="text" size="64" maxlength="200" value="'  . $guess_url . '" /></td>'; | 
|---|
| [548] | 69 | $form .= '</tr>'; | 
|---|
| [475] | 70 |  | 
|---|
| [454] | 71 | } | 
|---|
| [548] | 72 | if ($home_url_error){ | 
|---|
|  | 73 | if ($site_url_error) $form .= '<tr><td colspan="3"> </td></tr>';; | 
|---|
| [549] | 74 | $home_url_error_log = __('WordPress Blog address (URL) is different from access URL.','xpressme'); | 
|---|
| [548] | 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"> </td>'; | 
|---|
| [549] | 78 | $form .= '<td width="144">'. __('Blog address (URL)') .'</td>'; | 
|---|
|  | 79 | $form .= '<td>'; | 
|---|
|  | 80 | $form .= $home . '<br />'; | 
|---|
|  | 81 | $form .= ' to<br />'; | 
|---|
|  | 82 | $form .= '<input name="home_url_set" type="text" size="64" maxlength="200" value="'  . $guess_url . '" /></td>'; | 
|---|
| [548] | 83 | $form .= '</tr>'; | 
|---|
|  | 84 | } | 
|---|
|  | 85 | $form .= '</tbody>'; | 
|---|
|  | 86 | $form .= '</table><br />'; | 
|---|
| [549] | 87 | $form .= '<input type="submit" value= "'.__('Save Changes').'" name="submit_url_change" />' ."\n"; | 
|---|
|  | 88 | $form .= '</form>' ."\n"; | 
|---|
| [548] | 89 | echo $form; | 
|---|
|  | 90 | include $xoops_config->xoops_root_path . '/footer.php'; | 
|---|
|  | 91 | exit(); | 
|---|
| [454] | 92 | } | 
|---|
| [549] | 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 |  | 
|---|
| [454] | 105 | } | 
|---|
|  | 106 | } | 
|---|
|  | 107 |  | 
|---|
| [355] | 108 | require_once( dirname( __FILE__ ).'/request_url.php'); | 
|---|
| [551] | 109 | require_once( dirname( __FILE__ ).'/memory_limit.php'); | 
|---|
| [355] | 110 | if (is_xpress_index_page_call()){ | 
|---|
| [479] | 111 | //$_SERVER['REQUEST_METHOD'] = 'POST' is | 
|---|
| [360] | 112 | //When notifying by a private message, Notification_reserve_send(); | 
|---|
| [358] | 113 | //it is evaded that the data base becomes read-only as a result of the check on the referrer and the method. | 
|---|
| [477] | 114 | $request_method =  (isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : ''; | 
|---|
| [358] | 115 | $_SERVER['REQUEST_METHOD'] = 'POST'; | 
|---|
| [355] | 116 | require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php. | 
|---|
| [477] | 117 | $_SERVER['REQUEST_METHOD'] = $request_method; | 
|---|
| [551] | 118 | xpress_set_memory_limmit(); // Set memory limmit.(Limmit Value from XPressMe modele config.) | 
|---|
| [479] | 119 | unset($offset);         //This Trap is provides the case where $offset is defined on the XOOPS side. | 
|---|
| [355] | 120 | require_once(ABSPATH.'wp-settings.php'); | 
|---|
| [454] | 121 |  | 
|---|
| [479] | 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. | 
|---|
| [548] | 124 | global $xoopsUserIsAdmin; | 
|---|
|  | 125 | if ($xoopsUserIsAdmin) safe_site_url(); | 
|---|
| [454] | 126 |  | 
|---|
| [355] | 127 | if (!is_object($xoopsUser)){    // before login auth cookie clear | 
|---|
|  | 128 | wp_logout(); | 
|---|
|  | 129 | } | 
|---|
|  | 130 | wp(); | 
|---|
|  | 131 |  | 
|---|
| [421] | 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 |  | 
|---|
| [355] | 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 | } | 
|---|
| [358] | 152 |  | 
|---|
|  | 153 | Notification_reserve_send(); | 
|---|
| [355] | 154 | ob_start(); | 
|---|
| [360] | 155 | if (version_compare($xoops_config->wp_version,'2.2', '<')) | 
|---|
| [355] | 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(); | 
|---|
| [576] | 161 |  | 
|---|
|  | 162 | // insert credit | 
|---|
|  | 163 | $pattern = '<body'; | 
|---|
|  | 164 | $replace = "\n<!-- credit " . xpress_credit('echo=0&no_link=1') . " -->\n<body"; | 
|---|
|  | 165 | $wp_output = preg_replace("/" . $pattern . "/s", $replace, $wp_output); | 
|---|
|  | 166 |  | 
|---|
| [410] | 167 | //Rendering Select | 
|---|
|  | 168 | if( | 
|---|
|  | 169 | is_wordpress_style()            // When the display mode is WordPress style | 
|---|
|  | 170 | || is_feed()                            // It judges it here because it does in is_index_page() through feed to which the permalink is set. | 
|---|
|  | 171 | || is_iphone_with_wptouch()     // When iPhone access & used wptouch plugin (thx uemu) | 
|---|
|  | 172 | ){ | 
|---|
| [576] | 173 |  | 
|---|
| [410] | 174 | echo $wp_output; | 
|---|
| [355] | 175 | } else { | 
|---|
| [410] | 176 | require_once( dirname( __FILE__ ).'/xpress_render.php' ); | 
|---|
|  | 177 | xpress_render($wp_output); | 
|---|
| [355] | 178 | } | 
|---|
|  | 179 |  | 
|---|
|  | 180 | //When there is no block cache, and an optional block is different, cache is refreshed. | 
|---|
|  | 181 | //When adding, and changing and deleting Post & Comment, block cache is refreshed by add_action at any time. | 
|---|
|  | 182 | // This Function in xpressme plugin | 
|---|
|  | 183 | require_once( dirname( __FILE__ ).'/xpress_block_render.php' ); | 
|---|
|  | 184 | xpress_unnecessary_block_cache_delete($xoops_config->module_name); | 
|---|
| [573] | 185 | if (is_home()) { | 
|---|
|  | 186 | xpress_block_cache_refresh($xoops_config->module_name); | 
|---|
|  | 187 | require_once( dirname( __FILE__ ).'/xpress_block_header.php' ); | 
|---|
|  | 188 | set_xpress_block_header($xoops_config->module_name); | 
|---|
|  | 189 | } | 
|---|
| [355] | 190 | exit();         // The return to wp-blog-header.php is stolen here | 
|---|
|  | 191 | } | 
|---|
| [360] | 192 | if (is_admin_post_call()) require_once $xoops_config->xoops_mainfile_path;              // for Notification_triggerEvent | 
|---|
|  | 193 | if (is_xpress_comments_post_call()) require_once $xoops_config->xoops_mainfile_path;    // for Notification_triggerEvent | 
|---|
| [551] | 194 | xpress_set_memory_limmit(); // Set memory limmit.(Limmit Value from XPressMe modele config.) | 
|---|
| [355] | 195 | ?> | 
|---|