Change method request quotes from ipfw.ru/bash
This commit is contained in:
parent
f20e46c79b
commit
5d1081c1b3
33
parse.php
33
parse.php
|
@ -9,32 +9,33 @@ function getElementByClassname ($html, $classname) {
|
||||||
$tmp_dom = new DOMDocument();
|
$tmp_dom = new DOMDocument();
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
$tmp_dom->appendChild($tmp_dom->importNode($node, true));
|
$tmp_dom->appendChild($tmp_dom->importNode($node, true));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim($tmp_dom->saveHTML());
|
return trim($tmp_dom->saveHTML());
|
||||||
}
|
}
|
||||||
$quote = "";
|
|
||||||
$random = rand()&1;
|
$random = rand()&1;
|
||||||
|
$url= '';
|
||||||
|
$pre_quote = '';
|
||||||
|
$quote = "";
|
||||||
|
$class = '';
|
||||||
|
|
||||||
if ($random == 0){
|
if ($random == 0){
|
||||||
$file=file_get_contents("http://ipfw.ru/bash/fortune");
|
$url = "http://ipfw.ru/bash/random";
|
||||||
$file = mb_convert_encoding($file, 'UTF-8', 'KOI8-R');
|
$pre_quote = "from ipfw.ru/bash:<br><hr style='width: 33%;'>";
|
||||||
$arr = explode ('%', $file);
|
$class = "quotebody";
|
||||||
array_splice($arr,0,3);
|
|
||||||
shuffle($arr);
|
|
||||||
//foreach ($arr as $fortune){
|
|
||||||
// $fortune=nl2br($fortune);
|
|
||||||
//echo $fortune;
|
|
||||||
//echo "<br><hr><br>";
|
|
||||||
//}
|
|
||||||
$quote = "from ipfw.ru/bash:<br><hr style='width: 33%;'>".nl2br(htmlentities($arr[0]));
|
|
||||||
$quote = str_replace ("<br><br>","<br>", $quote);
|
|
||||||
}else{
|
}else{
|
||||||
|
$url = "http://ibash.org.ru/random.php";
|
||||||
|
$pre_quote = "from iBASH:<br><hr style='width: 33%;'>";
|
||||||
|
$class = "quotbody";
|
||||||
|
}
|
||||||
$data = "";
|
$data = "";
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
// Set some options - we are passing in a useragent too here
|
// Set some options - we are passing in a useragent too here
|
||||||
curl_setopt_array($curl, array(
|
curl_setopt_array($curl, array(
|
||||||
CURLOPT_RETURNTRANSFER => 1,
|
CURLOPT_RETURNTRANSFER => 1,
|
||||||
CURLOPT_URL => 'http://ibash.org.ru/random.php',
|
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'
|
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'
|
||||||
));
|
));
|
||||||
// Send the request & save response to $resp
|
// Send the request & save response to $resp
|
||||||
|
@ -42,7 +43,5 @@ if ($random == 0){
|
||||||
// Close request to clear up some resources
|
// Close request to clear up some resources
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
//$data = mb_convert_encoding($data, 'UTF-8', 'windows-1251');
|
//$data = mb_convert_encoding($data, 'UTF-8', 'windows-1251');
|
||||||
$quote = "from iBASH:<br><hr style='width: 33%;'>".getElementByClassname($data, "quotbody");
|
$quote = $pre_quote.getElementByClassname($data, $class);
|
||||||
}
|
|
||||||
//print_r ($arr);
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue