$MARUI_DOMAIN . '/contents/shopnews/$stcd/shop_article_list.xml', 'store-info' => array( 'news' => $MARUI_DOMAIN . '/contents/storenews/$stcd/store_article_list.xml', 'fair' => $MARUI_DOMAIN . '/contents/storenews/$stcd/store_article_list.xml', 'feature' => $MARUI_DOMAIN . '/contents/feature/$stcd/feature_article_list.xml', ), 'shop-guide' => $MARUI_DOMAIN . '/contents/shopinfo/$stcd/shop_introduce_list.xml', 'coupon' => $MARUI_DOMAIN . '/contents/coupon/$stcd/coupon_list.xml', 'campaign' => $MARUI_DOMAIN . '/contents/campaign/$stcd/campaign_list.xml' ); // 取得したURLから店舗番号の抽出 preg_match('/^\/(\d{3})\/.*/', $currentUrl, $stcdAry); // 取得したURLから記事区分の抽出 preg_match('/^\/\d{3}\/(.*).*?\/.*/', $currentUrl, $articleTypeAry); preg_match('/^\/\d{3}\/.*?\/(.*).html/', $currentUrl, $articleFileAry); // 取得したURLから記事連番の抽出 preg_match('/(article_id|coupon_id|shop_id|campaign_id)=(.*?)(&.*|$)/', $currentUrl, $articleIdAry); // 抽出必要データを変数化 $stcd = $stcdAry[1]; $articleType = $articleTypeAry[1]; $articleFile = $articleFileAry[1]; $articleId = htmlspecialchars($articleIdAry[2]); //----------------------------------------------------- // XMLデータを取得し、対象記事情報を取得 //----------------------------------------------------- if($articleType !== 'store-info') { $xmlPath = str_replace('$stcd', $stcd, $ARTICLE_PATH[$articleType]); } else { $xmlPath = str_replace('$stcd', $stcd, $ARTICLE_PATH[$articleType][$articleFile]); } $xmlData = simplexml_load_file($xmlPath, 'SimpleXMLElement', LIBXML_NOCDATA); //----------------------------------------------------- // 対象記事区分を取得 //----------------------------------------------------- switch($articleType) { case 'shop-news' : foreach($xmlData -> shop_article as $article) { if($articleId === strval($article -> shop_article_seq)) { $targetArticleType = strval($article -> shop_article_class); if($targetArticleType === '02') { $redirectPath = '/' . $stcd . '/sale-campaign/detail.html?article_seq=' . $article -> shop_article_seq . '&article_type=sha'; } else { $redirectPath = '/' . $stcd . '/recommend/detail.html?article_seq=' . $article -> shop_article_seq . '&article_type=sha'; } break; } } break; case 'store-info': switch($articleFile) { case 'feature' : foreach($xmlData -> feature_article as $feature) { if($articleId === strval($feature -> feature_article_seq)) { $articleTitle = strval($feature -> title); $articleText = strval($feature -> text); $saleKeyword = '<お得>'; $newsKeyword = '<お知らせ>'; if(preg_match('{' . $saleKeyword . '}', $articleTitle) || preg_match('{' . $saleKeyword . '}', $articleText)) { $redirectPath = '/' . $stcd . '/sale-campaign/detail.html?article_seq=' . $feature -> feature_article_seq . '&article_type=stf'; } else if(preg_match('{' . $newsKeyword . '}', $articleTitle) || preg_match('{' . $newsKeyword . '}', $articleText)) { $redirectPath = '/' . $stcd . '/news/detail.html?article_seq=' . $feature -> feature_article_seq . '&article_type=stf'; } else { $redirectPath = '/' . $stcd . '/feature/detail.html?article_seq=' . $feature -> feature_article_seq . '&article_type=stf'; } break; } } break; case 'news' : foreach($xmlData -> store_article as $storeArticle) { if($articleId === strval($storeArticle -> store_article_seq)) { $redirectPath = '/' . $stcd . '/news/detail.html?article_seq=' . $storeArticle -> store_article_seq . '&article_type=sta'; } } break; case 'fair' : foreach($xmlData -> store_article as $storeArticle) { if($articleId === strval($storeArticle -> store_article_seq)) { $redirectPath = '/' . $stcd . '/event/detail.html?article_seq=' . $storeArticle -> store_article_seq . '&article_type=sta'; break; } } break; } break; } //----------------------------------------------------- // metaタグを生成 //----------------------------------------------------- if($redirectPath) { echo "\t\t" . '' . "\n"; } else { echo "\t\t" . '' . "\n"; }