Scripts

Filesharing website link checker

simpele classe om te checken of een bestand nog steeds aanwezig is op een filesharing website zoals rapidshare.com. makkelijk te gebruiken, en je kan meerdere links te gelijk checken of een voor een. op het moment kan het 5 websites bekijken, die zijn: www.megaupload.com www.rapidshare.com www.rapidshare.de www.sendspace.com www.turboupload.com ik heb sendspace en turboupload gecomment binnen de classe om te laten zien hoet je nieuwe sites kan toevoegen. om het uit te breiden, kun je readmeNL.txt lezen binnen de zip of deze stukje lezen (gekopieerd en geplakt van de text bestand): je kan de zip hier downloaden: http://zeryl.net/linkchecker/linkchecker.zip of hier een voorbeeld bekijken: http://zeryl.net/linkchecker/ de site kan soms langzaam zijn, dus aub geduld hebben als je een van de links bekijkt de source van de pagina op de website is ook hier onder te vinden genaamd voorbeeld.php om links te checken, kun je meerdere tegelijk doen door de functie addLink($link) te gebruiken voor elke link, en later ze allemaal te gelijk lezen door de functie readLinks() aan te roepen (geeft array terug). om links een voor een te checken, kun je de functie checkLink($link) gebruiken, dit geeft gelijk een array terug. de terug gegeven array ziet er zo uit, ook uitbreiden horen deze array terug te geven: array( 'status' => '', // Dit is de status vab de url, dit kan ALLEEN 'Found' of 'Not Found' zijn 'filename' => '', // Als de bestand niet verwijderd is, de bestands naam, meeste filesharing sites geven dit 'size' => '', // De bestands groote, niet alle filesharing hosts geven dit gelijk, maar als het beschikbaar, kan het hier in 'desc' => '', // Informatie van de bestand, niet all sites geven dit, maar als het beschikbaar is, kan het hier in 'url' => '' // Dit hoort precies de eerste argument van de functie zijn ) dat is het volgens mij, vragen kunnen in de comment of naar feedback [ at ] zeryl [ punt ] net

filesharing-website-link-checker
FILE: linkchecker.php

[code]<?php
/*****
 *  Copyright 2008 Hoshang Sadiq, Zeryl
 *
 *  For more information on this script, visit:
 *  http://zeryl.net/linkchecker
 *
 *  This file is part of Zeryl Filesharing Link Checker (Z.F.L.C.)
 *
 *  Z.F.L.C. is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Z.F.L.C. is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Z.F.L.C.  If not, see <http://www.gnu.org/licenses/>.
 *******/
class linkChecker {
	private $links = array();
	private $sites = array();

	function __construct($sites = '') {
		if(is_array($sites)) {
			$this->sites = $sites;
		}
	}

  	function addLink($link) {
	  	$this->links[] = $link;
	}

  	function resetLinks() {
	  	$this->links = array();
	}

  	function addSite($site) {
		if(is_array($sites)) {
			$this->sites[] = $site;
		}
	}

	function checkLink($link) {
		$result = '';
		if(preg_match('/^http:\/\/(www\.)?megaupload\.com\/\?d=([A-Z0-9]{6,8})$/', $link)) {
			$result = $this->megauploadCom($link);
		} elseif(preg_match('/^http:\/\/(www\.)?rapidshare\.com\/files\/([0-9]{7,9})\/(.*?)(\.?h?t?m?l?)?$/', $link)) {
			$result = $this->rapidshareCom($link);
		} elseif(preg_match('/^http:\/\/(www\.)?rapidshare\.de\/files\/([0-9]{7,9})\/(.*?)(\.?h?t?m?l?)?$/', $link)) {
			$result = $this->rapidshareDe($link);
		// Heb dit vanwege phphulp gecomment zodat ik een kon laten zien om nieuwe sites to te voegen!
	//	} elseif(preg_match('/^http:\/\/(www\.)?sendspace\.com\/file\/([a-zA-Z0-9]{4,7})$/', $link)) {
	//		$result = $this->sendspaceCom($link);
	//	} elseif(preg_match('/^http:\/\/(www\.)?turboupload\.com\/download\/([a-zA-Z0-9]{10,14})$/', $link)) {
	//		$result = $this->turbouploadCom($link);
		} else {
			foreach($this->sites as $site => $siteInfo) {
				if(preg_match($siteInfo['regex'], $link)) {
					if($siteInfo['callback']['class'] != '') {
						$result = call_user_func(array($siteInfo['callback']['class'], $siteInfo['callback']['function']), $link); 
					}else{
						$result = call_user_func($siteInfo['callback']['function'], $link);
					}
				}
			}
		}
		if($result != '' && $result['status'] == ('Found' || 'Not Found')) {
			return $result;
		} else {
			return false;
		}
	}

