【发布时间】:2026-01-20 10:55:02
【问题描述】:
我正在创建一个简单的脚本,它通过文本文件搜索正确的组合,但它不起作用。我排除了所有问题,但所有部分都正常工作,但整个脚本仍然无法正常工作,我不知道如何修复它。
代码:
<html>
<form>
<input type="text" name="input" placeholder="hash"><button type="submit">Crack!</button>
</form>
<?php
$input = $_GET["input"]; // pulling input from url
$hashes = file_get_contents("hashes.txt"); // loading hashes
$hasharray = explode(";", $hashes); // separating hashcombos
$arraynum = count($hasharray); // counting number of hashcombos
// defining loop
$loopnum = 0;
while($loopnum < $arraynum) {
$combo = $hasharray[$loopnum]; // selecting hashcombo
$comboarray = explode("|", $combo); // separating hashcombo
$text = $comboarray[0];
$hash = $comboarray[1];
// cecking if hash matches
if($hash === $input) {
echo("Hash: $hash");
echo("<br>");
echo("Text: $text");
}
$loopnum = $loopnum + 1; // updating loop
}
?>
</html>
示例 hashes.txt:
test|example;
example|test;
【问题讨论】:
-
你得到什么错误信息?
-
没有错误,在网站上也没有在错误日志中提及
-
你能分享一个文件 hashes.txt 的样本吗?
-
尝试使用
$_POST而不是$_GET -
你没有提供足够的信息,hashes.txt 中有什么内容?我建议您逐行调试,使用
var_dump方法检查您是否获得了正确的数据。您的代码中似乎存在逻辑错误。
标签: php arrays if-statement comparison file-get-contents