2023-08-18 12:02:10 +03:00
|
|
|
<?php
|
|
|
|
function getElementByClassname ($html, $classname) {
|
|
|
|
$dom = new DOMDocument();
|
|
|
|
$dom->loadHTML($html);
|
|
|
|
|
|
|
|
$xpath = new DOMXpath($dom);
|
|
|
|
$nodes = $xpath->query('//div[@class="' . $classname . '"]');
|
|
|
|
|
|
|
|
$tmp_dom = new DOMDocument();
|
|
|
|
foreach ($nodes as $node) {
|
|
|
|
$tmp_dom->appendChild($tmp_dom->importNode($node, true));
|
2023-08-21 09:57:06 +03:00
|
|
|
break;
|
2023-08-18 12:02:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return trim($tmp_dom->saveHTML());
|
|
|
|
}
|
2023-08-21 09:57:06 +03:00
|
|
|
|
2023-08-18 12:02:10 +03:00
|
|
|
$random = rand()&1;
|
2023-08-21 09:57:06 +03:00
|
|
|
$url= '';
|
|
|
|
$pre_quote = '';
|
|
|
|
$quote = "";
|
|
|
|
$class = '';
|
|
|
|
|
2023-08-18 12:02:10 +03:00
|
|
|
if ($random == 0){
|
2023-08-21 09:57:06 +03:00
|
|
|
$url = "http://ipfw.ru/bash/random";
|
|
|
|
$pre_quote = "from ipfw.ru/bash:<br><hr style='width: 33%;'>";
|
|
|
|
$class = "quotebody";
|
2023-08-18 12:02:10 +03:00
|
|
|
}else{
|
2023-08-21 09:57:06 +03:00
|
|
|
$url = "http://ibash.org.ru/random.php";
|
|
|
|
$pre_quote = "from iBASH:<br><hr style='width: 33%;'>";
|
|
|
|
$class = "quotbody";
|
|
|
|
}
|
|
|
|
$data = "";
|
|
|
|
$curl = curl_init();
|
2023-08-18 12:02:10 +03:00
|
|
|
// Set some options - we are passing in a useragent too here
|
2023-08-21 09:57:06 +03:00
|
|
|
curl_setopt_array($curl, array(
|
|
|
|
CURLOPT_RETURNTRANSFER => 1,
|
|
|
|
CURLOPT_URL => $url,
|
|
|
|
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'
|
|
|
|
));
|
2023-08-18 12:02:10 +03:00
|
|
|
// Send the request & save response to $resp
|
2023-08-21 09:57:06 +03:00
|
|
|
$data = curl_exec($curl);
|
2023-08-18 12:02:10 +03:00
|
|
|
// Close request to clear up some resources
|
2023-08-21 09:57:06 +03:00
|
|
|
curl_close($curl);
|
2023-08-18 12:02:10 +03:00
|
|
|
//$data = mb_convert_encoding($data, 'UTF-8', 'windows-1251');
|
2023-08-21 09:57:06 +03:00
|
|
|
$quote = $pre_quote.getElementByClassname($data, $class);
|
2023-08-18 12:02:10 +03:00
|
|
|
?>
|