我有这个脚本,它带有一个带有不同链接和网址的txt文件。并且此脚本检查.txt文件中的链接上存在的反向链接。我的脚本就是这个
<?php
$needle = $_GET['utext'];
$file = $_GET['ufile'];
$source = file_get_contents($file);
$new = explode("\n",$source);
foreach ($new as $check){
$a = file_get_contents(trim($check));
if (strpos($a,$needle)){
$found[] = $check;
}
else{
$notfound[] = $check;
}
}
echo "Matches that were found: \n ".implode("\n","\n".$found)."\n";
echo "<br> <br> <br> <br>";
echo "Matches that were not found \n". implode("\n","\n".$notfound);
?>
答案 0 :(得分:0)
添加更多调试输出。 printf / echo-debugging不是抽屉里最尖锐的勺子,但它就是你开始的。
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$needle = $_GET['utext'];
$file = $_GET['ufile']; // that's ok regarding security?
$new = file($file, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
$new = array_map('trim', $new);
echo '#entries: ', count($new), "\n";
$found = array(); $notfound=array();
foreach ( $new as $check ) {
echo 'processing: ', $check;
$a = file_get_contents($check);
echo ', length: ', strlen($a);
if (strpos($a,$needle)) {
echo ", found\n";
$found[] = $check;
}
else {
echo ", not found\n";
$notfound[] = $check;
}
}
echo '#Matches: ', count($found), "\n";
echo '#No-Matches: ', count($notfound), "\n";
echo "Matches that were found:\n ", implode("\n", $found), "\n";
echo "Matches that were not found:\n", implode("\n", $notfound), "\n";