-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpost.php
65 lines (64 loc) · 2.66 KB
/
post.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
<?php
$VERSION = '0.3.8';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_REQUEST['posturl']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
// curl_setopt($ch, CURLINFO_HEADER_OUT, true);
if (isset($_REQUEST['ua'])) {
$ua = $_REQUEST['ua'];
}
else {
$ua = "onlineCoinCoin/" . $VERSION;
}
// $message = $_SERVER['QUERY_STRING'];
// $message = substr($message, strpos($message, 'postdata=')+9);
$message = $_REQUEST['postdata'];
$message = str_replace(array('#{plus}#', '#{amp}#', '#{dcomma}#', '#{percent}#'), array(urlencode('+'), urlencode('&'), '%3B', '%25'), $message);
$referer = $_REQUEST['posturl'];
$referer = substr($referer, 0, strrpos($referer, '/')+1);
curl_setopt($ch, CURLOPT_REFERER, $referer);
$rheaders = array(
'Accept: text/xml',
'Cache-Control: no-cache, must-revalidate' //,
// 'Referer: ' + $referer
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $rheaders);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
if (get_magic_quotes_gpc()) {
curl_setopt($ch, CURLOPT_POSTFIELDS, stripslashes($message)); // stripslashes(utf8_encode($message)));
}
else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
}
if (isset($_REQUEST['cookie'])) {
curl_setopt($ch, CURLOPT_COOKIE, $_REQUEST['cookie']);
}
$res = curl_exec($ch);
// error_log( "[olcc] " . $res); // curl_getinfo($ch, CURLINFO_HEADER_OUT));
// var_dump(curl_getinfo($ch));
// echo "UA=$ua<br />referer=$referer<br />cookie=".$_REQUEST['cookie']."<br />Data=".stripslashes(utf8_encode($message))."<br />Query_string=".$_SERVER['QUERY_STRING']."<br />";
echo('({');
if ($res === false) {
echo( "'error':'". curl_error($ch) ."'," );
}
else {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = preg_split("\n", substr($res, 0, $header_size));
foreach ($headers as $header) {
if (strpos($header, ':') > 0) {
list($name, $val) = preg_split(":", $header);
$tval = trim($val);
if (!empty($tval)) {
echo( "'" . trim(str_replace("-", "", $name)) . "':'" . addslashes($tval) . "'," );
}
}
}
echo( "'referer':\"" . $referer . "\"," );
echo( "'httpcode':" . curl_getinfo($ch, CURLINFO_HTTP_CODE) . "," );
//echo "UA=$ua<br />referer=$referer<br />cookie=".$_REQUEST['cookie']."<br />Data=".$message."<br />Query_string=".$_SERVER['QUERY_STRING']."<br />";
// echo $res;
}
echo("'result':\"".str_replace("\n","\\n",addslashes(substr($res, $header_size, strlen($res))))."\"");
echo('})');
?>