	function readLinks() {
		$allLinks = array();
		foreach($this->links as $lnk) {
			$allLinks[] = $this->checkLink($lnk);
		}
		return $allLinks;
	}


	// In this function '@' is used to make sure that we don't get any php errors if the page couldn't be downloaded..
	function getPage($url) {
		if (function_exists('curl_init')) {
			$ch = @curl_init($url);
			@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			$source = @curl_exec($ch);
			@curl_close($ch);
		} else if(function_exists('file_get_contents')) {
			$source = @file_get_contents($url);
		} else {
			$url = str_replace("http://","",$url);
			if (preg_match("#/#","$url")){
				$page = $url;
				$url = @explode("/",$url);
				$url = $url[0];
				$page = str_replace($url,"",$page);
				if (!$page || $page == ""){
					$page = "/";
				}
				$ip = gethostbyname($url);
			}else{
				$ip = gethostbyname($url);
				$page = "/";
			}
			$open = @fsockopen($ip, 80, $errno, $errstr, 60);
			$send = "GET $page HTTP/1.0\r\n";
			$send .= "Host: $url\r\n";
			if ($_SERVER['HTTP_REFERER']){
				$send .= "Referer: {$_SERVER['HTTP_REFERER']}\r\n";
			}
			$send .= "Accept-Language: en-us, en;q=0.50\r\n";
			$send .= "User-Agent: LinkCheckerScript\r\n";
			$send .= "Connection: Close\r\n\r\n";
			@fputs($open, $send);
			while (!feof($open)) {
				$return .= @fgets($open, 4096);
			}
			@fclose($open);
			$return = @explode("\r\n\r\n",$return,2);
			$source = $return[1];
		}
		return $source;
	}
	
	function megauploadCom($link) {
		$fgc = $this->getPage($link);
		preg_match('/\<b\>Filename:\<\/b\> (.*?)\<\/div\>/', $fgc, $matches);
		preg_match('/\<b\>Filesize:\<\/b\> (.*?)\<\/div\>/', $fgc, $matches2);
		preg_match('/\<b\>Description:\<\/b\> (.*?)\<\/div\>/', $fgc, $matches3);
		$ret = array();
		if(isset($matches[1]) && $matches[1] != '') {
			$ret['status'] = 'Found';
			$ret['filename'] = $matches[1];
			$ret['size'] = $matches2[1];
			$ret['desc'] = $matches3[1];
		} else {
			$ret['status'] = 'Not Found';
			$ret['filename'] = '';
			$ret['size'] = '';
			$ret['desc'] = '';
		}
		$ret['url'] = $link;
		return $ret;
	}
	
	function rapidshareDe($link) {
		$fgc = $this->getPage($link);
		preg_match('/\<h3\>You want to download (.*?)\<\/h3\>/', $fgc, $matches);
		$ret = array();
		if(isset($matches[1]) && $matches[1] != '') {
			$ret['status'] = 'Found';
			$ret['filename'] = $matches[1];
			$ret['size'] = 'Unknown Size';
		} else {
			$ret['status'] = 'Not Found';
			$ret['filename'] = '';
			$ret['size'] = '';
		}
	
		$ret['url'] = $link;
		return $ret;
	}
	
	function rapidshareCom($link) {
		$fgc = $this->getPage($link);
		preg_match('/\<p class="downloadlink"\>http:\/\/rapidshare\.com\/files\/([0-9]{0,9})\/(.*?) \<font style="color:#([a-fA-F0-9]{0,6});"\>\| ([0-9]+) (.*?){0,2}\<\/font\>\<\/p\>/', $fgc, $matches);
		$ret = array();
		if(isset($matches[0]) && $matches[0] != '') {
			$ret['status'] = 'Found';
			$ret['filename'] = $matches[2];
			$ret['size'] = $matches[4].' '.$matches[5];
		} else {
			$ret['status'] = 'Not Found';
			$ret['filename'] = '';
			$ret['size'] = '';
		}
	
		$ret['url'] = $link;
		return $ret;
	}

	function turbouploadCom($link) {
		$fgc = $this->getPage($link);
		$fgc = explode('<div id="process">', $fgc);
		$fgc = explode('</table>', $fgc[1]);
		$fgc = $fgc[0];
	
		preg_match_all('#\<tr\>(.*?)\<\/tr\>#s', $fgc, $tr);
		$td = explode('<td', $tr[0][0]);
		preg_match_all('/\<div align="left" class="style47"\>(.*?)\<\/div\>/s', $td[2], $file);
		$file = trim(preg_replace('/\<.*?\>/', '', $file[1][0]));
		$td = explode('<td', $tr[0][1]);
		preg_match_all('/\<div align="left"  class="style47"\>(.*?)\<\/div\>/s', $td[4], $size);
		$size = $size[1][0];
	
		$ret = array();
		if(isset($file) && $file != '') {
			$ret['status'] = 'Found';
			$ret['filename'] = $file;
			$ret['size'] = $size;
			$ret['desc'] = '';
		} else {
			$ret['status'] = 'Not Found';
			$ret['filename'] = '';
			$ret['size'] = '';
			$ret['desc'] = '';
		}
		$ret['url'] = $link;
		return $ret;
	}
}

