Version Description
- Full WordPress 3.5+ compatability! Note that this contains database changes so please backup your data.
=
Download this release
Release Info
| Developer | johnny5 |
| Plugin | |
| Version | 2.3.3 |
| Comparing to | |
| See all releases | |
Code changes from version 2.3.2 to 2.3.3
- fileio/apache.php +57 -95
- fileio/csv.php +32 -68
- fileio/rss.php +12 -14
- models/action.php +4 -4
- models/database.php +1 -2
- models/file_io.php +3 -3
- models/group.php +11 -14
- models/htaccess.php +120 -149
- models/log.php +12 -13
- models/match.php +11 -10
- models/module.php +25 -24
- models/monitor.php +1 -1
- models/pager.php +13 -5
- models/redirect.php +31 -22
- readme.txt +14 -4
- redirection.php +13 -9
- view/admin/group_list.php +4 -1
- view/admin/item.php +1 -1
- view/admin/options.php +8 -14
- view/admin/submenu.php +1 -1
- view/admin/support.php +4 -2
fileio/apache.php
CHANGED
|
@@ -1,63 +1,37 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
|
| 4 |
-
{
|
| 5 |
-
function strpbrk( $haystack, $char_list )
|
| 6 |
-
{
|
| 7 |
-
$strlen = strlen($char_list);
|
| 8 |
-
$found = false;
|
| 9 |
-
for( $i=0; $i<$strlen; $i++ ) {
|
| 10 |
-
if( ($tmp = strpos($haystack, $char_list{$i})) !== false ) {
|
| 11 |
-
if( !$found ) {
|
| 12 |
-
$pos = $tmp;
|
| 13 |
-
$found = true;
|
| 14 |
-
continue;
|
| 15 |
-
}
|
| 16 |
-
$pos = min($pos, $tmp);
|
| 17 |
-
}
|
| 18 |
-
}
|
| 19 |
-
if( !$found ) {
|
| 20 |
-
return false;
|
| 21 |
-
}
|
| 22 |
-
return substr($haystack, $pos);
|
| 23 |
-
}
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
class Red_Apache_File extends Red_FileIO
|
| 27 |
-
{
|
| 28 |
var $htaccess;
|
| 29 |
|
| 30 |
-
function collect
|
| 31 |
-
|
| 32 |
-
include_once (dirname (__FILE__).'/../models/htaccess.php');
|
| 33 |
|
| 34 |
-
$this->htaccess = new Red_Htaccess
|
| 35 |
$this->name = $module->name;
|
| 36 |
$this->id = $module->id;
|
| 37 |
|
| 38 |
// Get the items
|
| 39 |
$items = Red_Item::get_by_module( $module->id );
|
| 40 |
|
| 41 |
-
foreach ($items AS $item)
|
| 42 |
$this->htaccess->add ($item);
|
|
|
|
| 43 |
|
| 44 |
return true;
|
| 45 |
}
|
| 46 |
|
| 47 |
-
function feed ()
|
| 48 |
-
|
| 49 |
-
$filename = sprintf ('module_%d.htaccess', $this->id);
|
| 50 |
|
| 51 |
-
header
|
| 52 |
-
header
|
| 53 |
-
header
|
| 54 |
-
header
|
| 55 |
|
| 56 |
echo $this->htaccess->generate ($this->name);
|
| 57 |
}
|
| 58 |
|
| 59 |
-
function load
|
| 60 |
-
{
|
| 61 |
// Remove any comments
|
| 62 |
$data = preg_replace ('@#(.*)@', '', $data);
|
| 63 |
$data = str_replace ("\n", "\r", $data);
|
|
@@ -65,60 +39,54 @@ class Red_Apache_File extends Red_FileIO
|
|
| 65 |
|
| 66 |
// Split it into lines
|
| 67 |
$lines = array_filter (explode ("\r", $data));
|
| 68 |
-
if (count
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
$items[] = array
|
| 74 |
-
|
| 75 |
-
$items[] = array
|
| 76 |
-
|
| 77 |
-
$items[] = array
|
| 78 |
-
|
| 79 |
-
$items[] = array
|
| 80 |
-
else if (preg_match ('@Redirectmatch\s+(.*?)\s+(.*?)@i', $line, $matches) > 0)
|
| 81 |
-
$items[] = array ('source' => $this->decode_url ($matches[1]), 'target' => $this->decode_url ($matches[2]), 'code' => 302, 'regex' => true);
|
| 82 |
}
|
| 83 |
|
| 84 |
// Add items to group
|
| 85 |
-
if (count
|
| 86 |
-
|
| 87 |
-
foreach ($items AS $item)
|
| 88 |
-
{
|
| 89 |
$item['group'] = $group;
|
| 90 |
$item['red_action'] = 'url';
|
| 91 |
$item['match'] = 'url';
|
| 92 |
-
|
|
|
|
| 93 |
$item['red_action'] = 'pass';
|
| 94 |
|
| 95 |
-
Red_Item::create
|
| 96 |
}
|
| 97 |
|
| 98 |
-
return count
|
| 99 |
}
|
| 100 |
}
|
| 101 |
|
| 102 |
return 0;
|
| 103 |
}
|
| 104 |
|
| 105 |
-
function decode_url
|
| 106 |
-
|
| 107 |
-
$url =
|
| 108 |
-
$url = str_replace ('\\.', '.', $url);
|
| 109 |
return $url;
|
| 110 |
}
|
| 111 |
|
| 112 |
-
function is_str_regex
|
| 113 |
-
{
|
| 114 |
$regex = '()[]$^?+.';
|
| 115 |
$escape = false;
|
| 116 |
|
| 117 |
-
for ($x = 0; $x < strlen
|
| 118 |
-
|
| 119 |
-
if ($url{$x} == '\\')
|
| 120 |
$escape = true;
|
| 121 |
-
|
| 122 |
return true;
|
| 123 |
else
|
| 124 |
$escape = false;
|
|
@@ -127,49 +95,43 @@ class Red_Apache_File extends Red_FileIO
|
|
| 127 |
return false;
|
| 128 |
}
|
| 129 |
|
| 130 |
-
function is_regex
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
$tmp = ltrim ($url, '^');
|
| 135 |
-
$tmp = rtrim ($tmp, '$');
|
| 136 |
|
| 137 |
-
if ($this->is_str_regex
|
| 138 |
return true;
|
| 139 |
}
|
| 140 |
|
| 141 |
return false;
|
| 142 |
}
|
| 143 |
|
| 144 |
-
function regex_url ($url)
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
$tmp = ltrim ($url, '^');
|
| 149 |
-
$tmp = rtrim ($tmp, '$');
|
| 150 |
|
| 151 |
-
if ($this->is_str_regex
|
| 152 |
-
return '/'.$this->decode_url
|
| 153 |
|
| 154 |
-
return '/'.$this->decode_url
|
| 155 |
}
|
| 156 |
|
| 157 |
-
return $this->decode_url
|
| 158 |
}
|
| 159 |
|
| 160 |
-
function get_code ($code)
|
| 161 |
-
|
| 162 |
-
if (strpos ($code, '301') !== false || stripos ($code, 'permanent') !== false)
|
| 163 |
return 301;
|
| 164 |
-
|
| 165 |
return 302;
|
| 166 |
-
|
| 167 |
return 307;
|
| 168 |
-
|
| 169 |
return 404;
|
| 170 |
-
|
| 171 |
return 410;
|
| 172 |
return 0;
|
| 173 |
}
|
| 174 |
}
|
| 175 |
-
?>
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class Red_Apache_File extends Red_FileIO {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
var $htaccess;
|
| 5 |
|
| 6 |
+
function collect( $module ) {
|
| 7 |
+
include_once dirname( dirname( __FILE__ ) ).'/models/htaccess.php';
|
|
|
|
| 8 |
|
| 9 |
+
$this->htaccess = new Red_Htaccess( $module );
|
| 10 |
$this->name = $module->name;
|
| 11 |
$this->id = $module->id;
|
| 12 |
|
| 13 |
// Get the items
|
| 14 |
$items = Red_Item::get_by_module( $module->id );
|
| 15 |
|
| 16 |
+
foreach ( $items AS $item ) {
|
| 17 |
$this->htaccess->add ($item);
|
| 18 |
+
}
|
| 19 |
|
| 20 |
return true;
|
| 21 |
}
|
| 22 |
|
| 23 |
+
function feed () {
|
| 24 |
+
$filename = sprintf( 'module_%d.htaccess', $this->id );
|
|
|
|
| 25 |
|
| 26 |
+
header( 'Content-Type: application/octet-stream' );
|
| 27 |
+
header( 'Cache-Control: no-cache, must-revalidate' );
|
| 28 |
+
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
|
| 29 |
+
header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
|
| 30 |
|
| 31 |
echo $this->htaccess->generate ($this->name);
|
| 32 |
}
|
| 33 |
|
| 34 |
+
function load( $group, $data, $filename = '' ) {
|
|
|
|
| 35 |
// Remove any comments
|
| 36 |
$data = preg_replace ('@#(.*)@', '', $data);
|
| 37 |
$data = str_replace ("\n", "\r", $data);
|
| 39 |
|
| 40 |
// Split it into lines
|
| 41 |
$lines = array_filter (explode ("\r", $data));
|
| 42 |
+
if ( count( $lines ) > 0 ) {
|
| 43 |
+
foreach ( $lines AS $line ) {
|
| 44 |
+
if ( preg_match ('@rewriterule\s+(.*?)\s+(.*?)\s+(\[.*\])*@i', $line, $matches) > 0 )
|
| 45 |
+
$items[] = array('source' => $this->regex_url ($matches[1]), 'target' => $this->decode_url ($matches[2]), 'code' => $this->get_code ($matches[3]), 'regex' => $this->is_regex ($matches[1]) );
|
| 46 |
+
elseif ( preg_match( '@Redirect\s+(.*?)\s+(.*?)\s+(.*)@i', $line, $matches) > 0 )
|
| 47 |
+
$items[] = array( 'source' => $this->decode_url ($matches[2]), 'target' => $this->decode_url ($matches[3]), 'code' => $this->get_code ($matches[1]) );
|
| 48 |
+
elseif ( preg_match( '@Redirect\s+(.*?)\s+(.*?)@i', $line, $matches) > 0 )
|
| 49 |
+
$items[] = array( 'source' => $this->decode_url ($matches[1]), 'target' => $this->decode_url ($matches[2]), 'code' => 302);
|
| 50 |
+
elseif ( preg_match( '@Redirectmatch\s+(.*?)\s+(.*?)\s+(.*)@i', $line, $matches) > 0 )
|
| 51 |
+
$items[] = array( 'source' => $this->decode_url ($matches[2]), 'target' => $this->decode_url ($matches[3]), 'code' => $this->get_code ($matches[1]), 'regex' => true );
|
| 52 |
+
elseif ( preg_match( '@Redirectmatch\s+(.*?)\s+(.*?)@i', $line, $matches) > 0 )
|
| 53 |
+
$items[] = array( 'source' => $this->decode_url ($matches[1]), 'target' => $this->decode_url ($matches[2]), 'code' => 302, 'regex' => true );
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
// Add items to group
|
| 57 |
+
if ( count( $items ) > 0 ) {
|
| 58 |
+
foreach ( $items AS $item ) {
|
|
|
|
|
|
|
| 59 |
$item['group'] = $group;
|
| 60 |
$item['red_action'] = 'url';
|
| 61 |
$item['match'] = 'url';
|
| 62 |
+
|
| 63 |
+
if ( $item['code'] == 0 )
|
| 64 |
$item['red_action'] = 'pass';
|
| 65 |
|
| 66 |
+
Red_Item::create( $item );
|
| 67 |
}
|
| 68 |
|
| 69 |
+
return count( $items );
|
| 70 |
}
|
| 71 |
}
|
| 72 |
|
| 73 |
return 0;
|
| 74 |
}
|
| 75 |
|
| 76 |
+
function decode_url( $url ) {
|
| 77 |
+
$url = rawurldecode( $url );
|
| 78 |
+
$url = str_replace( '\\.', '.', $url );
|
|
|
|
| 79 |
return $url;
|
| 80 |
}
|
| 81 |
|
| 82 |
+
function is_str_regex( $url ) {
|
|
|
|
| 83 |
$regex = '()[]$^?+.';
|
| 84 |
$escape = false;
|
| 85 |
|
| 86 |
+
for ( $x = 0; $x < strlen( $url ); $x++ ) {
|
| 87 |
+
if ( $url{$x} == '\\' )
|
|
|
|
| 88 |
$escape = true;
|
| 89 |
+
elseif ( strpos( $regex, $url{$x} ) !== false && !$escape )
|
| 90 |
return true;
|
| 91 |
else
|
| 92 |
$escape = false;
|
| 95 |
return false;
|
| 96 |
}
|
| 97 |
|
| 98 |
+
function is_regex( $url ) {
|
| 99 |
+
if ( $this->is_str_regex( $url ) ) {
|
| 100 |
+
$tmp = ltrim( $url, '^' );
|
| 101 |
+
$tmp = rtrim( $tmp, '$' );
|
|
|
|
|
|
|
| 102 |
|
| 103 |
+
if ( $this->is_str_regex( $tmp ) )
|
| 104 |
return true;
|
| 105 |
}
|
| 106 |
|
| 107 |
return false;
|
| 108 |
}
|
| 109 |
|
| 110 |
+
function regex_url ($url) {
|
| 111 |
+
if ( $this->is_str_regex( $url ) ) {
|
| 112 |
+
$tmp = ltrim( $url, '^' );
|
| 113 |
+
$tmp = rtrim( $tmp, '$' );
|
|
|
|
|
|
|
| 114 |
|
| 115 |
+
if ( $this->is_str_regex( $tmp ) == false )
|
| 116 |
+
return '/'.$this->decode_url( $tmp );
|
| 117 |
|
| 118 |
+
return '/'.$this->decode_url( $url );
|
| 119 |
}
|
| 120 |
|
| 121 |
+
return $this->decode_url( $url );
|
| 122 |
}
|
| 123 |
|
| 124 |
+
function get_code ($code) {
|
| 125 |
+
if ( strpos( $code, '301' ) !== false || stripos( $code, 'permanent' ) !== false )
|
|
|
|
| 126 |
return 301;
|
| 127 |
+
elseif ( strpos( $code, '302' ) !== false )
|
| 128 |
return 302;
|
| 129 |
+
elseif ( strpos( $code, '307' ) !== false || stripos( $code, 'seeother' ) !== false )
|
| 130 |
return 307;
|
| 131 |
+
elseif ( strpos( $code, '404' ) !== false || stripos( $code, 'forbidden' ) !== false || strpos( $code, 'F' ) !== false )
|
| 132 |
return 404;
|
| 133 |
+
elseif ( strpos( $code, '410' ) !== false || stripos( $code, 'gone' ) !== false || strpos( $code, 'G' ) !== false )
|
| 134 |
return 410;
|
| 135 |
return 0;
|
| 136 |
}
|
| 137 |
}
|
|
|
fileio/csv.php
CHANGED
|
@@ -1,79 +1,45 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class Red_Csv_File extends Red_FileIO
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
{
|
| 7 |
-
$this->id = $module->id;
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
{
|
| 12 |
-
foreach ($items AS $item)
|
| 13 |
-
$this->items[] = array ('source' => $item->url, 'target' => ($item->action_type == 'url' ? $item->action_data : ''), 'last_count' => $item->last_count);
|
| 14 |
-
}
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
function feed ($filename = '', $heading = '')
|
| 18 |
-
{
|
| 19 |
-
$filename = sprintf (__ ('module_%d.csv', 'redirection'), $this->id);
|
| 20 |
|
| 21 |
-
|
| 22 |
-
header ("Cache-Control: no-cache, must-revalidate");
|
| 23 |
-
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
| 24 |
-
header ('Content-Disposition: attachment; filename="'.$filename.'"');
|
| 25 |
-
|
| 26 |
-
if (count ($this->items) > 0)
|
| 27 |
-
{
|
| 28 |
-
echo "source,target,hits\r\n";
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
-
function
|
| 36 |
-
|
| 37 |
-
// Escape any special values
|
| 38 |
-
$double = false;
|
| 39 |
-
if (strpos ($value, ',') !== false || $value == '')
|
| 40 |
-
$double = true;
|
| 41 |
-
|
| 42 |
-
if (strpos ($value, '"') !== false)
|
| 43 |
-
{
|
| 44 |
-
$double = true;
|
| 45 |
-
$value = str_replace ('"', '""', $value);
|
| 46 |
-
}
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
$string = str_replace('""', "'", $string);
|
| 56 |
-
$bits = explode ('"',$string);
|
| 57 |
-
$elements = array ();
|
| 58 |
|
| 59 |
-
|
| 60 |
-
{
|
| 61 |
-
if (($i % 2) == 1)
|
| 62 |
-
$elements[] = $bits[$i];
|
| 63 |
-
else
|
| 64 |
-
{
|
| 65 |
-
$rest = $bits[$i];
|
| 66 |
-
$rest = preg_replace ('/^'.$separator.'/', '', $rest);
|
| 67 |
-
$rest = preg_replace ('/'.$separator.'$/', '', $rest);
|
| 68 |
|
| 69 |
-
|
|
|
|
| 70 |
}
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
return $elements;
|
| 74 |
}
|
| 75 |
|
| 76 |
-
function load( $group, $data, $filename ) {
|
| 77 |
$count = 0;
|
| 78 |
$file = fopen( $filename, 'r' );
|
| 79 |
|
|
@@ -97,16 +63,15 @@ class Red_Csv_File extends Red_FileIO
|
|
| 97 |
return $count;
|
| 98 |
}
|
| 99 |
|
| 100 |
-
function is_regex ($url)
|
| 101 |
-
{
|
| 102 |
$regex = '()[]$^?+';
|
| 103 |
$escape = false;
|
| 104 |
|
| 105 |
-
for ($x = 0; $x < strlen
|
| 106 |
-
|
| 107 |
-
if ($url{$x} == '\\')
|
| 108 |
$escape = true;
|
| 109 |
-
|
| 110 |
return true;
|
| 111 |
else
|
| 112 |
$escape = false;
|
|
@@ -115,4 +80,3 @@ class Red_Csv_File extends Red_FileIO
|
|
| 115 |
return false;
|
| 116 |
}
|
| 117 |
}
|
| 118 |
-
?>
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class Red_Csv_File extends Red_FileIO {
|
| 4 |
+
var $id;
|
| 5 |
+
var $items;
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
function collect( $module ) {
|
| 8 |
+
$this->id = $module->id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
$items = Red_Item::get_by_module( $module->id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
if ( count( $items ) > 0 ) {
|
| 13 |
+
foreach ( $items AS $item ) {
|
| 14 |
+
$this->items[] = array(
|
| 15 |
+
'source' => $item->url,
|
| 16 |
+
'target' => ( $item->action_type == 'url' ? $item->action_data : '' ),
|
| 17 |
+
'last_count' => $item->last_count
|
| 18 |
+
);
|
| 19 |
+
}
|
| 20 |
}
|
| 21 |
}
|
| 22 |
|
| 23 |
+
function feed( $filename = '', $heading = '' ) {
|
| 24 |
+
$filename = sprintf( __( 'module_%d.csv', 'redirection' ), $this->id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
header( 'Content-Type: text/csv' );
|
| 27 |
+
header( 'Cache-Control: no-cache, must-revalidate' );
|
| 28 |
+
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
|
| 29 |
+
header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
|
| 30 |
|
| 31 |
+
if ( count( $this->items ) > 0 ) {
|
| 32 |
+
echo "source,target,hits\r\n";
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
$stdout = fopen( 'php://output', 'w' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
foreach ( $this->items AS $line ) {
|
| 37 |
+
fputcsv( $stdout, $line );
|
| 38 |
}
|
| 39 |
+
}
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
+
function load( $group, $data, $filename = '' ) {
|
| 43 |
$count = 0;
|
| 44 |
$file = fopen( $filename, 'r' );
|
| 45 |
|
| 63 |
return $count;
|
| 64 |
}
|
| 65 |
|
| 66 |
+
function is_regex ($url) {
|
|
|
|
| 67 |
$regex = '()[]$^?+';
|
| 68 |
$escape = false;
|
| 69 |
|
| 70 |
+
for ( $x = 0; $x < strlen( $url ); $x++ ) {
|
| 71 |
+
|
| 72 |
+
if ( $url{$x} == '\\' )
|
| 73 |
$escape = true;
|
| 74 |
+
elseif ( strpos( $regex, $url{$x} ) !== false && !$escape )
|
| 75 |
return true;
|
| 76 |
else
|
| 77 |
$escape = false;
|
| 80 |
return false;
|
| 81 |
}
|
| 82 |
}
|
|
|
fileio/rss.php
CHANGED
|
@@ -7,7 +7,7 @@ class Red_Rss_File extends Red_FileIO
|
|
| 7 |
function collect ($module)
|
| 8 |
{
|
| 9 |
$this->name = $module->name;
|
| 10 |
-
$this->items =
|
| 11 |
}
|
| 12 |
|
| 13 |
function feed ()
|
|
@@ -22,23 +22,23 @@ class Red_Rss_File extends Red_FileIO
|
|
| 22 |
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
| 23 |
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
| 24 |
<channel>
|
| 25 |
-
<title><?php echo $title.' - '; bloginfo_rss ('name'); ?></title>
|
| 26 |
-
<link><?php bloginfo_rss('url') ?></link>
|
| 27 |
<description><?php bloginfo_rss("description") ?></description>
|
| 28 |
-
<pubDate><?php echo
|
| 29 |
-
<generator><?php echo
|
| 30 |
-
<language><?php echo get_option
|
| 31 |
<?php
|
| 32 |
if (count ($this->items) > 0)
|
| 33 |
{
|
| 34 |
foreach ($this->items as $log) : ?>
|
| 35 |
<item>
|
| 36 |
-
<title
|
| 37 |
-
<link><![CDATA[<?php
|
| 38 |
-
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $log->
|
| 39 |
-
<guid isPermaLink="false"><?php
|
| 40 |
-
<description
|
| 41 |
-
<content:encoded
|
| 42 |
</item>
|
| 43 |
<?php endforeach; } ?>
|
| 44 |
</channel>
|
|
@@ -47,5 +47,3 @@ class Red_Rss_File extends Red_FileIO
|
|
| 47 |
die();
|
| 48 |
}
|
| 49 |
}
|
| 50 |
-
|
| 51 |
-
?>
|
| 7 |
function collect ($module)
|
| 8 |
{
|
| 9 |
$this->name = $module->name;
|
| 10 |
+
$this->items = Red_Item::get_by_module( $module->id );
|
| 11 |
}
|
| 12 |
|
| 13 |
function feed ()
|
| 22 |
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
| 23 |
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
| 24 |
<channel>
|
| 25 |
+
<title><?php echo esc_html( $title ).' - '; bloginfo_rss ('name'); ?></title>
|
| 26 |
+
<link><?php bloginfo_rss( 'url' ) ?></link>
|
| 27 |
<description><?php bloginfo_rss("description") ?></description>
|
| 28 |
+
<pubDate><?php echo esc_html( mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified( 'GMT' ), false ) ); ?></pubDate>
|
| 29 |
+
<generator><?php echo esc_html( 'http://wordpress.org/?v=' ); bloginfo_rss( 'version' ); ?></generator>
|
| 30 |
+
<language><?php echo get_option( 'rss_language' ); ?></language>
|
| 31 |
<?php
|
| 32 |
if (count ($this->items) > 0)
|
| 33 |
{
|
| 34 |
foreach ($this->items as $log) : ?>
|
| 35 |
<item>
|
| 36 |
+
<title><?php echo esc_html( $log->url ); ?></title>
|
| 37 |
+
<link><![CDATA[<?php echo home_url(); echo esc_html( $log->url ); ?>]]></link>
|
| 38 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $log->created, false); ?></pubDate>
|
| 39 |
+
<guid isPermaLink="false"><?php echo $log->id; ?></guid>
|
| 40 |
+
<description><?php echo esc_html( $log->url ); ?></description>
|
| 41 |
+
<content:encoded><?php if ( $log->referrer ) echo 'Referred by '.esc_html( $log->referrer ); ?></content:encoded>
|
| 42 |
</item>
|
| 43 |
<?php endforeach; } ?>
|
| 44 |
</channel>
|
| 47 |
die();
|
| 48 |
}
|
| 49 |
}
|
|
|
|
|
|
models/action.php
CHANGED
|
@@ -15,9 +15,9 @@ class Red_Action
|
|
| 15 |
|
| 16 |
function config () { }
|
| 17 |
|
| 18 |
-
function create ($name, $code)
|
| 19 |
{
|
| 20 |
-
$avail =
|
| 21 |
if (isset ($avail[$name]))
|
| 22 |
{
|
| 23 |
if (!class_exists (strtolower ($avail[$name][1])))
|
|
@@ -31,7 +31,7 @@ class Red_Action
|
|
| 31 |
return false;
|
| 32 |
}
|
| 33 |
|
| 34 |
-
function available ()
|
| 35 |
{
|
| 36 |
return array
|
| 37 |
(
|
|
@@ -60,4 +60,4 @@ class Red_Action
|
|
| 60 |
}
|
| 61 |
|
| 62 |
}
|
| 63 |
-
?>
|
| 15 |
|
| 16 |
function config () { }
|
| 17 |
|
| 18 |
+
static function create ($name, $code)
|
| 19 |
{
|
| 20 |
+
$avail = self::available ();
|
| 21 |
if (isset ($avail[$name]))
|
| 22 |
{
|
| 23 |
if (!class_exists (strtolower ($avail[$name][1])))
|
| 31 |
return false;
|
| 32 |
}
|
| 33 |
|
| 34 |
+
static function available ()
|
| 35 |
{
|
| 36 |
return array
|
| 37 |
(
|
| 60 |
}
|
| 61 |
|
| 62 |
}
|
| 63 |
+
?>
|
models/database.php
CHANGED
|
@@ -122,7 +122,6 @@ class RE_Database {
|
|
| 122 |
if ( $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}redirection_modules" ) == 0 ) {
|
| 123 |
$wpdb->insert( $wpdb->prefix.'redirection_modules', array( 'type' => 'wp', 'name' => __( 'WordPress', 'redirection' ), 'options' => '' ) );
|
| 124 |
$wpdb->insert( $wpdb->prefix.'redirection_modules', array( 'type' => 'apache', 'name' => __( 'Apache', 'redirection' ), 'options' => '' ) );
|
| 125 |
-
$wpdb->insert( $wpdb->prefix.'redirection_modules', array( 'type' => '404', 'name' => __( '404', 'redirection' ), 'options' => '' ) );
|
| 126 |
}
|
| 127 |
|
| 128 |
// Groups
|
|
@@ -192,7 +191,7 @@ class RE_Database {
|
|
| 192 |
PRIMARY KEY (`id`),
|
| 193 |
KEY `created` (`created`),
|
| 194 |
KEY `url` (`url`),
|
| 195 |
-
KEY `ip` (`ip`,`id`)
|
| 196 |
KEY `referrer` (`referrer`)
|
| 197 |
) $charset_collate;" );
|
| 198 |
}
|
| 122 |
if ( $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}redirection_modules" ) == 0 ) {
|
| 123 |
$wpdb->insert( $wpdb->prefix.'redirection_modules', array( 'type' => 'wp', 'name' => __( 'WordPress', 'redirection' ), 'options' => '' ) );
|
| 124 |
$wpdb->insert( $wpdb->prefix.'redirection_modules', array( 'type' => 'apache', 'name' => __( 'Apache', 'redirection' ), 'options' => '' ) );
|
|
|
|
| 125 |
}
|
| 126 |
|
| 127 |
// Groups
|
| 191 |
PRIMARY KEY (`id`),
|
| 192 |
KEY `created` (`created`),
|
| 193 |
KEY `url` (`url`),
|
| 194 |
+
KEY `ip` (`ip`,`id`),
|
| 195 |
KEY `referrer` (`referrer`)
|
| 196 |
) $charset_collate;" );
|
| 197 |
}
|
models/file_io.php
CHANGED
|
@@ -31,12 +31,12 @@ class Red_FileIO
|
|
| 31 |
$parts = pathinfo( $file['name'] );
|
| 32 |
|
| 33 |
if ( $parts['extension'] == 'csv' ) {
|
| 34 |
-
include dirname( __FILE__ ).'
|
| 35 |
$importer = new Red_Csv_File();
|
| 36 |
$data = '';
|
| 37 |
}
|
| 38 |
else {
|
| 39 |
-
include dirname( __FILE__ ).'
|
| 40 |
$importer = new Red_Apache_File();
|
| 41 |
$data = @file_get_contents ($file['tmp_name']);
|
| 42 |
}
|
|
@@ -47,5 +47,5 @@ class Red_FileIO
|
|
| 47 |
return 0;
|
| 48 |
}
|
| 49 |
|
| 50 |
-
function load ($group, $data) { }
|
| 51 |
}
|
| 31 |
$parts = pathinfo( $file['name'] );
|
| 32 |
|
| 33 |
if ( $parts['extension'] == 'csv' ) {
|
| 34 |
+
include dirname( dirname( __FILE__ ) ).'/fileio/csv.php';
|
| 35 |
$importer = new Red_Csv_File();
|
| 36 |
$data = '';
|
| 37 |
}
|
| 38 |
else {
|
| 39 |
+
include dirname( dirname( __FILE__ ) ).'/fileio/apache.php';
|
| 40 |
$importer = new Red_Apache_File();
|
| 41 |
$data = @file_get_contents ($file['tmp_name']);
|
| 42 |
}
|
| 47 |
return 0;
|
| 48 |
}
|
| 49 |
|
| 50 |
+
function load ($group, $data, $filename = '' ) { }
|
| 51 |
}
|
models/group.php
CHANGED
|
@@ -12,7 +12,7 @@ class Red_Group {
|
|
| 12 |
/**
|
| 13 |
* Get list of groups
|
| 14 |
*/
|
| 15 |
-
function get( $id ) {
|
| 16 |
global $wpdb;
|
| 17 |
|
| 18 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT {$wpdb->prefix}redirection_groups.*,COUNT( {$wpdb->prefix}redirection_items.id ) AS items,SUM( {$wpdb->prefix}redirection_items.last_count ) AS redirects FROM {$wpdb->prefix}redirection_groups LEFT JOIN {$wpdb->prefix}redirection_items ON {$wpdb->prefix}redirection_items.group_id={$wpdb->prefix}redirection_groups.id WHERE {$wpdb->prefix}redirection_groups.id=%d GROUP BY {$wpdb->prefix}redirection_groups.id", $id ) );
|
|
@@ -21,7 +21,7 @@ class Red_Group {
|
|
| 21 |
return false;
|
| 22 |
}
|
| 23 |
|
| 24 |
-
function get_for_module( $module ) {
|
| 25 |
global $wpdb;
|
| 26 |
|
| 27 |
$sql = $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS {$wpdb->prefix}redirection_groups.* FROM {$wpdb->prefix}redirection_groups WHERE {$wpdb->prefix}redirection_groups.module_id=%d", $module );
|
|
@@ -41,7 +41,7 @@ class Red_Group {
|
|
| 41 |
* Get all groups with number of items in each group
|
| 42 |
* DBW
|
| 43 |
*/
|
| 44 |
-
function get_all( $module, $pager ) {
|
| 45 |
global $wpdb;
|
| 46 |
|
| 47 |
$sql = $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS {$wpdb->prefix}redirection_groups.*,COUNT( {$wpdb->prefix}redirection_items.id ) AS items,SUM( {$wpdb->prefix}redirection_items.last_count ) AS redirects FROM {$wpdb->prefix}redirection_groups LEFT JOIN {$wpdb->prefix}redirection_items ON {$wpdb->prefix}redirection_items.group_id={$wpdb->prefix}redirection_groups.id WHERE {$wpdb->prefix}redirection_groups.module_id=%d", $module );
|
|
@@ -63,7 +63,7 @@ class Red_Group {
|
|
| 63 |
* Get list of groups
|
| 64 |
* DBW
|
| 65 |
*/
|
| 66 |
-
function get_for_select() {
|
| 67 |
global $wpdb;
|
| 68 |
|
| 69 |
$data = array();
|
|
@@ -80,13 +80,13 @@ class Red_Group {
|
|
| 80 |
/**
|
| 81 |
* Get first group ID
|
| 82 |
*/
|
| 83 |
-
function get_first_id() {
|
| 84 |
global $wpdb;
|
| 85 |
|
| 86 |
return $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}redirection_groups ORDER BY id LIMIT 0,1" );
|
| 87 |
}
|
| 88 |
|
| 89 |
-
function create( $data ) {
|
| 90 |
global $wpdb;
|
| 91 |
|
| 92 |
$name = trim( $data['name'] );
|
|
@@ -126,10 +126,10 @@ class Red_Group {
|
|
| 126 |
Red_Module::flush( $this->module_id );
|
| 127 |
}
|
| 128 |
|
| 129 |
-
function delete( $group ) {
|
| 130 |
global $wpdb;
|
| 131 |
|
| 132 |
-
$obj =
|
| 133 |
|
| 134 |
// Delete all items in this group
|
| 135 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $group ) );
|
|
@@ -146,14 +146,14 @@ class Red_Group {
|
|
| 146 |
}
|
| 147 |
}
|
| 148 |
|
| 149 |
-
function save_order( $items, $start ) {
|
| 150 |
global $wpdb;
|
| 151 |
|
| 152 |
foreach ( $items AS $pos => $id ) {
|
| 153 |
$wpdb->update( $wpdb->prefix.'redirection_groups', array( 'position' => $pos + $start ), array( 'id' => intval( $id ) ) );
|
| 154 |
}
|
| 155 |
|
| 156 |
-
$group =
|
| 157 |
Red_Module::flush( $group->module_id );
|
| 158 |
}
|
| 159 |
|
|
@@ -206,9 +206,6 @@ class Red_Group {
|
|
| 206 |
function hits() {
|
| 207 |
global $wpdb;
|
| 208 |
|
| 209 |
-
|
| 210 |
-
if ( $count > 0 )
|
| 211 |
-
return $count;
|
| 212 |
-
return 0;
|
| 213 |
}
|
| 214 |
}
|
| 12 |
/**
|
| 13 |
* Get list of groups
|
| 14 |
*/
|
| 15 |
+
static function get( $id ) {
|
| 16 |
global $wpdb;
|
| 17 |
|
| 18 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT {$wpdb->prefix}redirection_groups.*,COUNT( {$wpdb->prefix}redirection_items.id ) AS items,SUM( {$wpdb->prefix}redirection_items.last_count ) AS redirects FROM {$wpdb->prefix}redirection_groups LEFT JOIN {$wpdb->prefix}redirection_items ON {$wpdb->prefix}redirection_items.group_id={$wpdb->prefix}redirection_groups.id WHERE {$wpdb->prefix}redirection_groups.id=%d GROUP BY {$wpdb->prefix}redirection_groups.id", $id ) );
|
| 21 |
return false;
|
| 22 |
}
|
| 23 |
|
| 24 |
+
static function get_for_module( $module ) {
|
| 25 |
global $wpdb;
|
| 26 |
|
| 27 |
$sql = $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS {$wpdb->prefix}redirection_groups.* FROM {$wpdb->prefix}redirection_groups WHERE {$wpdb->prefix}redirection_groups.module_id=%d", $module );
|
| 41 |
* Get all groups with number of items in each group
|
| 42 |
* DBW
|
| 43 |
*/
|
| 44 |
+
static function get_all( $module, $pager ) {
|
| 45 |
global $wpdb;
|
| 46 |
|
| 47 |
$sql = $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS {$wpdb->prefix}redirection_groups.*,COUNT( {$wpdb->prefix}redirection_items.id ) AS items,SUM( {$wpdb->prefix}redirection_items.last_count ) AS redirects FROM {$wpdb->prefix}redirection_groups LEFT JOIN {$wpdb->prefix}redirection_items ON {$wpdb->prefix}redirection_items.group_id={$wpdb->prefix}redirection_groups.id WHERE {$wpdb->prefix}redirection_groups.module_id=%d", $module );
|
| 63 |
* Get list of groups
|
| 64 |
* DBW
|
| 65 |
*/
|
| 66 |
+
static function get_for_select() {
|
| 67 |
global $wpdb;
|
| 68 |
|
| 69 |
$data = array();
|
| 80 |
/**
|
| 81 |
* Get first group ID
|
| 82 |
*/
|
| 83 |
+
static function get_first_id() {
|
| 84 |
global $wpdb;
|
| 85 |
|
| 86 |
return $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}redirection_groups ORDER BY id LIMIT 0,1" );
|
| 87 |
}
|
| 88 |
|
| 89 |
+
static function create( $data ) {
|
| 90 |
global $wpdb;
|
| 91 |
|
| 92 |
$name = trim( $data['name'] );
|
| 126 |
Red_Module::flush( $this->module_id );
|
| 127 |
}
|
| 128 |
|
| 129 |
+
static function delete( $group ) {
|
| 130 |
global $wpdb;
|
| 131 |
|
| 132 |
+
$obj = self::get( $group );
|
| 133 |
|
| 134 |
// Delete all items in this group
|
| 135 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $group ) );
|
| 146 |
}
|
| 147 |
}
|
| 148 |
|
| 149 |
+
static function save_order( $items, $start ) {
|
| 150 |
global $wpdb;
|
| 151 |
|
| 152 |
foreach ( $items AS $pos => $id ) {
|
| 153 |
$wpdb->update( $wpdb->prefix.'redirection_groups', array( 'position' => $pos + $start ), array( 'id' => intval( $id ) ) );
|
| 154 |
}
|
| 155 |
|
| 156 |
+
$group = self::get( $items[0] );
|
| 157 |
Red_Module::flush( $group->module_id );
|
| 158 |
}
|
| 159 |
|
| 206 |
function hits() {
|
| 207 |
global $wpdb;
|
| 208 |
|
| 209 |
+
return (int)$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}redirection_logs WHERE group_id=%d", $this->id ) );
|
|
|
|
|
|
|
|
|
|
| 210 |
}
|
| 211 |
}
|
models/htaccess.php
CHANGED
|
@@ -1,167 +1,144 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class Red_Htaccess
|
| 4 |
-
{
|
| 5 |
var $settings;
|
| 6 |
var $items;
|
| 7 |
|
| 8 |
-
function
|
| 9 |
-
|
| 10 |
-
foreach ($settings AS $key => $value)
|
| 11 |
$this->settings[$key] = $value;
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
-
function encode_from
|
| 15 |
-
|
| 16 |
-
return '^'.$this->encode ($url).'$';
|
| 17 |
}
|
| 18 |
|
| 19 |
-
function encode2nd
|
| 20 |
-
|
| 21 |
-
$url =
|
| 22 |
-
$url = str_replace
|
| 23 |
-
$url = str_replace
|
| 24 |
-
$url = str_replace
|
| 25 |
-
$url = str_replace ('%24', '$', $url);
|
| 26 |
return $url;
|
| 27 |
}
|
| 28 |
|
| 29 |
-
function encode
|
| 30 |
-
|
| 31 |
-
$url =
|
| 32 |
-
$url = str_replace
|
| 33 |
-
$url = str_replace
|
| 34 |
-
$url = str_replace ('.', '\\.', $url);
|
| 35 |
return $url;
|
| 36 |
}
|
| 37 |
|
| 38 |
-
function encode_regex
|
| 39 |
-
|
| 40 |
-
$url = str_replace
|
| 41 |
-
$url = str_replace
|
| 42 |
-
$url = str_replace
|
| 43 |
-
$url = str_replace ('%24', '$', $url);
|
| 44 |
return $url;
|
| 45 |
}
|
| 46 |
|
| 47 |
-
function add_referrer
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
$from = $this->encode_regex (ltrim ($item->url, '/'));
|
| 52 |
|
| 53 |
-
if (($match->url_from || $match->url_notfrom) && $match->referrer)
|
| 54 |
-
|
| 55 |
-
$this->items[] = sprintf ('RewriteCond %%{HTTP_REFERER} %s [NC]', ($match->regex ? $this->encode_regex ($match->referrer) : $this->encode_from ($match->referrer)));
|
| 56 |
|
| 57 |
-
if ($match->url_from)
|
| 58 |
-
|
| 59 |
-
$
|
| 60 |
-
$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
|
| 61 |
}
|
| 62 |
|
| 63 |
-
if ($match->url_notfrom)
|
| 64 |
-
|
| 65 |
-
$
|
| 66 |
-
$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
|
| 67 |
}
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
| 71 |
-
function add_agent
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
$from = $this->encode_regex (ltrim ($item->url, '/'));
|
| 76 |
|
| 77 |
-
if (($match->url_from || $match->url_notfrom) && $match->user_agent)
|
| 78 |
-
|
| 79 |
-
$this->items[] = sprintf ('RewriteCond %%{HTTP_USER_AGENT} %s [NC]', ($match->regex ? $this->encode_regex ($match->user_agent) : $this->encode2nd ($match->user_agent)));
|
| 80 |
|
| 81 |
-
if ($match->url_from)
|
| 82 |
-
|
| 83 |
-
$
|
| 84 |
-
$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
|
| 85 |
}
|
| 86 |
|
| 87 |
-
if ($match->url_notfrom)
|
| 88 |
-
|
| 89 |
-
$
|
| 90 |
-
$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
|
| 91 |
}
|
| 92 |
}
|
| 93 |
}
|
| 94 |
|
| 95 |
-
function add_url
|
| 96 |
-
|
| 97 |
-
$
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
$from = $this->encode_regex (ltrim ($item->url, '/'));
|
| 101 |
|
| 102 |
-
if ($to)
|
| 103 |
-
$this->items[] = sprintf
|
| 104 |
}
|
| 105 |
|
| 106 |
-
function action_random
|
| 107 |
-
{
|
| 108 |
// Pick a WP post at random
|
| 109 |
global $wpdb;
|
| 110 |
|
| 111 |
-
$post = $wpdb->get_var
|
| 112 |
-
$url = parse_url (
|
| 113 |
|
| 114 |
-
return sprintf
|
| 115 |
}
|
| 116 |
|
| 117 |
-
function action_pass
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
else
|
| 122 |
-
return sprintf ('%s [L]', $this->encode2nd ($data), $code);
|
| 123 |
}
|
| 124 |
|
| 125 |
-
function action_error
|
| 126 |
-
|
| 127 |
-
if ($code == '410')
|
| 128 |
return '/ [G,L]';
|
| 129 |
return '/ [F,L]';
|
| 130 |
}
|
| 131 |
|
| 132 |
-
function action_url
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
else
|
| 137 |
-
return sprintf ('%s [R=%d,L]', $this->encode2nd ($data), $code);
|
| 138 |
}
|
| 139 |
|
| 140 |
-
function target
|
| 141 |
-
{
|
| 142 |
$target = 'action_'.$action;
|
| 143 |
|
| 144 |
-
if (method_exists
|
| 145 |
-
return $this->$target
|
| 146 |
return '';
|
| 147 |
}
|
| 148 |
|
| 149 |
-
function add
|
| 150 |
-
{
|
| 151 |
$target = 'add_'.$item->match_type;
|
| 152 |
|
| 153 |
-
if (method_exists
|
| 154 |
-
$this->$target
|
| 155 |
}
|
| 156 |
|
| 157 |
-
function generate
|
| 158 |
-
{
|
| 159 |
// Head of redirection section - do not localize this
|
| 160 |
global $redirection;
|
| 161 |
|
| 162 |
$text[] = '# Created by Redirection Module: '.$name;
|
| 163 |
$text[] = '# '.date ('r');
|
| 164 |
-
$text[] = '# Redirection '.$redirection->version
|
| 165 |
$text[] = '';
|
| 166 |
|
| 167 |
// Default blocked files - I can't think of a reason not to block these
|
|
@@ -172,33 +149,33 @@ class Red_Htaccess
|
|
| 172 |
$text[] = '';
|
| 173 |
|
| 174 |
// PHP options
|
| 175 |
-
if (isset
|
| 176 |
-
$text[] = 'php_value error_reporting '.($this->settings == 'none' ? '0' : 'E_ALL');
|
| 177 |
|
| 178 |
-
if (isset
|
| 179 |
$text[] = 'php_value memory_limit '.$this->settings['memory_limit'].'M';
|
| 180 |
|
| 181 |
-
if ($this->settings['allow_ip'] || $this->settings['ban_ip'])
|
| 182 |
-
{
|
| 183 |
$text[] = '';
|
| 184 |
$text[] = 'order allow,deny';
|
| 185 |
-
|
| 186 |
-
{
|
| 187 |
-
$ips = array_filter (
|
| 188 |
-
|
| 189 |
-
{
|
| 190 |
-
foreach ($ips AS $ip)
|
| 191 |
$text[] = 'deny from '.$ip;
|
|
|
|
| 192 |
}
|
| 193 |
}
|
| 194 |
|
| 195 |
-
if ($this->settings['allow_ip'])
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
if (count
|
| 199 |
-
|
| 200 |
-
foreach ($ips AS $ip)
|
| 201 |
$text[] = 'allow from '.$ip;
|
|
|
|
| 202 |
}
|
| 203 |
}
|
| 204 |
else
|
|
@@ -211,79 +188,73 @@ class Red_Htaccess
|
|
| 211 |
$text[] = '';
|
| 212 |
$text[] = '<IfModule mod_rewrite.c>';
|
| 213 |
|
| 214 |
-
if ($this->settings['canonical'] != 'default')
|
| 215 |
-
{
|
| 216 |
$text[] = 'RewriteEngine On';
|
| 217 |
$base = $this->settings['site'];
|
| 218 |
-
if ($base == '')
|
| 219 |
-
$base = get_option ('home');
|
| 220 |
|
| 221 |
-
$
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
-
if ($this->settings['canonical'] == 'nowww')
|
| 225 |
-
|
| 226 |
-
$text[] = 'RewriteCond %{HTTP_HOST} ^www\.'.str_replace ('.', '\\.', $base).'$ [NC]';
|
| 227 |
$text[] = 'RewriteRule ^(.*)$ http://'.$base.'/$1 [R=301,L]';
|
| 228 |
}
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
$text[] = 'RewriteCond %{HTTP_HOST} ^'.str_replace ('.', '\\.', $base).'$ [NC]';
|
| 232 |
$text[] = 'RewriteRule ^(.*)$ http://www.'.$base.'/$1 [R=301,L]';
|
| 233 |
}
|
| 234 |
|
| 235 |
$text[] = '';
|
| 236 |
}
|
| 237 |
|
| 238 |
-
if ($this->settings['strip_index'] == 'yes')
|
| 239 |
-
{
|
| 240 |
$text[] = 'RewriteCond %{THE_REQUEST} (.*)index\.(php|htm|html)\ HTTP/';
|
| 241 |
$text[] = 'RewriteRule ^(.*)index\.(php|html|htm)$ $1 [R=301,NC,L]';
|
| 242 |
$text[] = '';
|
| 243 |
}
|
| 244 |
|
| 245 |
// Add redirects
|
| 246 |
-
if (is_array
|
| 247 |
-
$text = array_merge
|
| 248 |
|
| 249 |
// End of mod_rewrite
|
| 250 |
$text[] = '</IfModule>';
|
| 251 |
$text[] = '';
|
| 252 |
|
| 253 |
-
if ($this->settings['raw'])
|
| 254 |
$text[] = $this->settings['raw'];
|
| 255 |
|
| 256 |
// End of redirection section
|
| 257 |
$text[] = '# End of Redirection';
|
| 258 |
$text[] = '';
|
| 259 |
|
| 260 |
-
$text = implode
|
| 261 |
-
$text = str_replace
|
| 262 |
-
$text = str_replace
|
| 263 |
return $text;
|
| 264 |
}
|
| 265 |
|
| 266 |
-
function save
|
| 267 |
-
|
| 268 |
-
$text = $this->generate ($name);
|
| 269 |
|
| 270 |
// Does the file already exist?
|
| 271 |
-
if (file_exists
|
| 272 |
-
|
| 273 |
-
$existing = @file_get_contents ($filename);
|
| 274 |
|
| 275 |
// Remove any existing Redirection module
|
| 276 |
-
$text .= preg_replace
|
| 277 |
}
|
| 278 |
|
| 279 |
-
$file = @fopen
|
| 280 |
-
if ($file)
|
| 281 |
-
|
| 282 |
-
$text = str_replace
|
| 283 |
-
$text = str_replace ("\r\n\r\n\r\n", "\r\n", $text);
|
| 284 |
|
| 285 |
-
fwrite
|
| 286 |
-
fclose
|
| 287 |
return true;
|
| 288 |
}
|
| 289 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class Red_Htaccess {
|
|
|
|
| 4 |
var $settings;
|
| 5 |
var $items;
|
| 6 |
|
| 7 |
+
function __construct( $settings ) {
|
| 8 |
+
foreach ( $settings AS $key => $value ) {
|
|
|
|
| 9 |
$this->settings[$key] = $value;
|
| 10 |
+
}
|
| 11 |
}
|
| 12 |
|
| 13 |
+
function encode_from( $url ) {
|
| 14 |
+
return '^'.$this->encode( $url ).'$';
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
+
function encode2nd( $url ) {
|
| 18 |
+
$url = urlencode( $url );
|
| 19 |
+
$url = str_replace( '%2F', '/', $url );
|
| 20 |
+
$url = str_replace( '%3A', ':', $url );
|
| 21 |
+
$url = str_replace( '+', '%20', $url );
|
| 22 |
+
$url = str_replace( '%24', '$', $url );
|
|
|
|
| 23 |
return $url;
|
| 24 |
}
|
| 25 |
|
| 26 |
+
function encode( $url ) {
|
| 27 |
+
$url = urlencode( $url );
|
| 28 |
+
$url = str_replace( '%2F', '/', $url );
|
| 29 |
+
$url = str_replace( '+', '%20', $url );
|
| 30 |
+
$url = str_replace( '.', '\\.', $url );
|
|
|
|
| 31 |
return $url;
|
| 32 |
}
|
| 33 |
|
| 34 |
+
function encode_regex( $url ) {
|
| 35 |
+
$url = str_replace( ' ', '%20', $url );
|
| 36 |
+
$url = str_replace( '.', '\\.', $url );
|
| 37 |
+
$url = str_replace( '\\.*', '.*', $url );
|
| 38 |
+
$url = str_replace( '%24', '$', $url );
|
|
|
|
| 39 |
return $url;
|
| 40 |
}
|
| 41 |
|
| 42 |
+
function add_referrer( $item, $match ) {
|
| 43 |
+
$from = $this->encode_from( ltrim( $item->url, '/' ) );
|
| 44 |
+
if ( $item->regex )
|
| 45 |
+
$from = $this->encode_regex( ltrim( $item->url, '/' ) );
|
|
|
|
| 46 |
|
| 47 |
+
if ( ( $match->url_from || $match->url_notfrom ) && $match->referrer ) {
|
| 48 |
+
$this->items[] = sprintf( 'RewriteCond %%{HTTP_REFERER} %s [NC]', ( $match->regex ? $this->encode_regex( $match->referrer ) : $this->encode_from( $match->referrer ) ) );
|
|
|
|
| 49 |
|
| 50 |
+
if ( $match->url_from ) {
|
| 51 |
+
$to = $this->target( $item->action_type, $match->url_from, $item->action_code, $item->regex );
|
| 52 |
+
$this->items[] = sprintf( 'RewriteRule %s %s', $from, $to );
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
+
if ( $match->url_notfrom ) {
|
| 56 |
+
$to = $this->target( $item->action_type, $match->url_notfrom, $item->action_code, $item->regex );
|
| 57 |
+
$this->items[] = sprintf( 'RewriteRule %s %s', $from, $to );
|
|
|
|
| 58 |
}
|
| 59 |
}
|
| 60 |
}
|
| 61 |
|
| 62 |
+
function add_agent( $item, $match ) {
|
| 63 |
+
$from = $this->encode( ltrim( $item->url, '/' ) );
|
| 64 |
+
if ( $item->regex )
|
| 65 |
+
$from = $this->encode_regex( ltrim( $item->url, '/' ) );
|
|
|
|
| 66 |
|
| 67 |
+
if ( ( $match->url_from || $match->url_notfrom ) && $match->user_agent ) {
|
| 68 |
+
$this->items[] = sprintf( 'RewriteCond %%{HTTP_USER_AGENT} %s [NC]', ( $match->regex ? $this->encode_regex( $match->user_agent ) : $this->encode2nd( $match->user_agent ) ) );
|
|
|
|
| 69 |
|
| 70 |
+
if ( $match->url_from ) {
|
| 71 |
+
$to = $this->target( $item->action_type, $match->url_from, $item->action_code, $item->regex );
|
| 72 |
+
$this->items[] = sprintf( 'RewriteRule %s %s', $from, $to );
|
|
|
|
| 73 |
}
|
| 74 |
|
| 75 |
+
if ( $match->url_notfrom ) {
|
| 76 |
+
$to = $this->target( $item->action_type, $match->url_notfrom, $item->action_code, $item->regex );
|
| 77 |
+
$this->items[] = sprintf( 'RewriteRule %s %s', $from, $to );
|
|
|
|
| 78 |
}
|
| 79 |
}
|
| 80 |
}
|
| 81 |
|
| 82 |
+
function add_url( $item, $match ) {
|
| 83 |
+
$to = $this->target( $item->action_type, $match->url, $item->action_code, $item->regex );
|
| 84 |
+
$from = $this->encode_from( ltrim( $item->url, '/' ) );
|
| 85 |
+
if ( $item->regex )
|
| 86 |
+
$from = $this->encode_regex( ltrim ($item->url, '/' ) );
|
|
|
|
| 87 |
|
| 88 |
+
if ( $to )
|
| 89 |
+
$this->items[] = sprintf( 'RewriteRule %s %s', $from, $to );
|
| 90 |
}
|
| 91 |
|
| 92 |
+
function action_random( $data, $code, $regex ) {
|
|
|
|
| 93 |
// Pick a WP post at random
|
| 94 |
global $wpdb;
|
| 95 |
|
| 96 |
+
$post = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} ORDER BY RAND() LIMIT 0,1" );
|
| 97 |
+
$url = parse_url( get_permalink( $post ) );
|
| 98 |
|
| 99 |
+
return sprintf( '%s [R=%d,L]', $this->encode( $url['path'] ), $code );
|
| 100 |
}
|
| 101 |
|
| 102 |
+
function action_pass( $data, $code, $regex ) {
|
| 103 |
+
if ( $regex )
|
| 104 |
+
return sprintf( '%s [L]', $this->encode2nd( $data ), $code );
|
| 105 |
+
return sprintf( '%s [L]', $this->encode2nd( $data ), $code );
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
|
| 108 |
+
function action_error( $data, $code, $regex) {
|
| 109 |
+
if ( $code == '410' )
|
|
|
|
| 110 |
return '/ [G,L]';
|
| 111 |
return '/ [F,L]';
|
| 112 |
}
|
| 113 |
|
| 114 |
+
function action_url( $data, $code, $regex ) {
|
| 115 |
+
if ( $regex )
|
| 116 |
+
return sprintf( '%s [R=%d,L]', $this->encode2nd( $data ), $code );
|
| 117 |
+
return sprintf( '%s [R=%d,L]', $this->encode2nd( $data ), $code );
|
|
|
|
|
|
|
| 118 |
}
|
| 119 |
|
| 120 |
+
function target( $action, $data, $code, $regex ) {
|
|
|
|
| 121 |
$target = 'action_'.$action;
|
| 122 |
|
| 123 |
+
if ( method_exists( $this, $target ) )
|
| 124 |
+
return $this->$target( $data, $code, $regex );
|
| 125 |
return '';
|
| 126 |
}
|
| 127 |
|
| 128 |
+
function add( $item ) {
|
|
|
|
| 129 |
$target = 'add_'.$item->match_type;
|
| 130 |
|
| 131 |
+
if ( method_exists( $this, $target ) )
|
| 132 |
+
$this->$target( $item, $item->match );
|
| 133 |
}
|
| 134 |
|
| 135 |
+
function generate( $name ) {
|
|
|
|
| 136 |
// Head of redirection section - do not localize this
|
| 137 |
global $redirection;
|
| 138 |
|
| 139 |
$text[] = '# Created by Redirection Module: '.$name;
|
| 140 |
$text[] = '# '.date ('r');
|
| 141 |
+
$text[] = '# Redirection '.$redirection->version().' - http://urbangiraffe.com/plugins/redirection/';
|
| 142 |
$text[] = '';
|
| 143 |
|
| 144 |
// Default blocked files - I can't think of a reason not to block these
|
| 149 |
$text[] = '';
|
| 150 |
|
| 151 |
// PHP options
|
| 152 |
+
if ( isset( $this->settings['error_level'] ) && $this->settings['error_level'] != 'default' )
|
| 153 |
+
$text[] = 'php_value error_reporting '.( $this->settings == 'none' ? '0' : 'E_ALL' );
|
| 154 |
|
| 155 |
+
if ( isset( $this->settings['memory_limit'] ) && $this->settings['memory_limit'] != 0 )
|
| 156 |
$text[] = 'php_value memory_limit '.$this->settings['memory_limit'].'M';
|
| 157 |
|
| 158 |
+
if ( ( isset( $this->settings['allow_ip'] ) && $this->settings['allow_ip'] ) || ( isset( $this->settings['ban_ip'] ) && $this->settings['ban_ip'] ) ) {
|
|
|
|
| 159 |
$text[] = '';
|
| 160 |
$text[] = 'order allow,deny';
|
| 161 |
+
|
| 162 |
+
if ( isset( $this->settings['ban_ip'] ) && $this->settings['ban_ip'] ) {
|
| 163 |
+
$ips = array_filter( explode( ',', $this->settings['ban_ip'] ) );
|
| 164 |
+
|
| 165 |
+
if ( count( $ips ) > 0 ) {
|
| 166 |
+
foreach ( $ips AS $ip ) {
|
| 167 |
$text[] = 'deny from '.$ip;
|
| 168 |
+
}
|
| 169 |
}
|
| 170 |
}
|
| 171 |
|
| 172 |
+
if ( $this->settings['allow_ip'] ) {
|
| 173 |
+
$ips = array_filter( explode( ',', $this->settings['allow_ip'] ) );
|
| 174 |
+
|
| 175 |
+
if ( count( $ips ) > 0 ) {
|
| 176 |
+
foreach ( $ips AS $ip ) {
|
|
|
|
| 177 |
$text[] = 'allow from '.$ip;
|
| 178 |
+
}
|
| 179 |
}
|
| 180 |
}
|
| 181 |
else
|
| 188 |
$text[] = '';
|
| 189 |
$text[] = '<IfModule mod_rewrite.c>';
|
| 190 |
|
| 191 |
+
if ( $this->settings['canonical'] != 'default' ) {
|
|
|
|
| 192 |
$text[] = 'RewriteEngine On';
|
| 193 |
$base = $this->settings['site'];
|
|
|
|
|
|
|
| 194 |
|
| 195 |
+
if ( $base == '' )
|
| 196 |
+
$base = get_option( 'home' );
|
| 197 |
+
|
| 198 |
+
$parts = parse_url( $base );
|
| 199 |
+
$base = str_replace( 'www.', '', $parts['host'] );
|
| 200 |
|
| 201 |
+
if ( $this->settings['canonical'] == 'nowww' ) {
|
| 202 |
+
$text[] = 'RewriteCond %{HTTP_HOST} ^www\.'.str_replace( '.', '\\.', $base ).'$ [NC]';
|
|
|
|
| 203 |
$text[] = 'RewriteRule ^(.*)$ http://'.$base.'/$1 [R=301,L]';
|
| 204 |
}
|
| 205 |
+
elseif ( $this->settings['canonical'] == 'www' ) {
|
| 206 |
+
$text[] = 'RewriteCond %{HTTP_HOST} ^'.str_replace( '.', '\\.', $base ).'$ [NC]';
|
|
|
|
| 207 |
$text[] = 'RewriteRule ^(.*)$ http://www.'.$base.'/$1 [R=301,L]';
|
| 208 |
}
|
| 209 |
|
| 210 |
$text[] = '';
|
| 211 |
}
|
| 212 |
|
| 213 |
+
if ( $this->settings['strip_index'] == 'yes' ) {
|
|
|
|
| 214 |
$text[] = 'RewriteCond %{THE_REQUEST} (.*)index\.(php|htm|html)\ HTTP/';
|
| 215 |
$text[] = 'RewriteRule ^(.*)index\.(php|html|htm)$ $1 [R=301,NC,L]';
|
| 216 |
$text[] = '';
|
| 217 |
}
|
| 218 |
|
| 219 |
// Add redirects
|
| 220 |
+
if ( is_array( $this->items ) )
|
| 221 |
+
$text = array_merge( $text, $this->items );
|
| 222 |
|
| 223 |
// End of mod_rewrite
|
| 224 |
$text[] = '</IfModule>';
|
| 225 |
$text[] = '';
|
| 226 |
|
| 227 |
+
if ( isset( $this->settings['raw'] ) && $this->settings['raw'] )
|
| 228 |
$text[] = $this->settings['raw'];
|
| 229 |
|
| 230 |
// End of redirection section
|
| 231 |
$text[] = '# End of Redirection';
|
| 232 |
$text[] = '';
|
| 233 |
|
| 234 |
+
$text = implode( "\r\n", $text );
|
| 235 |
+
$text = str_replace( "\r\n\r\n\r\n", "\r\n", $text );
|
| 236 |
+
$text = str_replace( "\r\n\r\n\r\n", "\r\n", $text );
|
| 237 |
return $text;
|
| 238 |
}
|
| 239 |
|
| 240 |
+
function save( $filename, $name ) {
|
| 241 |
+
$text = $this->generate( $name );
|
|
|
|
| 242 |
|
| 243 |
// Does the file already exist?
|
| 244 |
+
if ( file_exists( $filename) ) {
|
| 245 |
+
$existing = @file_get_contents( $filename );
|
|
|
|
| 246 |
|
| 247 |
// Remove any existing Redirection module
|
| 248 |
+
$text .= preg_replace( '@# Created by Redirection Module: '.$name.'(.*?)# End of Redirection@s', '', $existing );
|
| 249 |
}
|
| 250 |
|
| 251 |
+
$file = @fopen( $filename, 'w' );
|
| 252 |
+
if ( $file ) {
|
| 253 |
+
$text = str_replace( "\r\n\r\n\r\n", "\r\n", $text );
|
| 254 |
+
$text = str_replace( "\r\n\r\n\r\n", "\r\n", $text );
|
|
|
|
| 255 |
|
| 256 |
+
fwrite( $file, $text );
|
| 257 |
+
fclose( $file );
|
| 258 |
return true;
|
| 259 |
}
|
| 260 |
|
models/log.php
CHANGED
|
@@ -37,7 +37,7 @@ class RE_Log {
|
|
| 37 |
$this->url = stripslashes ($this->url);
|
| 38 |
}
|
| 39 |
|
| 40 |
-
function get_by_id( $id ) {
|
| 41 |
global $wpdb;
|
| 42 |
|
| 43 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_logs WHERE id=%d", $id ) );
|
|
@@ -46,7 +46,7 @@ class RE_Log {
|
|
| 46 |
return false;
|
| 47 |
}
|
| 48 |
|
| 49 |
-
function create( $url, $target, $agent, $ip, $referrer, $extra = array()) {
|
| 50 |
global $wpdb, $redirection;
|
| 51 |
|
| 52 |
$insert = array(
|
|
@@ -69,32 +69,31 @@ class RE_Log {
|
|
| 69 |
$wpdb->insert( $wpdb->prefix.'redirection_logs', $insert );
|
| 70 |
}
|
| 71 |
|
| 72 |
-
function show_url( $url ) {
|
| 73 |
-
$url = urldecode( $url );
|
| 74 |
return implode('​/', explode( '/', substr( $url, 0, 80 ) ) ).( strlen( $url ) > 80 ? '...' : '' );
|
| 75 |
}
|
| 76 |
|
| 77 |
-
function delete( $id ) {
|
| 78 |
global $wpdb;
|
| 79 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE id=%d", $id ) );
|
| 80 |
}
|
| 81 |
|
| 82 |
-
function delete_for_id( $id ) {
|
| 83 |
global $wpdb;
|
| 84 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE redirection_id=%d", $id ) );
|
| 85 |
}
|
| 86 |
|
| 87 |
-
function delete_for_group( $id ) {
|
| 88 |
global $wpdb;
|
| 89 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE group_id=%d", $id ) );
|
| 90 |
}
|
| 91 |
|
| 92 |
-
function delete_for_module( $id ) {
|
| 93 |
global $wpdb;
|
| 94 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE module_id=%d", $id ) );
|
| 95 |
}
|
| 96 |
|
| 97 |
-
function delete_all( $type = 'all', $id = 0 ) {
|
| 98 |
global $wpdb;
|
| 99 |
|
| 100 |
$where = array();
|
|
@@ -132,7 +131,7 @@ class RE_404 {
|
|
| 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 ) );
|
|
@@ -141,7 +140,7 @@ class RE_404 {
|
|
| 141 |
return false;
|
| 142 |
}
|
| 143 |
|
| 144 |
-
function create( $url, $agent, $ip, $referrer ) {
|
| 145 |
global $wpdb, $redirection;
|
| 146 |
|
| 147 |
$insert = array(
|
|
@@ -159,13 +158,13 @@ class RE_404 {
|
|
| 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();
|
| 37 |
$this->url = stripslashes ($this->url);
|
| 38 |
}
|
| 39 |
|
| 40 |
+
static function get_by_id( $id ) {
|
| 41 |
global $wpdb;
|
| 42 |
|
| 43 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_logs WHERE id=%d", $id ) );
|
| 46 |
return false;
|
| 47 |
}
|
| 48 |
|
| 49 |
+
static function create( $url, $target, $agent, $ip, $referrer, $extra = array()) {
|
| 50 |
global $wpdb, $redirection;
|
| 51 |
|
| 52 |
$insert = array(
|
| 69 |
$wpdb->insert( $wpdb->prefix.'redirection_logs', $insert );
|
| 70 |
}
|
| 71 |
|
| 72 |
+
static function show_url( $url ) {
|
|
|
|
| 73 |
return implode('​/', explode( '/', substr( $url, 0, 80 ) ) ).( strlen( $url ) > 80 ? '...' : '' );
|
| 74 |
}
|
| 75 |
|
| 76 |
+
static function delete( $id ) {
|
| 77 |
global $wpdb;
|
| 78 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE id=%d", $id ) );
|
| 79 |
}
|
| 80 |
|
| 81 |
+
static function delete_for_id( $id ) {
|
| 82 |
global $wpdb;
|
| 83 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE redirection_id=%d", $id ) );
|
| 84 |
}
|
| 85 |
|
| 86 |
+
static function delete_for_group( $id ) {
|
| 87 |
global $wpdb;
|
| 88 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE group_id=%d", $id ) );
|
| 89 |
}
|
| 90 |
|
| 91 |
+
static function delete_for_module( $id ) {
|
| 92 |
global $wpdb;
|
| 93 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_logs WHERE module_id=%d", $id ) );
|
| 94 |
}
|
| 95 |
|
| 96 |
+
static function delete_all( $type = 'all', $id = 0 ) {
|
| 97 |
global $wpdb;
|
| 98 |
|
| 99 |
$where = array();
|
| 131 |
$this->created = mysql2date ('U', $this->created);
|
| 132 |
}
|
| 133 |
|
| 134 |
+
static function get_by_id( $id ) {
|
| 135 |
global $wpdb;
|
| 136 |
|
| 137 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_404 WHERE id=%d", $id ) );
|
| 140 |
return false;
|
| 141 |
}
|
| 142 |
|
| 143 |
+
static function create( $url, $agent, $ip, $referrer ) {
|
| 144 |
global $wpdb, $redirection;
|
| 145 |
|
| 146 |
$insert = array(
|
| 158 |
$wpdb->insert( $wpdb->prefix.'redirection_404', $insert );
|
| 159 |
}
|
| 160 |
|
| 161 |
+
static function delete( $id ) {
|
| 162 |
global $wpdb;
|
| 163 |
|
| 164 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_404 WHERE id=%d", $id ) );
|
| 165 |
}
|
| 166 |
|
| 167 |
+
static function delete_all() {
|
| 168 |
global $wpdb;
|
| 169 |
|
| 170 |
$where = array();
|
models/match.php
CHANGED
|
@@ -25,10 +25,11 @@ class Red_Match {
|
|
| 25 |
|
| 26 |
function Red_Match( $values = '' ) {
|
| 27 |
if ( $values ) {
|
| 28 |
-
$
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
foreach ( $obj AS $key => $value ) {
|
| 33 |
$this->$key = $value;
|
| 34 |
}
|
|
@@ -64,8 +65,8 @@ class Red_Match {
|
|
| 64 |
return $false;
|
| 65 |
}
|
| 66 |
|
| 67 |
-
function create( $name, $data = '' ) {
|
| 68 |
-
$avail =
|
| 69 |
if ( isset( $avail[strtolower( $name )] ) ) {
|
| 70 |
$classname = $name.'_match';
|
| 71 |
|
|
@@ -77,19 +78,19 @@ class Red_Match {
|
|
| 77 |
return false;
|
| 78 |
}
|
| 79 |
|
| 80 |
-
function all() {
|
| 81 |
$data = array();
|
| 82 |
|
| 83 |
-
$avail =
|
| 84 |
foreach ( $avail AS $name => $file ) {
|
| 85 |
-
$obj =
|
| 86 |
$data[$name] = $obj->name();
|
| 87 |
}
|
| 88 |
|
| 89 |
return $data;
|
| 90 |
}
|
| 91 |
|
| 92 |
-
function available() {
|
| 93 |
return array (
|
| 94 |
'url' => 'url.php',
|
| 95 |
'referrer' => 'referrer.php',
|
| 25 |
|
| 26 |
function Red_Match( $values = '' ) {
|
| 27 |
if ( $values ) {
|
| 28 |
+
$this->url = $values;
|
| 29 |
+
|
| 30 |
+
$obj = maybe_unserialize( $values );
|
| 31 |
+
|
| 32 |
+
if ( is_array( $obj ) ) {
|
| 33 |
foreach ( $obj AS $key => $value ) {
|
| 34 |
$this->$key = $value;
|
| 35 |
}
|
| 65 |
return $false;
|
| 66 |
}
|
| 67 |
|
| 68 |
+
static function create( $name, $data = '' ) {
|
| 69 |
+
$avail = self::available();
|
| 70 |
if ( isset( $avail[strtolower( $name )] ) ) {
|
| 71 |
$classname = $name.'_match';
|
| 72 |
|
| 78 |
return false;
|
| 79 |
}
|
| 80 |
|
| 81 |
+
static function all() {
|
| 82 |
$data = array();
|
| 83 |
|
| 84 |
+
$avail = self::available();
|
| 85 |
foreach ( $avail AS $name => $file ) {
|
| 86 |
+
$obj = self::create( $name );
|
| 87 |
$data[$name] = $obj->name();
|
| 88 |
}
|
| 89 |
|
| 90 |
return $data;
|
| 91 |
}
|
| 92 |
|
| 93 |
+
static function available() {
|
| 94 |
return array (
|
| 95 |
'url' => 'url.php',
|
| 96 |
'referrer' => 'referrer.php',
|
models/module.php
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
class Red_Module {
|
|
|
|
|
|
|
| 4 |
function Red_Module( $values = '' ) {
|
| 5 |
if ( is_object( $values ) ) {
|
| 6 |
foreach ( $values AS $key => $value ) {
|
|
@@ -18,14 +20,14 @@ class Red_Module {
|
|
| 18 |
function module_flush_delete() {
|
| 19 |
}
|
| 20 |
|
| 21 |
-
function flush( $id ) {
|
| 22 |
-
$module =
|
| 23 |
if ( $module && $module->is_valid() )
|
| 24 |
$module->module_flush( Red_Item::get_all_for_module( $id ) );
|
| 25 |
}
|
| 26 |
|
| 27 |
-
function flush_delete( $id ) {
|
| 28 |
-
$module =
|
| 29 |
if ( $module )
|
| 30 |
$module->module_flush_delete();
|
| 31 |
}
|
|
@@ -37,7 +39,7 @@ class Red_Module {
|
|
| 37 |
$options = $this->save( $data );
|
| 38 |
$wpdb->update( $wpdb->prefix.'redirection_modules', array( 'name' => trim( $data['name'] ), 'options' => empty( $options ) ? '' : serialize( $options ) ), array( 'id' => intval( $this->id ) ) );
|
| 39 |
|
| 40 |
-
|
| 41 |
}
|
| 42 |
|
| 43 |
function delete() {
|
|
@@ -53,13 +55,13 @@ class Red_Module {
|
|
| 53 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_modules WHERE id=%d", $this->id ) );
|
| 54 |
|
| 55 |
RE_Log::delete_for_module( $this->id );
|
| 56 |
-
|
| 57 |
-
|
| 58 |
}
|
| 59 |
|
| 60 |
-
function clear_cache( $module ) {
|
| 61 |
delete_option( 'redirection_module_cache' );
|
| 62 |
-
|
| 63 |
}
|
| 64 |
|
| 65 |
function create( $data ) {
|
|
@@ -76,19 +78,19 @@ class Red_Module {
|
|
| 76 |
|
| 77 |
$wpdb->insert( $wpdb->prefix.'redirection_modules', $db );
|
| 78 |
|
| 79 |
-
|
| 80 |
return $wpdb->insert_id;
|
| 81 |
}
|
| 82 |
|
| 83 |
return false;
|
| 84 |
}
|
| 85 |
|
| 86 |
-
function get( $id ) {
|
| 87 |
global $wpdb;
|
| 88 |
|
| 89 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_modules WHERE id=%d", $id ) );
|
| 90 |
if ( $row )
|
| 91 |
-
return
|
| 92 |
return false;
|
| 93 |
}
|
| 94 |
|
|
@@ -103,7 +105,7 @@ class Red_Module {
|
|
| 103 |
$items = array();
|
| 104 |
if ( count( $rows ) > 0 ) {
|
| 105 |
foreach ( $rows AS $row ) {
|
| 106 |
-
$items[] =
|
| 107 |
}
|
| 108 |
}
|
| 109 |
|
|
@@ -115,24 +117,24 @@ class Red_Module {
|
|
| 115 |
/**
|
| 116 |
* Get all modules
|
| 117 |
*/
|
| 118 |
-
function get_all() {
|
| 119 |
global $wpdb;
|
| 120 |
|
| 121 |
$rows = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}redirection_modules WHERE id > 0 ORDER BY id" );
|
| 122 |
$items = array();
|
| 123 |
if ( count( $rows ) > 0 ) {
|
| 124 |
foreach ( $rows AS $row ) {
|
| 125 |
-
$items[] =
|
| 126 |
}
|
| 127 |
}
|
| 128 |
|
| 129 |
-
return $items;
|
| 130 |
}
|
| 131 |
|
| 132 |
/**
|
| 133 |
* Get first module
|
| 134 |
*/
|
| 135 |
-
function get_first_id() {
|
| 136 |
global $wpdb;
|
| 137 |
return $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}redirection_modules ORDER BY id LIMIT 0,1" );
|
| 138 |
}
|
|
@@ -141,9 +143,9 @@ class Red_Module {
|
|
| 141 |
* Get all modules
|
| 142 |
*/
|
| 143 |
|
| 144 |
-
function get_for_select() {
|
| 145 |
$data = array();
|
| 146 |
-
$items =
|
| 147 |
|
| 148 |
foreach ( $items AS $item ) {
|
| 149 |
$data[$item->id] = $item->name;
|
|
@@ -155,14 +157,14 @@ class Red_Module {
|
|
| 155 |
/**
|
| 156 |
* Get all module types
|
| 157 |
*/
|
| 158 |
-
function get_types() {
|
| 159 |
return array (
|
| 160 |
'apache' => __( 'Apache', 'redirection' ),
|
| 161 |
'wp' => __( 'WordPress', 'redirection' ),
|
| 162 |
);
|
| 163 |
}
|
| 164 |
|
| 165 |
-
function new_item( $data ) {
|
| 166 |
$map = array (
|
| 167 |
'apache' => array( 'Apache_Module', 'apache.php' ),
|
| 168 |
'wp' => array( 'WordPress_Module', 'wordpress.php' ),
|
|
@@ -234,14 +236,14 @@ class Red_Module {
|
|
| 234 |
function hits() {
|
| 235 |
global $wpdb;
|
| 236 |
|
| 237 |
-
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(
|
| 238 |
if ( $count > 0 )
|
| 239 |
return $count;
|
| 240 |
return 0;
|
| 241 |
}
|
| 242 |
|
| 243 |
function reset() {
|
| 244 |
-
|
| 245 |
|
| 246 |
$groups = Red_Group::get_for_module( $this->id );
|
| 247 |
if ( count( $groups ) > 0 ) {
|
|
@@ -263,4 +265,3 @@ class Red_Module {
|
|
| 263 |
function config() {
|
| 264 |
}
|
| 265 |
}
|
| 266 |
-
|
| 1 |
<?php
|
| 2 |
|
| 3 |
class Red_Module {
|
| 4 |
+
var $id;
|
| 5 |
+
|
| 6 |
function Red_Module( $values = '' ) {
|
| 7 |
if ( is_object( $values ) ) {
|
| 8 |
foreach ( $values AS $key => $value ) {
|
| 20 |
function module_flush_delete() {
|
| 21 |
}
|
| 22 |
|
| 23 |
+
static function flush( $id ) {
|
| 24 |
+
$module = self::get( $id );
|
| 25 |
if ( $module && $module->is_valid() )
|
| 26 |
$module->module_flush( Red_Item::get_all_for_module( $id ) );
|
| 27 |
}
|
| 28 |
|
| 29 |
+
static function flush_delete( $id ) {
|
| 30 |
+
$module = self::get( $id );
|
| 31 |
if ( $module )
|
| 32 |
$module->module_flush_delete();
|
| 33 |
}
|
| 39 |
$options = $this->save( $data );
|
| 40 |
$wpdb->update( $wpdb->prefix.'redirection_modules', array( 'name' => trim( $data['name'] ), 'options' => empty( $options ) ? '' : serialize( $options ) ), array( 'id' => intval( $this->id ) ) );
|
| 41 |
|
| 42 |
+
self::clear_cache( $this->id );
|
| 43 |
}
|
| 44 |
|
| 45 |
function delete() {
|
| 55 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_modules WHERE id=%d", $this->id ) );
|
| 56 |
|
| 57 |
RE_Log::delete_for_module( $this->id );
|
| 58 |
+
self::clear_cache( $this->id );
|
| 59 |
+
self::flush_delete( $this->id );
|
| 60 |
}
|
| 61 |
|
| 62 |
+
static function clear_cache( $module ) {
|
| 63 |
delete_option( 'redirection_module_cache' );
|
| 64 |
+
self::flush( $module );
|
| 65 |
}
|
| 66 |
|
| 67 |
function create( $data ) {
|
| 78 |
|
| 79 |
$wpdb->insert( $wpdb->prefix.'redirection_modules', $db );
|
| 80 |
|
| 81 |
+
self::flush( $wpdb->insert_id );
|
| 82 |
return $wpdb->insert_id;
|
| 83 |
}
|
| 84 |
|
| 85 |
return false;
|
| 86 |
}
|
| 87 |
|
| 88 |
+
static function get( $id ) {
|
| 89 |
global $wpdb;
|
| 90 |
|
| 91 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_modules WHERE id=%d", $id ) );
|
| 92 |
if ( $row )
|
| 93 |
+
return self::new_item( $row );
|
| 94 |
return false;
|
| 95 |
}
|
| 96 |
|
| 105 |
$items = array();
|
| 106 |
if ( count( $rows ) > 0 ) {
|
| 107 |
foreach ( $rows AS $row ) {
|
| 108 |
+
$items[] = self::new_item( $row );
|
| 109 |
}
|
| 110 |
}
|
| 111 |
|
| 117 |
/**
|
| 118 |
* Get all modules
|
| 119 |
*/
|
| 120 |
+
static function get_all() {
|
| 121 |
global $wpdb;
|
| 122 |
|
| 123 |
$rows = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}redirection_modules WHERE id > 0 ORDER BY id" );
|
| 124 |
$items = array();
|
| 125 |
if ( count( $rows ) > 0 ) {
|
| 126 |
foreach ( $rows AS $row ) {
|
| 127 |
+
$items[] = self::new_item( $row );
|
| 128 |
}
|
| 129 |
}
|
| 130 |
|
| 131 |
+
return array_filter( $items );
|
| 132 |
}
|
| 133 |
|
| 134 |
/**
|
| 135 |
* Get first module
|
| 136 |
*/
|
| 137 |
+
static function get_first_id() {
|
| 138 |
global $wpdb;
|
| 139 |
return $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}redirection_modules ORDER BY id LIMIT 0,1" );
|
| 140 |
}
|
| 143 |
* Get all modules
|
| 144 |
*/
|
| 145 |
|
| 146 |
+
static function get_for_select() {
|
| 147 |
$data = array();
|
| 148 |
+
$items = self::get_all();
|
| 149 |
|
| 150 |
foreach ( $items AS $item ) {
|
| 151 |
$data[$item->id] = $item->name;
|
| 157 |
/**
|
| 158 |
* Get all module types
|
| 159 |
*/
|
| 160 |
+
static function get_types() {
|
| 161 |
return array (
|
| 162 |
'apache' => __( 'Apache', 'redirection' ),
|
| 163 |
'wp' => __( 'WordPress', 'redirection' ),
|
| 164 |
);
|
| 165 |
}
|
| 166 |
|
| 167 |
+
static function new_item( $data ) {
|
| 168 |
$map = array (
|
| 169 |
'apache' => array( 'Apache_Module', 'apache.php' ),
|
| 170 |
'wp' => array( 'WordPress_Module', 'wordpress.php' ),
|
| 236 |
function hits() {
|
| 237 |
global $wpdb;
|
| 238 |
|
| 239 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}redirection_logs WHERE module_id=%d", $this->id ) );
|
| 240 |
if ( $count > 0 )
|
| 241 |
return $count;
|
| 242 |
return 0;
|
| 243 |
}
|
| 244 |
|
| 245 |
function reset() {
|
| 246 |
+
self::clear_cache( $this->id );
|
| 247 |
|
| 248 |
$groups = Red_Group::get_for_module( $this->id );
|
| 249 |
if ( count( $groups ) > 0 ) {
|
| 265 |
function config() {
|
| 266 |
}
|
| 267 |
}
|
|
|
models/monitor.php
CHANGED
|
@@ -34,7 +34,7 @@ class Red_Monitor {
|
|
| 34 |
$before = esc_url( $_POST['redirection_slug'] );
|
| 35 |
$site = parse_url( get_site_url() );
|
| 36 |
|
| 37 |
-
if ( in_array( $post->post_status, array( 'publish', 'static' ) ) && $before != $after && $before != '/' && $before != $site['path'].'/' ) {
|
| 38 |
Red_Item::create( array(
|
| 39 |
'source' => $before,
|
| 40 |
'target' => $after,
|
| 34 |
$before = esc_url( $_POST['redirection_slug'] );
|
| 35 |
$site = parse_url( get_site_url() );
|
| 36 |
|
| 37 |
+
if ( in_array( $post->post_status, array( 'publish', 'static' ) ) && $before != $after && $before != '/' && ( !isset( $site['path'] ) || ( isset( $site['path'] ) && $before != $site['path'].'/' ) ) ) {
|
| 38 |
Red_Item::create( array(
|
| 39 |
'source' => $before,
|
| 40 |
'target' => $after,
|
models/pager.php
CHANGED
|
@@ -4,7 +4,11 @@ if ( !class_exists( 'WP_List_Table' ) )
|
|
| 4 |
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
| 5 |
|
| 6 |
class Redirection_Log_Table extends WP_List_Table {
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
//Set parent defaults
|
| 9 |
parent::__construct( array(
|
| 10 |
'singular' => 'item', //singular name of the listed records
|
|
@@ -24,7 +28,7 @@ class Redirection_Log_Table extends WP_List_Table {
|
|
| 24 |
}
|
| 25 |
|
| 26 |
function column_ip( $item ) {
|
| 27 |
-
return '<a href="
|
| 28 |
}
|
| 29 |
|
| 30 |
function column_url( $item ) {
|
|
@@ -143,7 +147,11 @@ class Redirection_Log_Table extends WP_List_Table {
|
|
| 143 |
}
|
| 144 |
|
| 145 |
class Redirection_404_Table extends WP_List_Table {
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
//Set parent defaults
|
| 148 |
parent::__construct( array(
|
| 149 |
'singular' => 'item', //singular name of the listed records
|
|
@@ -161,7 +169,7 @@ class Redirection_404_Table extends WP_List_Table {
|
|
| 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="
|
| 165 |
}
|
| 166 |
|
| 167 |
function column_url( $item ) {
|
|
@@ -398,7 +406,7 @@ class RE_Pager
|
|
| 398 |
|
| 399 |
$searchbits = array ();
|
| 400 |
foreach ($searches AS $search)
|
| 401 |
-
$searchbits[] = $wpdb->prepare( $search.' LIKE
|
| 402 |
|
| 403 |
$sql .= implode (' OR ', $searchbits);
|
| 404 |
$sql .= ')';
|
| 4 |
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
| 5 |
|
| 6 |
class Redirection_Log_Table extends WP_List_Table {
|
| 7 |
+
private $lookup;
|
| 8 |
+
|
| 9 |
+
function __construct( $options ) {
|
| 10 |
+
$this->lookup = $options['lookup'];
|
| 11 |
+
|
| 12 |
//Set parent defaults
|
| 13 |
parent::__construct( array(
|
| 14 |
'singular' => 'item', //singular name of the listed records
|
| 28 |
}
|
| 29 |
|
| 30 |
function column_ip( $item ) {
|
| 31 |
+
return '<a href="'.esc_attr( $this->lookup ).esc_attr( $item->ip ).'">'.esc_html( $item->ip ).'</a>';
|
| 32 |
}
|
| 33 |
|
| 34 |
function column_url( $item ) {
|
| 147 |
}
|
| 148 |
|
| 149 |
class Redirection_404_Table extends WP_List_Table {
|
| 150 |
+
private $lookup;
|
| 151 |
+
|
| 152 |
+
function __construct( $options ) {
|
| 153 |
+
$this->lookup = $options['lookup'];
|
| 154 |
+
|
| 155 |
//Set parent defaults
|
| 156 |
parent::__construct( array(
|
| 157 |
'singular' => 'item', //singular name of the listed records
|
| 169 |
function column_ip( $item ) {
|
| 170 |
$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>';
|
| 171 |
|
| 172 |
+
return sprintf( '%1$s %2$s', '<a href="'.esc_attr( $this->lookup ).esc_attr( long2ip( $item->ip ) ).'">'.long2ip( $item->ip ).'</a>', $this->row_actions( $actions ) );
|
| 173 |
}
|
| 174 |
|
| 175 |
function column_url( $item ) {
|
| 406 |
|
| 407 |
$searchbits = array ();
|
| 408 |
foreach ($searches AS $search)
|
| 409 |
+
$searchbits[] = $wpdb->prepare( $search.' LIKE %s', '%'.like_escape( $this->search ).'%' );
|
| 410 |
|
| 411 |
$sql .= implode (' OR ', $searchbits);
|
| 412 |
$sql .= ')';
|
models/redirect.php
CHANGED
|
@@ -20,7 +20,9 @@ this software, even if advised of the possibility of such damage.
|
|
| 20 |
For full license details see license.txt
|
| 21 |
============================================================================================================ */
|
| 22 |
class Red_Item {
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
var $url = null;
|
| 25 |
var $regex = false;
|
| 26 |
var $action_data = null;
|
|
@@ -62,7 +64,7 @@ class Red_Item {
|
|
| 62 |
}
|
| 63 |
}
|
| 64 |
|
| 65 |
-
function get_all_for_module( $module ) {
|
| 66 |
global $wpdb;
|
| 67 |
|
| 68 |
$sql = "SELECT @redirection_items.*,@redirection_groups.tracking FROM @redirection_items INNER JOIN @redirection_groups ON @redirection_groups.id=@redirection_items.group_id AND @redirection_groups.status='enabled' AND @redirection_groups.module_id='$module' WHERE @redirection_items.status='enabled' ORDER BY @redirection_groups.position,@redirection_items.position";
|
|
@@ -79,7 +81,7 @@ class Red_Item {
|
|
| 79 |
return $items;
|
| 80 |
}
|
| 81 |
|
| 82 |
-
function exists( $url ) {
|
| 83 |
global $wpdb;
|
| 84 |
|
| 85 |
if ( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$wpdb->prefix}redirection_items WHERE url=%s", $url ) ) > 0 )
|
|
@@ -87,7 +89,7 @@ class Red_Item {
|
|
| 87 |
return false;
|
| 88 |
}
|
| 89 |
|
| 90 |
-
function get_for_url( $url, $type ) {
|
| 91 |
global $wpdb;
|
| 92 |
|
| 93 |
$sql = $wpdb->prepare( "SELECT @redirection_items.*,@redirection_groups.tracking,@redirection_groups.position AS group_pos,@redirection_modules.id AS module_id FROM @redirection_items INNER JOIN @redirection_groups ON @redirection_groups.id=@redirection_items.group_id AND @redirection_groups.status='enabled' INNER JOIN @redirection_modules ON @redirection_modules.id=@redirection_groups.module_id AND @redirection_modules.type=%s WHERE( @redirection_items.regex=1 OR @redirection_items.url=%s)", $type, $url );
|
|
@@ -107,7 +109,7 @@ class Red_Item {
|
|
| 107 |
return $items;
|
| 108 |
}
|
| 109 |
|
| 110 |
-
function get_by_module( $module ) {
|
| 111 |
global $wpdb;
|
| 112 |
|
| 113 |
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->prefix}redirection_items INNER JOIN {$wpdb->prefix}redirection_groups ON {$wpdb->prefix}redirection_groups.id={$wpdb->prefix}redirection_items.group_id";
|
|
@@ -126,11 +128,16 @@ class Red_Item {
|
|
| 126 |
/**
|
| 127 |
* Get redirection items in a group
|
| 128 |
*/
|
| 129 |
-
function get_by_group( $group, &$pager ) {
|
| 130 |
global $wpdb;
|
| 131 |
|
| 132 |
-
$
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
$items = array();
|
| 136 |
if ( count( $rows ) > 0 ) {
|
|
@@ -142,7 +149,7 @@ class Red_Item {
|
|
| 142 |
return $items;
|
| 143 |
}
|
| 144 |
|
| 145 |
-
function get_by_id( $id ) {
|
| 146 |
global $wpdb;
|
| 147 |
|
| 148 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_items WHERE id=%d", $id ) );
|
|
@@ -151,7 +158,7 @@ class Red_Item {
|
|
| 151 |
return false;
|
| 152 |
}
|
| 153 |
|
| 154 |
-
function auto_generate() {
|
| 155 |
global $redirection;
|
| 156 |
|
| 157 |
$options = $redirection->get_options();
|
|
@@ -163,15 +170,15 @@ class Red_Item {
|
|
| 163 |
return $url;
|
| 164 |
}
|
| 165 |
|
| 166 |
-
function create( $details ) {
|
| 167 |
global $wpdb;
|
| 168 |
|
| 169 |
// Auto generate URLs
|
| 170 |
if ( $details['source'] == '' )
|
| 171 |
-
$details['source'] =
|
| 172 |
|
| 173 |
if ( $details['target'] == '' )
|
| 174 |
-
$details['target'] =
|
| 175 |
|
| 176 |
// Make sure we don't redirect to ourself
|
| 177 |
if ( $details['source'] == $details['target'] )
|
|
@@ -195,7 +202,7 @@ class Red_Item {
|
|
| 195 |
$action_code = intval( $details['action_code'] );
|
| 196 |
|
| 197 |
$data = array(
|
| 198 |
-
'url' =>
|
| 199 |
'action_type' => $details['red_action'],
|
| 200 |
'regex' => $regex,
|
| 201 |
'position' => $position,
|
|
@@ -206,18 +213,20 @@ class Red_Item {
|
|
| 206 |
'group_id' => $group_id
|
| 207 |
);
|
| 208 |
|
|
|
|
|
|
|
| 209 |
$wpdb->insert( $wpdb->prefix.'redirection_items', $data );
|
| 210 |
|
| 211 |
$group = Red_Group::get( $group_id );
|
| 212 |
Red_Module::flush( $group->module_id );
|
| 213 |
|
| 214 |
-
return
|
| 215 |
}
|
| 216 |
|
| 217 |
return false;
|
| 218 |
}
|
| 219 |
|
| 220 |
-
function delete_by_group( $group ) {
|
| 221 |
global $wpdb;
|
| 222 |
|
| 223 |
RE_Log::delete_for_group( $group);
|
|
@@ -228,7 +237,7 @@ class Red_Item {
|
|
| 228 |
Red_Module::flush( $group->module_id );
|
| 229 |
}
|
| 230 |
|
| 231 |
-
function delete( $id ) {
|
| 232 |
global $wpdb;
|
| 233 |
|
| 234 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE id=%d", $id ) );
|
|
@@ -245,7 +254,7 @@ class Red_Item {
|
|
| 245 |
}
|
| 246 |
|
| 247 |
|
| 248 |
-
function sanitize_url( $url, $regex ) {
|
| 249 |
// Make sure that the old URL is relative
|
| 250 |
$url = preg_replace( '@^https?://(.*?)/@', '/', $url );
|
| 251 |
$url = preg_replace( '@^https?://(.*?)$@', '/', $url );
|
|
@@ -261,7 +270,7 @@ class Red_Item {
|
|
| 261 |
global $wpdb;
|
| 262 |
|
| 263 |
$this->regex = isset( $details['regex'] ) ? 1 : 0;
|
| 264 |
-
$this->url =
|
| 265 |
$this->title = $details['title'];
|
| 266 |
|
| 267 |
$data = $this->match->data( $details );
|
|
@@ -283,14 +292,14 @@ class Red_Item {
|
|
| 283 |
}
|
| 284 |
}
|
| 285 |
|
| 286 |
-
function save_order( $items, $start ) {
|
| 287 |
global $wpdb;
|
| 288 |
|
| 289 |
foreach ( $items AS $pos => $id ) {
|
| 290 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'position' => $pos + $start ), array( 'id' => $id ) );
|
| 291 |
}
|
| 292 |
|
| 293 |
-
$item =
|
| 294 |
$group = Red_Group::get( $item->group_id );
|
| 295 |
if ( $group )
|
| 296 |
Red_Module::flush( $group->module_id );
|
|
@@ -380,7 +389,7 @@ class Red_Item {
|
|
| 380 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'status' => $this->status ), array( 'id' => $this->id ) );
|
| 381 |
}
|
| 382 |
|
| 383 |
-
function actions( $action = '' ) {
|
| 384 |
$actions = array(
|
| 385 |
'url' => __( 'Redirect to URL', 'redirection' ),
|
| 386 |
'random' => __( 'Redirect to random post', 'redirection' ),
|
| 20 |
For full license details see license.txt
|
| 21 |
============================================================================================================ */
|
| 22 |
class Red_Item {
|
| 23 |
+
var $id = null;
|
| 24 |
+
var $created;
|
| 25 |
+
var $referrer;
|
| 26 |
var $url = null;
|
| 27 |
var $regex = false;
|
| 28 |
var $action_data = null;
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
| 67 |
+
static function get_all_for_module( $module ) {
|
| 68 |
global $wpdb;
|
| 69 |
|
| 70 |
$sql = "SELECT @redirection_items.*,@redirection_groups.tracking FROM @redirection_items INNER JOIN @redirection_groups ON @redirection_groups.id=@redirection_items.group_id AND @redirection_groups.status='enabled' AND @redirection_groups.module_id='$module' WHERE @redirection_items.status='enabled' ORDER BY @redirection_groups.position,@redirection_items.position";
|
| 81 |
return $items;
|
| 82 |
}
|
| 83 |
|
| 84 |
+
static function exists( $url ) {
|
| 85 |
global $wpdb;
|
| 86 |
|
| 87 |
if ( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$wpdb->prefix}redirection_items WHERE url=%s", $url ) ) > 0 )
|
| 89 |
return false;
|
| 90 |
}
|
| 91 |
|
| 92 |
+
static function get_for_url( $url, $type ) {
|
| 93 |
global $wpdb;
|
| 94 |
|
| 95 |
$sql = $wpdb->prepare( "SELECT @redirection_items.*,@redirection_groups.tracking,@redirection_groups.position AS group_pos,@redirection_modules.id AS module_id FROM @redirection_items INNER JOIN @redirection_groups ON @redirection_groups.id=@redirection_items.group_id AND @redirection_groups.status='enabled' INNER JOIN @redirection_modules ON @redirection_modules.id=@redirection_groups.module_id AND @redirection_modules.type=%s WHERE( @redirection_items.regex=1 OR @redirection_items.url=%s)", $type, $url );
|
| 109 |
return $items;
|
| 110 |
}
|
| 111 |
|
| 112 |
+
static function get_by_module( $module ) {
|
| 113 |
global $wpdb;
|
| 114 |
|
| 115 |
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->prefix}redirection_items INNER JOIN {$wpdb->prefix}redirection_groups ON {$wpdb->prefix}redirection_groups.id={$wpdb->prefix}redirection_items.group_id";
|
| 128 |
/**
|
| 129 |
* Get redirection items in a group
|
| 130 |
*/
|
| 131 |
+
static function get_by_group( $group, &$pager ) {
|
| 132 |
global $wpdb;
|
| 133 |
|
| 134 |
+
$sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $group );
|
| 135 |
+
|
| 136 |
+
if ( $pager->search )
|
| 137 |
+
$sql .= $wpdb->prepare( ' AND url LIKE %s', '%'.like_escape( $pager->search ).'%' );
|
| 138 |
+
|
| 139 |
+
$rows = $wpdb->get_results( $sql.' ORDER BY position' );
|
| 140 |
+
$pager->set_total( $wpdb->get_var( $sql ) );
|
| 141 |
|
| 142 |
$items = array();
|
| 143 |
if ( count( $rows ) > 0 ) {
|
| 149 |
return $items;
|
| 150 |
}
|
| 151 |
|
| 152 |
+
static function get_by_id( $id ) {
|
| 153 |
global $wpdb;
|
| 154 |
|
| 155 |
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}redirection_items WHERE id=%d", $id ) );
|
| 158 |
return false;
|
| 159 |
}
|
| 160 |
|
| 161 |
+
static function auto_generate() {
|
| 162 |
global $redirection;
|
| 163 |
|
| 164 |
$options = $redirection->get_options();
|
| 170 |
return $url;
|
| 171 |
}
|
| 172 |
|
| 173 |
+
static function create( $details ) {
|
| 174 |
global $wpdb;
|
| 175 |
|
| 176 |
// Auto generate URLs
|
| 177 |
if ( $details['source'] == '' )
|
| 178 |
+
$details['source'] = self::auto_generate();
|
| 179 |
|
| 180 |
if ( $details['target'] == '' )
|
| 181 |
+
$details['target'] = self::auto_generate();
|
| 182 |
|
| 183 |
// Make sure we don't redirect to ourself
|
| 184 |
if ( $details['source'] == $details['target'] )
|
| 202 |
$action_code = intval( $details['action_code'] );
|
| 203 |
|
| 204 |
$data = array(
|
| 205 |
+
'url' => self::sanitize_url( $details['source'], $regex),
|
| 206 |
'action_type' => $details['red_action'],
|
| 207 |
'regex' => $regex,
|
| 208 |
'position' => $position,
|
| 213 |
'group_id' => $group_id
|
| 214 |
);
|
| 215 |
|
| 216 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE url=%s AND action_type=%s AND action_data=%s", $data['action_data'], $data['action_type'], $data['url'] ) );
|
| 217 |
+
|
| 218 |
$wpdb->insert( $wpdb->prefix.'redirection_items', $data );
|
| 219 |
|
| 220 |
$group = Red_Group::get( $group_id );
|
| 221 |
Red_Module::flush( $group->module_id );
|
| 222 |
|
| 223 |
+
return self::get_by_id( $wpdb->insert_id );
|
| 224 |
}
|
| 225 |
|
| 226 |
return false;
|
| 227 |
}
|
| 228 |
|
| 229 |
+
static function delete_by_group( $group ) {
|
| 230 |
global $wpdb;
|
| 231 |
|
| 232 |
RE_Log::delete_for_group( $group);
|
| 237 |
Red_Module::flush( $group->module_id );
|
| 238 |
}
|
| 239 |
|
| 240 |
+
static function delete( $id ) {
|
| 241 |
global $wpdb;
|
| 242 |
|
| 243 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE id=%d", $id ) );
|
| 254 |
}
|
| 255 |
|
| 256 |
|
| 257 |
+
static function sanitize_url( $url, $regex ) {
|
| 258 |
// Make sure that the old URL is relative
|
| 259 |
$url = preg_replace( '@^https?://(.*?)/@', '/', $url );
|
| 260 |
$url = preg_replace( '@^https?://(.*?)$@', '/', $url );
|
| 270 |
global $wpdb;
|
| 271 |
|
| 272 |
$this->regex = isset( $details['regex'] ) ? 1 : 0;
|
| 273 |
+
$this->url = self::sanitize_url( $details['old'], $this->regex );
|
| 274 |
$this->title = $details['title'];
|
| 275 |
|
| 276 |
$data = $this->match->data( $details );
|
| 292 |
}
|
| 293 |
}
|
| 294 |
|
| 295 |
+
static function save_order( $items, $start ) {
|
| 296 |
global $wpdb;
|
| 297 |
|
| 298 |
foreach ( $items AS $pos => $id ) {
|
| 299 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'position' => $pos + $start ), array( 'id' => $id ) );
|
| 300 |
}
|
| 301 |
|
| 302 |
+
$item = self::get_by_id( $id );
|
| 303 |
$group = Red_Group::get( $item->group_id );
|
| 304 |
if ( $group )
|
| 305 |
Red_Module::flush( $group->module_id );
|
| 389 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'status' => $this->status ), array( 'id' => $this->id ) );
|
| 390 |
}
|
| 391 |
|
| 392 |
+
static function actions( $action = '' ) {
|
| 393 |
$actions = array(
|
| 394 |
'url' => __( 'Redirect to URL', 'redirection' ),
|
| 395 |
'random' => __( 'Redirect to random post', 'redirection' ),
|
readme.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
=== Plugin Name ===
|
| 2 |
Contributors: johnny5
|
| 3 |
Donate link: http://urbangiraffe.com/about/
|
| 4 |
Tags: post, admin, seo, pages, manage, 301, 404, redirect, permalink
|
| 5 |
-
Requires at least: 3.
|
| 6 |
-
Tested up to: 3.
|
| 7 |
-
Stable tag: 2.
|
| 8 |
|
| 9 |
Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files.
|
| 10 |
|
|
@@ -88,8 +88,18 @@ The plugin works in a similar manner to how WordPress handles permalinks and sho
|
|
| 88 |
|
| 89 |
Full documentation can be found on the [Redirection](http://urbangiraffe.com/plugins/redirection/) page.
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
== Changelog ==
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
= 2.3.2 =
|
| 94 |
* WP 3.5 compat
|
| 95 |
* Fix export
|
| 1 |
+
=== Plugin Name ===
|
| 2 |
Contributors: johnny5
|
| 3 |
Donate link: http://urbangiraffe.com/about/
|
| 4 |
Tags: post, admin, seo, pages, manage, 301, 404, redirect, permalink
|
| 5 |
+
Requires at least: 3.2
|
| 6 |
+
Tested up to: 3.7
|
| 7 |
+
Stable tag: 2.3.3
|
| 8 |
|
| 9 |
Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files.
|
| 10 |
|
| 88 |
|
| 89 |
Full documentation can be found on the [Redirection](http://urbangiraffe.com/plugins/redirection/) page.
|
| 90 |
|
| 91 |
+
== Upgrade Notice ==
|
| 92 |
+
|
| 93 |
+
= 2.3.3 =
|
| 94 |
+
* Full WordPress 3.5+ compatability! Note that this contains database changes so please backup your data.
|
| 95 |
+
|
| 96 |
== Changelog ==
|
| 97 |
|
| 98 |
+
= 2.3.3 =
|
| 99 |
+
* Fix PHP strict, props to Juliette Folmer
|
| 100 |
+
* Fix RSS entry date, props to Juliette
|
| 101 |
+
* Fix pagination
|
| 102 |
+
|
| 103 |
= 2.3.2 =
|
| 104 |
* WP 3.5 compat
|
| 105 |
* Fix export
|
redirection.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Redirection
|
| 4 |
Plugin URI: http://urbangiraffe.com/plugins/redirection/
|
| 5 |
Description: Manage all your 301 redirects and monitor 404 errors
|
| 6 |
-
Version: 2.3.
|
| 7 |
Author: John Godley
|
| 8 |
Author URI: http://urbangiraffe.com
|
| 9 |
============================================================================================================
|
|
@@ -169,7 +169,6 @@ class Redirection extends Redirection_Plugin {
|
|
| 169 |
$options = array();
|
| 170 |
|
| 171 |
$defaults = array (
|
| 172 |
-
'lookup' => 'http://urbangiraffe.com/map/?from=redirection&ip=',
|
| 173 |
'support' => false,
|
| 174 |
'log_redirections' => true,
|
| 175 |
'log_404s' => true,
|
|
@@ -185,8 +184,7 @@ class Redirection extends Redirection_Plugin {
|
|
| 185 |
$options[$key] = $value;
|
| 186 |
}
|
| 187 |
|
| 188 |
-
|
| 189 |
-
$options['lookup'] = 'http://urbangiraffe.com/map/?from=redirection&ip=';
|
| 190 |
|
| 191 |
return $options;
|
| 192 |
}
|
|
@@ -262,7 +260,9 @@ class Redirection extends Redirection_Plugin {
|
|
| 262 |
$this->render_message( __( 'Your logs have been deleted', 'redirection' ) );
|
| 263 |
}
|
| 264 |
|
| 265 |
-
$
|
|
|
|
|
|
|
| 266 |
|
| 267 |
if ( isset( $_GET['module'] ) )
|
| 268 |
$table->prepare_items( 'module', intval( $_GET['module'] ) );
|
|
@@ -273,7 +273,6 @@ class Redirection extends Redirection_Plugin {
|
|
| 273 |
else
|
| 274 |
$table->prepare_items();
|
| 275 |
|
| 276 |
-
$options = $this->get_options();
|
| 277 |
$this->render_admin( 'log', array( 'options' => $options, 'table' => $table, 'lookup' => $options['lookup'] ) );
|
| 278 |
}
|
| 279 |
|
|
@@ -285,10 +284,11 @@ class Redirection extends Redirection_Plugin {
|
|
| 285 |
$this->render_message( __( 'Your logs have been deleted', 'redirection' ) );
|
| 286 |
}
|
| 287 |
|
| 288 |
-
$
|
|
|
|
|
|
|
| 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'] ) );
|
| 293 |
}
|
| 294 |
|
|
@@ -310,7 +310,11 @@ class Redirection extends Redirection_Plugin {
|
|
| 310 |
$pager = new RE_Pager( $_GET, admin_url( add_query_arg( array( 'sub' => 'groups' ), 'tools.php?page=redirection.php' ) ), 'position', 'ASC' );
|
| 311 |
$items = Red_Group::get_all( $module, $pager );
|
| 312 |
|
| 313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
}
|
| 315 |
|
| 316 |
function admin_redirects( $group ) {
|
| 3 |
Plugin Name: Redirection
|
| 4 |
Plugin URI: http://urbangiraffe.com/plugins/redirection/
|
| 5 |
Description: Manage all your 301 redirects and monitor 404 errors
|
| 6 |
+
Version: 2.3.3
|
| 7 |
Author: John Godley
|
| 8 |
Author URI: http://urbangiraffe.com
|
| 9 |
============================================================================================================
|
| 169 |
$options = array();
|
| 170 |
|
| 171 |
$defaults = array (
|
|
|
|
| 172 |
'support' => false,
|
| 173 |
'log_redirections' => true,
|
| 174 |
'log_404s' => true,
|
| 184 |
$options[$key] = $value;
|
| 185 |
}
|
| 186 |
|
| 187 |
+
$options['lookup'] = 'http://geomaplookup.net/?ip=';
|
|
|
|
| 188 |
|
| 189 |
return $options;
|
| 190 |
}
|
| 260 |
$this->render_message( __( 'Your logs have been deleted', 'redirection' ) );
|
| 261 |
}
|
| 262 |
|
| 263 |
+
$options = $this->get_options();
|
| 264 |
+
|
| 265 |
+
$table = new Redirection_Log_Table( $options );
|
| 266 |
|
| 267 |
if ( isset( $_GET['module'] ) )
|
| 268 |
$table->prepare_items( 'module', intval( $_GET['module'] ) );
|
| 273 |
else
|
| 274 |
$table->prepare_items();
|
| 275 |
|
|
|
|
| 276 |
$this->render_admin( 'log', array( 'options' => $options, 'table' => $table, 'lookup' => $options['lookup'] ) );
|
| 277 |
}
|
| 278 |
|
| 284 |
$this->render_message( __( 'Your logs have been deleted', 'redirection' ) );
|
| 285 |
}
|
| 286 |
|
| 287 |
+
$options = $this->get_options();
|
| 288 |
+
|
| 289 |
+
$table = new Redirection_404_Table( $options );
|
| 290 |
$table->prepare_items( isset( $_GET['ip'] ) ? $_GET['ip'] : false );
|
| 291 |
|
|
|
|
| 292 |
$this->render_admin( 'log', array( 'options' => $options, 'table' => $table, 'lookup' => $options['lookup'] ) );
|
| 293 |
}
|
| 294 |
|
| 310 |
$pager = new RE_Pager( $_GET, admin_url( add_query_arg( array( 'sub' => 'groups' ), 'tools.php?page=redirection.php' ) ), 'position', 'ASC' );
|
| 311 |
$items = Red_Group::get_all( $module, $pager );
|
| 312 |
|
| 313 |
+
$module = Red_Module::get( $module );
|
| 314 |
+
if ( $module )
|
| 315 |
+
$this->render_admin( 'group_list', array( 'options' => $this->get_options(), 'groups' => $items, 'pager' => $pager, 'modules' => Red_Module::get_for_select(), 'module' => $module ) );
|
| 316 |
+
else
|
| 317 |
+
$this->render_message( __( 'Unknown module', 'redirection' ) );
|
| 318 |
}
|
| 319 |
|
| 320 |
function admin_redirects( $group ) {
|
view/admin/group_list.php
CHANGED
|
@@ -102,7 +102,10 @@
|
|
| 102 |
</tr>
|
| 103 |
<tr>
|
| 104 |
<th width="50"></th>
|
| 105 |
-
<td
|
|
|
|
|
|
|
|
|
|
| 106 |
</tr>
|
| 107 |
</table>
|
| 108 |
</form>
|
| 102 |
</tr>
|
| 103 |
<tr>
|
| 104 |
<th width="50"></th>
|
| 105 |
+
<td>
|
| 106 |
+
<input class="button-primary" type="submit" name="add" value="<?php esc_attr_e( 'Add', 'redirection' ); ?>"/>
|
| 107 |
+
<input type="hidden" name="module_id" value="<?php echo $module->id ?>"/>
|
| 108 |
+
</td>
|
| 109 |
</tr>
|
| 110 |
</table>
|
| 111 |
</form>
|
view/admin/item.php
CHANGED
|
@@ -19,7 +19,7 @@
|
|
| 19 |
<div class="item<?php if ($redirect->regex) echo ' item-regex' ?>">
|
| 20 |
<input type="checkbox" class="check" name="checkall[]" value="<?php echo $redirect->id ?>"/>
|
| 21 |
|
| 22 |
-
<a href="<?php echo $this->url ($redirect->url) ?>" class="redirection-edit"><?php if ($redirect->title) echo esc_html( $redirect->title ); else echo RE_Log::show_url
|
| 23 |
|
| 24 |
<?php if ($redirect->match_type != 'url') echo '('.esc_html( $redirect->match_name() ).')' ?>
|
| 25 |
|
| 19 |
<div class="item<?php if ($redirect->regex) echo ' item-regex' ?>">
|
| 20 |
<input type="checkbox" class="check" name="checkall[]" value="<?php echo $redirect->id ?>"/>
|
| 21 |
|
| 22 |
+
<a href="<?php echo $this->url ($redirect->url) ?>" class="redirection-edit"><?php if ($redirect->title) echo esc_html( $redirect->title ); else echo esc_html( RE_Log::show_url( $redirect->url ) ); ?></a>
|
| 23 |
|
| 24 |
<?php if ($redirect->match_type != 'url') echo '('.esc_html( $redirect->match_name() ).')' ?>
|
| 25 |
|
view/admin/options.php
CHANGED
|
@@ -12,20 +12,14 @@
|
|
| 12 |
|
| 13 |
<table cellpadding="3" width="100%" class="form-table">
|
| 14 |
<tr>
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
<tr>
|
| 24 |
-
<th align="right" valign="top"><?php _e( 'IP Lookup Service', 'redirection' ); ?>:</th>
|
| 25 |
-
<td>
|
| 26 |
-
<input type="text" style="width: 95%" name="lookup" value="<?php echo esc_attr( $options['lookup'] ) ?>" id="lookup"/><br/>
|
| 27 |
-
</td>
|
| 28 |
-
</tr>
|
| 29 |
<tr>
|
| 30 |
<th align="right"><?php _e( 'Plugin Support', 'redirection' ); ?>:</th>
|
| 31 |
<td>
|
| 12 |
|
| 13 |
<table cellpadding="3" width="100%" class="form-table">
|
| 14 |
<tr>
|
| 15 |
+
<th valign="top" align="right"><?php _e( 'Auto-generate URL', 'redirection' ) ?>:</th>
|
| 16 |
+
<td>
|
| 17 |
+
<input type="text" name="auto_target" style="width: 95%" value="<?php echo esc_attr( $options['auto_target'] ) ?>"/>
|
| 18 |
+
<br/>
|
| 19 |
+
<span class="sub"><?php _e( 'This will be used to auto-generate a URL if no URL is given. You can use the special tags $dec$ or $hex$ to have a unique ID inserted (either decimal or hex)', 'redirection' ); ?></span>
|
| 20 |
+
|
| 21 |
+
</td>
|
| 22 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
<tr>
|
| 24 |
<th align="right"><?php _e( 'Plugin Support', 'redirection' ); ?>:</th>
|
| 25 |
<td>
|
view/admin/submenu.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
<ul class="subsubsub">
|
| 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 |
<?php _e( 'Redirects', 'redirection' ); ?>
|
| 7 |
</a> |
|
| 8 |
</li>
|
| 2 |
|
| 3 |
<ul class="subsubsub">
|
| 4 |
<li>
|
| 5 |
+
<a <?php if ( !isset( $_GET['sub'] ) || $_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 |
<?php _e( 'Redirects', 'redirection' ); ?>
|
| 7 |
</a> |
|
| 8 |
</li>
|
view/admin/support.php
CHANGED
|
@@ -7,9 +7,11 @@
|
|
| 7 |
|
| 8 |
<p style="clear: both">
|
| 9 |
<?php _e( 'Redirection is free to use - life is wonderful and lovely! However, it has required a great deal of time and effort to develop and if it has been useful you can help support this development by <strong>making a small donation</strong>.', 'redirection'); ?>
|
| 10 |
-
<?php _e( 'This will act as an incentive for me to carry on developing
|
| 11 |
</p>
|
| 12 |
|
|
|
|
|
|
|
| 13 |
<p><?php _e( 'If you are using this plugin in a commercial setup, or feel that it\'s been particularly useful, then you may want to consider a <strong>commercial donation</strong>.', 'redirection' )?>
|
| 14 |
|
| 15 |
<ul class="donations">
|
|
@@ -18,7 +20,7 @@
|
|
| 18 |
<input type="hidden" name="cmd" value="_xclick">
|
| 19 |
<input type="hidden" name="business" value="admin@urbangiraffe.com">
|
| 20 |
<input type="hidden" name="item_name" value="Redirection - Individual">
|
| 21 |
-
<input type="hidden" name="amount" value="
|
| 22 |
<input type="hidden" name="buyer_credit_promo_code" value="">
|
| 23 |
<input type="hidden" name="buyer_credit_product_category" value="">
|
| 24 |
<input type="hidden" name="buyer_credit_shipping_method" value="">
|
| 7 |
|
| 8 |
<p style="clear: both">
|
| 9 |
<?php _e( 'Redirection is free to use - life is wonderful and lovely! However, it has required a great deal of time and effort to develop and if it has been useful you can help support this development by <strong>making a small donation</strong>.', 'redirection'); ?>
|
| 10 |
+
<?php _e( 'This will act as an incentive for me to carry on developing. You get some useful software and I get to carry on making it. Everybody wins.', 'redirection'); ?>
|
| 11 |
</p>
|
| 12 |
|
| 13 |
+
<p><?php _e( 'Please note that a donation is just a donation - it is not a payment for support. I am not a business, this is not a product, and I\'m afraid I cannot provide paid support' ); ?></p>
|
| 14 |
+
|
| 15 |
<p><?php _e( 'If you are using this plugin in a commercial setup, or feel that it\'s been particularly useful, then you may want to consider a <strong>commercial donation</strong>.', 'redirection' )?>
|
| 16 |
|
| 17 |
<ul class="donations">
|
| 20 |
<input type="hidden" name="cmd" value="_xclick">
|
| 21 |
<input type="hidden" name="business" value="admin@urbangiraffe.com">
|
| 22 |
<input type="hidden" name="item_name" value="Redirection - Individual">
|
| 23 |
+
<input type="hidden" name="amount" value="16.00">
|
| 24 |
<input type="hidden" name="buyer_credit_promo_code" value="">
|
| 25 |
<input type="hidden" name="buyer_credit_product_category" value="">
|
| 26 |
<input type="hidden" name="buyer_credit_shipping_method" value="">
|
