PluginProbe
Redirection / 2.7.1
Redirection v2.7.1
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / models / match.php

match.php in Redirection 2.7.1, at models/match.php

68 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 abstract class Red_Match {
4 public $url;
5
6 public function __construct( $values = '' ) {
7 if ( $values ) {
8 $this->url = $values;
9
10 $obj = maybe_unserialize( $values );
11
12 if ( is_array( $obj ) ) {
13 foreach ( $obj as $key => $value ) {
14 $this->$key = $value;
15 }
16 }
17 }
18 }
19
20 abstract public function save( array $details, $no_target_url = false );
21 abstract public function name();
22 abstract public function get_target( $url, $matched_url, $regex );
23
24 public function sanitize_url( $url ) {
25 // No new lines
26 $url = preg_replace( "/[\r\n\t].*?$/s", '', $url );
27
28 // Clean control codes
29 $url = preg_replace( '/[^\PC\s]/u', '', $url );
30
31 return $url;
32 }
33
34 static function create( $name, $data = '' ) {
35 $avail = self::available();
36 if ( isset( $avail[ strtolower( $name ) ] ) ) {
37 $classname = $name.'_match';
38
39 if ( ! class_exists( strtolower( $classname ) ) )
40 include( dirname( __FILE__ ).'/../matches/'.$avail[ strtolower( $name ) ] );
41 return new $classname( $data );
42 }
43
44 return false;
45 }
46
47 static function all() {
48 $data = array();
49
50 $avail = self::available();
51 foreach ( $avail as $name => $file ) {
52 $obj = self::create( $name );
53 $data[ $name ] = $obj->name();
54 }
55
56 return $data;
57 }
58
59 static function available() {
60 return array(
61 'url' => 'url.php',
62 'referrer' => 'referrer.php',
63 'agent' => 'user-agent.php',
64 'login' => 'login.php',
65 );
66 }
67 }
68