Miscellany
public text v1 · immutable<?
if(array_key_exists('q', $_GET)) {
$data = file_get_contents('http://pipes.yahoo.com/pipes/pipe.run?_id=38aeb08c2644cb16b9914abebecda70a&_render=rss&keywords='. urlencode($_GET['q']));
if (!empty($data)) $xml = new SimpleXMLElement($data);
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo $_GET['q']; ?></title>
<style>
html,body {
height:100%;
margin:0;
padding:0;
font: 1.0em Arial,Helvetica,sans-serif;
}
img, form {
margin: 0;
padding: 0;
border: 0;
}
input {
margin: 0;
padding: 0;
}
body {
background-color: #FFFFFF;
}
#reg {
position: absolute;
left: 50%;
top: 60px;
margin-left: -381px;
width: 762px;
height: 106px;
background-image: url('fon.png');
background-repeat: no-repeat;
background-position: 50% 50%;
}
#content {
position: absolute;
left: 50%;
top: 200px;
margin-left: -370px;
width: 740px;
}
#regforma{
padding: 35px 0px 0px 25px;
}
#regtext {
background: transparent;
background-image: url('input.png');
background-repeat: no-repeat;
background-position: center center;
border: 0px;
width: 640px;
height: 29px;
}
#regbutton {
background: transparent;
background-image: url('button.png');
background-repeat: no-repeat;
background-position: center center;
border: 0px;
width: 70px;
height: 29px;
cursor: pointer;
color: #444444;
}
#notfound {
font: 1.3em Arial,Helvetica,sans-serif;
font-weight: bold;
margin-left: 30px;
}
.result_list {
list-style: none outside none;
margin: 0;
padding: 0;
}
.result_item {
margin-bottom: 1.8em;
}
.result_title {
display: inline;
font-size: 0.9em;
font-weight: 400;
margin: 0;
}
.result_title_link {
color: #795e00;
font-size: 125%;
line-height: 1.3em;
margin-right: 0.4em;
}
.item_text {
line-height: 1.3em;
padding-top: 5px;
}
.item_text img {
padding-right: 5px;
}
.item_guid {
color: #a47f00;
}
.item_date{
font-size: 70%;
}
</style>
</head>
<body>
<h1><? echo $_GET['q']; ?></h1>
<?
if(isset($xml)) {
print(
' <div id="content">');
$items = $xml->xpath('channel/item');
if(empty($items)){
print(
' <div id="notfound">Не удалось найти искомую комбинацию слов.</div>');
}else{
unset($xml);
$sort_proxy = array();
foreach($items as $k=>$item){
$sort_proxy[$k] = IntVal(strtotime($item->pubDate));
if(!empty($item->pubDate)){
$item->pubDate = date('d.m.Y H:i:s', strtotime($item->pubDate));
}
if(!empty($item->description)){
preg_match('/<img[^>]+src\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/si', $item->description,$img);
$item->description = preg_replace('#<a.*>.*</a>#USi','', $item->description);
$item->description = strip_tags($item->description,'<a>');
if(!empty($img[1])) $item->description = '<img src="'.$img[1].'" align="left" />'.$item->description;
}
if(!empty($item->guid)){
if(strpos($item->guid, "http")===false) $item->guid = '';
}
}
array_multisort($sort_proxy, SORT_DESC, $items);
print(
' <ol class="result_list">');
foreach($items as $k=>$item){
print(
' <li class="result_item">'.
' <h2 class="result_title">'.
' <a target="_blank" href="'.$item->link.'" class="result_title_link">'.
' <span>'.$item->title.'</span>'.
' </a>'.
' </h2>'.
' <div class="item_guid">'.$item->guid.'</div>'.
' <div class="item_date">'.$item->pubDate.'</div>'.
' <div class="item_text">'.$item->description.'</div>'.
' </li>');
}
print(
' </ol>');
}
print(
' </div>');
}
?>
</body>
</html>