public function rule($name, $match, $rules = NULL) { if (isset($this->post[$name])) { $this->inputs[$name] = $this->post[$name]; $this->sent = 1; } else { $this->valid = 0; } $match = basic_regex($match); $this->rules[$name]['match'] = $match; $this->rules[$name]['unique'] = 0; $this->rules[$name]['md5'] = 0; if ($rules) { $_rules = explode(',', $rules); foreach ($_rules as $rule) { if (preg_match('/unique/', $rule)) { $array = array('', ''); $unique_data = explode('.', substr($rule, 7, -1)) + $array; $this->rules[$name]['unique'] = array('table' => $unique_data[0], 'field' => $unique_data[1]); } else { $this->rules[$name][$rule] = 1; } } } }
public function route() { foreach ($this->routes as $key => $value) { $key = basic_regex($key); if (preg_match($key, $this->request)) { if (strpos($value, '$') !== false) { $value = preg_replace($key, $value, $this->request); } $this->segments = explode('/', $value); } } }