Link to home
Start Free TrialLog in
Avatar of aplelois
aplelois

asked on

delete button not working for link checker

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>";
}
?>
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Hi!

You have a space in "Delete Urls" for the value on your delete button... Should be value=\"DeleteUrls\"...
Actually, if you need the space in the button value for display, then you could change:

if($submit=="DeleteUrls"){

to:

if($submit==="Delete Urls"){    // <----- add a space there also
Oh, and you'll need to change this also:

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

to:

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

...because the name of your submit (Delete Urls) button is "btnsubmit"
(<input type=\"submit\" name=\"btnsubmit\" value=\"Delete Urls\">)
Avatar of aplelois
aplelois

ASKER

ok I deleted the space and I try to delete but is not working!

Have you sorted out the "submit" / "btnsubmit" issue ?
ok I did what you said about the space in both places!!
I changed the line too and its deleting the record..

I get this notices

Notice: Undefined variable: C110 in /home/virtual/site4/fst/var/www/html/hardlinks/checkurls.php on line 32
Notice: Undefined variable: C111 in /home/virtual/site4/fst/var/www/html/hardlinks/checkurls.php on line 32
Notice: Undefined variable: C112 in /home/virtual/site4/fst/var/www/html/hardlinks/checkurls.php on line 32

then I check the file config.inc.php
and I see it like this

site.com

site2.com

site3.com

and before the delete was like this
site.com
site2.com
site3.com
line 32
if($$nn!="true"){
Should that line not be:

if($nn!="true"){

???
now it doesnt delete!
but still adds the (return key)
Ok, change it back to

if($$nn!="true"){

...if that deletes the records as it should... Then try changing this line:

if(!fwrite($fp,$ee[$i][1]."\n\n"))

...to:

if(!fwrite($fp,$ee[$i][1]."\n"))

(should be line 34) ...for the extra line break problem...
perfect it works!!

is there a way to fix those notices on this line

if($$nn!="true"){
ASKER CERTIFIED SOLUTION
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that was it! thank you so much!
Cool! You're welcome, glad I could help!