paygol.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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;
  9. $settings = $db->getSettings();
  10. $cart_id = $_GET['cart_id'];
  11. if(!empty($cart_id))
  12. {
  13. $orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
  14. if( !empty( $orders ) )
  15. {
  16. $cart['price'] = 0;
  17. foreach($orders as $order)
  18. {
  19. if( $order['qty'] > 1 )
  20. $order['invoice_duration'] = $order['invoice_duration']."s";
  21. $cart['price'] += $order['price'];
  22. if( !isset( $cart['name'] ) )
  23. $cart['name'] = $order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
  24. else
  25. $cart['name'] .= ' + '.$order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
  26. }
  27. $total = $cart['price']+($settings['tax_amount']/100*$cart['price']);
  28. if ($total === 0)
  29. {
  30. $db->query("UPDATE " . $table_prefix . "billing_carts
  31. SET paid=1
  32. WHERE cart_id=".$cart_id);
  33. $view->refresh("home.php?m=billing&p=cart",0);
  34. }
  35. else
  36. {
  37. $s = ( isset($_SERVER['HTTPS']) and get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
  38. $p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
  39. $this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
  40. $current_folder_url = str_replace( curPageName(), "", $this_script);
  41. echo '<script src="http://www.paygol.com/micropayment/js/paygol.js" type="text/javascript"></script>'.
  42. '<form name="pg_frm">'.
  43. ' <input type="hidden" name="pg_serviceid" value="'.$settings['paygol_service_id'].'">'."\n".
  44. ' <input type="hidden" name="pg_currency" value="'.$settings['currency'].'">'."\n".
  45. ' <input type="hidden" name="pg_name" value=\''.$cart['name'].'\'>'."\n".
  46. ' <input type="hidden" name="pg_custom" value="'.$cart_id.'">'."\n".
  47. ' <input type="hidden" name="pg_price" value="'.number_format( $total , 2 ).'">'."\n".
  48. ' <input type="hidden" name="pg_return_url" value="'.urlencode($this_script.'?m=billing&p=cart').'">'."\n".
  49. ' <input type="hidden" name="pg_cancel_url" value="'.$this_script.'?m=billing&p=cart">'."\n".
  50. ' <input type="hidden" name="pg_notify_url" value="'.$current_folder_url.'modules/billing/paygol-ipn.php">'."\n".
  51. ' <input type="image" name="pg_button" class="paygol" src="http://www.paygol.com/micropayment/img/buttons/150/black_en_pbm.png"'.
  52. ' border="0" onClick="pg_reDirect(this.form)">'."\n".
  53. '</form>';
  54. }
  55. }
  56. }
  57. }
  58. ?>