function test_pattern() { // blognone //$url = "/news/28710/กไอซีที-เริ่มโครงการ-wi-fi-ฟรี-28-ธค-นี้-ที่สยามดิสคัฟเวอรี่"; //$url = "/news/28710/กไอซีที-เริ่มโครงการ-wi-fi-ฟรี-28-ธค-นี้-ที่สยามดิสคัฟเวอรี่#comment-368466"; // dek-d //$url = "/board/view.php?id=2340585"; //$url = "/board/view.php?pno=6&id=2340585"; // lcdtv //$url = "./detail.asp?param_id=850"; $url = "/mainblog.php?id=goirish2011&month=01-02-2012&group=24&gblog=54"; $domain_id = 22; $sub_comment = $this->custom_model->get_value('domain', 'sub_comment_pattern', $domain_id); $child = $this->custom_model->get_value('domain', 'child_pattern', $domain_id); echo $url; echo "<br>"; if (preg_match($child, $url)) { echo "child"; } else { if ($sub_comment != null && preg_match($sub_comment, $url)) { echo "sub_comment"; } else { echo "bad"; } } echo "<hr>"; $parent_page_id = 67045; // if url start with "?", get parent page (which is not also a sub_comment page) and entail if ($url[0] == "?") { $parent = new Page_model(); $parent->init($parent_page_id); while ($parent->sub_comment) { $parent->init($parent->parent_page_id); } $str = explode("?", $parent->url); $url = $str[0] . $url; } // if url start with ".", trim it out if ($url[0] == ".") { $url = substr($url, 1); } echo "url:" . $url; }