2011-02-05 92 views
-1

我有了這個腳本,它產生以下錯誤:001校驗失敗校驗失敗

這是劇本,我不知道有什麼不對的地方,你能幫幫我嗎?

<?php 

/* 

    Access control for TargetPay Pay per Use 
    (C) TargetMedia 2007 

    Upload this file in the protected directory and make sure 
    that .htaccess support is enabled. 

    MODIFICATIONS IN THIS CODE ARE ALLOWED BUT NOT SUPPORTED 

    Product-ID: 28717 Generated: 16-01-2011 14:57:05 

*/ 

define ("CHECKSUM", "739b54dc26"); 
define ("ERR001", "001 Checksum failure"); 
define ("ERR002", "002 Can't open .htaccess for writing. Check rights."); 
define ("ERR003", "003 I/O Error, cannot write to .htaccess. Disk full?"); 

list($thispage) = explode("?", 
    "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]); 

$payscreen = "http://www.targetpay.nl/send/?id=28717&rtlo=51090". 
    "&pm=".urlencode("inline=1"). 
    "&ref=".urlencode($thispage); 

header ("Content-type: text/plain"); 

if ($_GET["checksum"] != CHECKSUM) { 
    die (ERR001); 
    } 

function ip2hex ($ip) { 
    list ($a,$b,$c,$d) = explode(".", $ip); 
    return str_pad(dechex($a),2,"0",STR_PAD_LEFT). 
      str_pad(dechex($b),2,"0",STR_PAD_LEFT). 
      str_pad(dechex($c),2,"0",STR_PAD_LEFT). 
      str_pad(dechex($d),2,"0",STR_PAD_LEFT); 
    } 

function hex2ip ($hex) { 
    return hexdec(substr($hex,0,2)).".". 
      hexdec(substr($hex,2,2)).".". 
      hexdec(substr($hex,4,2)).".". 
      hexdec(substr($hex,6,2)); 
    } 

function parse ($whitelist, $payscreen) { 
    $here = substr($_SERVER["SCRIPT_FILENAME"], 
     strrpos ($_SERVER["SCRIPT_FILENAME"], "/") + 1); 

    $o = "ErrorDocument 403 $payscreen\n". 
      "<Files .htaccess>\n". 
      "Order allow,deny\n". 
      "Deny from all\n". 
      "</Files>\n". 
      "<Files $here>\n". 
      "Order allow,deny\n". 
      "Allow from all\n". 
      "</Files>\n". 
      "Order deny,allow\n". 
      "Deny from all\n"; 

    if ((!$whitelist) || ($whitelist=="empty")) { 
     return $o; } 

    $iplist = explode(",", $whitelist); 
    foreach ($iplist as $hex) { 
     $ip = hex2ip ($hex); 
     if ($ip) { 
      $o .= "Allow from $ip\n"; 
      } 
     } 
    return $o; 
    } 

if ($_GET["register"]) { 
    $fp = @fopen(".htaccess", "w+"); 
    if (!$fp) { 
     die (ERR002); 
     } 
    if ([email protected] ($fp, parse($_GET["register"],$payscreen))) { 
     die (ERR003); 
     } 
    @fclose ($fp); 
    echo "000 OK"; 
    } 

if ($_GET["reset"]) { 
    @unlink (".htaccess"); 
    $fp = @fopen(".htaccess", "w+"); 
    if (!$fp) { 
     die (ERR002); 
     } 
    if ([email protected] ($fp, parse("",$payscreen))) { 
     die (ERR003); 
     } 
    @fclose ($fp); 
    echo "000 RESET OK"; 
    } 

if ($_GET["dump"]) { 
    echo @implode("",file(".htaccess")); 
    echo "\n-EOF-"; 
    } 
?> 

非常感謝!

+3

這需要基本調試。 `$ _GET [「校驗和」]`包含什麼,它爲什麼不同於`739b54dc26`?只有你(或者Targetpay的支持)才能回答這個問題。這不是一個編程問題,因此 – 2011-02-05 17:44:16

回答

1

我不認爲它的錯誤。其實

if($_GET["checksum"] != CHECKSUM) { 
    die (ERR001); 
} 

這個條件變成了真,所以輸出沒有錯誤。 所以只需從最初獲取它的任何位置檢查GET數據。它肯定不是編程錯誤。

+0

所以我需要刪除! ?讓我們試試看。 – Andre 2011-02-05 17:47:22

+0

不要刪除它,因爲它一定是出於某種目的。找出並找到$ GET是你提供給你的腳本。我希望你知道。 http://localhost/test.php?checksum = 739b54dc26,這個腳本會正常工作。 – ayush 2011-02-05 17:50:01

0

你需要通過GET與調用腳本,至少,這個參數:

checksum=739b54dc26 

,所以如果你的網頁是test.php的,在本地主機上,這樣調用它(您可以添加其他參數當然請求字符串):

http://localhost/test.php?checksum=739b54dc26 

希望它可以幫助