免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3390 | 回复: 7
打印 上一主题 下一主题

PHP出错,要疯狂了~~~ [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-10 17:29 |只看该作者 |倒序浏览
  1. <?php

  2. # IMPORTANT: Do not edit below unless you know what you are doing!
  3. if(!defined('IN_ANNOUNCE'))
  4.   die('Hacking attempt!');

  5. require_once($rootpath . 'include/config_announce.php');
  6. require_once($rootpath . 'include/secrets.php');

  7.   function checkconnect ($ip = '', $port = '')
  8.   {
  9.     return (!@fsockopen ($ip, $port, $errno, $errstr, 5) ? 'no' : (@fclose ($sockres) ? 'yes' : 'yes'));
  10.   }

  11. function err($msg) {
  12.         benc_resp(array("failure reason" => array(type => "string", value => $msg)));
  13.         exit();
  14. }

  15. function benc_resp($d) {
  16.         benc_resp_raw(benc(array(type => "dictionary", value => $d)));
  17. }

  18. function benc_resp_raw($x) {
  19.         header("Content-Type: text/plain");
  20.         header("Pragma: no-cache");
  21.         print($x);
  22. }

  23. function get_date_time($timestamp = 0) {
  24.         if ($timestamp)
  25.                 return date("Y-m-d H:i:s", $timestamp);
  26.         else
  27.                 return date("Y-m-d H:i:s");
  28. }

  29. function gmtime() {
  30.     return TIMENOW;
  31. }

  32. function strip_magic_quotes($arr) {
  33.         foreach ($arr as $k => $v)
  34.         {
  35.          if (is_array($v))
  36.           { $arr[$k] = strip_magic_quotes($v); }
  37.          else
  38.           { $arr[$k] = stripslashes($v); }
  39.         }

  40.         return $arr;
  41. }

  42. function mksize($bytes) {
  43.         if ($bytes < 1000 * 1024)
  44.                 return number_format($bytes / 1024, 2) . " kB";
  45.         elseif ($bytes < 1000 * 1048576)
  46.                 return number_format($bytes / 1048576, 2) . " MB";
  47.         elseif ($bytes < 1000 * 1073741824)
  48.                 return number_format($bytes / 1073741824, 2) . " GB";
  49.         else
  50.                 return number_format($bytes / 1099511627776, 2) . " TB";
  51. }

  52. function emu_getallheaders() {
  53.    foreach($_SERVER as $name => $value)
  54.            if(substr($name, 0, 5) == 'HTTP_')
  55.                    $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
  56.    return $headers;
  57. }

  58. function clientbancheck($client='',$agent='',$uagent='')
  59. {
  60.         global $SITENAME, $bannedclientdetect, $self, $event;
  61.         if ($bannedclientdetect == 'yes') {
  62.                 $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',);
  63.                
  64.                 foreach($array as $bannedclient){
  65.                         if($bannedclient == substr($client,0,strlen($bannedclient)))
  66.                                 err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  67.                 }
  68.                
  69.                 if (ereg('^Mozilla\\/', $agent) || ereg('^Opera\\/', $agent) || ereg('^Links ', $agent) || ereg('^Lynx\\/', $agent))
  70.                         err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  71.                 elseif(ereg('^BitTorrent\\/S-', $agent))
  72.                         err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  73.                 elseif(ereg('^ABC\\/ABC', $agent))
  74.                         err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  75.                 elseif(ereg('^Python-urllib\\/2.4', $agent))
  76.                         err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  77.                 elseif(($agent == "uTorrent/1300") || ($agent == "ABC 3.01/ABC-3.0.1") || (substr($agent,0,15) == "Azureus 2.3.0.6")  )
  78.                         err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  79.                 elseif ("text/html, */*" == $_SERVER["HTTP_ACCEPT"] || "Close" == $_SERVER["HTTP_CONNECTION"] && "gzip, deflate" != $_SERVER["HTTP_ACCEPT_ENCODING"])
  80.                         err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  81.                 elseif ($_SERVER['HTTP_ACCEPT'] == 'text/html, */*' && $_SERVER['HTTP_ACCEPT_ENCODING'] == 'identity')
  82.                         err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');

  83.                 if (!isset($self))
  84.                 {
  85.                         if ($agent == "BitTorrent/ABC-2.6.9" && $_SERVER["SERVER_PROTOCOL"] == "HTTP/1.1")
  86.                                 err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  87.                         elseif ($agent == "uTorrent/1300" && $_GET["event"] == "started" && $_GET["uploaded"] == 30)
  88.                                 err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  89.                         elseif (($agent == "uTorrent/1400" || $agent == "uTorrent/1300") && strtoupper($_GET["key"]) != $_GET["key"])
  90.                                 err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  91.                         elseif ($_GET["event"] == "stopped" && $_GET["compact"] == 1 && preg_match("/^Azureus 2\.2\.0\.[0-2].*/", $agent))
  92.                                 err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  93.                         elseif (preg_match("/ABC-/", $agent) && $event == "started")
  94.                                 err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  95.                 }

  96.                 $bua = mysql_query('SELECT agent FROM banned_agent') or err('Tracker error (1)');
  97.                 while ($nea = mysql_fetch_array($bua)){
  98.                         $n = $nea['agent'];
  99.                         $nr = preg_replace('/\//', '\/', $n);
  100.                         $neadle = '/\b'.$nr.'\b/i';
  101.                         if (preg_match($neadle, $uagent))
  102.                                 err($SITENAME.' has banned this client. Please use 礣orrent or Azerus.');
  103.                 }
  104.         }
  105. }


  106. function portblacklisted($port) {
  107.         if ($port >= 411 && $port <= 413)
  108.                 return true;
  109.         if ($port >= 6881 && $port <= 6889)
  110.                 return true;
  111.         if ($port == 1214)
  112.                 return true;
  113.         if ($port >= 6346 && $port <= 6347)
  114.                 return true;
  115.         if ($port == 4662)
  116.                 return true;
  117.         if ($port == 6699)
  118.                 return true;
  119.         return false;
  120. }

  121. function validip($ip) {
  122.         if (!empty($ip) && $ip == long2ip(ip2long($ip)))
  123.         {
  124.                                 $reserved_ips = array (
  125.                                 array('0.0.0.0','2.255.255.255'),
  126.                                 array('10.0.0.0','10.255.255.255'),
  127.                                 array('127.0.0.0','127.255.255.255'),
  128.                                 array('169.254.0.0','169.254.255.255'),
  129.                                 array('172.16.0.0','172.31.255.255'),
  130.                                 array('192.0.2.0','192.0.2.255'),
  131.                                 array('192.168.0.0','192.168.255.255'),
  132.                                 array('255.255.255.0','255.255.255.255')
  133.                 );

  134.                 foreach ($reserved_ips as $r)
  135.                 {
  136.                                 $min = ip2long($r[0]);
  137.                                 $max = ip2long($r[1]);
  138.                                 if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
  139.                 }
  140.                 return true;
  141.         }
  142.         else return false;
  143. }

  144. function getip() {
  145.    if (isset($_SERVER)) {
  146.      if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  147.        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  148.      } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) {
  149.        $ip = $_SERVER['HTTP_CLIENT_IP'];
  150.      } else {
  151.        $ip = $_SERVER['REMOTE_ADDR'];
  152.      }
  153.    } else {
  154.      if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
  155.        $ip = getenv('HTTP_X_FORWARDED_FOR');
  156.      } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
  157.        $ip = getenv('HTTP_CLIENT_IP');
  158.      } else {
  159.        $ip = getenv('REMOTE_ADDR');
  160.      }
  161.    }

  162.    return $ip;
  163. }

  164. function dbconn() {
  165.         global $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_charset;
  166.         if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass))
  167.     {
  168.                 err('dbconn: mysql_connect: ' . mysql_error());
  169.     }
  170.     mysql_select_db($mysql_db) or err('dbconn: mysql_select_db: ' + mysql_error());

  171.         mysql_query('SET NAMES '.$mysql_charset);


  172. function sqlesc($value) {
  173.     // Stripslashes
  174.    /*if (get_magic_quotes_gpc()) {
  175.        $value = stripslashes($value);
  176.    }*/
  177.    // Quote if not a number or a numeric string
  178.    if (!is_numeric($value)) {
  179.        $value = "'" . mysql_real_escape_string($value) . "'";
  180.    }
  181.    return $value;
  182. }

  183. function hash_pad($hash) {
  184.     return str_pad($hash, 20);
  185. }

  186. function hash_where($name, $hash) {
  187.     $shhash = preg_replace('/ *$/s', "", $hash);
  188.     return "($name = " . sqlesc($hash) . " OR $name = " . sqlesc($shhash) . ")";
  189. }

  190. function unesc($x) {
  191.         if (get_magic_quotes_gpc())
  192.                 return stripslashes($x);
  193.         return $x;
  194. }

  195. function gzip() {
  196.         if (@extension_loaded('zlib') && @ini_get('zlib.output_compression') != '1' && @ini_get('output_handler') != 'ob_gzhandler') {
  197.                 @ob_start('ob_gzhandler');
  198.         }
  199. }

  200. ?>
