| [1] | 1 | <?php
 | 
|---|
 | 2 | 
 | 
|---|
 | 3 | //< style >< script >< link > tag is pulled out from the header of html contents. 
 | 
|---|
 | 4 | function get_mod_header($contents)
 | 
|---|
 | 5 | {
 | 
|---|
| [201] | 6 |         global $xpress_config;
 | 
|---|
| [278] | 7 |         
 | 
|---|
 | 8 |         $pattern = "<body[^>]*?>(.*)<\/body>";
 | 
|---|
 | 9 |         $body_cut = preg_replace("/".$pattern."/s" , '' , $contents);
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | 
 | 
|---|
| [1] | 12 |         $pattern = "<head[^>]*?>(.*)<\/head>";
 | 
|---|
| [451] | 13 |         $head_str = '';
 | 
|---|
 | 14 |         if (preg_match("/".$pattern."/s",  $body_cut, $head_matches)){
 | 
|---|
 | 15 |                 $head_str = $head_matches[1];
 | 
|---|
 | 16 |         }
 | 
|---|
| [201] | 17 |         $pattern = '<head[^>]*?>';
 | 
|---|
 | 18 |         $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
 | 
|---|
 | 19 |         $pattern = '<\/head>';
 | 
|---|
 | 20 |         $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
 | 
|---|
 | 21 |         $pattern = '<\s*html\s+xmlns[^>]*?>';
 | 
|---|
 | 22 |         $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
 | 
|---|
 | 23 |         $pattern = '<\s*head\s+profile[^>]*?>';
 | 
|---|
 | 24 |         $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
 | 
|---|
 | 25 |         $pattern = '<\s*meta\s+http-equiv[^>]*?>';
 | 
|---|
 | 26 |         $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
 | 
|---|
 | 27 |         $pattern = '<title[^>]*?>(.*)<\s*\/\s*title\s*>';
 | 
|---|
 | 28 |         $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 |         $head_str = meta_name_cut('robots',$head_str);
 | 
|---|
 | 31 |         $head_str = meta_name_cut('keywords',$head_str);
 | 
|---|
 | 32 |         $head_str = meta_name_cut('description',$head_str);
 | 
|---|
 | 33 |         $head_str = meta_name_cut('rating',$head_str);
 | 
|---|
 | 34 |         $head_str = meta_name_cut('author',$head_str);
 | 
|---|
 | 35 |         $head_str = meta_name_cut('copyright',$head_str);
 | 
|---|
 | 36 |         $head_str = meta_name_cut('generator',$head_str);
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 |         $head_str = preg_replace("/^(\s)*(\r|\n|\r\n)/m", "", $head_str);       
 | 
|---|
| [361] | 39 |         $head_str = $head_str . "\n<!-- credit " . xpress_credit('echo=0&no_link=1') . " -->\n";
 | 
|---|
| [201] | 40 |         return $head_str;
 | 
|---|
| [1] | 41 | }
 | 
|---|
 | 42 | 
 | 
|---|
| [201] | 43 | function meta_name_cut($name = '', $head_str)
 | 
|---|
 | 44 | {
 | 
|---|
 | 45 |         $pattern = '<\s*meta\s+name\s*=\s*["\']' . $name . '["\'][^>]*?>';
 | 
|---|
 | 46 |         $head_str = preg_replace("/".$pattern."/i" , '' , $head_str);
 | 
|---|
 | 47 |         return $head_str;
 | 
|---|
 | 48 | }
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | // for title reprace plugin (all in one seo pack)
 | 
|---|
 | 51 | function get_xpress_title($contents)
 | 
|---|
 | 52 | {
 | 
|---|
 | 53 |         $pattern = '<title[^>]*?>(.*)<\s*\/\s*title\s*>';
 | 
|---|
| [451] | 54 |         $title_str = '';
 | 
|---|
 | 55 |         if (preg_match("/".$pattern."/i",  $contents, $head_matches)){
 | 
|---|
 | 56 |                 $title_str = $head_matches[1];
 | 
|---|
 | 57 |         }
 | 
|---|
| [201] | 58 |         return $title_str;
 | 
|---|
 | 59 | }
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 | function get_xpress_meta_name($name = '',$contents)
 | 
|---|
 | 62 | {
 | 
|---|
 | 63 |         $pattern = '<\s*meta\s+name\s*=\s*["\']' . $name . '["\']\s*content\s*=\s*[\'"](.*)[\'"]\s*\/\s*>';
 | 
|---|
| [451] | 64 |         $meta = '';
 | 
|---|
 | 65 |         if (preg_match("/".$pattern."/i",  $contents, $head_matches)){
 | 
|---|
 | 66 |                 $meta = @$head_matches[1];
 | 
|---|
 | 67 |         }
 | 
|---|
| [201] | 68 |         return $meta;
 | 
|---|
 | 69 | }
 | 
|---|
 | 70 | 
 | 
|---|
| [26] | 71 | // get sidebar rendaring 
 | 
|---|
 | 72 | function get_sidebar_rander($name = null)
 | 
|---|
 | 73 | {
 | 
|---|
 | 74 |         $templates = array();
 | 
|---|
 | 75 |         if ( isset($name) )
 | 
|---|
 | 76 |                 $templates[] = "sidebar-{$name}.php";
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 |         $templates[] = "sidebar.php";
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 |         $link= locate_template($templates, false);
 | 
|---|
 | 81 |         if ('' == $link)
 | 
|---|
 | 82 |                 $link =  get_theme_root() . '/default/sidebar.php';
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 |         ob_start();
 | 
|---|
 | 85 |                 require($link);
 | 
|---|
 | 86 |                 $sidebar = ob_get_contents();
 | 
|---|
 | 87 |         ob_end_clean();
 | 
|---|
 | 88 |         return $sidebar;
 | 
|---|
 | 89 | }
 | 
|---|
 | 90 | 
 | 
|---|
| [1] | 91 | // < body > tag is pulled out from the header of html contents. 
 | 
|---|
 | 92 | function get_body($contents)
 | 
|---|
 | 93 | {
 | 
|---|
| [26] | 94 |         $xpess_config = new XPressME_Class();
 | 
|---|
| [1] | 95 |         $pattern = "<body[^>]*?>(.*)<\/body>";
 | 
|---|
| [451] | 96 |         $body = '';
 | 
|---|
 | 97 |         if(preg_match("/".$pattern."/s",  $contents, $body_matches)){
 | 
|---|
 | 98 |                 $body = $body_matches[1];
 | 
|---|
 | 99 |         }
 | 
|---|
| [26] | 100 |         if (!$xpess_config->is_theme_sidebar_disp){
 | 
|---|
 | 101 |                 $side_panel = get_sidebar_rander();
 | 
|---|
 | 102 |                         $body = str_replace($side_panel,'',$body);
 | 
|---|
 | 103 |         }
 | 
|---|
| [1] | 104 |         return $body;
 | 
|---|
 | 105 | }
 | 
|---|
 | 106 | 
 | 
|---|
 | 107 | //Making of module header
 | 
|---|
 | 108 | function get_xpress_module_header($contents)
 | 
|---|
 | 109 | {
 | 
|---|
 | 110 |         global $xoopsTpl;
 | 
|---|
 | 111 |         if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
 | 
|---|
 | 112 |                 $preload_make_module_header = $xoopsTpl->get_template_vars('xoops_module_header');
 | 
|---|
 | 113 |         } else {
 | 
|---|
 | 114 |                 $preload_make_module_header = '';
 | 
|---|
 | 115 |         }
 | 
|---|
 | 116 |         
 | 
|---|
 | 117 |         if (! empty($preload_make_module_header)){
 | 
|---|
 | 118 |         $preload_make_module_header = '<!-- preload added module header -->
 | 
|---|
 | 119 | ' . $preload_make_module_header . '
 | 
|---|
 | 120 | ';
 | 
|---|
 | 121 |         }
 | 
|---|
 | 122 |         
 | 
|---|
 | 123 |         $wp_module_header = '<!-- wordpress  added module header -->
 | 
|---|
 | 124 | ' . get_mod_header($contents) . '
 | 
|---|
 | 125 | <!-- end of wordpress  added module header -->';
 | 
|---|
 | 126 |         
 | 
|---|
 | 127 |         return $preload_make_module_header . $wp_module_header;
 | 
|---|
 | 128 | }
 | 
|---|
 | 129 | 
 | 
|---|
| [229] | 130 | //PHP_SELF and GET are remake for the XOOPS event notification.
 | 
