PluginProbe
Redirection / 2.6
Redirection v2.6
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.6, at models/match.php

96 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Red_Match {
4 public $url;
5
6 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 function data( $details ) {
21 $data = $this->save( $details );
22 if ( count( $data ) === 1 && ! is_array( current( $data ) ) )
23 $data = current( $data );
24 else
25 $data = serialize( $data );
26 return $data;
27 }
28
29 function save( $details ) {
30 return array();
31 }
32
33 function name() {
34 return '';
35 }
36
37 function show() {
38 }
39
40 function wants_it() {
41 return true;
42 }
43
44 function get_target( $url, $matched_url, $regex ) {
45 return false;
46 }
47
48 function sanitize_url( $url ) {
49 // No new lines
50 $url = preg_replace( "/[\r\n\t].*?$/s", '', $url );
51
52 // Clean control codes
53 $url = preg_replace( '/[^\PC\s]/u', '', $url );
54
55 return $url;
56 }
57
58 static function create( $name, $data = '' ) {
59 $avail = self::available();
60 if ( isset( $avail[ strtolower( $name ) ] ) ) {
61 $classname = $name.'_match';
62
63 if ( ! class_exists( strtolower( $classname ) ) )
64 include( dirname( __FILE__ ).'/../matches/'.$avail[ strtolower( $name ) ] );
65 return new $classname( $data );
66 }
67
68 return false;
69 }
70
71 static function all() {
72 $data = array();
73
74 $avail = self::available();
75 foreach ( $avail as $name => $file ) {
76 $obj = self::create( $name );
77 $data[ $name ] = $obj->name();
78 }
79
80 return $data;
81 }
82
83 static function available() {
84 return array(
85 'url' => 'url.php',
86 'referrer' => 'referrer.php',
87 'agent' => 'user-agent.php',
88 'login' => 'login.php',
89 );
90 }
91
92 function match_name() {
93 return '';
94 }
95 }
96