Repository navigation
Expand file tree
/
Copy pathipn.php
More file actions
80 lines (55 loc) · 1.82 KB
/
Copy pathipn.php
File metadata and controls
80 lines (55 loc) · 1.82 KB
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
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("db_nepalstay") or die(mysql_error());
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// PAYMENT VALIDATED & VERIFIED!
$email = $_POST['payer_email'];
$password = mt_rand(1000, 9999);
mysql_query("INSERT INTO users (stay_email, user_pass_md5) VALUES('". mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error());
$to = $email;
$subject = 'Download Area | Login credentials';
$message = '
Thank you for your purchase
Your account information
-------------------------
Email: '.$email.'
Password: '.$password.'
-------------------------
You can now login at http://yourwebsite.com/PayPal/';
$headers = 'From:noreply@downloadarea.com' . "\r\n";
mail($to, $subject, $message, $headers);
}
else if (strcmp ($res, "INVALID") == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
$to = 'admin@yourwebsite.com';
$subject = 'Download Area | Invalid Payment';
$message = '
Dear Administrator,
A payment has been made but is flagged as INVALID.
Please verify the payment manualy and contact the buyer.
Buyer Email: '.$email.'
';
$headers = 'From:noreply@yourwebsite.com' . "\r\n";
mail($to, $subject, $message, $headers);
}
}
fclose ($fp);
}
?>