Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 133 lines (119 sloc) 5.191 kb
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi 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 Agent_Match extends Red_Match {
24 var $user_agent;
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
25
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
26 function name() {
27 return __( 'URL and user agent', 'redirection' );
28 }
29
30 function show() {
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
31 $defined = array(
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
32 'feedburner|feedvalidator' => __( 'FeedBurner', 'redirection' ),
33 'MSIE' => __( 'Internet Explorer', 'redirection' ),
34 'Firefox' => __( 'FireFox', 'redirection' ),
35 'Opera' => __( 'Opera', 'redirection' ),
36 'Safari' => __( 'Safari', 'redirection' ),
37 'iPhone' => __( 'iPhone', 'redirection' ),
38 'iPad' => __( 'iPad', 'redirection' ),
39 'Android' => __( 'Android', 'redirection' ),
40 'Wii' => __( 'Nintendo Wii', 'redirection' ),
41 );
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
42
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
43 ?>
44 <tr>
45 <th width="100"><?php _e( 'User Agent', 'redirection' ); ?>:</th>
46 <td>
47 <input id="user_agent_<?php echo $this->id ?>" style="width: 65%" type="text" name="user_agent" value="<?php echo esc_attr( $this->user_agent ); ?>"/>
786a739 Updating to Version 2.3.13
ivdimova authored
48 <select style="width: 30%" class="change-user-agent">
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
49 <?php foreach ( $defined AS $key => $value ) : ?>
50 <option value="<?php echo $key ?>"<?php if ( $key == $this->user_agent ) echo ' selected="selected"' ?>><?php echo esc_html( $value ) ?></option>
51 <?php endforeach; ?>
52 </select>
53 </td>
54 </tr>
55 <?php if ( $this->action->can_change_code() ) : ?>
56 <tr>
57 <th><?php _e( 'HTTP Code', 'redirection' ); ?>:</th>
58 <td>
59 <select name="action_code">
60 <?php $this->action->display_actions(); ?>
61 </select>
62 </td>
63 </tr>
64 <?php endif; ?>
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
65
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
66 <?php if ( $this->action->can_perform_action() ) : ?>
786a739 Updating to Version 2.3.13
ivdimova authored
67 <tr>
68 <th></th>
69 <td>
70 <p style="padding: 0.5em"><?php _e( 'The visitor will be redirected from the source URL if the user agent 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. <strong>All matches are performed as regular expressions</strong>.
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
71 ', 'redirection' ); ?></p>
786a739 Updating to Version 2.3.13
ivdimova authored
72 </td>
73 </tr>
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
74 <tr>
75 <th width="100" valign="top">
76 <?php if ( strlen( $this->url_from ) > 0 ) : ?>
77 <a target="_blank" href="<?php echo esc_url( $this->url_from ) ?>"><?php _e( 'Matched', 'redirection' ); ?>:</a>
78 <?php else : ?>
79 <?php _e( 'Matched', 'redirection' ); ?>:
80 <?php endif; ?>
81 </th>
82 <td valign="top"><input style="width: 95%" type="text" name="url_from" value="<?php echo esc_attr( $this->url_from ); ?>" id="new"/></td>
83 </tr>
84 <tr>
85 <th width="100" valign="top">
86 <?php if ( strlen( $this->url_notfrom ) > 0 ) : ?>
87 <a target="_blank" href="<?php echo esc_url( $this->url_notfrom ) ?>"><?php _e( 'Not matched', 'redirection' ); ?>:</a>
88 <?php else : ?>
89 <?php _e( 'Not matched', 'redirection' ); ?>:
90 <?php endif; ?>
91 </th>
92 <td valign="top">
93 <input style="width: 95%" type="text" name="url_notfrom" value="<?php echo esc_attr( $this->url_notfrom ); ?>" id="new"/><br/>
94 </td>
95 </tr>
96 <?php endif; ?>
97 <?php
98 }
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
99
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
100 function save( $details ) {
101 if ( isset( $details['target'] ) )
102 $details['url_from'] = $details['target'];
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
103
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
104 return array(
786a739 Updating to Version 2.3.13
ivdimova authored
105 'url_from' => isset( $details['url_from'] ) ? $details['url_from'] : false,
106 'url_notfrom' => isset( $details['url_notfrom'] ) ? $details['url_notfrom'] : false,
107 'user_agent' => isset( $details['user_agent'] ) ? $details['user_agent'] : false
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
108 );
109 }
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
110
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
111 function initialize( $url ) {
112 $this->url = array( $url, '' );
113 }
114
115 function wants_it() {
116 // Match referrer
117 return true;
118 }
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
119
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
120 function get_target( $url, $matched_url, $regex ) {
121 // Check if referrer matches
122 if ( preg_match( '@'.str_replace( '@', '\\@', $this->user_agent ).'@i', $_SERVER['HTTP_USER_AGENT'], $matches ) > 0 )
123 return preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $this->url_from, $url );
124 elseif ( $this->url_notfrom != '' )
125 return $this->url_notfrom;
126 return false;
127 }
1ddcfd2 Chris Mospaw update wp-redirection to 2.2.13 http://plugins.svn.wordpress.org/redirec...
mospaw authored
128
b6ebaff Matthew Richmond adding version 2.2.10 from http://plugins.svn.wordpress.org/redirection/...
bigdawggi authored
129 function match_name() {
130 return sprintf( 'user agent - %s', $this->user_agent );
131 }
132 }
Something went wrong with that request. Please try again.