Skip to content

Commit a8f5a01

Browse files
committed
paypal ipn files
1 parent 6bfc4d4 commit a8f5a01

File tree

4 files changed

+173
-0
lines changed

4 files changed

+173
-0
lines changed

ipn/css/style.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
body{
2+
background: #2D2D2D; /* Set Website Background Color */
3+
font: 11px 'Verdana'; /* Set Website Font Size & Font Type */
4+
}
5+
6+
#wrap{
7+
margin: 0 auto; /* Center Our Content */
8+
width: 500px; /* Set The Width For Our Content */
9+
background: #FFF; /* Set Content Background Color */
10+
padding: 10px; /* Set Padding For Content */
11+
border: 1px solid #000; /* Add A Border Around The Content */
12+
}
13+
14+
label{
15+
display: block; /* Make sure the label is on a single line */
16+
margin: 3px; /* Create some distance away from the input fields */
17+
}
18+
19+
input{
20+
padding: 3px; /* Give the text some more space */
21+
border: 1px solid gray; /* Add a border around the input fields */
22+
margin: 3px; /* Create some distance away from the labels */
23+
}

ipn/index.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<title>Nettuts.com | Purchase access to download area</title>
5+
<link rel="stylesheet" type="text/css" media="All" href="css/style.css" />
6+
</head>
7+
<body>
8+
9+
<div id="wrap">
10+
<h2>Purchase Access</h2>
11+
<p>Please click the button below to receive login details for the download area. <br />
12+
Already have an account? <a href="login.php">Login</a> here.</p>
13+
14+
Your PayPal Button Coder Here....
15+
16+
</div>
17+
18+
</body>
19+
</html>

ipn/ipn.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
mysql_connect("localhost", "root", "") or die(mysql_error());
4+
mysql_select_db("db_nepalstay") or die(mysql_error());
5+
6+
7+
// read the post from PayPal system and add 'cmd'
8+
$req = 'cmd=_notify-validate';
9+
foreach ($_POST as $key => $value) {
10+
$value = urlencode(stripslashes($value));
11+
$req .= "&$key=$value";
12+
}
13+
// post back to PayPal system to validate
14+
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
15+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
16+
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
17+
18+
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
19+
20+
21+
if (!$fp) {
22+
// HTTP ERROR
23+
} else {
24+
fputs ($fp, $header . $req);
25+
while (!feof($fp)) {
26+
$res = fgets ($fp, 1024);
27+
if (strcmp ($res, "VERIFIED") == 0) {
28+
29+
// PAYMENT VALIDATED & VERIFIED!
30+
31+
$email = $_POST['payer_email'];
32+
$password = mt_rand(1000, 9999);
33+
34+
mysql_query("INSERT INTO users (stay_email, user_pass_md5) VALUES('". mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error());
35+
36+
$to = $email;
37+
$subject = 'Download Area | Login credentials';
38+
$message = '
39+
40+
Thank you for your purchase
41+
42+
Your account information
43+
-------------------------
44+
Email: '.$email.'
45+
Password: '.$password.'
46+
-------------------------
47+
48+
You can now login at http://yourwebsite.com/PayPal/';
49+
$headers = 'From:[email protected]' . "\r\n";
50+
51+
mail($to, $subject, $message, $headers);
52+
53+
54+
55+
}
56+
57+
else if (strcmp ($res, "INVALID") == 0) {
58+
59+
// PAYMENT INVALID & INVESTIGATE MANUALY!
60+
61+
62+
$subject = 'Download Area | Invalid Payment';
63+
$message = '
64+
65+
Dear Administrator,
66+
67+
A payment has been made but is flagged as INVALID.
68+
Please verify the payment manualy and contact the buyer.
69+
70+
Buyer Email: '.$email.'
71+
';
72+
$headers = 'From:[email protected]' . "\r\n";
73+
74+
mail($to, $subject, $message, $headers);
75+
76+
}
77+
}
78+
fclose ($fp);
79+
}
80+
?>

ipn/login.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<title>Nettuts.com | Login</title>
5+
<link rel="stylesheet" type="text/css" media="All" href="css/style.css" />
6+
</head>
7+
<body>
8+
9+
<div id="wrap">
10+
11+
<?php
12+
13+
mysql_connect("localhost", "root", "") or die(mysql_error());
14+
mysql_select_db("db_nepalstay") or die(mysql_error());
15+
16+
if(isset($_POST['email']) && isset($_POST['password'])){
17+
// Verify
18+
$email = mysql_escape_string($_POST['email']);
19+
$password = md5($_POST['password']);
20+
21+
$gUser = mysql_query("SELECT * FROM stay_user WHERE user_email='".$email."' AND user_pass_md5='".$password."' LIMIT 1") or die(mysql_error());
22+
$verify = mysql_num_rows($gUser);
23+
24+
if($verify > 0){
25+
echo '<h2>Login Complete</h2>
26+
<p>Click here to download our program</p>';
27+
}else{
28+
echo '<h2>Login Failed</h2>
29+
<p>Sorry your login credentials are incorrect.';
30+
}
31+
}else{
32+
?>
33+
<h2>Login</h2>
34+
<p>Please enter your login credentials to get access to the download area</p>
35+
36+
<form method="post" action="">
37+
<fieldset>
38+
<label for="email">Email:</label><input type="text" name="email" value="" />
39+
<label for="password">Password:</label><input type="text" name="password" value="" />
40+
<input type="submit" value="Login" />
41+
</fieldset>
42+
</form>
43+
44+
<?php
45+
}
46+
?>
47+
48+
</div>
49+
50+
</body>
51+
</html>

0 commit comments

Comments
 (0)