skrill.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. function curPageName()
  3. {
  4. return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
  5. }
  6. function exec_ogp_module()
  7. {
  8. global $db,$view,$settings;
  9. $cart_id = $_GET['cart_id'];
  10. if(!empty($cart_id))
  11. {
  12. $orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
  13. if( !empty( $orders ) )
  14. {
  15. $cart['price'] = 0;
  16. foreach($orders as $order)
  17. {
  18. if( $order['qty'] > 1 )
  19. $order['invoice_duration'] = $order['invoice_duration']."s";
  20. $cart['price'] += $order['price'];
  21. if( !isset( $cart['name'] ) )
  22. $cart['name'] = $order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
  23. else
  24. $cart['name'] .= ' + '.$order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
  25. }
  26. $total = $cart['price']+($settings['tax_amount']/100*$cart['price']);
  27. if ($total === 0)
  28. {
  29. $db->query("UPDATE " . $table_prefix . "billing_carts
  30. SET paid=1
  31. WHERE cart_id=".$cart_id);
  32. $view->refresh("home.php?m=simple-billing&p=cart",0);
  33. }
  34. else
  35. {
  36. $s = ( isset($_SERVER['HTTPS']) and get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
  37. $p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
  38. $this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
  39. $current_folder_url = str_replace( curPageName(), "", $this_script);
  40. $lang_array = array('Danish' => 'DA',
  41. 'English' => 'EN',
  42. 'French' => 'FR',
  43. 'German' => 'DE',
  44. 'Polish' => 'PL',
  45. 'Russian' => 'RU',
  46. 'Spanish' => 'ES');
  47. $ogp_lang = !empty($_SESSION['users_lang']) ? $_SESSION['users_lang'] : $settings['panel_language'];
  48. $skrill_lang = 'EN';
  49. foreach($lang_array as $userlang => $langcode )
  50. {
  51. if($userlang == $ogp_lang)
  52. $skrill_lang = $langcode;
  53. }
  54. $url = "https://www.moneybookers.com/app/payment.pl";
  55. $ipn_url = $current_folder_url.'modules/simple-billing/skrill-ipn.php';
  56. $return_url = $current_folder_url.'home.php?m=simple-billing&p=cart';
  57. $amount = number_format( $total , 2 );
  58. $fields = array(
  59. 'pay_to_email' => urlencode($settings['skrill_email']),
  60. 'status_url' => urlencode($ipn_url),
  61. 'language' => $skrill_lang,
  62. 'amount' => urlencode($amount),
  63. 'currency' => $settings['currency'],
  64. 'detail1_description' => urlencode("CART ID: ".$cart_id),
  65. 'detail1_text' => urlencode($cart['name']),
  66. 'return_url' => urlencode($return_url),
  67. 'return_url_text' => urlencode(get_lang('back_to_your_cart')),
  68. 'return_url_target' => '3',
  69. 'cancel_url' => urlencode($return_url),
  70. 'cancel_url_target' => '3',
  71. 'merchant_fields' => 'cart_id',
  72. 'cart_id' => $cart_id
  73. );
  74. //url-ify the data for the POST
  75. foreach($fields as $key=>$value)
  76. {
  77. $fields_string .= $key.'='.$value.'&';
  78. }
  79. $fields_string = rtrim($fields_string, '&');
  80. $ch = curl_init();
  81. curl_setopt($ch, CURLOPT_URL, $url);
  82. curl_setopt($ch,CURLOPT_POST, 1);
  83. curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
  84. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  85. echo curl_exec($ch);
  86. curl_close($ch);
  87. echo "<h2>".get_lang_f('redirecting_to',get_lang('skrill'))."</h2>";
  88. echo "<img style='border:4px dotted white;background:black' src='modules/addonsmanager/loading.gif' width='180' height='180' /img><br><br>";
  89. }
  90. }
  91. }
  92. }
  93. ?>