Code: Select all
<?php
// begin of smf elit 2
require_once('forum/SSI.php');
unset($context['linktree']);
$context['menu_buttons'] = array(
'home' => array(
'title' => 'Home',
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'active_button' => true,
),
'forum' => array(
'title' => 'Forum',
'href' => 'http://www.forum-racunara.com/forum/',
'show' => true,
'sub_buttons' => array(
),
'active_button' => false,
),
'download' => array(
'title' => 'Download',
'href' => 'http://link2.com/otherpage.php',
'show' => true,
'sub_buttons' => array(
),
'active_button' => false,
),
'ihosting' => array(
'title' => 'I-Hosting',
'href' => 'http://link2.com/otherpage.php',
'show' => true,
'sub_buttons' => array(
),
'active_button' => false,
),
'tools' => array(
'title' => 'Tools',
'href' => 'http://link2.com/otherpage.php',
'show' => true,
'sub_buttons' => array(
),
'active_button' => false,
),
'chat' => array(
'title' => 'Chat',
'href' => 'http://link2.com/otherpage.php',
'show' => true,
'sub_buttons' => array(
),
'active_button' => false,
),
'kontakt' => array(
'title' => 'Kontakt',
'href' => 'http://link3.com/otherpage.php',
'show' => true,
'sub_buttons' => array(
),
'active_button' => false,
'is_last' => true,
),
);
template_header();
// end of smf elit 2
//Make a title spider
$tspider = new tagSpider();
// input box
$urlrun = $_POST['urlrun'];
if (!$urlrun) die("<form method='post'><input type='text' name='urlrun'> <input type='submit'></form>");
//Pass URL to the fetch page function
$tspider->fetchPage($urlrun);
// Enter the tags into the parse array function
$linkarray = $tspider->parse_array();
print_r($linkarray);
echo "<h2>Links present on page: ".$urlrun."</h2><br />";
echo "<table align=\"center\" bordercolor=\"#006600\" bgcolor=\"#CCCCCC\">";
$search = array('http://rapidshare.com','hotfile.com');
foreach ($linkarray as $link) {
foreach($search as $search_term) { // this line had gone
if(strpos($link, $search_term) > -1) { // this line should contain $search_term not $search
$link = rtrim($link, "\"");
echo "
<tr>
<td>$link</td>
</tr>";
}
} // this line had gone
}
echo "</table>";
exit;
class tagSpider
{
var $crl; // this will hold our curl instance
var $html; // this is where we dump the html we get
var $binary; // set for binary type transfer
var $url; // this is the url we are going to do a pass on
function tagSpider()
{
$this->html = "";
$this->binary = 0;
$this->url = "";
}
function fetchPage($url)
{
$this->url = $url;
if (isset($this->url)) {
$this->ch = curl_init (); // start cURL instance
curl_setopt ($this->ch, CURLOPT_RETURNTRANSFER, 1); // this tells cUrl to return the data
curl_setopt ($this->ch, CURLOPT_URL, $this->url); // set the url to download
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
curl_setopt($this->ch, CURLOPT_BINARYTRANSFER, $this->binary); // tell cURL if the data is binary data or not
$this->html = curl_exec($this->ch); // grabs the webpage from the internet
curl_close ($this->ch); // closes the connection
// $this->html = file_get_contents($url);
}
}
function parse_array() // this function takes the grabbed html and picked out the pieces we want
{
$regex = '#'.
'(?:^|[\s\(\)\[\]\{\}\\\'\\\";]+)(?![\@\!\#])'.
'('.
'(?:'.
'(?:'. //Known protocols
'(?:'.
'(?:(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|irc)://)'.
'|'.
'(?:(?:mailto|aim|tel|xmpp):)'.
')'.
'(?:[\pN\pL\-\_\+\%\~]+(?::[\pN\pL\-\_\+\%\~]+)?\@)?'. //user:pass@
'(?:'.
'(?:'.
'\[[\pN\pL\-\_\:\.]+(?<![\.\:])\]'. //[dns]
')|(?:'.
'[\pN\pL\-\_\:\.]+(?<![\.\:])'. //dns
')'.
')'.
')'.
'|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'. //IPv4
'|(?:'. //IPv6
'\[?(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}(?:(?:[0-9A-Fa-f]{1,4})|:))|(?:(?:[0-9A-Fa-f]{1,4}:){6}(?::|(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(?::[0-9A-Fa-f]{1,4})))|(?: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4F|?????????|XN--9T4B11YI5A|???|XN--DEBA0AD|????|XN--G6W251D|??|XN--HGBK6AJ7F53BBA|???????|XN--HLCJ6AYA9ESC7A|???????|XN--JXALPDLP|??????|XN--KGBECHTV|??????|XN--ZCKZAH|???|YE|YT|YU|ZA|ZM|ZW|local|loc|onion)'.
')(?![\pN\pL\-\_])'.
')'.
'(?:'.
'(?:\:\d+)?'. //:port
'(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@]*)?'. // /path
'(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@\/]*)?'. // ?query string
'(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\@/\?\#]*)?'. // #fragment
')(?<![\?\.\,\#\,])'.
')'.
'#ixu';
preg_match_all($regex, $this->html, $matching_data); // match data between specificed tags
return $matching_data[1];
}
}