示例#1
0
function redirector_log_404() {

	if ( $error404 = Redirector404s::findByURL($_SERVER['REQUEST_URI']) ) {
		
		$error404->hits++;
		$error404->updated = date('Y-m-d H:i:s');
		$error404->save();
	
	}
	else {
	
		$error404 = new Redirector404s(array(
			'url'		=> $_SERVER['REQUEST_URI'],
			'hits'		=> 1,
			'created'	=> date('Y-m-d H:i:s'),
			'updated'	=> date('Y-m-d H:i:s')
		));
		$error404->save();
		
	}

}
	function remove($type,$id) {

		self::__checkPermission('redirector_delete');
		
		switch ($type) {
			
			case 'redirect':
				$record = RedirectorRedirects::findById($id);
				break;
			
			case '404':
				$record = Redirector404s::findById($id);
				break;
			
			default:
				$record = false;
				break;
		
		}

		if ( $record === false ) {
			
			Flash::set( 'error', __('Could not find :type record!', array( ':type' => $type ) ) );
			
			redirect( get_url('plugin/redirector/') );
		
		}
		
		if ( ! $record->delete() ) {
			
			Flash::set( 'error', __('Could not delete :type record!', array( ':type' => $type ) ) );
			
			redirect( get_url('plugin/redirector/') );
		
		}
		
		Flash::set( 'success', __('Redirect has been deleted!') );

		redirect( get_url('plugin/redirector/') );

	}