- 论坛徽章:
- 0
|
- <?php
- # IMPORTANT: Do not edit below unless you know what you are doing!
- if(!defined('IN_ANNOUNCE'))
- die('Hacking attempt!');
- require_once($rootpath . 'include/config_announce.php');
- require_once($rootpath . 'include/secrets.php');
- function checkconnect ($ip = '', $port = '')
- {
- return (!@fsockopen ($ip, $port, $errno, $errstr, 5) ? 'no' : (@fclose ($sockres) ? 'yes' : 'yes'));
- }
- function err($msg) {
- benc_resp(array("failure reason" => array(type => "string", value => $msg)));
- exit();
- }
- function benc_resp($d) {
- benc_resp_raw(benc(array(type => "dictionary", value => $d)));
- }
- function benc_resp_raw($x) {
- header("Content-Type: text/plain");
- header("Pragma: no-cache");
- print($x);
- }
- function get_date_time($timestamp = 0) {
- if ($timestamp)
- return date("Y-m-d H:i:s", $timestamp);
- else
- return date("Y-m-d H:i:s");
- }
- function gmtime() {
- return TIMENOW;
- }
- function strip_magic_quotes($arr) {
- foreach ($arr as $k => $v)
- {
- if (is_array($v))
- { $arr[$k] = strip_magic_quotes($v); }
- else
- { $arr[$k] = stripslashes($v); }
- }
- return $arr;
- }
- function mksize($bytes) {
- if ($bytes < 1000 * 1024)
- return number_format($bytes / 1024, 2) . " kB";
- elseif ($bytes < 1000 * 1048576)
- return number_format($bytes / 1048576, 2) . " MB";
- elseif ($bytes < 1000 * 1073741824)
- return number_format($bytes / 1073741824, 2) . " GB";
- else
- return number_format($bytes / 1099511627776, 2) . " TB";
- }
- function emu_getallheaders() {
- foreach($_SERVER as $name => $value)
- if(substr($name, 0, 5) == 'HTTP_')
- $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
- return $headers;
- }
- function clientbancheck($client='',$agent='',$uagent='')
- {
- global $SITENAME, $bannedclientdetect, $self, $event;
- if ($bannedclientdetect == 'yes') {
- $array = Array('BS', '\0\2BS', '\0\3BS', 'exbc\0L', 'exbcL', 'exbcLORD', '-TS', 'Mbrst', '-BB', '-SZ', 'XBT', 'turbo', 'A301', 'A310', '-UT11', '-UT12', '-UT13', '-UT14', '-UT15', 'FUTB', 'exbc\08', 'exbc\09', 'exbc\0:', '-BC0059-', '-BC0060-', '-BC0061-', '-BC0062-', '-BC0063-', '-BC0064-', '-BC0065-', '-BC0066-', '-BC0067-', '-BC0068-', '-BC0069-', '-BC0070-', '-BC0071-', '-BC0072-', '-BC0073-', '-BC0074-', '-BC0075-', '-BC0076-', '-BC0077-', '-BC0078-', '-BC0079-', '-BC0080-', '-BC0081-', 'M4', 'AZ2500BT',);
-
- foreach($array as $bannedclient){
- if($bannedclient == substr($client,0,strlen($bannedclient)))
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- }
-
- if (ereg('^Mozilla\\/', $agent) || ereg('^Opera\\/', $agent) || ereg('^Links ', $agent) || ereg('^Lynx\\/', $agent))
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif(ereg('^BitTorrent\\/S-', $agent))
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif(ereg('^ABC\\/ABC', $agent))
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif(ereg('^Python-urllib\\/2.4', $agent))
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif(($agent == "uTorrent/1300") || ($agent == "ABC 3.01/ABC-3.0.1") || (substr($agent,0,15) == "Azureus 2.3.0.6") )
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif ("text/html, */*" == $_SERVER["HTTP_ACCEPT"] || "Close" == $_SERVER["HTTP_CONNECTION"] && "gzip, deflate" != $_SERVER["HTTP_ACCEPT_ENCODING"])
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif ($_SERVER['HTTP_ACCEPT'] == 'text/html, */*' && $_SERVER['HTTP_ACCEPT_ENCODING'] == 'identity')
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- if (!isset($self))
- {
- if ($agent == "BitTorrent/ABC-2.6.9" && $_SERVER["SERVER_PROTOCOL"] == "HTTP/1.1")
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif ($agent == "uTorrent/1300" && $_GET["event"] == "started" && $_GET["uploaded"] == 30)
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif (($agent == "uTorrent/1400" || $agent == "uTorrent/1300") && strtoupper($_GET["key"]) != $_GET["key"])
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif ($_GET["event"] == "stopped" && $_GET["compact"] == 1 && preg_match("/^Azureus 2\.2\.0\.[0-2].*/", $agent))
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- elseif (preg_match("/ABC-/", $agent) && $event == "started")
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- }
- $bua = mysql_query('SELECT agent FROM banned_agent') or err('Tracker error (1)');
- while ($nea = mysql_fetch_array($bua)){
- $n = $nea['agent'];
- $nr = preg_replace('/\//', '\/', $n);
- $neadle = '/\b'.$nr.'\b/i';
- if (preg_match($neadle, $uagent))
- err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
- }
- }
- }
- function portblacklisted($port) {
- if ($port >= 411 && $port <= 413)
- return true;
- if ($port >= 6881 && $port <= 6889)
- return true;
- if ($port == 1214)
- return true;
- if ($port >= 6346 && $port <= 6347)
- return true;
- if ($port == 4662)
- return true;
- if ($port == 6699)
- return true;
- return false;
- }
- function validip($ip) {
- if (!empty($ip) && $ip == long2ip(ip2long($ip)))
- {
- $reserved_ips = array (
- array('0.0.0.0','2.255.255.255'),
- array('10.0.0.0','10.255.255.255'),
- array('127.0.0.0','127.255.255.255'),
- array('169.254.0.0','169.254.255.255'),
- array('172.16.0.0','172.31.255.255'),
- array('192.0.2.0','192.0.2.255'),
- array('192.168.0.0','192.168.255.255'),
- array('255.255.255.0','255.255.255.255')
- );
- foreach ($reserved_ips as $r)
- {
- $min = ip2long($r[0]);
- $max = ip2long($r[1]);
- if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
- }
- return true;
- }
- else return false;
- }
- function getip() {
- if (isset($_SERVER)) {
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) {
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- } else {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- } else {
- if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
- $ip = getenv('HTTP_X_FORWARDED_FOR');
- } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
- $ip = getenv('HTTP_CLIENT_IP');
- } else {
- $ip = getenv('REMOTE_ADDR');
- }
- }
- return $ip;
- }
- function dbconn() {
- global $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_charset;
- if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass))
- {
- err('dbconn: mysql_connect: ' . mysql_error());
- }
- mysql_select_db($mysql_db) or err('dbconn: mysql_select_db: ' + mysql_error());
- mysql_query('SET NAMES '.$mysql_charset);
- function sqlesc($value) {
- // Stripslashes
- /*if (get_magic_quotes_gpc()) {
- $value = stripslashes($value);
- }*/
- // Quote if not a number or a numeric string
- if (!is_numeric($value)) {
- $value = "'" . mysql_real_escape_string($value) . "'";
- }
- return $value;
- }
- function hash_pad($hash) {
- return str_pad($hash, 20);
- }
- function hash_where($name, $hash) {
- $shhash = preg_replace('/ *$/s', "", $hash);
- return "($name = " . sqlesc($hash) . " OR $name = " . sqlesc($shhash) . ")";
- }
- function unesc($x) {
- if (get_magic_quotes_gpc())
- return stripslashes($x);
- return $x;
- }
- function gzip() {
- if (@extension_loaded('zlib') && @ini_get('zlib.output_compression') != '1' && @ini_get('output_handler') != 'ob_gzhandler') {
- @ob_start('ob_gzhandler');
- }
- }
- ?>
复制代码 出错信息:
Parse error: parse error in D:\wwwroot\mumudemingzi\web\include\functions_announce.php on line 230,也就是最后一行好像,各位大哥大姐帮忙看看,一个现成的源代码,怎么搞都不行~~~ |
|