1
|
|
|
<?php |
2
|
|
|
/************************************************************************** |
3
|
|
|
********** English Wikipedia Account Request Interface ********** |
4
|
|
|
*************************************************************************** |
5
|
|
|
** Wikipedia Account Request Graphic Design by Charles Melbye, ** |
6
|
|
|
** which is licensed under a Creative Commons ** |
7
|
|
|
** Attribution-Noncommercial-Share Alike 3.0 United States License. ** |
8
|
|
|
** ** |
9
|
|
|
** All other code are released under the Public Domain ** |
10
|
|
|
** by the ACC Development Team. ** |
11
|
|
|
** ** |
12
|
|
|
** See CREDITS for the list of developers. ** |
13
|
|
|
***************************************************************************/ |
14
|
|
|
|
15
|
|
|
class accRequest |
16
|
|
|
{ |
17
|
|
|
public function isTOR() |
18
|
|
|
{ |
19
|
|
|
// Checks whether the IP is of the TOR network. |
20
|
|
|
$toruser = $this->checktor($_SERVER['REMOTE_ADDR']); |
21
|
|
|
|
22
|
|
|
// Checks whether the tor field in the array is said to yes. |
23
|
|
|
if ($toruser['tor'] == "yes") { |
24
|
|
|
// Gets message to display to the user. |
25
|
|
|
$message = InterfaceMessage::get(InterfaceMessage::DECL_BANNED); |
26
|
|
|
|
27
|
|
|
// Displays the appropiate message to the user. |
28
|
|
|
echo "$message<strong><a href=\"https://en.wikipedia.org/wiki/Tor_%28anonymity_network%29\">TOR</a> nodes are not permitted to use this tool, due to abuse.</strong><br /></div>\n"; |
29
|
|
|
|
30
|
|
|
// Display the footer of the interface. |
31
|
|
|
BootstrapSkin::displayPublicFooter(); |
32
|
|
|
|
33
|
|
|
// we probably want to output |
34
|
|
|
ob_end_flush(); |
35
|
|
|
|
36
|
|
|
// Terminates the current script, as the user is banned. |
37
|
|
|
// This is done because the requesting process should be stopped. |
38
|
|
|
die(); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/* |
43
|
|
|
* Check if the supplied host is a TOR node. |
44
|
|
|
*/ |
45
|
|
|
public function checktor($addr) |
46
|
|
|
{ |
47
|
|
|
// Creates empty array. |
48
|
|
|
$flags = array(); |
49
|
|
|
|
50
|
|
|
// Sets tor variable to no. |
51
|
|
|
$flags['tor'] = "no"; |
52
|
|
|
|
53
|
|
|
// Breaks the IP string up into an array. |
54
|
|
|
$p = explode(".", $addr); |
55
|
|
|
|
56
|
|
|
// Checks whether the user uses the IPv6 addy. |
57
|
|
|
// Returns the flags array with the false variable. |
58
|
|
|
if (strpos($addr, ':') != -1) { |
59
|
|
|
return $flags; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// Generates a new host name by means of the IP array and TOR string. |
63
|
|
|
$ahbladdr = $p['3'] . "." . $p['2'] . "." . $p['1'] . "." . $p['0'] . "." . "tor.ahbl.org"; |
64
|
|
|
|
65
|
|
|
// Get the IP address corresponding to a given host name. |
66
|
|
|
$ahbl = gethostbyname($ahbladdr); |
67
|
|
|
|
68
|
|
|
// In the returned IP adress is one of the following, it is from the TOR network. |
69
|
|
|
// There is then a yes flag assigned to the flag array. |
70
|
|
|
if ($ahbl == "127.0.0.2") { |
71
|
|
|
$flags['transit'] = "yes"; |
72
|
|
|
$flags['tor'] = "yes"; |
73
|
|
|
} |
74
|
|
|
if ($ahbl == "127.0.0.3") { |
75
|
|
|
$flags['exit'] = "yes"; |
76
|
|
|
$flags['tor'] = "yes"; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
// The flags array are returned to the isTor method. |
80
|
|
|
return ($flags); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.