Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 127 lines (112 sloc) 4.751 kB
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
1 <?php
2 /**
3 * Redirection
4 *
5 * @package Redirection
6 * @author John Godley
7 * @copyright Copyright( C ) John Godley
8 **/
9
10 /*
11 ============================================================================================================
12 This software is provided "as is" and any express or implied warranties, including, but not limited to, the
13 implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
14 the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or
15 consequential damages( including, but not limited to, procurement of substitute goods or services; loss of
16 use, data, or profits; or business interruption ) however caused and on any theory of liability, whether in
17 contract, strict liability, or tort( including negligence or otherwise ) arising in any way out of the use of
18 this software, even if advised of the possibility of such damage.
19
20 For full license details see license.txt
21 ============================================================================================================ */
22
23 class Referrer_Match extends Red_Match {
24 var $referrer;
25 var $regex;
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
26
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
27 function name() {
28 return __( 'URL and referrer', 'redirection' );
29 }
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
30
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
31 function show() {
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
32 $codes = array(
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
33 301 => get_status_header_desc( 301 ),
34 302 => get_status_header_desc( 302 ),
35 307 => get_status_header_desc( 307 )
36 );
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
37
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
38 ?>
39 <tr>
40 <th width="100"><?php _e( 'Referrer', 'redirection' ); ?>:</th>
41 <td valign="top">
42 <input style="width: 85%" type="text" name="referrer" value="<?php echo esc_attr( $this->referrer ); ?>"/>
43 <label><?php _e( 'Regex', 'redirection' ); ?>: <input type="checkbox" name="regex" <?php if ( $this->regex == true ) echo ' checked="checked"' ?>/></label>
44 </td>
45 </tr>
46 <tr>
47 <th><?php _e( 'HTTP Code', 'redirection' ); ?>:</th>
48 <td>
49 <select name="action_code">
50 <?php foreach ( $codes AS $key => $code ) : ?>
51 <option value="<?php echo $key ?>"<?php if ( $key == $this->action_code ) echo ' selected="selected"' ?>><?php printf( '%s - %s', $key, $code ) ?></option>
52 <?php endforeach?>
53 </select>
54 </td>
55 </tr>
786a739 Updating to Version 2.3.13
ivdimova authored
56 <tr>
57 <th><?php _e( 'HTTP Code', 'redirection' ); ?>:</th>
58 <td>
59 <p style="padding: 0.5em"><?php _e( 'The visitor will be redirected from the source URL if the referrer matches. You can specify a <em>matched</em> target URL as the address to send visitors if they do match, and <em>not matched</em> if they don\'t match. Leaving a URL blank means that the visitor is not redirected.', 'redirection' ); ?></p>
60 </td>
61 </tr>
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
62 <tr>
63 <th width="100" valign="top">
64 <?php if ( strlen( $this->url_from ) > 0 ) : ?>
65 <a target="_blank" href="<?php echo esc_url( $this->url_from ) ?>"><?php _e( 'Matched', 'redirection' ); ?>:</a>
66 <?php else : ?>
67 <?php _e( 'Matched', 'redirection' ); ?>:
68 <?php endif; ?>
69 </th>
70 <td valign="top"><input style="width: 95%" type="text" name="url_from" value="<?php echo esc_attr( $this->url_from ); ?>" id="new"/></td>
71 </tr>
72 <tr>
73 <th width="100" valign="top">
74 <?php if ( strlen( $this->url_notfrom ) > 0 ) : ?>
75 <a target="_blank" href="<?php echo $this->url_notfrom ?>"><?php _e( 'Not matched', 'redirection' ); ?>:</a>
76 <?php else : ?>
77 <?php _e( 'Not matched', 'redirection' ); ?>:
78 <?php endif; ?>
79 </th>
80 <td valign="top">
81 <input style="width: 95%" type="text" name="url_notfrom" value="<?php echo esc_attr( $this->url_notfrom ); ?>" id="new"/><br/>
82 </td>
83 </tr>
84 <?php
85 }
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
86
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
87 function save( $details ) {
88 if ( isset( $details['target'] ) )
89 $details['url_from'] = $details['target'];
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
90
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
91 return array(
92 'url_from' => $details['url_from'],
786a739 Updating to Version 2.3.13
ivdimova authored
93 'url_notfrom' => isset( $details['url_notfrom'] ) ? $details['url_notfrom'] : false,
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
94 'regex' => isset( $details['regex'] ) ? true : false,
786a739 Updating to Version 2.3.13
ivdimova authored
95 'referrer' => isset( $details['referrer'] ) ? $details['referrer'] : false
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
96 );
97 }
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
98
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
99 function initialize( $url ) {
100 $this->url = array( $url, '' );
101 }
102
103 function wants_it() {
104 // Match referrer
105 return true;
106 }
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
107
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
108 function get_target( $url, $matched_url, $regex ) {
109 $target = false;
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
110
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
111 // Check if referrer matches
112 if ( ( $this->regex == false && $_SERVER['HTTP_REFERER'] == $this->referrer ) ||( $this->regex == true && preg_match( '@'.str_replace( '@', '\\@', $this->referrer ).'@', $_SERVER['HTTP_REFERER'], $matches ) ) ) {
113 $target = $this->url_from;
114
115 if ( $regex )
116 $target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $target, $url );
117 }
118 elseif ( $this->url_notfrom != '' )
119 $target = $this->url_notfrom;
120 return $target;
121 }
1ddcfd2 @mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redi…
mospaw authored
122
b6ebaff adding version 2.2.10 from http://plugins.svn.wordpress.org/redirecti…
Matt Richmond authored
123 function match_name() {
124 return sprintf( 'referrer - <code>%s</code>', $this->referrer );
125 }
126 }
Something went wrong with that request. Please try again.