I need a simple java script which checks if a page has still my link on it.

Discussion in 'JavaScript' started by Ravi, Oct 31, 2005.

  1. #1
    I need a simple java script which checks if a page has still my link on it. (To check if the reciprocal link is still there).

    Can anyone help?
    Plz..its very Urgent..Plz Help me..
     
    Ravi, Oct 31, 2005 IP
  2. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't know if it is possible in Javascript.. it would be much simpler in a server side language like PHP or ASP.
     
    TheHoff, Oct 31, 2005 IP
  3. S4M4

    S4M4 Well-Known Member

    Messages:
    76
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    100
    #3
    As said by vBMechanic you have to use a server side language to code your script.
     
    S4M4, Nov 3, 2005 IP
  4. blackpepper

    blackpepper Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi everyone,
    I'm interested in this topic too... let's say I need a script that goes through a list of url's and check for a backlink to my site.. Anyone knows of a script that does that? I know it must be a server side script

    Thanks for any help
     
    blackpepper, Nov 3, 2005 IP
  5. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #5
    TheHoff, Nov 4, 2005 IP
  6. rederick

    rederick Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    $recip = "http://www.example.com";  // this is the reciprocal url... that EXACTLY must match
    
    $filename="links1.txt"; //File with sites where your link is suppose to be 1 per line.
    
    $found = 0;
    $notfound = 0;
    function backlinkCheck($siteurl, $recip) {
    	if ($arrText = file($siteurl)){
    
    
    	for ($i=0; $i<count($arrText); $i++) {
    		$text = $text . $arrText[$i];
    	}
    	if (eregi($recip, $text)) {
    		return true; // set true if there is a backlink
    		fclose ($fd);
    	} else {
    		return false; // set false if backlink is missing
    		fclose ($fd);
    	    }
        }
       return false;
    }
    echo "<h2>Link Checker</h2>";
    echo "<p> This will check if the text ".$recip ." is found on the webpage</p><hr>";
    
    	$file_contents=file("$filename");
    	for ( $i=0;  $i < sizeof($file_contents); $i++) {
    		
    	$line = ($file_contents[$i]);
    	$line = trim($line);
    	$siteurl=$line;
    	
    	if (backlinkCheck($siteurl, $recip)) {
    		echo "<p>Backlink was <b>FOUND</b> on: ".$siteurl."</p>\n\n";
    		$found++;
    	} else {
    		echo "<p>Backlink was <b>NOT FOUND</b> on: ".$siteurl."</p>\n\n";
    		$notfound++;
    	}
        
    	
    }
    echo "Total Found ".$found ."<br>";
    echo "Total Not Found ".$notfound ."<br>";	
    echo "Total Links Checked ".($notfound+$found)."<br>";
    PHP:
    Something like this works, might need a bit of tweaking.
     
    rederick, Nov 11, 2005 IP
  7. blackpepper

    blackpepper Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks a lot! I'll try the scripts and see the results... the php code needs the exact url I guess, otherwise it'll need to spider the whole site.:rolleyes:
     
    blackpepper, Nov 14, 2005 IP
  8. luvkycool

    luvkycool Guest

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Lets see if i can help out,after all i got help here too.
    Its the minimum i can do.

    Lets see a list of urls..check for backlinks

    so lets say the urls are an array

    you can get it from a db or so ,but i make an array for now
    <?php
    
    $urls=array('www.this.com','www.that.com');
    $tocheck='www.mysite.com';
    
    function CheckforBL(&$urls,&$tocheck)
    {
    
    foreach ($urls as $url)
    {
    $matches=array();
    $handle=@fopen($url,'r');
    while(!feof($handle))
    {
    $data=fgets($handle);
    if (is_array($data)){foreach($data as $ln)
    {
    if (stristr($tocheck,$ln)!==false)$matches[]=$url;
    }
    }
    else{
    
    if (stristr($tocheck,$data)!==false)$matches[]=$url:
    }
    fclose($handles);
    }
    return $matches;
    }
    
    
    ?>
    PHP:
    Not sure if this going to work,
    as i just coded it now in the reply lol
     
    luvkycool, Nov 17, 2005 IP
  9. blackpepper

    blackpepper Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9

    Trying to find the tweaking... :confused:

    it gives me this error.... Parse error: parse error, unexpected T_STRING in C:\Program Files\Apache Group\Apache2\htdocs\blchecker\blcheck.php on line 7

    thanks for the help :D
     
    blackpepper, Nov 18, 2005 IP
  10. blackpepper

    blackpepper Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Well, the script seems to be working now but it crash after some time of execution.... what could it be wrong!?
    The code is:
    <?php
    $recip = 'http://www.domain.com'; // this is the reciprocal url... that EXACTLY must match
    $filename = 'links1.txt'; //File with sites where your link is suppose to be 1 per line
    $found = 0;
    $notfound = 0;
    function backlinkCheck($siteurl, $recip) {
    	if ($arrText = file($siteurl)){
    		for ($i=0; $i<count($arrText); $i++) {
    			$text = $text . $arrText[$i];
    		}
    		if (eregi($recip, $text)) {
    			fclose ($fd);
    		} else {
    			return false; // set false if cklinbak is missing
    			fclose ($fd);
    			}
    		}
    	return false;
    }
    echo '<h2>Link Checker</h2>';
    echo '<p> This will check if the text '.$recip .' is found on the webpages</p><hr>';
    		$file_contents=file($filename);
    		for ( $i=0; $i < sizeof($file_contents); $i++) {
    			$line = ($file_contents[$i]);
    			$line = trim($line);
    			$siteurl=$line;
    		if (backlinkCheck($siteurl, $recip)) {
    			echo '<p>Backlink was <b>FOUND</b> on: '.$siteurl."</p>\n\n";
    			$found++;
    		} else {
    			echo '<p>Backlink was <b>NOT FOUND</b> on: '.$siteurl."</p>\n\n";
    			$notfound++;
    		}
    }
    echo 'Total Found '.$found .'<br>';
    echo 'Total Not Found '.$notfound .'<br>';
    echo 'Total Links Checked '.($notfound+$found).'<br>';
    echo 'Total Not Found '.$notfound .'<br>';
    echo 'Total Links Checked '.($notfound+$found).'<br>';
    ?>
    
    Code (markup):
    And the result I get is:

    Link Checker

    This will check if the text http://www.domain.com is found on the webpages

    Backlink was NOT FOUND on: http://www.vlib.org/

    Backlink was NOT FOUND on: http://www.netcenter.com/

    Backlink was NOT FOUND on: http://www.msn.com/

    Backlink was NOT FOUND on: http://www.indiana.edu/

    Backlink was NOT FOUND on: http://www.dmoz.org/

    Backlink was NOT FOUND on: http://www.bbc.co.uk/

    Backlink was NOT FOUND on: http://www.zeal.com/

    Backlink was NOT FOUND on: http://www.yell.co.uk/

    Backlink was NOT FOUND on: http://www.yahoo.com.au/

    Backlink was NOT FOUND on: http://www.wisenut.com/

    Backlink was NOT FOUND on: http://www.webcrawler.com/

    Backlink was NOT FOUND on: http://www.voila.fr/

    Backlink was NOT FOUND on: http://www.tripod.lycos.com/

    Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Group\Apache2\htdocs\blcheck\blcheck.php on line 7


    BTW if this post belongs to php section, would be great if a moderator moves it.
     
    blackpepper, Nov 18, 2005 IP
  11. rederick

    rederick Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #11
    rederick, Nov 19, 2005 IP
  12. blackpepper

    blackpepper Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    The code is working now, I just modified the mac execution time in the php.ini to 0 (unlimited) (since I'm running locally).
    The problem now is that it checks only the exact url, I wonder if checking the whole site (to see if your url is there) would take much time to do it? I'm kind of beginner so I need some help if it's possible. Thanks in advance..
     
    blackpepper, Nov 20, 2005 IP
  13. blackpepper

    blackpepper Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    thanks a lot for the tip rederick... that was the solution..
     
    blackpepper, Nov 20, 2005 IP
  14. blackpepper

    blackpepper Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Does anyone know if there's a way to check a whole domain (like a spider) for your backlink? Because sometimes I don't know the exact page where my backlink is...

    thanks.
     
    blackpepper, Nov 24, 2005 IP
  15. ezpz

    ezpz Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    I know this thread has long grown cold, but I think I've got something which could help anyone else who comes across it. My site hosts a CGI script which checks for links between two pages. So you can call it with Javascript and get the results in an iframe:

      var src="http://www.sectorprime.com/cgi-bin/link_form_validation.pl"
        + "?sectorprimelink=" + encodeURI("<A PAGE WHICH LINKS TO www.sectorprime.com>")
        + "&fromurl=" + encodeURI("<THE PAGE THE LINK SHOULD BE ON>")
        + "&tourl=" + encodeURI("<THE PAGE THE LINK SHOULD BE TO>");
      frames['linkValidationFrame'].location.href=src;
    Code (markup):
    By default, the page loaded in the iframe contains a simple message, such as "Reciprocal link exists". However, you can also pass parameters which cause the iframe contents to be redirected to one of your own pages:

      var src=<AS ABOVE>
        + "passurl=" + encodeURI("<MY PASS PAGE>");
      frames['linkValidationFrame'].location.href=src;
    Code (markup):
    Because this is one of your own pages, you can now interact between the frames without being restricted by cross-site scripting safeguards. For instance your pass page could include:

      <body onload="parent.setReciprocalLinkOkay(true)"> 
    Code (markup):
    which would fire the method in the original (parent) frame.

    So, going back to Ravi's original request:

    this is possible, if someone else is willing to host the CGI script. Anyone's script would do - if you want to use mine, full details of all the parameters are on http://www.sectorprime.com/link_form_validation.htm.
     
    ezpz, Sep 15, 2007 IP