|---|
 | 131 | function xpress_remake_global_for_permlink(){
 | 
|---|
 | 132 |         global $wp_db,$wp_query;
 | 
|---|
 | 133 |         $php_self = $_SERVER['PHP_SELF'];
 | 
|---|
 | 134 |         $get = $_GET;
 | 
|---|
 | 135 | 
 | 
|---|
 | 136 |         if (preg_match('/\/$/',$php_self) && !preg_match('/index.php/',$php_self)) {
 | 
|---|
 | 137 |                 $php_self = $php_self . 'index.php';
 | 
|---|
 | 138 |                 $_SERVER['PHP_SELF'] = $php_self;
 | 
|---|
 | 139 |         }
 | 
|---|
 | 140 |         if (empty($_GET)){
 | 
|---|
 | 141 |                 $query_vars = $wp_query->query_vars;
 | 
|---|
 | 142 |                 $post = $wp_query->post;
 | 
|---|
 | 143 |                 if ($wp_query->is_single) {
 | 
|---|
 | 144 |                         $_GET = array('p'=>$post->ID);
 | 
|---|
 | 145 |                 } else if($wp_query->is_category){
 | 
|---|
 | 146 |                         $_GET = array('cat'=>$query_vars['cat']);
 | 
|---|
 | 147 |                 } else if($wp_query->is_author){
 | 
|---|
 | 148 |                         $_GET = array('author'=>$query_vars['author']);
 | 
|---|
 | 149 |                 }
 | 
|---|
 | 150 |         }
 | 
|---|
 | 151 | }
 | 
|---|
 | 152 | 
 | 
|---|
| [1] | 153 | //rendering for the module header and the body
 | 
|---|
 | 154 | function xpress_render($contents){
 | 
|---|
| [346] | 155 |         global $xoops_config;
 | 
|---|
 | 156 |         global $xoopsUser , $xoopsTpl,$xpress_config , $xoopsModule , $xoopsLogger, $xoopsConfig ; //for XOOPS
 | 
|---|
| [422] | 157 |         
 | 
|---|
 | 158 |         require_once( ABSPATH .'/include/xpress_breadcrumbs.php' );
 | 
|---|
| [451] | 159 |         $xoops_breadcrumbs = get_breadcrumbs();
 | 
|---|
 | 160 | 
 | 
|---|
| [229] | 161 |         xpress_remake_global_for_permlink();
 | 
|---|
| [109] | 162 |         $mydirname = basename(dirname(dirname(__FILE__)));
 | 
|---|
| [96] | 163 |         include $xoops_config->xoops_root_path ."/header.php";
 | 
|---|
| [451] | 164 |         $xoopsTpl->assign('xoops_breadcrumbs', $xoops_breadcrumbs);
 | 
|---|
| [1] | 165 |         $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
 | 
|---|
| [201] | 166 |         $page_title = $GLOBALS["xoopsModule"]->getVar("name"). ' »'. get_xpress_title($contents);
 | 
|---|
| [1] | 167 |         $xoopsTpl->assign('xoops_pagetitle', $page_title);
 | 
|---|
| [201] | 168 |         
 | 
|---|
 | 169 |         $xoops_keywords = $xoopsTpl->get_template_vars('xoops_meta_keywords');
 | 
|---|
 | 170 |         $wp_keyword = get_xpress_meta_name('keywords',$contents);
 | 
|---|
 | 171 |         switch ($xpress_config->meta_keyword_type){
 | 
|---|
 | 172 |                 case 'xoops':
 | 
|---|
 | 173 |                         break;
 | 
|---|
 | 174 |                 case 'wordpress':
 | 
|---|
 | 175 |                         if (!empty($wp_keyword))
 | 
|---|
 | 176 |                                 $xoopsTpl->assign('xoops_meta_keywords', $wp_keyword);
 | 
|---|
 | 177 |                         break;
 | 
|---|
 | 178 |                 case 'wordpress_xoops':
 | 
|---|
 | 179 |                         if (!empty($wp_keyword)){
 | 
|---|
 | 180 |                                 if (!empty($xoops_keywords)){
 | 
|---|
 | 181 |                                         $keywords = $wp_keyword . ', ' . $xoops_keywords;
 | 
|---|
 | 182 |                                 } else {
 | 
|---|
 | 183 |                                         $keywords = $wp_keyword;
 | 
|---|
 | 184 |                                 }
 | 
|---|
 | 185 |                                 $xoopsTpl->assign('xoops_meta_keywords', $keywords);
 | 
|---|
 | 186 |                         } 
 | 
|---|
 | 187 |                         break;
 | 
|---|
 | 188 |                 default :
 | 
|---|
 | 189 |         }
 | 
|---|
 | 190 | 
 | 
|---|
 | 191 |         $xoops_description = $xoopsTpl->get_template_vars('xoops_meta_description');
 | 
|---|
 | 192 |         $wp_description = get_xpress_meta_name('description',$contents);
 | 
|---|
 | 193 |         switch ($xpress_config->meta_description_type){
 | 
|---|
 | 194 |                 case 'xoops':
 | 
|---|
 | 195 |                         break;
 | 
|---|
 | 196 |                 case 'wordpress':
 | 
|---|
 | 197 |                         if (!empty($wp_description))
 | 
|---|
 | 198 |                                 $xoopsTpl->assign('xoops_meta_description', $wp_description);
 | 
|---|
 | 199 |                         break;
 | 
|---|
 | 200 |                 case 'wordpress_xoops':
 | 
|---|
 | 201 |                         if (!empty($wp_description)){
 | 
|---|
 | 202 |                                 if (!empty($xoops_description)){
 | 
|---|
 | 203 |                                         $description = $wp_description . ' ' . $xoops_description;
 | 
|---|
 | 204 |                                 } else {
 | 
|---|
 | 205 |                                         $description = $wp_description;
 | 
|---|
 | 206 |                                 }
 | 
|---|
 | 207 |                                 $xoopsTpl->assign('xoops_meta_description', $description);
 | 
|---|
 | 208 |                         } 
 | 
|---|
 | 209 |                         break;
 | 
|---|
 | 210 |                 default :
 | 
|---|
 | 211 |         }
 | 
|---|
| [202] | 212 | 
 | 
|---|
 | 213 |         $wp_robots = get_xpress_meta_name('robots',$contents);
 | 
|---|
 | 214 |         switch ($xpress_config->meta_robot_type){
 | 
|---|
 | 215 |                 case 'xoops':
 | 
|---|
 | 216 |                         break;
 | 
|---|
 | 217 |                 case 'wordpress':
 | 
|---|
 | 218 |                         if (!empty($wp_robots))
 | 
|---|
 | 219 |                                 $xoopsTpl->assign('xoops_meta_robots', $wp_robots);
 | 
|---|
 | 220 |                         break;
 | 
|---|
 | 221 |                 default :
 | 
|---|
 | 222 |         }
 | 
|---|
| [201] | 223 |         
 | 
|---|
| [164] | 224 |         $xpress_data['body_contents'] = get_body($contents);
 | 
|---|
 | 225 |         // used $GLOBALS. becose xpress_left_arrow_post_link() and xpress_right_arrow_post_link() is other loop in this position
 | 
|---|
| [451] | 226 |         $xpress_data['left_post_link'] = @$GLOBALS['left_arrow_post_link'];
 | 
|---|
 | 227 |         $xpress_data['right_post_link'] = @$GLOBALS['right_arrow_post_link'];
 | 
|---|
| [272] | 228 |         $xpress_data['left_posts_link'] =  str_replace('«','',xpress_left_arrow_posts_link('echo=0'));
 | 
|---|
 | 229 |         $xpress_data['right_posts_link'] = str_replace('»','',xpress_right_arrow_posts_link('echo=0'));
 | 
|---|
 | 230 |         $xpress_data['now_user_level'] = xpress_now_user_level('echo=0');
 | 
|---|
| [164] | 231 | 
 | 
|---|
| [343] | 232 |         //If notification_select.php is not executed in CMS other than XCL, the selector of in-line is not displayed. 
 | 
|---|
 | 233 |         if (is_object($xoopsModule) && $xoopsModule->getVar('hasnotification') == 1 && is_object($xoopsUser)) {
 | 
|---|
 | 234 |                 require_once $xoops_config->xoops_root_path . '/include/notification_select.php';
 | 
|---|
 | 235 |         }
 | 
|---|
 | 236 |         
 | 
|---|
| [164] | 237 |         $xoopsTpl->assign('xpress', $xpress_data);
 | 
|---|
| [109] | 238 |         $templates_file = 'db:'.$mydirname. '_index.html';
 | 
|---|
 | 239 |         echo $xoopsTpl->fetch( $templates_file ) ;
 | 
|---|
| [96] | 240 |         include $xoops_config->xoops_root_path . '/footer.php';
 | 
|---|
| [1] | 241 | }
 | 
|---|
 | 242 | 
 | 
|---|
 | 243 | ?> | 
|---|