private function checkPattern()
{
$match_found = FALSE;
if (is_array($this->pattern_search)) {
foreach ($this->pattern_search as $type => $RawSearchPatterns) {
if (!empty($RawSearchPatterns) && is_array($RawSearchPatterns)) {
foreach ($RawSearchPatterns as $key => $search) {
if ($match_found == FALSE) {
if (isset($this->pattern_replace[$type][$key]) && isset($this->pattern_search[$type][$key])) {
$search_pattern = $this->pattern_search[$type][$key];
$replace_pattern = $this->pattern_replace[$type][$key];
if (isset($this->rewrite_code[$type]) && isset($this->rewrite_replace[$type])) {
$search = str_replace($this->rewrite_code[$type], $this->rewrite_replace[$type], $search);
}
$search = "~" . $this->cleanRegex($search) . "\$~i";
if (preg_match($search, $this->requesturi, $matches)) {
$url_info = $this->explodeURL($replace_pattern, "&");
$this->pathtofile = str_replace("../", "", $url_info[0]);
preg_match_all($search, $this->requesturi, $url_matches, PREG_SET_ORDER);
if (isset($url_info[1])) {
// indicate has $_GET request
/**
* File path is in search pattern
*/
preg_match_all("~%(.*?)%~i", $search_pattern, $tag_matches);
$tag_values = array();
if (!empty($tag_matches[0])) {
$tagData = array_combine(range(1, count($tag_matches[0])), array_values($tag_matches[0]));
$tagRequests = array_combine(range(1, count($tag_matches[0])), array_values($tag_matches[1]));
foreach ($tagData as $tagKey => $tagVal) {
$tag_values[$tagRequests[$tagKey]] = $matches[$tagKey];
}
$urlParams = array_combine(array_values($tagData), array_values($tag_values));
}
/**
* Read the Request URL pattern
*/
if (isset($url_info[1]) && !empty($urlParams)) {
$parameters = array();
foreach ($url_info[1] as $paramKey => $paramVal) {
if (!$paramVal) {
$paramVal = TRUE;
}
$value = isset($tag_values[$paramKey]) ? $tag_values[$paramKey] : $paramVal;
// If key is not val, (i.e. such as post_id=%thread_id%) the below will find and insert value
if (stristr($value, "%")) {
$value = isset($urlParams[$value]) ? $urlParams[$value] : $paramVal;
}
$parameters[$paramKey] = $value;
}
$this->get_parameters = $parameters;
}
$this->setVariables();
$this->setWarning(9, $this->requesturi);
// Regex pattern found
break;
}
}
} else {
die("You do not have correct Permalink rules Driver. See that your driver is properly set!");
}
} else {
$this->setWarning(3, $this->requesturi);
// Regex pattern not found
}
}
}
}
}
}