Advertisement
Guest User

coding sent email

a guest
Nov 29th, 2017
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. <?php
  2.  
  3. include("dbconn.php");
  4. require("phpmailer/PHPMailerAutoload.php");
  5.  
  6. class ipnn
  7. {
  8.  
  9. public function __construct($mode = 'sandbox')
  10. {
  11.  
  12. if($mode == 'sandbox')
  13. $this->_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
  14.  
  15. else
  16. $this->_url = 'https://www.paypal.com/cgi-bin/webscr';
  17. }
  18.  
  19. public function run()
  20. {
  21.  
  22. $raw_post_data = file_get_contents('php://input');
  23. $raw_post_array = explode('&', $raw_post_data);
  24. $_POST = array();
  25.  
  26. foreach ($raw_post_array as $keyval)
  27. {
  28. $keyval = explode ('=', $keyval);
  29. if (count($keyval) == 2)
  30. $_POST[$keyval[0]] = urldecode($keyval[1]);
  31. }
  32.  
  33.  
  34. $postFields = 'cmd=_notify-validate';
  35. if(function_exists('get_magic_quotes_gpc'))
  36. {
  37. $get_magic_quotes_exists = true;
  38. }
  39. //var_dump($postFields);die;
  40.  
  41. //cmd=_notify-validate&param=value&param2=value2;
  42. foreach ($_POST as $key => $value)
  43. {
  44. if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1)
  45. {
  46. $value = urlencode(stripslashes($value));
  47. }
  48. else
  49. {
  50. $value = urlencode($value);
  51. }
  52.  
  53. $postFields .= "&$key=$value";
  54. }
  55. $paypalUrl= "https://www.sandbox.paypal.com/cgi-bin/webscr";
  56. $ch = curl_init($paypalUrl);
  57.  
  58. curl_setopt_array($ch, array(
  59. CURLOPT_URL => $this->_url,
  60. CURLOPT_RETURNTRANSFER => true,
  61. CURLOPT_SSL_VERIFYPEER => false,
  62. CURLOPT_POST => true,
  63. CURLOPT_POSTFIELDS => $postFields
  64. ));
  65.  
  66. $result = curl_exec($ch);
  67. curl_close($ch);
  68.  
  69. $tokens = explode("\r\n\r\n", trim($result));
  70. $result = trim(end($tokens));
  71.  
  72. if (strcmp($result, "VERIFIED") == 0 || strcasecmp($result, "VERIFIED") == 0)
  73. {
  74. include("dbconn.php");
  75.  
  76. $mail = new PHPMailer();
  77.  
  78. // set mailer to use SMTP
  79. $mail->IsSMTP();
  80. $mail->Debugoutput = 'html';
  81. // As this email.php script lives on the same server as our email server
  82. // we are setting the HOST to localhost
  83. $mail->Host = "smtp.gmail.com"; // specify main and backup server
  84. $mail->Port = 587;
  85. $mail->SMTPAuth = true; // turn on SMTP authentication
  86.  
  87. // When sending email using PHPMailer, you need to send from a valid email address
  88. // In this case, we setup a test email account with the following credentials:
  89. // email: send_from_PHPMailer@bradm.inmotiontesting.com
  90. // pass: password
  91. $mail->Username = "atomsphera1@gmail.com"; // SMTP username
  92. $mail->Password = "pentium123"; // SMTP password
  93. $mail->setFrom('Football_Ticket@Fam.com', 'Nazmi Mohamad');
  94.  
  95. $item_number = $_POST['item_number'];
  96. $item_name = $_POST['item_name'];
  97. $txn_id = $_POST['txn_id'];
  98. $payment_gross = $_POST['mc_gross'];
  99. $currency_code = $_POST['mc_currency'];
  100. $payment_status = $_POST['payment_status'];
  101. $payer_email = $_POST['payer_email'];
  102. $payer_status = $_POST['payer_status'];
  103. $payer_id = $_POST['payer_id'];
  104. $ic = $_POST['custom'];
  105. $gameid = $_POST['quantity'];
  106. $payment_date = date('Y-m-d H:i:s');
  107.  
  108. $sql5 = "SELECT * FROM pay WHERE txn_id = '$txn_id'";
  109. $query5 = mysqli_query($dbconn, $sql5);
  110. $row5 = mysqli_num_rows($query5);
  111.  
  112. if ($row5 > 0)
  113. {
  114. echo "Duplicate transaction ID occured so we killed the IPN script. \n\n\n$req";
  115. exit();
  116. }
  117. else
  118. {
  119.  
  120. $insert = mysqli_query($dbconn, "INSERT INTO pay VALUES('".''."','".$txn_id."','".$item_number."','".$item_name."','".$payment_gross."','".$currency_code."','".$payment_status."','".$payer_id."','".$payer_email."','".$payer_status."','".$ic."','".$payment_date."')");
  121.  
  122. $a = "<img src='qr_img.php?d=$ic,$item_number,$item_name,$payment_status,$payment_gross'>";
  123.  
  124. echo "Your payment has been recorded!";
  125.  
  126. //$mail->From = $email;
  127.  
  128. // below we want to set the email address we will be sending our email to.
  129. $mail->addAddress('bobby.mieyehh2723@gmail.com');
  130. //$to_array = explode(',', $to);
  131. //foreach($to_array as $address)
  132. //{
  133. // $mail->addAddress($address, 'Web Enquiry');
  134. //}
  135.  
  136. // set word wrap to 50 characters
  137. $mail->WordWrap = 50;
  138. // set email format to HTML
  139. $mail->IsHTML(true);
  140.  
  141. //$mail->Subject = "You have received feedback from your website!";
  142.  
  143. // $message is the user's message they typed in
  144. // on our contact us page. We set this variable at
  145. // the top of this page with:
  146. // $message = $_REQUEST['message'] ;
  147. $subject = 'Your Payment Receipt';
  148. $mail->Subject = $subject;
  149. $mail->AltSubject = $subject;
  150. $mail->AddEmbeddedImage('qr_img.php?d=$ic,$item_number,$item_name,$payment_status,$payment_gross', 'qr');
  151. $mail->Body = "<img src=\"cid:qr\" />, $payment_status, $item_name, $ic, $payment_gross";
  152. $mail->AltBody = "<img src=\"cid:qr\" />, $payment_status, $item_name, $ic, $payment_gross";
  153.  
  154. if(!$mail->Send())
  155. {
  156. echo "Message could not be sent. <p>";
  157. echo "Mailer Error: " . $mail->ErrorInfo;
  158. exit;
  159. }
  160.  
  161. echo "Message has been sent";
  162.  
  163. }
  164.  
  165. mysqli_close($dbconn);
  166. }
  167.  
  168. $fh = fopen('result.txt', 'w');
  169. fwrite($fh, $result . ' -- ' . $postFields);
  170. fclose($fh);
  171.  
  172. //echo $result;
  173. //echo $postFields;
  174. echo "<table style=color:#FFF> <tr> <td>";
  175. echo "<img src='qr_img.php?d=$ic,$item_number,$item_name,$payment_status,$payment_gross'> </td> </tr>";
  176. echo"<tr><td>Identication Number: </td>";
  177. echo"<td>".$ic."</td></tr>";
  178. echo"<tr><td>Your Email: </td>";
  179. echo"<td>".$payer_email."</td></tr>";
  180. echo"<tr><td>Payment: </td>";
  181. echo"<td>".$payment_gross."</td></tr>";
  182. echo"<tr><td>Payment Status: </td>";
  183. echo"<td>".$payment_status."</td></tr>";
  184. echo"<tr><td>Payer Status: </td>";
  185. echo"<td>".$payer_status."</td></tr>";
  186. echo"<tr><td>Payment Date: </td>";
  187. echo"<td>".$payment_date."</td></tr>";
  188. echo"<tr><td>Payment Date: </td>";
  189. echo"<td>".$gameid."</td></tr>";
  190. echo"<br><tr><td>"."<input type=button value=Print class='btn btn-primary' style='width:80px'>"."</td></tr>";
  191.  
  192.  
  193.  
  194.  
  195. }
  196. }
  197.  
  198.  
  199.  
  200.  
  201. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement