The Quick and drity solution I've found:
First, create a file with this content, and name it "linkchecker.php" or whatever you want:
- Code: Select all
<?php
//open database connection
$username = "username";
$password = "pass"; //input your password here.
$database = "db";
//connect to database
$link=mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("<b>Unable to specified database</b>");
//retrieve reciprocal links
$query="select returnBond,siteid from Arfooo_sites";
$result=mysql_query($query) or die('Error, query failed');
$row=0;
$numrows=mysql_num_rows($result);
$myURL="http://www.ortohogar.com";
//loop through reciprocal links
while($row<$numrows)
{
$backlink=mysql_result($result,$row,"returnBond");
$check=linkcheck($myURL,$backlink);
mysql_query("update Arfooo_sites set backlinkExists ='" .$check ."' where siteid=" .mysql_result($result,$row,"siteid") ) or die("fallo");
$row++;
}
//check reciprocal link function
function linkcheck($mylink,$link)
{
$content = getPage($link);
return checkPage($content, $mylink);
}
mysql_close($link);
function checkPage($content, $mylink){
$check = "0";
if (strlen($content) > 10){
$startPos = 0;
while (strpos($content,'<a ',$startPos) and $check=="0"){
$spos = strpos($content,'<a ',$startPos);
$tmppos = strpos($content,'>',$spos);
$spos = strpos($content,'href',$spos);
$spos1 = strpos($content,'"',$spos)+1;
$spos2 = strpos($content,"'",$spos)+1;
//echo "<br>" .$spos1 ." sd " .$spos2 ."<br>";
if ($spos2 < $spos1 and $spos2>1) $spos = $spos2;
else $spos = $spos1;
$epos1 = strpos($content,'"',$spos);
$epos2 = strpos($content,"'",$spos);
if ($epos2 < $epos1 and $epos2>0) $epos = $epos2;
else $epos = $epos1;
$startPos = $epos;
$link = substr($content,$spos,$epos-$spos);
flush();
if (strpos($link,'http://') !== false){
if (strcasecmp($link,$mylink)==0) {
$check= "1";
}
}
}
}
if ($check=="1")
{
echo "-> correcto<br>" ;
}
else
{
echo "-> <b>NO VALIDO</b><br>";
}
flush();
return $check;
}
function getPage($link){
echo "cargando: " .$link;
flush();
if ($fp = fopen($link, 'r')) {
$content = '';
while ($line = fread($fp, 1024)) {
$content .= $line;
}
$content .= $line;
}
return $content;
}
?>
I have no idea of php, so I merged and tortured several pieces of code found across all the internet. It simply works. Just upload it to your server and execute it:
http://myfabulousdomain.com/linkchecker.phpIt tests if the backlinks are active, notifies you of the state of every backlink and saves it in the database.
But, ¿how to known from inside arfooo what backlinks are valid?... I hacked a little the file /admin/templates/arfooo/site/search.tpl
- Code: Select all
<thead>
<tr>
<th>{'siteSearch_th_website_name'|lang}</th>
<th>{'siteSearch_th_url'|lang}</th>
<th>{'siteSearch_th_ban'|lang}</th>
<th>{'siteSearch_th_backlink'|lang}</th>
<!-- Add this column to the table, call it "valid" in your language -->
<th>Válido</th>
<!-- end mod 1-->
<th>{'Management'|lang}</th>
</tr>
</thead>
<tbody>
{foreach from=$sites value=site}
<tr class="line{cycle values='1,2'}">
<td><a href="{"/admin/site/edit/$site.siteId"|url}" title="{$site.siteTitle}">{$site.siteTitle}</a></td>
<td><a href="{"/admin/site/edit/$site.siteId"|url}" title="{$site.siteTitle}">{$site.url}</a></td>
<td>{if $site.status == 'banned'}<span class="text_red">{'Yes'|lang}</span>{else}<span class="text_green">{'No'|lang}</span>{/if}</td>
<td>{if $site.returnBond == ''}<span class="text_red">{'No'|lang}</span>{else}<span class="text_green">{'Yes'|lang}</span>{/if}</td>
<!-- And now, add the corresponding data column -->
<td>{if $site.backlinkExists == '0'}<span class="text_red">{'No'|lang}</span>{else}<span class="text_green">{'Yes'|lang}</span>{/if}</td>
<!-- End mod 2, and end of little hack -->
<td><a href="{"/admin/site/edit/$site.siteId"|url}" class="link_green">{'link_edit'|lang}</a> |
<a onclick="return $.confirmLinkClick('{'Do you really want to delete it?'|lang}', this.href)" href="{"/admin/site/delete/$site.siteId"|url}" class="link_red">{'link_delete'|lang}</a></td>
</tr>
Now, you can go to directory->search websites, and the list will show you the valid and invalid backlinks.
Bye!
