PageRenderTime 24ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/cp/chatusers/makepayment.php

https://bitbucket.org/rubbystar/carimod
PHP | 206 lines | 122 code | 44 blank | 40 comment | 20 complexity | 2ba7646a8482021597ce08293e33b0fb MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, GPL-3.0
  1. <? if (!isset($_COOKIE["id"]) || $_COOKIE['usertype']!="chatusers" )
  2. {
  3. header("location: ../../login.php");
  4. } else{
  5. include("../../dbase.php");
  6. $result=mysql_query("SELECT user from chatusers WHERE id='$_COOKIE[id]' LIMIT 1");
  7. while($row = mysql_fetch_array($result))
  8. { $username=$row[user]; }
  9. }
  10. ?>
  11. <?
  12. include("_members.header.php");
  13. ?><style type="text/css">
  14. <!--
  15. body,td,th {
  16. color: #FFFFFF;
  17. font-family: Arial, Helvetica, sans-serif;
  18. font-size: 14px;
  19. }
  20. body {
  21. background-color: #8F0000;
  22. }
  23. a:link {
  24. color: #FFFFFF;
  25. text-decoration: none;
  26. }
  27. a:visited {
  28. text-decoration: none;
  29. color: #FFFFFF;
  30. }
  31. a:hover {
  32. text-decoration: none;
  33. color: #FFCC00;
  34. }
  35. a:active {
  36. text-decoration: none;
  37. color: #FFFFFF;
  38. }
  39. -->
  40. </style>
  41. <table width="720" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#8F0000" class="form_definitions">
  42. <tr valign="top">
  43. <td>
  44. <?
  45. ob_start();
  46. // read the post from PayPal system and add 'cmd'
  47. $req = 'cmd=_notify-synch';
  48. $tx_token = $_GET['tx'];
  49. $auth_token = "ZpnErSeMfYzm_hMXS9ldyHtbLlp5t15bww03vmIK-x1k9sfdZ6SyILPuStG";
  50. $req .= "&tx=$tx_token&at=$auth_token";
  51. // post back to PayPal system to validate
  52. $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  53. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  54. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  55. $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
  56. // If possible, securely post back to paypal using HTTPS
  57. // Your PHP server will need to be SSL enabled
  58. // $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
  59. if (!$fp) {
  60. // HTTP ERROR
  61. } else {
  62. fputs ($fp, $header . $req);
  63. // read the body data
  64. $res = '';
  65. $headerdone = false;
  66. while (!feof($fp)) {
  67. $line = fgets ($fp, 1024);
  68. if (strcmp($line, "\r\n") == 0) {
  69. // read the header
  70. $headerdone = true;
  71. }
  72. else if ($headerdone)
  73. {
  74. // header has been read. now read the contents
  75. $res .= $line;
  76. }
  77. }
  78. // parse the data
  79. $lines = explode("\n", $res);
  80. $keyarray = array();
  81. if (strcmp ($lines[0], "SUCCESS") == 0) {
  82. //for ($i=1; $i<count($lines);$i++){
  83. //list($key,$val) = explode("=", $lines[$i]);
  84. //$keyarray[urldecode($key)] = urldecode($val);
  85. //}
  86. //// check the payment_status is Completed
  87. //// check that txn_id has not been previously processed
  88. //// check that receiver_email is your Primary PayPal email
  89. //// check that payment_amount/payment_currency are correct
  90. //// process payment
  91. //$firstname = $keyarray['first_name'];
  92. //$lastname = $keyarray['last_name'];
  93. //$itemname = $keyarray['item_name'];
  94. //$amount = $keyarray['payment_gross'];
  95. //
  96. //echo ("<p><h3>Thank you for your purchase!</h3></p>");
  97. //
  98. //echo ("<b>Payment Details</b><br>\n");
  99. //echo ("<li>Name: $firstname $lastname</li>\n");
  100. //echo ("<li>Item: $itemname</li>\n");
  101. //echo ("<li>Amount: $amount</li>\n");
  102. //echo ("");
  103. //dl_file("full/whyinstrumental.mp3");
  104. include("../../dbase.php");
  105. $result=mysql_query("SELECT user,money from chatusers WHERE id='$_COOKIE[id]' LIMIT 1");
  106. while($row = mysql_fetch_array($result))
  107. { $username=$row['user'];$money=$row['money']; }
  108. if (strstr($_REQUEST[amt],".") == "")
  109. {
  110. echo $money=$money + $_REQUEST[amt].".00";
  111. }
  112. else
  113. {
  114. $money=$money + $_REQUEST[amt];
  115. }
  116. echo $sql="Update chatusers set money=$money where user='$username'";
  117. $res=mysql_query($sql);
  118. mysql_query("insert into payments (ammount, details) values ('".$_REQUEST['amt']."', '$username')");
  119. echo '<script>window.location="buyminutes.php"</script>';
  120. }
  121. else if (strcmp ($lines[0], "FAIL") == 0) {
  122. //var_dump($_REQUEST);
  123. // log for manual investigation
  124. include("../../dbase.php");
  125. $result=mysql_query("SELECT user,money from chatusers WHERE id='$_COOKIE[id]' LIMIT 1");
  126. while($row = mysql_fetch_array($result))
  127. { $username=$row['user'];$money=$row['money']; }
  128. if (strstr($_REQUEST[amt],".") == "")
  129. {
  130. echo $money=$money + $_REQUEST[amt].".00";
  131. }
  132. else
  133. {
  134. $money=$money + $_REQUEST[amt];
  135. }
  136. $sql="Update chatusers set money=$money where user='$username'";
  137. $res=mysql_query($sql);
  138. mysql_query("insert into payments (ammount, details) values ('".$_REQUEST['amt']."', '$username')");
  139. echo '<script>window.location="buyminutes.php"</script>';
  140. }
  141. }
  142. fclose ($fp);
  143. //if ($_REQUEST['st'] == 'Pending' || $_REQUEST['st'] == 'Completed')
  144. //{
  145. //
  146. //}
  147. //var_dump($_REQUEST);
  148. //
  149. ?>
  150. </td>
  151. </tr>
  152. <tr>
  153. <td class="form_definitions"> <p>&nbsp;</p> </td>
  154. </tr>
  155. </table>
  156. <br>
  157. </td>
  158. </tr>
  159. </table>
  160. <?
  161. include("_members.footer.php");
  162. ?>