This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnp-router.php
145 lines (115 loc) · 3.28 KB
/
np-router.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/*
* NPChan
* Author: Aadarsha Paudel
* License: GNU GPL v3
* URL: http://github.com/npchan/npchan
* -----------------------------------------
* Router Page (This file redirects everything to their location (well, most of em'))
* -----------------------------------------
* Contributions:
*
* -----------------------------------------
* This file redirects stuffs around and is the core part of the site.
* Please edit carefully.
*/
// simply redirect empty requests
if(empty($_GET['page'])){
header("location: /");
die;
}
define('AUTH', 'true');
require_once 'np-header.php';
$_POST_PAGE=true;
$p=filter_text($_GET['page']);
// check for board
function is_board($p){
global $pdo;
$p=strtolower($p);
$stmt=$pdo->prepare("SELECT count(*) FROM `boards` WHERE `board`=?");
$stmt->execute([strtolower($p)]);
return $stmt->fetchColumn()!=0 ? true: false;
}
function is_page($p){
global $pdo;
$p=strtolower($p);
$page=["about", "contact", "support", "donate", "faq", "advertise", "rules", "terms", "press", "legal", "feedback", "source", "help"];
if(in_array($p, $page)){
if($p=="support"){
$p="donate";
}
if($p=="terms"){
$p="rules";
}
if($p=="bug"){
$p="feedback";
}
if($p=="help"){
$p="faq";
}
return $p;
}
return false;
}
if(is_page($p)!=false){
$p=is_page($p);
require("np-page.php");
die;
}
/* Some Alternate Board links */
// anime and manga
if($p=="manga" || $p=="anime"){$p="a";}
// comics board
if($p=="comics" || $p=="cartoon" || $p=="comic"){$p="co";}
// nepal board
if($p=="nepal" || $p=="nepali" || $p=="mrr" || $p=="wrr" || $p=="mwrr" || $p=="nrr" || $p=="srr" || $p=="mr" || $p=="general"){$p="np";}
// technology
if($p=="tech" || $p=="hack" || $p=="hacker" || $p=="code" || $p=="gentoo" || $p=="arch" || $p=="linux" || $p=="gnu" || $p=="t" || $p=="technology"){$p="g";}
// art
if($p=="art"){$p="lit";}
// math
if($p=="math" || $p=="science" || $p=="education" || $p=="edu"){$p="sci";}
// seusy stuffs
if($p=="hc" || $p=="sexy" || $p=="sex" || $p=="porn" || $p=="seusy" || $p=="kanda" || $p=="bob" || $p=="vagene"){$p="s";}
// video games
if($p=="vg" || $p=="videogame" || $p=="games"){$p="v";}
// meta board
if($p=="sudo" || $p=="meta" || $p=="helpline"){$p="npchan";}
// automobiles
if($p=="bike" || $p=="car" || $p=="cycle" || $p=="drive" || $p=="ride" || $p=="vehicles"){$p="auto";}
// dyi
if($p=="do" || $p=="creative"){$p="dyi";}
// hentai and adult cartoon/drawings
if($p=="ac" || $p=="hentai" || $p=="adultcartoon" || $p=="adultdrawings" || $p=="ad"){ $p="h";}
// culture and religion
if($p=="religion" || $p=="cult" || $p=="culture"){$p="cr";}
// cam and social
if($p=="cam" || $p=="introduce" || $p=="friends" || $p=="date" || $p=="meetup" || $p=="social"){ $p="soc";}
// politics
if($p=="politics"){$p="pol";}
/* Redirect to Board */
if(is_board($p)){
// do we have the P?
if(!empty($_GET['p'])){
$b_page=strtolower(trim(strip_tags($_GET['p'])));
}
require("np-board.php");
die;
}
/* Redirect to Settings Page */
if($p=="settings"){
require("np-settings.php");
die;
}
if($p=="random"){
header("Location: /random.php");
die;
}
/* Redirect to Moderator's Panel */
if($p=="mod" || $p=="admin"){
header("Location: /mod/index.php");
die;
}
// if nothing matches right, showing error page
require 'np-error.php';
die;