PluginProbe
Redirection / 3.4
Redirection v3.4
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 / matches / cookie.php

cookie.php in Redirection 3.4, at matches/cookie.php

32 lines 824 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 include_once dirname( __FILE__).'/http-header.php';
4
5 class Cookie_Match extends Header_Match {
6 function name() {
7 return __( 'URL and cookie', 'redirection' );
8 }
9
10 function get_target( $url, $matched_url, $regex ) {
11 $target = false;
12 $matched = Redirection_Request::get_cookie( $this->name ) === $this->value;
13
14 if ( $this->regex ) {
15 $matched = preg_match( '@'.str_replace( '@', '\\@', $this->value ).'@', Redirection_Request::get_cookie( $this->name ), $matches ) > 0;
16 }
17
18 // Check if referrer matches
19 if ( $matched && $this->url_from !== '' ) {
20 $target = $this->url_from;
21 } elseif ( ! $matched && $this->url_notfrom !== '' ) {
22 $target = $this->url_notfrom;
23 }
24
25 if ( $regex && $target ) {
26 $target = $this->get_target_regex_url( $matched_url, $target, $url );
27 }
28
29 return $target;
30 }
31 }
32