This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathproxy.php
85 lines (62 loc) · 1.66 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
include 'util.php';
$function = $_GET['do'];
if ( function_exists($function)) {
echo $function($_GET);
}
else {
echo "Bad function name.";
}
/**
*
* Load a remote webpage.
*
* @param array $args
* @return HTML string of page
*/
function getUrl($args) {
$fp = fopen( $args['url'], 'r');
$content = "";
while( !feof($fp) ) {
$buffer = trim( fgets( $fp, 4096 ) );
$content .= $buffer;
}
return $content;
}
function currencyConvert($args) {
extract($args);
$cc = new CurrencyConvert();
// Let's make a nice format.
$currencies = $cc->getSupportedCurrencies();
$from = strtoupper(substr($from,0,3));
$to = strtoupper(substr($to,0,3));
$from_text = $currencies[$from];
$to_text = $currencies[$to];
$number = money_format('%i', $cc->convert($amount, $from, $to));
return $amount .' '. $from_text .' is equal to '. $number .' '. $to_text .'s.';
}
function getCurrencies($args) {
$input = strtolower($args['q']);
$output = array();
$cc = new CurrencyConvert();
$array = $cc->getSupportedCurrencies();
// Make sure they're alphabetic
ksort($array, SORT_STRING);
// Try this crap hack
foreach($array as $key=>$value) {
//$tmp[] = $key .': '. $value;
}
//$array = $tmp;
// Reduce the array to only those values specified by the user.
// @todo There must be a better way to reduce!
foreach($array as $key=>$value) {
//if ( (strpos(strtolower($key), $input) !== FALSE) || (strpos(strtolower($value), $input) !== FALSE) ) {
if ((strpos(strtolower($key . $value), $input) !== FALSE) ) {
$output[] = "$key: $value\n";
}
}
if ($output) {
return implode("\n", $output);
}
return 'Nothing found!';
}