This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.php
104 lines (101 loc) · 3.45 KB
/
constants.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
// Redirects for old NetCat urls
class netcat {
public $ok = false, $board;
private $conn, $prefix, $res;
public function __construct($INFO) {
if ( ! $this->conn = mysql_connect($INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass']) ) return;
if ( ! mysql_select_db($INFO['sql_database'], $this->conn) ) return;
if ( ! $this->query("SET NAMES utf8") ) return;
$this->prefix = $INFO['sql_tbl_prefix'];
$this->board = $INFO['board_url'];
$this->ok = true;
}
function query($sql) {
$this->res = mysql_query($sql, $this->conn);
if(!$this->res) return;
return $this->res;
}
function fetch($res = '') {
if(!empty($res)) $this->res = $res;
return mysql_fetch_array($this->res, MYSQL_ASSOC);
}
function safe($string) {
return mysql_real_escape_string($string, $this->conn);
}
function old_topic($id, $sub_id, $st) {
$id = intval($id); $sub_id = intval($sub_id);
$this->query("SELECT * FROM {$this->prefix}netcat_oldies WHERE old_topic = {$id} AND old_sub = {$sub_id}", $this->conn);
if($row = $this->fetch()) {
$this->topic($row['new_topic'], $st);
}
}
function old_forum($id) {
$id = intval($id);
$this->query("SELECT * FROM {$this->prefix}netcat_oldies WHERE old_topic = 0, old_sub = {$id}", $this->conn);
if($row = $this->fetch()) {
$this->forum($row['new_sub'], $st);
}
}
function topic($id, $st) {
$id = intval($id);
$this->query("SELECT * FROM {$this->prefix}netcat_map WHERE type = 'topics' AND old_id = {$id}", $this->conn);
if($row = $this->fetch()) {
$this->redirect("index.php?showtopic=".$row['new_id'].'&st='.$st);
}
}
function member($id) {
$id = intval($id);
$this->query("SELECT * FROM {$this->prefix}netcat_map WHERE type = 'members' AND old_id = {$id}", $this->conn);
if($row = $this->fetch()) {
$this->redirect("index.php?showuser=".$row['new_id']);
}
}
function forum($id) {
$id = intval($id);
$this->query("SELECT * FROM {$this->prefix}netcat_map WHERE type = 'forums' AND old_id = {$id}", $this->conn);
if($row = $this->fetch()) {
$this->redirect("index.php?showforum=".$row['new_id'].'&st='.$st);
}
}
function forum_furls() {
$u = explode("/", $_SERVER['REQUEST_URI']);
if ( empty($u[2]) || empty($u[1]) ) return;
$furl = $this->safe("/".$u[1]."/".$u[2]."/");
$this->query("SELECT * FROM {$this->prefix}netcat_redirects WHERE app = 'forums' AND furl = '{$furl}'", $this->conn);
if($row = $this->fetch()) {
$this->redirect("index.php?showforum=".$row['new_id']);
}
}
function redirect($uri) {
header("Location: {$this->board}/{$uri}");
exit;
}
function adios() {
mysql_close($this->conn);
}
}
if(substr($_SERVER['REQUEST_URI'],0,3)=='/f/') {
require_once( dirname( __FILE__ ) . '/conf_global.php' );
$netcat = new netcat($INFO);
unset($INFO);
if ( $netcat->ok ) {
$st = !empty($_GET['Page_NUM']) ? intval($_GET['curPos'])*20 : 0;
$st = !empty($_GET['curPos']) ? intval($_GET['curPos']) : $st;
if ( !empty($_GET['Topic_ID']) && !empty($_GET['Subdiv_ID']) ) {
$netcat->old_topic($_GET['Topic_ID'], $_GET['Subdiv_ID'], $st);
}
if ( !empty($_GET['Subdiv_ID']) ) {
$netcat->old_forum($_GET['Subdiv_ID']);
}
if ( preg_match("/topic_([0-9]{1,10})\./iu", $_SERVER['REQUEST_URI'], $match) ) {
$netcat->topic($match[1], $st);
}
if ( preg_match("/profile_([0-9]{1,10})\./iu", $_SERVER['REQUEST_URI'], $match) ) {
$netcat->member($match[1]);
}
$netcat->forum_furls();
}
$netcat->adios();
unset($netcat);
}