- Joined
- Sep 19, 2011
- Messages
- 240
- Reaction score
- 35
Anyone got a fix?
<?php
function filter($var)
{
return stripslashes(htmlspecialchars($var));
}
require_once('paypal.class.php'); // include the class file
$p = new paypal_class;
$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (empty($_GET['action'])) $_GET['action'] = 'process';
switch ($_GET['action']) {
case 'process':
if(!isset($_POST['name']))
{
echo 'You need to enter in a username before you can purcahse VIP!';
die;
}
$swag = filter($_POST['name']);
$p->add_field('business', '[email protected]');
$p->add_field('return', 'http://localhost/me'.$_SERVER['HTTP_HOST']); //The success URL
$p->add_field('custom', $swag);
$p->add_field('cancel_return', 'http://localhost/vip'.$_SERVER['HTTP_HOST']); // The "canceled" URL
$p->add_field('notify_url', $this_script.'?action=ipn'); //The IPN URL, the URL pointing to THIS page.
$p->add_field('item_number', 'Hotel VIP');
$p->add_field('item_name', 'Hotel VIP');
$p->add_field('amount', '0.10');
$p->submit_paypal_post();
break;
case 'ipn':
if ($p->validate_ipn()) {
$host = "localhost";
$username = "root";
$password = "PIGSRUS123";
$dbname = "phoenix";
$connect = mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($dbname, $connect) or die("Could not connect to database, error: ".mysql_error());
mysql_query("UPDATE users SET vip = 1 WHERE username = '".$p->ipn_data['custom']."' LIMIT 1");
mysql_query("UPDATE users SET rank = 2 WHERE username = '".$p->ipn_data['custom']."' LIMIT 1");
}
break;
}
?>
<?php
class paypal_class {
var $last_error; // holds the last error encountered
var $ipn_log; // bool: log IPN results to text file?
var $ipn_log_file; // filename of the IPN log
var $ipn_response; // holds the IPN response from paypal
var $ipn_data = array(); // array contains the POST values for IPN
var $fields = array(); // array holds the fields to submit to paypal
public function paypal_class() {
// initialization constructor. Called when class is created.
$this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
$this->last_error = '';
$this->ipn_log_file = '.ipn_results.log';
$this->ipn_log = true;
$this->ipn_response = '';
// populate $fields array with a few default values. See the paypal
// documentation for a list of fields and their data types. These defaul
// values can be overwritten by the calling script.
$this->add_field('rm','2'); // Return method = POST
$this->add_field('cmd','_xclick');
}
public function add_field($field, $value) {
$this->fields["$field"] = $value;
}
public function submit_paypal_post() {
echo "<form method=\"post\" name=\"paypal_form\" ";
echo "action=\"".$this->paypal_url."\">\n";
foreach ($this->fields as $name => $value)
{
echo "<input type=\"hidden\" name=\"$name\" value=\"$value\"/>\n";
}
echo "Hey there! Please wait...<br />";
echo 'We are making a secure connection between you and PayPal...';
echo '</form>';
echo'
<script language="javascript">
window.onload = document.forms[\'paypal_form\'].submit();
</script>';
die;
}
public function validate_ipn() {
$url_parsed=parse_url($this->paypal_url);
$post_string = '';
foreach ($_POST as $field=>$value) {
$this->ipn_data["$field"] = $value;
$post_string .= $field.'='.urlencode(stripslashes($value)).'&';
}
$post_string.="cmd=_notify-validate"; // append ipn command
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if(!$fp) {
$this->last_error = "fsockopen error no. $errnum: $errstr";
$this->log_ipn_results(false);
return false;
} else {
// Post the data back to paypal
fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n");
fputs($fp, "Host: $url_parsed[host]\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string . "\r\n\r\n");
while(!feof($fp)) {
$this->ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}
if (eregi("VERIFIED",$this->ipn_response)) {
// Valid IPN transaction.
$this->log_ipn_results(true);
return true;
} else {
$this->last_error = 'IPN Validation Failed!';
$this->log_ipn_results(false);
return false;
}
}
public function log_ipn_results($success) {
if (!$this->ipn_log) return;
// Timestamp
$text = '['.date('m/d/Y g:i A').'] - ';
// Success or failure being logged?
if ($success) $text .= "SUCCESS!\n";
else $text .= 'FAIL: '.$this->last_error."\n";
// Log the POST variables
$text .= "IPN POST Vars from Paypal:\n";
foreach ($this->ipn_data as $key=>$value) {
$text .= "$key=$value, ";
}
// Log the response from the paypal server
$text .= "\nIPN Response from Paypal Server:\n ".$this->ipn_response;
// Write to log
$fp=fopen($this->ipn_log_file,'a');
fwrite($fp, $text . "\n\n");
fclose($fp);
}
public function dump_fields() {
echo "<h3>paypal_class->dump_fields() Output:</h3>";
echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">
<tr>
<td bgcolor=\"black\"><b><font color=\"white\">Field Name</font></b></td>
<td bgcolor=\"black\"><b><font color=\"white\">Value</font></b></td>
</tr>";
ksort($this->fields);
foreach ($this->fields as $key => $value) {
echo "<tr><td>$key</td><td>".urldecode($value)." </td></tr>";
}
echo "</table><br>";
}
}
Hello there... Since I don't have a hotel anymore, I am going to be releasing my automatic VIP script... Yes, this is a 'real' automatic VIP, not a exploit filled, after payment redirection, this is the real deal!
This script only works once the user has PAYED for the VIP, and you can edit the MySQL updates to what you want.. I have it set to:
PHP:mysql_query("UPDATE users SET vip = 1 WHERE username = '".$p->ipn_data['custom']."' LIMIT 1"); mysql_query("UPDATE users SET rank = 2 WHERE username = '".$p->ipn_data['custom']."' LIMIT 1");
Well, what's the download?
To view the content, you need to sign in or register
How do I use this ****?
Are you an idiot? Just put the folder 'swag_pp' into the main directory of your hotel's CMS, and where ever you want to put the purchase button, add this code:
PHP:<form action="swag_pp/paypal.php" method="post" name="paypal"> <label for="name"><b>Username:</b></label><br /> <input id="name" name="name" onclick="changeName()" type="text" value="<?php echo $_SESSION['username']; ?>" /><br /> <button name="submit" type="submit" name="buy" class="button" style="float:middle; onclick="return submitForm()">Buy VIP!</button></form>
Once you've done that, you're ready to go, and you don't have to worry about that fukin manual VIP again
This hasn't been tested yet, but I'll test it once I get my cash tomorrow so I can check it, but yeah, this is a release, and here are some images:
![]()
![]()
![]()
Once you click on 'Buy' it gets your PayPal details and sends it to my email... Nah, I'm joking, it makes a secure connection, and then allows the person to login through PayPal and pay, once they have payed, it'll update the script, and it'll run the MySQL querys, and you're all done!
There are no errors, I've tested it, except for the actual payment, but yeah, it's cool and If you need help PM me, REP/Like this if you find it helpful, I will be updating it so it's more, you know, good looking when it comes to the buy now button, and if there are errors, post here and I'll update and fix it ASAP.
Thanks to PayPal for some of the script!
UPDATE:
I almost forgot, once you've uploaded it, go into:
/swag_pp/paypal.php, find:
And replace with your email!PHP:
Also, find:
And change your DB details!PHP:if ($p->validate_ipn()) {![]()
Thanks for this.
But how to make the USD to EURO ?
Code://Checking Currency is USD if($payment_currency == '[B][I][COLOR="#FF0000"]USD[/COLOR][/I][/B]'){//Success