PDA

View Full Version : php Link Checker



4don4i
04-21-2012, 10:32 PM
Code:
<?php
set_time_limit(0);

define('MAX_LINKS', 50);

$sites = array
(
'rapidshare.com' => 'FILE DOWNLOAD',
'rapidshare.de' => 'Choose download-type',
'megashares.com' => 'Filename',
'megaupload.com' => 'Filename:',
'filefactory.com' => 'file uploaded',
'netload.in' => 'dl_first_tacho.gif',
'depositfiles.com' => 'File name:',
'sendspace.com' => '<b>Size:',
'uploading.com' => 'ico_download_file',
'ul.to' => '"inputActive"',
'ziddu.com' => 'File Size',
'uploaded.to' => '"inputActive"',
'easy-share.com' => 'dwait',
'hotfile.com' => '<td>Downloading ',
'mediafire.com' => 'Processing download request...',
'storage.to' => 'Downloading:',
'uploadbox.com' => 'Free Download',
'2shared.com' => 'File size',
'zshare.net' => 'File Name'
);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simple Link Checker</title>
<style type="text/css">
<!--
body {
font:9pt verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif;
}
.green {
color:green;
}
.red {
color: red;
}
-->
</style>
</head>
<body>
<b> Supported File Hosts:</b><br />
<?php // List supported sites
$es = 0;
echo '<table cellspacing="2" cellpadding="2"><tr>';
foreach ($sites as $site => $match){
echo '<td>'.$site.'</td>';
++$es;
echo ($es%5) ? '' : '</tr><tr>';
}
echo '</tr></table>';
?>
<br />
<br />
<form action="" method="post">
<b>Links To Check:</b><br />
<textarea rows="8" cols="52" name="links" class="textarea"></textarea><br />
<br />
<input type="submit" value="Check Links" name="checklinks" class="button" /><input type="reset" value="Clear" class="button">
</form>
<br />
<br />

<?php
// edit it and the script wont work :P
function getPage($url){
if(function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
curl_close ($ch);
return $page;
}
return file_get_contents($url);
}

if($_POST){

$links = explode("\n", implode("\n", explode(" ", $_POST['links'])));
$checked = 0;
$alive = 0;

foreach($links as $link){
$link = trim($link);

foreach($sites as $site => $match){
if(stristr($link,$site)){
$page = getPage($link);
$link = htmlentities($link);
if(stristr($page,$match)) {
echo '<span class="green">Alive: <a href="'.$link.'"><b>'.$link.'</b></a></span><br />';
$alive++;
} else echo '<span class="red">Dead: <a href="'.$link.'"><b>'.$link.'</b></a></span><br />';

$checked++;
}

if($checked >= MAX_LINKS){
echo '<br />Maximum No ('.MAX_LINKS.') of links has been reached.</body></html>';
break 2;
}
}
}
echo ($checked == 0) ? '<span class="red">No supported links found.</span><br />' : '<br />'.$checked.' link'.(($checked == 1) ? '' : 's').' checked. ('.round($alive/$checked*100).'% alive)<br />';
}
?>
<br /><br />
</body></html>

freshcvv
07-03-2012, 03:15 PM
nice scripts

card
07-04-2012, 07:33 AM
Thanks mate. Nice script just checked it on localhost :D

Sense09
11-06-2012, 12:39 PM
Nice, but not clean ;)