-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.php
61 lines (50 loc) · 1.33 KB
/
action.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
<?php
function page() {
$pageURL = 'http';
if (isset($_SERVER["HTTPS"])) {
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}
else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$extra = "";
$page = page();
if (substr_count($page, "?") > 0) {
$explode = explode("?", $page);
$extra = "?" . $explode[1];
}
$server = "showdown";
$url = "http://play.pokemonshowdown.com/~~" . $server . "/action.php" . $extra;
//get encoded variables
$postvars = "";
if (isset($_GET['post'])) {
$postvars = urldecode($_GET['post']);
}
$postvarsarray = explode("|", $postvars);
$postarray = Array();
for ($i = 0; $i < substr_count($postvars, "|"); $i++) {
$part = $postvarsarray[$i];
$postarray[$part] = $_POST[$part];
}
//structure it
$fields_string = "";
foreach($postarray as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'& ');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($postarray));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);