troubleshooting Question

delete button not working for link checker

Avatar of aplelois
aplelois asked on
PHP
14 Comments1 Solution266 ViewsLast Modified:
hello,
can someone please tell me why the delete button is not working!

<?
error_reporting(E_ALL);
ini_set('display_errors', '1');

set_time_limit (0);

if($_GET) { extract($_GET, EXTR_PREFIX_SAME, "get_"); }
if($_POST) { extract($_POST, EXTR_PREFIX_SAME, "post_"); }

echo "<form action=\"checkurls.php\" method=\"post\">\n";
echo "<center></table>\n";
echo "<table width=\"600\" border=\"1\">\n";
echo "<tr><td colspan=\"3\" align=\"center\"><b>Link Exchange Cheater Checker</b></td></tr>\n";
echo "<tr><td><b>Url</b></td><td><b>Status</b></td><td style=\"text-align: center\"><b>Delete</b></td></tr>\n";
$aa=file_get_contents("config.inc.php");
preg_match_all( "/http:\/\/www.([^\"]+)\"/i" ,$aa,$ee,PREG_SET_ORDER );
$URL=$ee[0][1];

$aa=file_get_contents("links.inc.php");
preg_match_all( "/(.*?)\n/i" ,$aa,$ee,PREG_SET_ORDER );

$submit = isset($_REQUEST['submit']) ? $_REQUEST['submit'] : '';
$delete = isset($_REQUEST['delete']) ? $_REQUEST['delete'] : '';

if($submit=="DeleteUrls"){
            $fp=@fopen("links.inc.php","w");
            if($fp){
                  for($i=0;$i<count($ee);$i++){
                        $x=count($ee);
                        $nn="C$x$i";
                        if($$nn!="true"){
                              if(!fwrite($fp,$ee[$i][1]."\n\n"))
                                    echo "fwrite err<br>";
                        }
                  }
                  fclose($fp);
            }else die("can't write links.inc.php");
}

$aa=file_get_contents("links.inc.php");
preg_match_all( "/(.*?)\n/i" ,$aa,$ee,PREG_SET_ORDER );

$n=0;
for($i=0;$i<count($ee);$i++){
      preg_match_all( "/href=\"([^\"]+)\"/i" ,$ee[$i][1],$ff,PREG_SET_ORDER );
      if(count($ff)==0)continue;
      $newurl=$ff[0][1];
      $bb=@file_get_contents($newurl);
      if(!$bb){
            printf("<tr><td><a href='%s'>%s</a></td><td><font color=\"green\"><b>Page Not Found</b></font></td>\n<td style=\"text-align: center\"><input type='checkbox' name=C%d%d value=\"true\" checked></td></tr>\n\n",
                  $newurl,$newurl,count($ee),$i);
      }elseif(!strstr($bb,$URL)){
            printf("<tr><td><a href='%s'>%s</a></td><td><font color=\"red\"><b>Link Not Found</b></font></td><td style=\"text-align: center\"><input type='checkbox' name=C%d%d value=true checked></td></tr>\n",$newurl,$newurl,count($ee),$i);
            $dd[$n]=$newurl;
            $n++;
      }else
            printf("<tr><td><a href='%s'>%s</a></td><td><font color=\"#4261fc\"><b>Good.. Link Found</b></font>\n</td><td style=\"text-align: center\">&nbsp;</td></tr>\n",$newurl,$newurl,count($ee),$i);
      flush();
}
if($delete=="auto"){
      $fp=@fopen("links.inc.php","w");
      if($fp){
            for($i=0;$i<count($ee);$i++){
                  if(strlen($ee[$i][1])<5)continue;
                  $f=0;
                  for($j=0;$j<$n;$j++){
                        if(strstr($ee[$i][1],$dd[$j])){
                              $f=1;
                              break;
                        }
                  }
                  if(!$f){
                        if(!fwrite($fp,$ee[$i][1]."\n\n"))
                              echo "fwrite err<br>";
                  }
            }
            fclose($fp);
      }else die("can't write links.inc.php");
}else{
      echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" name=\"btnsubmit\" value=\"Delete Urls\"></td></tr>";
      echo "</table></form>";
}
?>
ASKER CERTIFIED SOLUTION
Julian Matz
Technical Support
Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros