-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss2map.php
71 lines (69 loc) · 2.64 KB
/
rss2map.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
if(preg_match('/rss2map.php$/',$_SERVER["PHP_SELF"])){?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RSS 2 Map result</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css">
<link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/base/base.css" type="text/css">
</head>
<body>
<?php }
if(isset($_GET['feed']) || isset($rss2mapfeed)){?>
<?php
$url = isset($rss2mapfeed) ? $rss2mapfeed : $_GET['feed'];
$key = 'PbXUT7HV34Fq2KhMd68qS.CRZY9RWjW_dEQLgINMwG.eNxu2hf84BTkvHNttEg4-';
// ^ get your own!
$apiendpoint = 'http://wherein.yahooapis.com/v1/document';
$inputType = 'text/rss';
$outputType = 'rss';
$post = 'appid='.$key.'&documentURL='.$url.'&documentType='.
$inputType.'&outputType='.$outputType;
$ch = curl_init($apiendpoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$results = curl_exec($ch);
$results = preg_replace('/cl:/','cl',$results);
$places = simplexml_load_string($results, 'SimpleXMLElement',
LIBXML_NOCDATA);
function cleanup($elm){
return preg_replace('/\n\r?+/','',addslashes($elm));
}
$output .= '[';
if($places->channel->item){
foreach($places->channel->item as $p){
$locs = $p->clcontentlocation;
if($locs){
foreach($locs->clplace as $pl){
$content = '<h2><a href=\"'.$p->link.'\">'.cleanup($p->title).
'</a></h2><p>'.cleanup($p->description).'</p>';
$locations[] = '{"name":"'.$pl->name.'","title":"'.
cleanup($p->title).
'","lat":"'.$pl->cllatitude.'","content":"'.$content.
'","lon":"'.$pl->cllongitude.'"}';
}
}
}
}
if(isset($locations)){
$output .= implode(',',$locations);
}
$output .= ']';
?>
<div id="rss2map"></div>
<link rel="stylesheet" href="rss2map.css" type="text/css">
<script src="http://yui.yahooapis.com/2.6.0/build/utilities/utilities.js"></script>
<script type="text/javascript" src="http://l.yimg.com/d/lib/map/js/api/ymapapi_3_8_2_3.js"></script>
<script type="text/javascript" src="rss2map.js"></script>
<script type="text/javascript">
var YMAPPID = '<?php echo $key;?>';
rss2map(<?php echo $output;?>);
</script>
<?php }
if(preg_match('/rss2map.php$/',$_SERVER["PHP_SELF"])){?>
</body>
</html>
<?php } ?>