PluginProbe
Redirection / 3.5
Redirection v3.5
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-deprecated.php

match-deprecated.php in Redirection 3.5, at models/match-deprecated.php

70 lines 1.6 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 function __construct( $values = '' ) {
5 if ( $values ) {
6 $this->load( $values );
7 }
8 }
9
10 abstract public function save( array $details, $no_target_url = false );
11 abstract public function name();
12 abstract public function get_target( $url, $matched_url, $regex );
13 abstract public function get_data();
14 abstract public function load( $values );
15
16 public function sanitize_url( $url ) {
17 // No new lines
18 $url = preg_replace( "/[\r\n\t].*?$/s", '', $url );
19
20 // Clean control codes
21 $url = preg_replace( '/[^\PC\s]/u', '', $url );
22
23 return $url;
24 }
25
26 protected function get_target_regex_url( $matched_url, $target, $url ) {
27 return preg_replace( '@' . str_replace( '@', '\\@', $matched_url ) . '@', $target, $url );
28 }
29
30 static function create( $name, $data = '' ) {
31 $avail = self::available();
32 if ( isset( $avail[ strtolower( $name ) ] ) ) {
33 $classname = $name . '_match';
34
35 if ( ! class_exists( strtolower( $classname ) ) ) {
36 include( dirname( __FILE__ ) . '/../matches/' . $avail[ strtolower( $name ) ] );
37 }
38
39 return new $classname( $data );
40 }
41
42 return false;
43 }
44
45 static function all() {
46 $data = array();
47
48 $avail = self::available();
49 foreach ( $avail as $name => $file ) {
50 $obj = self::create( $name );
51 $data[ $name ] = $obj->name();
52 }
53
54 return $data;
55 }
56
57 static function available() {
58 return array(
59 'url' => 'url.php',
60 'referrer' => 'referrer.php',
61 'agent' => 'user-agent.php',
62 'login' => 'login.php',
63 'header' => 'http-header.php',
64 'custom' => 'custom-filter.php',
65 'cookie' => 'cookie.php',
66 'role' => 'user-role.php',
67 );
68 }
69 }
70