复制代码
出错信息:
Parse error: parse error in D:\wwwroot\mumudemingzi\web\include\functions_announce.php on line 230,也就是最后一行好像,各位大哥大姐帮忙看看,一个现成的源代码,怎么搞都不行~~~

论坛徽章:
0
2 [报告]
发表于 2010-04-10 20:10 |只看该作者
186行,函数没有关门吧

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
3 [报告]
发表于 2010-04-10 21:52 |只看该作者
确实186行那个函数没有后续的}

论坛徽章:
0
4 [报告]
发表于 2010-04-11 02:21 |只看该作者
回复 2# php_


    唉,太专业了,该关哪呢?我是拿来就用的,PHP正从头开始

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
5 [报告]
发表于 2010-04-11 09:13 |只看该作者
}放在195行

论坛徽章:
54
2017金鸡报晓
日期:2017-02-08 10:39:42操作系统版块每日发帖之星
日期:2016-03-08 06:20:00操作系统版块每日发帖之星
日期:2016-03-07 06:20:00操作系统版块每日发帖之星
日期:2016-02-22 06:20:00操作系统版块每日发帖之星
日期:2016-01-29 06:20:00操作系统版块每日发帖之星
日期:2016-01-27 06:20:00操作系统版块每日发帖之星
日期:2016-01-20 06:20:00操作系统版块每日发帖之星
日期:2016-01-06 06:20:0015-16赛季CBA联赛之江苏
日期:2015-12-21 20:00:24操作系统版块每日发帖之星
日期:2015-12-21 06:20:00IT运维版块每日发帖之星
日期:2015-11-17 06:20:002015亚冠之广州恒大
日期:2015-11-12 10:58:02
6 [报告]
发表于 2010-04-11 21:37 |只看该作者
186行,函数没有关门吧
php_ 发表于 2010-04-10 20:10



    关门这词很生动。

论坛徽章:
0
7 [报告]
发表于 2010-04-12 10:19 |只看该作者
LZ难道是用记事本写代码吗?

这么低级的问题用IDE就解决了

论坛徽章:
0
8 [报告]
发表于 2010-04-15 09:35 |只看该作者
这问题都得自己调了吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP