-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproxy.php
46 lines (40 loc) · 1.15 KB
/
proxy.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
<?php
//
// basic proxy
// @author: Ido Green | @greenido
//
//
// parsing the RSS to JSON
//
function ParseRssToJSON($url) {
$fileContents= file_get_contents($url);
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
$fileContents = trim(str_replace('"', "'", $fileContents));
$simpleXml = simplexml_load_string($fileContents);
$json = json_encode($simpleXml);
return $json;
}
//
// Fetch a url and echo it back to stdout
//
function getUrl($url) {
//error_log("Fetch:" . $url);
// PROD
$handle = fopen($url, "rb");
$ret = stream_get_contents($handle);
fclose($handle);
//error_log("ret:\n $ret \n");
// TESTING: '{"id":"1527628240688","title":"התרעות פיקוד העורף ","data":["מרכז הנגב, עוטף עזה 234"]}';
//$ret = '{"id":"' . time() . '","title":"התרעות פיקוד העורף ","data":["מרכז הנגב, עוטף עזה 234"]}';
echo $ret;
}
//
// Start the party
//
if (isset($_GET['url']) ) {
getUrl($_GET['url']);
}
else {
error_log("Err: yo! you are missing the url to fetch for you.");
echo "You must send a 'url' so the proxy will work on something...";
}