add_to_cart.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2010 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function exec_ogp_module()
  25. {
  26. global $db;
  27. $settings = $db->getSettings();
  28. require('includes/config.inc.php');
  29. $service_id = $_REQUEST['service_id'];
  30. // Query for Selected service info.
  31. $qry_service = "SELECT DISTINCT service_id, home_cfg_id, mod_cfg_id, service_name, remote_server_id, slot_max_qty, slot_min_qty, price_hourly, price_monthly, price_year, description, img_url FROM ".$table_prefix."billing_services WHERE service_id=".$service_id;
  32. $result_service = $db->resultQuery($qry_service);
  33. $row_service = $result_service[0];
  34. //Compiling info about invoice to create an invoice order.
  35. // remote server value
  36. $remote_server_id = $row_service['remote_server_id'];
  37. // request ogp user to create a home path.
  38. $r_server = $db->getRemoteServer($remote_server_id);
  39. $ogp_user = $r_server['ogp_user'];
  40. // request the user name and the game name to generate a game home name.
  41. $home_name = $_POST['home_name'];
  42. //Calculating Price
  43. if ($_POST['invoice_duration'] == "hour")
  44. {
  45. $price_slot=$row_service['price_hourly'];
  46. }
  47. elseif ($_POST['invoice_duration'] == "month")
  48. {
  49. $price_slot=$row_service['price_monthly'];
  50. }
  51. elseif ($_POST['invoice_duration'] == "year")
  52. {
  53. $price_slot=$row_service['price_year']*12;
  54. }
  55. $price = $_POST['max_players']*$price_slot*$_POST['qty'];
  56. //Game Server Values
  57. $ip_id = $_POST['ip_id'];
  58. $ip = $db->getIpById($ip_id);
  59. $max_players = $_POST['max_players'];
  60. $qty = $_POST['qty'];
  61. $invoice_duration = $_POST['invoice_duration'];
  62. $user_id = $_SESSION['user_id'];
  63. $remote_control_password = $_POST['remote_control_password'];
  64. $ftp_password = $_POST['ftp_password'];
  65. $tax_amount = $settings['tax_amount'];
  66. $currency = $settings['currency'];
  67. global $view;
  68. if( isset( $_POST["add_to_cart"] ) )
  69. {
  70. if( isset( $_SESSION['CART'] ) )
  71. {
  72. $i = count( $_SESSION['CART'] );
  73. $i++;
  74. }
  75. else
  76. {
  77. $i = 0;
  78. }
  79. $_SESSION['CART'][$i] = array( "cart_id" => $i,
  80. "service_id" => $service_id,
  81. "home_name" => $home_name,
  82. "ip" => $ip_id,
  83. "max_players" => $max_players,
  84. "qty" => $qty,
  85. "invoice_duration" => $invoice_duration,
  86. "price" => $price,
  87. "remote_control_password" => $remote_control_password,
  88. "ftp_password" => $ftp_password,
  89. "tax_amount" => $tax_amount,
  90. "currency" => $currency,
  91. "paid" => 0);
  92. echo '<meta http-equiv="refresh" content="0;url=?m=billing&amp;p=cart">';
  93. }
  94. }
  95. ?>