| 1 |
<?php |
| 2 |
/** |
| 3 |
* Redirection |
| 4 |
* |
| 5 |
* @package Redirection |
| 6 |
* @author John Godley |
| 7 |
* @copyright Copyright (C) John Godley |
| 8 |
**/ |
| 9 |
|
| 10 |
/* |
| 11 |
============================================================================================================ |
| 12 |
This software is provided "as is" and any express or implied warranties, including, but not limited to, the |
| 13 |
implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall |
| 14 |
the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or |
| 15 |
consequential damages (including, but not limited to, procurement of substitute goods or services; loss of |
| 16 |
use, data, or profits; or business interruption) however caused and on any theory of liability, whether in |
| 17 |
contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of |
| 18 |
this software, even if advised of the possibility of such damage. |
| 19 |
|
| 20 |
For full license details see license.txt |
| 21 |
============================================================================================================ */ |
| 22 |
|
| 23 |
class Red_Match |
| 24 |
{ |
| 25 |
var $url; |
| 26 |
|
| 27 |
function Red_Match ($values = '') |
| 28 |
{ |
| 29 |
if ($values) |
| 30 |
{ |
| 31 |
$obj = @unserialize ($values); |
| 32 |
if ($obj === false) |
| 33 |
$this->url = $values; |
| 34 |
else |
| 35 |
{ |
| 36 |
foreach ($obj AS $key => $value) |
| 37 |
$this->$key = $value; |
| 38 |
} |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
function data ($details) |
| 43 |
{ |
| 44 |
$data = $this->save ($details); |
| 45 |
if (count ($data) == 1 && !is_array (current ($data))) |
| 46 |
$data = current ($data); |
| 47 |
else |
| 48 |
$data = serialize ($data); |
| 49 |
return $data; |
| 50 |
} |
| 51 |
|
| 52 |
function save ($details) { return array (); } |
| 53 |
function name () { return ''; } |
| 54 |
function show () { } |
| 55 |
function wants_it () { return true; } |
| 56 |
function get_target ($url, $matched_url, $regex) { return $false; } |
| 57 |
|
| 58 |
function create ($name, $data = '') |
| 59 |
{ |
| 60 |
$avail = Red_Match::available (); |
| 61 |
if (isset ($avail[strtolower ($name)])) |
| 62 |
{ |
| 63 |
$classname = $name.'_match'; |
| 64 |
|
| 65 |
if (!class_exists (strtolower ($classname))) |
| 66 |
include (dirname (__FILE__).'/../matches/'.$avail[strtolower ($name)]); |
| 67 |
return new $classname ($data); |
| 68 |
} |
| 69 |
return false; |
| 70 |
} |
| 71 |
|
| 72 |
function all () |
| 73 |
{ |
| 74 |
$data = array (); |
| 75 |
|
| 76 |
$avail = Red_Match::available (); |
| 77 |
foreach ($avail AS $name => $file) |
| 78 |
{ |
| 79 |
$obj = Red_Match::create ($name); |
| 80 |
$data[$name] = $obj->name (); |
| 81 |
} |
| 82 |
|
| 83 |
return $data; |
| 84 |
} |
| 85 |
|
| 86 |
function available () |
| 87 |
{ |
| 88 |
return array |
| 89 |
( |
| 90 |
'url' => 'url.php', |
| 91 |
'referrer' => 'referrer.php', |
| 92 |
'agent' => 'user_agent.php', |
| 93 |
'login' => 'login.php', |
| 94 |
); |
| 95 |
} |
| 96 |
|
| 97 |
function match_name () { return ''; } |
| 98 |
} |
| 99 |
|
| 100 |
?> |