Jump to content
MakeWebGames

Placebo

Members
  • Posts

    6
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Placebo

  1. IPN.php <?php // CONFIG: Enable debug mode. This means we'll log requests into 'ipn.log' in the same directory. // Especially useful if you encounter network errors or other intermittent problems with IPN (validation). // Set this to 0 once you go live or don't require logging. define("DEBUG", 1); // Set to 0 once you're ready to go live define("USE_SANDBOX", 1); define("LOG_FILE", "ipn.log"); // Read POST data // reading posted data directly from $_POST causes serialization // issues with array data in POST. Reading raw POST data from input stream instead. $raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $keyval) { $keyval = explode ('=', $keyval); if (count($keyval) == 2) $myPost[$keyval[0]] = urldecode($keyval[1]); } // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&$key=$value"; } // Post IPN data back to PayPal to validate the IPN data is genuine // Without this step anyone can fake IPN data if(USE_SANDBOX == true) { $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; } else { $paypal_url = "https://www.paypal.com/cgi-bin/webscr"; } $ch = curl_init($paypal_url); if ($ch == FALSE) { return FALSE; } curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); if(DEBUG == true) { curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLINFO_HEADER_OUT, 1); } // CONFIG: Optional proxy configuration //curl_setopt($ch, CURLOPT_PROXY, $proxy); //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); // Set TCP timeout to 30 seconds curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); // CONFIG: Please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path // of the certificate as shown below. Ensure the file is readable by the webserver. // This is mandatory for some environments. //$cert = __DIR__ . "./cacert.pem"; //curl_setopt($ch, CURLOPT_CAINFO, $cert); $res = curl_exec($ch); if (curl_errno($ch) != 0) // cURL error { if(DEBUG == true) { error_log(date('[Y-m-d H:i e] '). "Can't connect to PayPal to validate IPN message: " . curl_error($ch) . PHP_EOL, 3, LOG_FILE); } curl_close($ch); exit; } else { // Log the entire HTTP response if debug is switched on. if(DEBUG == true) { error_log(date('[Y-m-d H:i e] '). "HTTP request of validation request:". curl_getinfo($ch, CURLINFO_HEADER_OUT) ." for IPN payload: $req" . PHP_EOL, 3, LOG_FILE); error_log(date('[Y-m-d H:i e] '). "HTTP response of validation request: $res" . PHP_EOL, 3, LOG_FILE); } curl_close($ch); } // Inspect IPN validation result and act accordingly // Split response headers and payload, a better way for strcmp $tokens = explode("\r\n\r\n", trim($res)); $res = trim(end($tokens)); if (strcmp ($res, "VERIFIED") == 0) { // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; include("DBController.php"); $db = new DBController(); // check whether the payment_status is Completed $isPaymentCompleted = false; if($payment_status == "Completed") { $isPaymentCompleted = true; } // check that txn_id has not been previously processed $isUniqueTxnId = false; $param_type="s"; $param_value_array = array($txn_id); $result = $db->runQuery("SELECT * FROM payment WHERE txn_id = ?",$param_type,$param_value_array); if(empty($result)) { $isUniqueTxnId = true; } // check that receiver_email is your PayPal email // check that payment_amount/payment_currency are correct if($isPaymentCompleted) { ///ALTER THIS QUERY TO MATCH YOUR INSERT QUERY $param_type = "sssdss"; $param_value_array = array($item_number, $item_name, $payment_status, $payment_amount, $payment_currency, $txn_id); $payment_id = $db->insert("INSERT INTO payment(item_number, item_name, payment_status, payment_amount, payment_currency, txn_id) VALUES(?, ?, ?, ?, ?, ?)", $param_type, $param_value_array); error_log(date('[Y-m-d H:i e] '). "Verified IPN: $req ". PHP_EOL, 3, LOG_FILE); } // process payment and mark item as paid. if(DEBUG == true) { error_log(date('[Y-m-d H:i e] '). "Verified IPN: $req ". PHP_EOL, 3, LOG_FILE); } } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation // Add business logic here which deals with invalid IPN messages if(DEBUG == true) { error_log(date('[Y-m-d H:i e] '). "Invalid IPN: $req" . PHP_EOL, 3, LOG_FILE); } } ?> DBController.php <?php class DBController { private $host = "host"; private $user = "username"; private $password = "password"; private $database = "dbname"; private $conn; function __construct() { $this->conn = $this->connectDB(); } function connectDB() { $conn = mysqli_connect($this->host, $this->user, $this->password, $this->database); return $conn; } function runQuery($query, $param_type, $param_value_array) { $sql = $this->conn->prepare($query); $this->bindQueryParams($sql, $param_type, $param_value_array); $sql->execute(); $result = $sql->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $resultset[] = $row; } } if (! empty($resultset)) { return $resultset; } } function bindQueryParams($sql, $param_type, $param_value_array) { $param_value_reference[] = & $param_type; for ($i = 0; $i < count($param_value_array); $i ++) { $param_value_reference[] = & $param_value_array[$i]; } call_user_func_array(array( $sql, 'bind_param' ), $param_value_reference); } function insert($query, $param_type, $param_value_array) { $sql = $this->conn->prepare($query); $this->bindQueryParams($sql, $param_type, $param_value_array); $sql->execute(); } } ?> read the comments in it as you have sandbox testing mode and a debug file logger to configure at the top, you ipn is like mine was old! Is the IPN.php and a files called DBController.php that found very handy to adapt
  2. So been having a play around over the last few weeks with a Police Feature. Got basic version up and running so far. Each round has it own Police Station and Independent Police Force. The Police Station can utilize four Main officers every 30Mins (30Min Shift rotation). May set this to be randomised to alter shift lengths Each Officer has their own unique attribute stats for Observation/Bribe/Street Activity & Drug Market Activity. Each of these attributes are effected by how long the officer has been on shift, The longer on Shift the more fatigued they get, thus lowering their observation & activity and increasing the likelihood they will accept a bribe. Bribe part is still being worked on so not currently active. The activity of the Police can be seen from the Police Station page which gives a run down of on duty officers, and the Stations Activity in the Drug market and on the Streets. Play it right and carry out actions when the stations activity has reduced. Currently though Police are monitoring the Drug Market on the street watching for people making transactions. They are also watching the Streets for any other criminal Activities/Fighting. Get caught and you get held up for a given amount of time for questioning by the police, which prevents you moving any Drugs or Cash you have leaving them open to being stolen by someone else.
  3. Funny you say that they are the games that got me into coding. (that is if we both thinking a guy that used the handle AeroCloud? i used to be a mod on the games forums at one point and coded a app that actually boted the game, which was kinda naughty... but upside i admitted it to him and pointed out some coding issues that allowed me to glitch the hell out his cash generating script. And i have to be honest i felt bad for using the name but i couldn't find a name that i felt fitted.
  4. its going i got the Hint with someone Saying None your Business 😅
  5. It doesn't surprise me with the typos. 🤣🤣 the css is a bit of a hash-up at moment due to wanting to look into responsive designs and i know very little about it until recently. The time out issue is a new one on me hopefully nothing site related, im yet to come across such issue recently. Also working on a help/user guide at moment very bitty and some of it is pigeon English most likely as i typed it in a rush and haven't updated. cheers for the input so far, seem like too nice and polite bunch really....was expecting a bit abuse
  6. Ok so.. been playing around with making this as a hobby for to many years to count. Rebranded the game multiple times now most recently in last month. https://www.streetwarz.co.uk 100% self taught in all coding and has been alot of swearing and head banging over the years. Decided with everything that's going on and with the spare time to dig out the scripts and put them back online and redo it all again. Still bit clunky in places, bearing in mind until a few months ago i hadn't touched the scripts in 8year or so... Currently trying to get head around making it mobile responsive and bring scripting back upto date. It is very basic on theme, personally not a fan of high graphics usage slowing pages down, but this may change if i get the core scripting ever completed. Game Features: Follower Stat Training (Attack and Defensive Stats) Follower Recruitment (Thug/Dealer/Pimp) Various Shops - Charm, Ring, Weapons, Corner Shop To buy account addons (using ingame money not real money). Drug Market - With historical & live Drug yield & value displays. Banking System - Keep your cash safe Private Investor - to Auto invest cash funds Mobs - Create a Mob, Invite Others and use the mob to generate followers/cash/Homies for all your mob members and more still in the works... Any feedback/guidance or even abuse is welcomed...
×
×
  • Create New...