Changeset 543833
- Timestamp:
- 05/13/2012 05:32:31 PM (14 years ago)
- Location:
- redirection/trunk
- Files:
-
- 2 added
- 1 deleted
- 13 edited
-
locale/da.mo (added)
-
locale/da.po (added)
-
models/database.php (modified) (8 diffs)
-
models/log.php (modified) (2 diffs)
-
models/module.php (modified) (2 diffs)
-
models/pager.php (modified) (6 diffs)
-
modules/404.php (deleted)
-
readme.txt (modified) (2 diffs)
-
redirection.php (modified) (12 diffs)
-
view/admin/group_list.php (modified) (1 diff)
-
view/admin/item_list.php (modified) (2 diffs)
-
view/admin/log.php (modified) (1 diff)
-
view/admin/module_list.php (modified) (2 diffs)
-
view/admin/options.php (modified) (1 diff)
-
view/admin/submenu.php (modified) (1 diff)
-
view/admin/support.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
redirection/trunk/models/database.php
r537877 r543833 17 17 18 18 class RE_Database { 19 function get_charset() { 20 global $wpdb; 21 22 $charset_collate = ''; 23 if ( ! empty($wpdb->charset) ) 24 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 25 26 if ( ! empty($wpdb->collate) ) 27 $charset_collate .= " COLLATE $wpdb->collate"; 28 29 return $charset_collate; 30 } 31 19 32 function install() { 20 33 global $wpdb; 34 35 $charset_collate = $this->get_charset(); 21 36 22 37 $create = array( … … 41 56 KEY `group_idpos` (`group_id`,`position`), 42 57 KEY `group` (`group_id`) 43 ) ",58 ) $charset_collate", 44 59 45 60 "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}redirection_groups`( … … 53 68 KEY `module_id` (`module_id`), 54 69 KEY `status` (`status`) 55 ) ",70 ) $charset_collate", 56 71 57 72 "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}redirection_logs`( … … 72 87 KEY `group_id` (`group_id`), 73 88 KEY `module_id` (`module_id`) 74 ) ",89 ) $charset_collate", 75 90 76 91 "CREATE TABLE `{$wpdb->prefix}redirection_modules`( … … 82 97 KEY `name` (`name`), 83 98 KEY `type` (`type`) 84 )", 99 ) $charset_collate", 100 101 "CREATE TABLE `{$wpdb->prefix}redirection_404` ( 102 `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 103 `created` datetime NOT NULL, 104 `url` varchar(255) NOT NULL DEFAULT '', 105 `agent` varchar(255) DEFAULT NULL, 106 `referrer` varchar(255) DEFAULT NULL, 107 `ip` int(10) unsigned NOT NULL, 108 PRIMARY KEY (`id`), 109 KEY `created` (`created`), 110 KEY `url` (`url`), 111 KEY `ip` (`ip`), 112 KEY `referrer` (`referrer`) 113 ) $charset_collate;" 85 114 ); 86 115 … … 132 161 if ( version_compare( $current, '2.2' ) == -1 ) 133 162 $this->upgrade_to_220(); 163 164 if ( version_compare( $current, '2.3.1' ) == -1 ) 165 $this->upgrade_to_231(); 166 167 $success = true; 134 168 } 135 169 … … 139 173 $wpdb->hide_errors(); 140 174 return $success; 175 } 176 177 function upgrade_to_231() { 178 global $wpdb; 179 180 $charset_collate = $this->get_charset(); 181 182 $wpdb->query( "DELETE FROM {$wpdb->prefix}redirection_modules WHERE type='404'" ); 183 $wpdb->query( "UPDATE {$wpdb->prefix}redirection_groups SET module_id=1 WHERE module_id=3" ); 184 185 $wpdb->query( "CREATE TABLE `{$wpdb->prefix}redirection_404` ( 186 `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 187 `created` datetime NOT NULL, 188 `url` varchar(255) NOT NULL DEFAULT '', 189 `agent` varchar(255) DEFAULT NULL, 190 `referrer` varchar(255) DEFAULT NULL, 191 `ip` int(10) unsigned NOT NULL, 192 PRIMARY KEY (`id`), 193 KEY `created` (`created`), 194 KEY `url` (`url`), 195 KEY `ip` (`ip`,`id`) 196 KEY `referrer` (`referrer`) 197 ) $charset_collate;" ); 141 198 } 142 199 … … 197 254 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}redirection_groups;" ); 198 255 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}redirection_modules;" ); 256 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}redirection_404;" ); 199 257 200 258 delete_option( 'redirection_lookup' ); -
redirection/trunk/models/log.php
r540923 r543833 47 47 } 48 48 49 function create ($url, $target, $agent, $ip, $referrer, $extra = array()) {49 function create( $url, $target, $agent, $ip, $referrer, $extra = array()) { 50 50 global $wpdb, $redirection; 51 51 52 52 $insert = array( 53 'url' => urldecode( $url ), 54 'sent_to' => $target, 55 'created' => current_time( 'mysql' ), 56 'agent' => $agent, 57 'ip' => $ip, 58 'referrer' => $referrer, 59 'redirection_id' => isset( $extra['redirect_id'] ) ? $extra['redirect_id'] : 0, 60 'module_id' => isset( $extra['module_id'] ) ? $extra['module_id'] : 0, 61 'group_id' => isset( $extra['group_id'] ) ? $extra['group_id'] : 0, 53 'url' => urldecode( $url ), 54 'created' => current_time( 'mysql' ), 55 'ip' => $ip, 62 56 ); 63 57 58 if ( !empty( $agent ) ) 59 $insert['agent'] = $agent; 60 61 if ( !empty( $referrer ) ) 62 $insert['referrer'] = $referrer; 63 64 $insert['sent_to'] = $target; 65 $insert['redirection_id'] = isset( $extra['redirect_id'] ) ? $extra['redirect_id'] : 0; 66 $insert['module_id'] = isset( $extra['module_id'] ) ? $extra['module_id'] : 0; 67 $insert['group_id'] = isset( $extra['group_id'] ) ? $extra['group_id'] : 0; 68 64 69 $wpdb->insert( $wpdb->prefix.'redirection_logs', $insert ); 65 66 // Expire old entries67 $options = $redirection->get_options();68 if ( $options['expire'] != 0 )69 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE created < DATE_SUB(NOW(), INTERVAL %d DAY)", $options['expire'] ) );70 70 } 71 71 … … 117 117 } 118 118 119 class RE_404 { 120 var $id; 121 var $created; 122 var $url; 123 var $agent; 124 var $referrer; 125 var $ip; 126 127 function RE_404( $values ) { 128 foreach ( $values AS $key => $value ) { 129 $this->$key = $value; 130 } 131 132 $this->created = mysql2date ('U', $this->created); 133 } 134 135 function get_by_id( $id ) { 136 global $wpdb; 137 138 $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_404 WHERE id=%d", $id ) ); 139 if ( $row ) 140 return new RE_404( $row ); 141 return false; 142 } 143 144 function create( $url, $agent, $ip, $referrer ) { 145 global $wpdb, $redirection; 146 147 $insert = array( 148 'url' => urldecode( $url ), 149 'created' => current_time( 'mysql' ), 150 'ip' => ip2long( $ip ), 151 ); 152 153 if ( !empty( $agent ) ) 154 $insert['agent'] = $agent; 155 156 if ( !empty( $referrer ) ) 157 $insert['referrer'] = $referrer; 158 159 $wpdb->insert( $wpdb->prefix.'redirection_404', $insert ); 160 } 161 162 function delete( $id ) { 163 global $wpdb; 164 165 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_404 WHERE id=%d", $id ) ); 166 } 167 168 function delete_all() { 169 global $wpdb; 170 171 $where = array(); 172 if ( isset( $_POST['s'] ) ) 173 $where[] = $wpdb->prepare( 'url LIKE %s', '%'.$_POST['s'].'%' ); 174 175 $where_cond = ""; 176 if ( count( $where ) > 0 ) 177 $where_cond = " WHERE ".implode( ' AND ', $where ); 178 179 $wpdb->query( "DELETE FROM {$wpdb->prefix}redirection_404 ".$where_cond ); 180 } 181 } 182 -
redirection/trunk/models/module.php
r537877 r543833 160 160 'apache' => __( 'Apache', 'redirection' ), 161 161 'wp' => __( 'WordPress', 'redirection' ), 162 '404' => __( '404 Errors', 'redirection' ),163 162 ); 164 163 } … … 168 167 'apache' => array( 'Apache_Module', 'apache.php' ), 169 168 'wp' => array( 'WordPress_Module', 'wordpress.php' ), 170 '404' => array( 'Error404_Module', '404.php' )171 169 ); 172 170 -
redirection/trunk/models/pager.php
r540923 r543833 5 5 6 6 class Redirection_Log_Table extends WP_List_Table { 7 function __construct(){ 8 global $status, $page; 9 7 function __construct() { 10 8 //Set parent defaults 11 9 parent::__construct( array( … … 94 92 95 93 $per_page = 25; 96 $hidden = array();97 94 $columns = $this->get_columns(); 98 95 $sortable = $this->get_sortable_columns(); 99 96 $current_page = $this->get_pagenum(); 100 97 101 $this->_column_headers = array( $columns, $hidden, $sortable );98 $this->_column_headers = array( $columns, array(), $sortable ); 102 99 103 100 // Process any stuff … … 105 102 106 103 $orderby = ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'happened_at'; 107 $order = ( ! empty( $_GET['order'] ) ) ? strtolower( $_GET['order'] ) : 'desc';104 $order = ( ! empty( $_GET['order'] ) ) ? strtolower( $_GET['order'] ) : 'desc'; 108 105 109 106 if ( !in_array( $orderby, array_keys( $this->get_sortable_columns() ) ) ) … … 122 119 123 120 if ( isset( $_POST['s'] ) ) 124 $where[] = $wpdb->prepare( 'url LIKE %s', '%'. $_POST['s'].'%' );121 $where[] = $wpdb->prepare( 'url LIKE %s', '%'.like_escape( stripslashes( $_POST['s'] ) ).'%' ); 125 122 126 123 $where_cond = ""; … … 128 125 $where_cond = " WHERE ".implode( ' AND ', $where ); 129 126 130 $rows = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}redirection_logs FORCE INDEX(created) ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", $this->get_pagenum() - 1, $per_page ) ); 131 $total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}redirection_logs".$where_cond ); 132 133 $data = array (); 127 $table = $wpdb->prefix.'redirection_logs'; 128 129 $rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", $this->get_pagenum() - 1, $per_page ) ); 130 $total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond ); 131 132 $this->items = array(); 134 133 foreach ( (array)$rows AS $row ) { 135 $data[] = new RE_Log( $row ); 136 } 137 138 $this->items = $data; 134 $this->items[] = new RE_Log( $row ); 135 } 139 136 140 137 $this->set_pagination_args( array( … … 146 143 } 147 144 145 class Redirection_404_Table extends WP_List_Table { 146 function __construct() { 147 //Set parent defaults 148 parent::__construct( array( 149 'singular' => 'item', //singular name of the listed records 150 'plural' => 'items', //plural name of the listed records 151 'ajax' => false //does this table support ajax? 152 ) ); 153 } 154 155 function column_created( $item ) { 156 $actions['add'] = '<a href="'.esc_url( $item->url ).'" class="add-log">'.__( 'Add redirect', 'redirection' ).'</a>'; 157 158 return sprintf( '%1$s %2$s', date_i18n( get_option( 'date_format' ), $item->created ).' '.gmdate( get_option( 'time_format' ), $item->created ), $this->row_actions( $actions ) ); 159 } 160 161 function column_ip( $item ) { 162 $actions['add'] = '<a href="'.admin_url( 'tools.php?page=redirection.php&sub=404s&ip='.esc_attr( long2ip( $item->ip ) ) ).'">'.__( 'Show only this IP', 'redirection' ).'</a>'; 163 164 return sprintf( '%1$s %2$s', '<a href="http://urbangiraffe.com/map/?ip='.esc_attr( long2ip( $item->ip ) ).'&from=redirection">'.long2ip( $item->ip ).'</a>', $this->row_actions( $actions ) ); 165 } 166 167 function column_url( $item ) { 168 return '<a href="'.esc_url( $item->url ).'">'.esc_html( $item->show_url( $item->url ) ).'</a>'; 169 } 170 171 function column_referrer( $item ) { 172 $actions = array( 173 'agent' => esc_html( $item->agent ), 174 ); 175 176 return sprintf( '%1$s %2$s', '<a href="'.esc_url( $item->referrer ).'">'.esc_html( parse_url( $item->referrer, PHP_URL_HOST ) ).'</a>', $this->row_actions( $actions ) ); 177 } 178 179 function column_cb($item){ 180 return sprintf( 181 '<input type="checkbox" name="%1$s[]" value="%2$s" />', 182 /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie") 183 /*$2%s*/ $item->id //The value of the checkbox should be the record's id 184 ); 185 } 186 187 function get_columns(){ 188 $columns = array( 189 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text 190 'created' => __( 'Date', 'redirection' ), 191 'url' => __( 'Source URL', 'redirection' ), 192 'referrer' => __( 'Referrer', 'redirection' ), 193 'ip' => __( 'IP', 'redirection' ), 194 ); 195 return $columns; 196 } 197 198 function get_sortable_columns() { 199 $sortable_columns = array( 200 'created' => array( 'id', true ), 201 'url' => array( 'url', false), 202 'referrer' => array( 'referrer', false ), 203 ); 204 return $sortable_columns; 205 } 206 207 function get_bulk_actions() { 208 $actions = array( 209 'delete' => __( 'Delete', 'redirection' ) 210 ); 211 return $actions; 212 } 213 214 function process_bulk_action() { 215 if ( 'delete' === $this->current_action() ) { 216 foreach( $_POST['item'] AS $id ) { 217 RE_404::delete( intval( $id ) ); 218 } 219 } 220 } 221 222 function prepare_items( $restrict_by_ip = false ) { 223 global $wpdb; 224 225 $per_page = 25; 226 $columns = $this->get_columns(); 227 $sortable = $this->get_sortable_columns(); 228 $current_page = $this->get_pagenum(); 229 230 $this->_column_headers = array( $columns, array(), $sortable ); 231 232 // Process any stuff 233 $this->process_bulk_action(); 234 235 $orderby = ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id'; 236 $order = ( ! empty( $_GET['order'] ) ) ? strtolower( $_GET['order'] ) : 'desc'; 237 238 if ( !in_array( $orderby, array_keys( $sortable ) ) ) 239 $orderby = 'id'; 240 241 if ( !in_array( $order, array( 'asc', 'desc' ) ) ) 242 $order = 'desc'; 243 244 $where = array(); 245 if ( isset( $_POST['s'] ) ) 246 $where[] = $wpdb->prepare( 'url LIKE %s', '%'.$_POST['s'].'%' ); 247 248 if ( $restrict_by_ip !== false ) 249 $where[] = $wpdb->prepare( 'ip=INET_ATON(%s)', $restrict_by_ip ); 250 251 $where_cond = ""; 252 if ( count( $where ) > 0 ) 253 $where_cond = " WHERE ".implode( ' AND ', $where ); 254 255 $table = $wpdb->prefix.'redirection_404'; 256 257 $rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", $this->get_pagenum() - 1, $per_page ) ); 258 $total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond ); 259 260 $this->items = array(); 261 foreach ( (array)$rows AS $row ) { 262 $this->items[] = new RE_Log( $row ); 263 } 264 265 $this->set_pagination_args( array( 266 'total_items' => $total_items, 267 'per_page' => $per_page, 268 'total_pages' => ceil( $total_items / $per_page ) 269 ) ); 270 } 271 } 148 272 149 273 class RE_Pager -
redirection/trunk/readme.txt
r540923 r543833 56 56 * Belarusian, thanks to Alexander Ovsov 57 57 * Czech, thanks to Martin Jurica 58 * Danish, thanks to Rasmus Himmelstrup 58 59 59 60 == Installation == … … 89 90 90 91 == Changelog == 92 93 = 2.3.0 = 94 * Remove 404 module and move 404 logs into a seperate option 95 * Add Danish translation, thanks to Rasmus Himmelstrup 91 96 92 97 = 2.2.14 = -
redirection/trunk/redirection.php
r540976 r543833 4 4 Plugin URI: http://urbangiraffe.com/plugins/redirection/ 5 5 Description: Manage all your 301 redirects and monitor 404 errors 6 Version: 2. 2.146 Version: 2.3.1 7 7 Author: John Godley 8 8 Author URI: http://urbangiraffe.com … … 29 29 include dirname( __FILE__ ).'/models/monitor.php'; 30 30 include dirname( __FILE__ ).'/modules/wordpress.php'; 31 include dirname( __FILE__ ).'/modules/404.php'; 32 33 define( 'REDIRECTION_VERSION', '2.2' ); 31 32 define( 'REDIRECTION_VERSION', '2.3.1' ); 34 33 35 34 if ( class_exists( 'Redirection' ) ) … … 62 61 $this->wp = new WordPress_Module(); 63 62 $this->wp->start(); 64 65 $this->error = new Error404_Module();66 $this->error->start();67 63 } 68 64 69 65 $this->monitor = new Red_Monitor( $this->get_options() ); 66 $this->add_action ('template_redirect' ); 70 67 } 71 68 … … 113 110 'type' => 1, 114 111 'progress' => '<img src="'.plugin_dir_url( __FILE__ ).'/images/progress.gif" alt="loading" width="50" height="16"/>', 115 'are_you_sure' => __( 'Are you sure?', 'redirection' ),112 'are_you_sure' => __( 'Are you sure?', 'redirection' ), 116 113 'none_select' => __( 'No items have been selected', 'redirection' ) 117 114 ) ); … … 119 116 120 117 function admin_menu() { 121 add_management_page( __( "Redirection", 'redirection' ), __( "Redirection", 'redirection' ), "administrator", basename( __FILE__ ), array( &$this, "admin_screen" ) ); 118 add_management_page( __( "Redirection", 'redirection' ), __( "Redirection", 'redirection' ), "administrator", basename( __FILE__ ), array( &$this, "admin_screen" ) ); 119 } 120 121 function expire_logs() { 122 global $wpdb; 123 124 // Expire old entries 125 $options = $redirection->get_options(); 126 if ( $options['expire'] != 0 ) { 127 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE created < DATE_SUB(NOW(), INTERVAL %d DAY) LIMIT 1000", $options['expire'] ) ); 128 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_404 WHERE created < DATE_SUB(NOW(), INTERVAL %d DAY) LIMIT 1000", $options['expire'] ) ); 129 } 122 130 } 123 131 124 132 function admin_screen() { 125 $this->update(); 133 $this->update(); 134 $this->expire_logs(); 126 135 127 136 // Decide what to do … … 133 142 if ( $_GET['sub'] == 'log' ) 134 143 return $this->admin_screen_log(); 135 elseif ( $_GET['sub'] == 'options' ) 136 return $this->admin_screen_options(); 137 elseif ( $_GET['sub'] == 'process' ) 138 return $this->admin_screen_process(); 139 elseif ( $_GET['sub'] == 'groups' ) 144 elseif ( $_GET['sub'] == '404s' ) 145 return $this->admin_screen_404(); 146 elseif ( $_GET['sub'] == 'options' ) 147 return $this->admin_screen_options(); 148 elseif ( $_GET['sub'] == 'process' ) 149 return $this->admin_screen_process(); 150 elseif ( $_GET['sub'] == 'groups' ) 140 151 return $this->admin_groups( isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0 ); 141 152 elseif ( $_GET['sub'] == 'modules' ) 142 153 return $this->admin_screen_modules(); 143 154 elseif ( $_GET['sub'] == 'support' ) 144 return $this->render_admin('support' );155 return $this->render_admin('support', array( 'options' => $this->get_options() ) ); 145 156 } 146 157 … … 149 160 150 161 function admin_screen_modules() { 151 if ( isset( $_POST['create'] ) && check_admin_referer( 'redirection-module_add' ) ) { 152 $data = stripslashes_deep( $_POST ); 153 154 if ( ( $module = Red_Module::create( $data ) ) ) { 155 $moduleid = 0; 156 if ( isset( $_POST['module'] ) ) 157 $moduleid = intval( $_POST['module'] ); 158 159 $this->render_message( __( 'Your module was successfully created', 'redirection' ) ); 160 Red_Module::flush( $moduleid ); 161 } 162 else 163 $this->render_error( __( 'Your module was not created - did you provide a name?', 'redirection' ) ); 164 } 165 166 $options = $this->get_options(); 167 $this->render_admin( 'module_list', array( 'modules' => Red_Module::get_all(), 'module_types' => Red_Module::get_types(), 'token' => $options['token'] ) ); 162 $options = $this->get_options(); 163 $this->render_admin( 'module_list', array( 'options' => $this->get_options(), 'modules' => Red_Module::get_all(), 'module_types' => Red_Module::get_types(), 'token' => $options['token'] ) ); 168 164 } 169 165 … … 279 275 280 276 $options = $this->get_options(); 281 $this->render_admin( 'log', array( 'table' => $table, 'lookup' => $options['lookup'] ) ); 277 $this->render_admin( 'log', array( 'options' => $options, 'table' => $table, 'lookup' => $options['lookup'] ) ); 278 } 279 280 function admin_screen_404() { 281 include dirname( __FILE__ ).'/models/pager.php'; 282 283 if ( isset( $_POST['deleteall'] ) && check_admin_referer( 'redirection-process_logs' ) ) { 284 RE_404::delete_all(); 285 $this->render_message( __( 'Your logs have been deleted', 'redirection' ) ); 286 } 287 288 $table = new Redirection_404_Table(); 289 $table->prepare_items( isset( $_GET['ip'] ) ? $_GET['ip'] : false ); 290 291 $options = $this->get_options(); 292 $this->render_admin( 'log', array( 'options' => $options, 'table' => $table, 'lookup' => $options['lookup'] ) ); 282 293 } 283 294 … … 300 311 $items = Red_Group::get_all( $module, $pager ); 301 312 302 $this->render_admin( 'group_list', array( ' groups' => $items, 'pager' => $pager, 'modules' => Red_Module::get_for_select(), 'module' => Red_Module::get( $module ) ) );313 $this->render_admin( 'group_list', array( 'options' => $this->get_options(), 'groups' => $items, 'pager' => $pager, 'modules' => Red_Module::get_for_select(), 'module' => Red_Module::get( $module ) ) ); 303 314 } 304 315 … … 312 323 $items = Red_Item::get_by_group( $group, $pager ); 313 324 314 $this->render_admin( 'item_list', array('items' => $items, 'pager' => $pager, 'group' => Red_Group::get( $group ), 'groups' => Red_Group::get_for_select(), 'date_format' => get_option( 'date_format' ) ) );325 $this->render_admin( 'item_list', array( 'options' => $this->get_options(), 'items' => $items, 'pager' => $pager, 'group' => Red_Group::get( $group ), 'groups' => Red_Group::get_for_select(), 'date_format' => get_option( 'date_format' ) ) ); 315 326 } 316 327 … … 328 339 $readme = file_get_contents( dirname( __FILE__ ).'/readme.txt' ); 329 340 330 $start = strpos( $readme, __( 'Redirection is available in' ));341 $start = strpos( $readme, 'Redirection is available in' ); 331 342 $end = strpos( $readme, '==', $start ); 332 343 if ( $start !== false && $end !== false ) { … … 341 352 return $locales; 342 353 } 354 355 /** 356 * Matches 404s 357 * @return [type] [description] 358 */ 359 function template_redirect() { 360 if ( is_404() ) { 361 $options = $this->get_options(); 362 363 if ( $options['log_404s'] ) { 364 $log = RE_404::create( red_get_url(), red_user_agent(), red_ip(), red_http_referrer() ); 365 } 366 } 367 } 368 } 369 370 function red_get_url() { 371 if ( isset( $_SERVER['REQUEST_URI'] ) ) 372 return $_SERVER['REQUEST_URI']; 373 return ''; 374 } 375 376 function red_user_agent() { 377 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) 378 return $_SERVER['HTTP_USER_AGENT']; 379 return false; 380 } 381 382 function red_http_referrer() { 383 if ( isset( $_SERVER['HTTP_REFERER'] ) ) 384 return $_SERVER['HTTP_REFERER']; 385 return false; 386 } 387 388 function red_ip() { 389 if ( isset( $_SERVER['REMOTE_ADDR'] ) ) 390 return $_SERVER['REMOTE_ADDR']; 391 elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) 392 return $_SERVER['HTTP_X_FORWARDED_FOR']; 393 return ''; 343 394 } 344 395 -
redirection/trunk/view/admin/group_list.php
r539832 r543833 6 6 <h2><?php _e( 'Groups for module', 'redirection' ); ?>: <a href="edit.php?page=redirection.php&sub=modules"><?php echo esc_html( $module->name ) ?></a></h2> 7 7 8 <?php $this->render_admin( 'submenu' ); ?>8 <?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?> 9 9 10 10 <div id="pager" class="pager"> -
redirection/trunk/view/admin/item_list.php
r539832 r543833 8 8 9 9 <?php if ( $group ) : ?> 10 <a href="<?php echo $this->base (); ?>?page=redirection.php&sub=groups&id=<?php echo $group->module_id ?>">10 <a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=groups&id=<?php echo $group->module_id ?>"> 11 11 <?php echo esc_html( $group->name ); ?> 12 12 </a> … … 14 14 </h2> 15 15 16 <?php $this->render_admin( 'submenu' ); ?>16 <?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?> 17 17 18 18 <div id="pager" class="pager"> -
redirection/trunk/view/admin/log.php
r540923 r543833 6 6 <h2><?php _e ('Redirection Log', 'redirection'); ?></h2> 7 7 8 <?php $this->render_admin( 'submenu' ); ?>8 <?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?> 9 9 10 10 <form method="POST" action=""> -
redirection/trunk/view/admin/module_list.php
r539832 r543833 6 6 <h2><?php _e( 'Modules', 'redirection' ); ?></h2> 7 7 8 <?php $this->render_admin( 'submenu' ); ?>8 <?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?> 9 9 10 10 <?php if ( count( $modules ) > 0 ) : ?> … … 31 31 </div> 32 32 33 <div class="wrap">34 <h2><?php _e( 'Add Module', 'redirection' ); ?></h2>35 <p><?php _e( 'A module is a controlling element that determines how redirections are handled. Elements in a WordPress module are handled by WordPress, elements in an Apache module are handled by <code>.htaccess</code>, and elements in a 404 module affect how 404 errors are logged.', 'redirection' ); ?></p>36 37 <form action="" method="post" accept-charset="utf-8">38 <?php wp_nonce_field( 'redirection-module_add' ); ?>39 40 <table class="edit" summary="modules">41 <tr>42 <th width="100"><?php _e( 'Name', 'redirection' ); ?>:</th>43 <td><input size="40" type="text" name="name" value=""/></td>44 </tr>45 <tr>46 <th width="100"><?php _e( 'Type', 'redirection' ); ?>:</th>47 <td>48 <select name="type">49 <?php echo $this->select( $module_types ); ?>50 </select>51 </td>52 </tr>53 <tr>54 <td></td>55 <td><input class="button-primary" type="submit" name="create" value="<?php _e( 'Create', 'redirection' ); ?>"/></td>56 </tr>57 </table>58 </form>59 </div>60 61 33 <script type="text/javascript"> 62 34 jQuery(document ).ready( function() { -
redirection/trunk/view/admin/options.php
r540976 r543833 5 5 6 6 <h2><?php _e( 'Options', 'redirection' ) ?></h2> 7 <?php $this->render_admin( 'submenu' ); ?>7 <?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?> 8 8 9 9 <form method="post" action="" style="clear: both"> -
redirection/trunk/view/admin/submenu.php
r421720 r543833 2 2 3 3 <ul class="subsubsub"> 4 <li>5 <a <?php if ( !isset( $_GET['sub'] ) ) echo 'class="current"'; ?> href="?page=redirection.php<?php if ( isset( $_GET['id'] ) ) echo '&id='.intval( $_GET['id'] ) ?>">4 <li> 5 <a <?php if ( !isset( $_GET['sub'] ) ) echo 'class="current"'; ?> href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?><?php if ( isset( $_GET['id'] ) ) echo '&id='.intval( $_GET['id'] ) ?>"> 6 6 <?php _e( 'Redirects', 'redirection' ); ?> 7 7 </a> | 8 8 </li> 9 <li>10 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'groups' ) echo 'class="current"'; ?> href="?page=redirection.php&sub=groups<?php if ( isset( $_GET['id'] ) ) echo '&id='.intval( $_GET['id'] ) ?>">9 <li> 10 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'groups' ) echo 'class="current"'; ?> href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=groups<?php if ( isset( $_GET['id'] ) ) echo '&id='.intval( $_GET['id'] ) ?>"> 11 11 <?php _e( 'Groups', 'redirection' ); ?> 12 12 </a> | 13 13 </li> 14 <li>15 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'modules' ) echo 'class="current"'; ?> href="?page=redirection.php&sub=modules">14 <li> 15 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'modules' ) echo 'class="current"'; ?> href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=modules"> 16 16 <?php _e( 'Modules', 'redirection' ); ?> 17 17 </a> | 18 18 </li> 19 <li> 20 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'log' ) echo 'class="current"'; ?>href="?page=redirection.php&sub=log"> 19 20 <?php if ( isset( $options['log_redirections'] ) && $options['log_redirections'] ) : ?> 21 <li> 22 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'log' ) echo 'class="current"'; ?> href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=log"> 21 23 <?php _e( 'Log', 'redirection' ); ?> 22 24 </a> | 23 25 </li> 24 <li> 25 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'options' ) echo 'class="current"'; ?>href="?page=redirection.php&sub=options"> 26 <?php endif; ?> 27 28 <?php if ( isset( $options['log_404s'] ) && $options['log_404s'] ) : ?> 29 <li> 30 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == '404s' ) echo 'class="current"'; ?> href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=404s"> 31 <?php if ( isset( $_GET['ip'] ) ) : ?> 32 <?php printf( __( '404s from %s', 'redirection' ), long2ip( ip2long( $_GET['ip'] ) ) ); ?> 33 <?php else : ?> 34 <?php _e( '404s', 'redirection' ); ?> 35 <?php endif; ?> 36 </a> | 37 </li> 38 <?php endif; ?> 39 40 <li> 41 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'options' ) echo 'class="current"'; ?> href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=options"> 26 42 <?php _e( 'Options', 'redirection' ); ?> 27 43 </a> | 28 44 </li> 29 <li>30 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'support' ) echo 'class="current"'; ?> href="?page=redirection.php&sub=support">45 <li> 46 <a <?php if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'support' ) echo 'class="current"'; ?> href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=support"> 31 47 <?php _e( 'Support', 'redirection' ); ?> 32 48 </a> -
redirection/trunk/view/admin/support.php
r537877 r543833 4 4 5 5 <h2><?php _e ('Redirection Support', 'redirection'); ?></h2> 6 <?php $this->render_admin( 'submenu' ); ?>6 <?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?> 7 7 8 8 <p style="clear: both">
Note: See TracChangeset
for help on using the changeset viewer.