Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.45 KB | None | 0 0
  1. <?php
  2. define("_VALID_PHP", true);
  3. function debugPP($string)
  4. {
  5. $file = "debug.txt";
  6. $open = fopen($file, "a");
  7. fwrite($open, $string);
  8. }
  9. if (isset($_POST['payment_status'])) {
  10.  
  11. require_once('config.php');
  12. require_once('global.php');
  13. require_once('mail/PHPMailerAutoload.php');
  14.  
  15. set_time_limit(0);
  16. function verifyTxnId($txn_id, $odb)
  17. {
  18. $sql = $odb->prepare("SELECT COUNT(id) FROM `payment_logs` WHERE tid = :tid LIMIT 1");
  19. $sql -> execute(array(":tid" => $txn_id));
  20. if ($sql -> fetchColumn(0) > 0)
  21. return false;
  22. else
  23. return true;
  24.  
  25. }
  26.  
  27. $req = 'cmd=_notify-validate';
  28.  
  29. foreach ($_POST as $key => $value) {
  30. $value = urlencode(stripslashes($value));
  31. $req .= '&' . $key . '=' . $value;
  32.  
  33. }
  34. $demo = false;
  35. $url = 'www.paypal.com';
  36.  
  37. $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
  38. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  39. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  40. $fp = fsockopen($url, 80, $errno, $errstr, 30);
  41.  
  42. $payment_status = $_POST['payment_status'];
  43. $receiver_email = $_POST['business'];
  44. list($membership_id, $user_id) = explode("_", $_POST['item_number']);
  45. $mc_gross = $_POST['mc_gross'];
  46. $txn_id = $_POST['txn_id'];
  47.  
  48. debugPP("Selecting Price\n");
  49.  
  50. $getxn_id = verifyTxnId($txn_id, $odb);
  51. $pricesql = $odb -> prepare("SELECT `price` FROM `packages` WHERE id = :id");
  52. $pricesql -> execute(array(":id" => (int)$membership_id));
  53. $price = $pricesql -> fetchColumn(0);
  54.  
  55. debugPP("Selecting Client's PayPal Email\n");
  56.  
  57. $pp_emailsql = $odb -> query("SELECT `paypal` FROM `settings` LIMIT 1");
  58. $pp_email = $pp_emailsql->fetchColumn(0);
  59.  
  60. if (!$fp) {
  61. echo $errstr . ' (' . $errno . ')';
  62. } else {
  63. fputs($fp, $header . $req);
  64.  
  65. debugPP("Phase 1\n");
  66.  
  67. while (!feof($fp)) {
  68. $res = fgets($fp, 1024);
  69. debugPP("Phase 2\n");
  70. if (strcmp($res, "VERIFIED") == 0) {
  71. if (preg_match('/Completed/', $payment_status)) {
  72. debugPP("Phase 3\n");
  73. if($mc_gross == $price){
  74. debugPP("price check success!");
  75. $SQLGetUser = $odb -> prepare("SELECT `username` FROM `accounts` WHERE `id` = :id");
  76. $SQLGetUser -> execute(array(':id' => $user_id));
  77. $payerusername = $SQLGetUser -> fetchColumn(0);
  78. debugPP("Phase 6\n");
  79. $SQLGetUserInfo = $odb -> prepare("SELECT `username`,`email`,`rVPN`,`expire` FROM `accounts` WHERE `id` = :id LIMIT 1");
  80. $SQLGetUserInfo -> execute(array(':id' => $user_id));
  81. $userInfo = $SQLGetUserInfo -> fetch(PDO::FETCH_ASSOC);
  82. $userMail = $userInfo['email'];
  83. $userName = $userInfo['username'];
  84. $currpass = $userInfo['rVPN'];
  85. $currexpire = $userInfo['expire'];
  86. //GET PACKAGE DETAILS
  87. $SQLGetPackages = $odb -> prepare("SELECT * FROM `packages` WHERE `id` = :id LIMIT 1");
  88. $SQLGetPackages -> execute(array(':id' => $membership_id));
  89. $getInfo = $SQLGetPackages -> fetch(PDO::FETCH_ASSOC);
  90. $portforward = $getInfo['pfenabled'];
  91. $plength = $getInfo['length'];
  92. $unit = $getInfo['unit'];
  93. if ($currpass != 0 && $currexpire != 0) {
  94. $newExpire = strtotime("+{$plength} {$unit}", $currexpire);
  95.  
  96. $update1 = $odb -> prepare("UPDATE `accounts` SET `expire` = :expire WHERE `id` = :id");
  97. $update1 -> execute(array(':expire' => $newExpire, ':id' => $user_id));
  98.  
  99. $maildate = date("m-d-Y h:i:s A", $newExpire);
  100. //Mail VPN Information
  101. $mailcontent = 'Hello '.$userName.', <br><br> Your vpn account has been extended until <b>'.$maildate.'</b><br><br>Thank you!';
  102. $from = $gsetting -> getSiteMail($odb);
  103. $fromname = $gsetting -> getSiteTitle($odb);
  104. $mail = new PHPMailer;
  105. if ($rvpnmailer == 'php') {
  106. $mail->isSendmail();
  107. } else {
  108. $mail->isSMTP();
  109. $mail->SMTPSecure = $smtpauthtype;
  110. $mail->Host = $rshost;
  111. $mail->Port = $rsport;
  112. $mail->SMTPAuth = $smtpauthstat;
  113. $mail->Username = $rsuser;
  114. $mail->Password = $rspass;
  115. }
  116. $mail->setFrom($from, $fromname);
  117. $mail->addReplyTo($from, $fromname);
  118. $mail->addAddress($userMail, $userName);
  119. $mail->Subject = 'VPN Login Information';
  120. $mail->msgHTML($mailcontent);
  121. $mail->send();
  122. } else {
  123. $newExpire = strtotime("+{$plength} {$unit}");
  124. debugPP("Phase 7\n");
  125. $update1 = $odb -> prepare("UPDATE `accounts` SET `expire` = :expire WHERE `id` = :id");
  126. $update1 -> execute(array(':expire' => $newExpire, ':id' => $user_id));
  127. $update2 = $odb -> prepare("UPDATE `accounts` SET `pfoption` = :pfoption WHERE `id` = :id");
  128. $update2 -> execute(array(':pfoption' => $portforward, ':id' => $user_id));
  129. debugPP("Phase 8\n");
  130. $vpnPass = $rvpn -> genPass();
  131. //$update3 = $odb -> prepare("UPDATE `accounts` SET `rVPN` = :rvpn WHERE `id` = :id");
  132. //$update3 -> execute(array(':rvpn' => $vpnPass, ':id' => $user_id));
  133. debugPP("Phase 9\n");
  134. //Check if there an offline server and save action for it
  135. //$rvpn -> saveAction($odb, 'create', $user_id, $vpnPass, 0, 0);
  136. //debugPP("Phase 10\n");
  137. //Create VPN Account
  138. $rvpn -> createVPNAccount($rad, $user_id, $vpnPass, $encryptionKey);
  139. debugPP("Phase 11\n");
  140. //Mail VPN Information
  141.  
  142. //$mailcontent = 'Hello, <br><br> Below you can find your vpn client login information: <br>Username: '.$user_id.'<br>Password: '.$vpnPass.'<br><br>Thank you!';
  143. $mailcontent = 'Hello '.$userName.',
  144. <br>
  145. PLEASE READ THIS EMAIL IN FULL AND PRINT IT FOR YOUR RECORDS
  146. <br>
  147. Thank you for your order! Your secure vpn account has now been setup and this email contains all the information you will need in order to begin using your account.
  148. <br>
  149. <u>New Account Information</u>
  150. <br>
  151. <strong>VPN Subscription Length:</strong> '.$length.' '.$unit.'<br>
  152. <strong>Expiration Date/Time:</strong> '.date('m/d/Y H:i:s', $newExpire).'<br>
  153. <u>VPN Login Details</u><br>
  154. <strong>VPN Username:</strong> '.$user_id.'<br>
  155. <strong>VPN Password:</strong> '.$vpnPass.'<br>
  156.  
  157. <u>VPN Server Access Details:</u><br>
  158.  
  159. All the resources you need to use our VPN network can be found on the Downloads tab right after you login to <a href="https://www.crypticvpn.com">CrypticVPN.com</a><br>
  160. <u>Windows Users (XP/Vista/7/8/10) :</u><br>
  161.  
  162. Windows Users can use the CrypticVPN Client.<br>
  163. Once you download the CrypticVPN client, make sure you run it as Administrator by right clicking on it and selecting "Run as Administrator".
  164. <br>
  165. It may prompt you to install a new driver, click "Yes" and wait around 1 minute for it to finish downloading and installing OpenVPN.
  166. <br>
  167. Once that finishes close CrypticVPN and relaunch it and you should be able to use the client to connect to our servers.
  168. <br>
  169. If you do not want to use the CrypticVPN Client you can download the appropriate OpenVPN software <a href="https://openvpn.net/index.php/open-source/downloads.html">here</a> and use the config files from our website.
  170. <br><u>OSX (Mac) Users:</u>
  171. <br> Mac Users can download the TunnelBlick client from <a href="https://tunnelblick.net/downloads.html">here</a> and get the VPN config files from our website.
  172. <br><u>Linux Users:</u>
  173. <br>Linux users can install OpenVPN and use the Config files located on our website.
  174.  
  175. <br><u>Smartphones/Other Devices:</u>
  176. <br> If you have a smartphone such as an iPhone or Android, you can install the official OpenVPN Client and use the config files located on our website.
  177. <br>
  178. Thank you for choosing CrypticVPN.
  179. <br>
  180. Best regards,
  181. <br>
  182. - CrypticVPN Staff';
  183. $from = $gsetting -> getSiteMail($odb);
  184. $fromname = $gsetting -> getSiteTitle($odb);
  185. debugPP("Phase 12\n");
  186. $mail = new PHPMailer;
  187. if ($rvpnmailer == 'php') {
  188. $mail->isSendmail();
  189. } else {
  190. $mail->isSMTP();
  191. $mail->SMTPSecure = $smtpauthtype;
  192. $mail->Host = $rshost;
  193. $mail->Port = $rsport;
  194. $mail->SMTPAuth = true;
  195. $mail->Username = $rsuser;
  196. $mail->Password = $rspass;
  197. }
  198. $mail->setFrom($from, $fromname);
  199. $mail->addReplyTo($from, $fromname);
  200. $mail->addAddress($userMail, $userName);
  201. $mail->Subject = 'VPN Login Information';
  202. $mail->msgHTML($mailcontent);
  203. $mail->send();
  204. }
  205. $data = array(
  206. ':tid' => $txn_id,
  207. ':plan' => $membership_id,
  208. ':proccessor' => 'Paypal',
  209. ':user' => $user_id,
  210. ':paid' => $mc_gross,
  211. );
  212. $odb -> setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
  213. $insertsql = $odb -> prepare("INSERT INTO `payment_logs` VALUES(NULL, :tid, :user, :proccessor, :paid, :plan, UNIX_TIMESTAMP())");
  214. $insertsql -> execute($data);
  215. debugPP("Phase 14\n");
  216. }
  217. }else{
  218. debugPP("Price Check Failed");
  219. }
  220.  
  221. }
  222. }
  223. fclose($fp);
  224. }
  225. }
  226. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement