add_to_cart.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. else
  56. {
  57. $price_slot=$row_service['price_monthly'];
  58. }
  59. //Game Server Values
  60. $ip_id = $_POST['ip_id'];
  61. $ip = $db->getIpById($ip_id);
  62. $max_players = $_POST['max_players'];
  63. $qty = $_POST['qty'];
  64. $invoice_duration = $_POST['invoice_duration'];
  65. $user_id = $_SESSION['user_id'];
  66. $remote_control_password = $_POST['remote_control_password'];
  67. $ftp_password = $_POST['ftp_password'];
  68. $tax_amount = $settings['tax_amount'];
  69. $currency = $settings['currency'];
  70. $qry_services = "SELECT * FROM OGP_DB_PREFIXbilling_services".$where_service_id;
  71. $services = $db->resultQuery($qry_services);
  72. foreach ($services as $key => $row) {
  73. if($max_players < $row['slot_min_qty'] || $qty < 1){
  74. $max_players = $row['slot_min_qty'];
  75. $qty = 1;
  76. }
  77. }
  78. $price = $max_players*$price_slot*$qty;
  79. global $view;
  80. if( isset( $_POST["add_to_cart"] ) )
  81. {
  82. if( isset( $_SESSION['CART'] ) )
  83. {
  84. $i = count( $_SESSION['CART'] );
  85. $i++;
  86. }
  87. else
  88. {
  89. $i = 0;
  90. }
  91. $_SESSION['CART'][$i] = array( "cart_id" => $i,
  92. "service_id" => $service_id,
  93. "home_name" => $home_name,
  94. "ip" => $ip_id,
  95. "max_players" => $max_players,
  96. "qty" => $qty,
  97. "invoice_duration" => $invoice_duration,
  98. "price" => $price,
  99. "remote_control_password" => $remote_control_password,
  100. "ftp_password" => $ftp_password,
  101. "tax_amount" => $tax_amount,
  102. "currency" => $currency,
  103. "paid" => 0);
  104. echo '<meta http-equiv="refresh" content="0;url=?m=simple-billing&amp;p=cart">';
  105. }
  106. }
  107. ?>