function sendspaceCom($link) {
	global $linkchecker;
	$fgc = $linkchecker->getPage($link);
	preg_match('/\<b\>Name:\<\/b\> (.*?)\<br\>/', $fgc, $matches);
	preg_match('/\<b\>Size:\<\/b\> (.*?)\<br\>/', $fgc, $matches2);
	preg_match('/\<b\>Description:\<\/b\> (.*?)The download link is located below.\<\/td\>/', $fgc, $matches3);
	$ret = array();
	if(isset($matches[1]) && $matches[1] != '') {
		$ret['status'] = 'Found';
		$ret['filename'] = trim($matches[1]);
		$ret['size'] = trim(isset($matches2[1]) ? $matches2[1] : '');
		$ret['desc'] = trim(isset($matches3[1]) ? $matches3[1] : '');
	} else {
		$ret['status'] = 'Not Found';
		$ret['filename'] = '';
		$ret['size'] = '';
		$ret['desc'] = '';
	}
	$ret['url'] = $link;
	return $ret;
}

?>[/code]


FILE: voorbeeld.php
[code]<?php
/*****
 *  Copyright 2008 Hoshang Sadiq, Zeryl
 *
 *  For more information on this script, visit:
 *  http://zeryl.net/linkchecker
 *
 *  This file is part of Zeryl Filesharing Link Checker (Z.F.L.C.)
 *
 *  Z.F.L.C. is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Z.F.L.C. is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Z.F.L.C.  If not, see <http://www.gnu.org/licenses/>.
 *******/

include ('linkchecker.php');

$sites = array(
	'turboupload.com' => array(
		'regex' => '/^http:\/\/(www\.)?turboupload\.com\/download\/([a-zA-Z0-9]{10,14})$/',
		'callback' => array(
			'class' => 'linkChecker',
			'function' => 'turbouploadCom'
		)
	),
	'sendspace.com' => array(
		'regex' => '/^http:\/\/(www\.)?sendspace\.com\/file\/([a-zA-Z0-9]{4,7})$/',
		'callback' => array(
			'class' => '',
			'function' => 'sendspaceCom'
		)
	)
);

echo '<h1>Filesharing Link Checker</h1>';

if(isset($_POST['links'])) {
	echo '<pre>';
	$linkchecker = new linkChecker($sites);
	$links = trim(addslashes(htmlspecialchars($_POST['links'])));
	$array = explode("\n", $links);
	echo "Please be patient for the page to load fully. This operation can take a while depending on the number of links and the speed of the filesharing host.<br />";
	for($i=0;$i<count($array);$i++) {
		$lnk = trim($array[$i]);
		if($lnk != '') {
			if(substr($lnk, 0, 7) != 'http://') {
				$lnk = 'http://'.$lnk;
			}
			$result = $linkchecker->checkLink($lnk);
			if($result != '' && $result['status'] == ('Found' || 'Not Found')) {
				echo (($result['status'] == 'Found') ? '<span style="color: green">Found</span> : '.$result['url'].' : '.$result['filename'] .' ('.$result['size'].')' : '<span style="color: red">Not Found</span> : '.$result['url']).'<br>';
				$text2 .= $result['url']."\n";
				flush();
			}
		}
		$lnk = '';
		$result = '';
	}
	echo 'Done<br /><br />';
	echo '</pre>';
}
//print_r($test->checkLink('LINK HIER'));
//$test->addLink('LINK HIER');
//$test->addLink('LINK HIER');
//print_r($test->readLinks());
?>

Put all the links in the box beneath, then click on Check Links
<form action="<?php echo basename(__FILE__); ?>" method="POST">
<textarea cols="100" rows="20" name="links"></textarea>
<br />
<input type="submit" value="Check links">
</form>

This website currently supports <a href="http://www.megaupload.com/">www.megaupload.com</a>, <a href="http://www.rapidshare.com/">www.rapidshare.com</a>, <a href="http://www.rapidshare.de/">www.rapidshare.de</a>, <a href="http://www.sendspace.com/">www.sendspace.com</a>, <a href="http://www.turboupload.com/">www.turboupload.com</a><br />
<a href="http://zeryl.net/linkchecker/download.php">Download this script</a>[/code]

Reacties

0
Nog geen reacties.