shop.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. if (isset($_POST['save']) AND !empty($_POST['description']))
  29. {
  30. $new_description = str_replace("\\r\\n", "<br>", $_POST['description']);
  31. $service = $_POST['service_id'];
  32. $change_description = "UPDATE OGP_DB_PREFIXbilling_services
  33. SET description ='".$new_description."'
  34. WHERE service_id=".$service;
  35. $save = $db->query($change_description);
  36. }
  37. ?>
  38. <table class="center">
  39. <tr>
  40. <td>
  41. <a href="?m=simple-billing&p=cart"><img SRC="images/cart.png" BORDER="0" WIDTH=22 HEIGHT=20/><?php print_lang('your_cart');?></a>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td>
  46. <?php
  47. echo date('d-m-Y');
  48. ?>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td>
  53. <?php
  54. echo date('H:i');
  55. ?>
  56. </td>
  57. </tr>
  58. </table>
  59. <?php
  60. // Shop Form
  61. if(isset($_REQUEST['service_id'])) $where_service_id = " WHERE service_id=".$_REQUEST['service_id']; else $where_service_id = "";
  62. $qry_services = "SELECT * FROM OGP_DB_PREFIXbilling_services".$where_service_id;
  63. $services = $db->resultQuery($qry_services);
  64. foreach ($services as $key => $row) {
  65. $service_id[$key] = $row['service_id'];
  66. $home_cfg_id[$key] = $row['home_cfg_id'];
  67. $mod_cfg_id[$key] = $row['mod_cfg_id'];
  68. $service_name[$key] = $row['service_name'];
  69. $remote_server_id[$key] = $row['remote_server_id'];
  70. $slot_max_qty[$key] = $row['slot_max_qty'];
  71. $slot_min_qty[$key] = $row['slot_min_qty'];
  72. $price_hourly[$key] = $row['price_hourly'];
  73. $price_monthly[$key] = $row['price_monthly'];
  74. $price_year[$key] = $row['price_year'];
  75. $description[$key] = $row['description'];
  76. $img_url[$key] = $row['img_url'];
  77. $ftp[$key] = $row['ftp'];
  78. $install_method[$key] = $row['install_method'];
  79. $manual_url[$key] = $row['manual_url'];
  80. $access_rights[$key] = $row['access_rights'];
  81. }
  82. array_multisort($service_name,
  83. $service_id,
  84. $home_cfg_id,
  85. $mod_cfg_id,
  86. $remote_server_id,
  87. $slot_max_qty,
  88. $slot_min_qty,
  89. $price_hourly,
  90. $price_monthly,
  91. $price_year,
  92. $description,
  93. $img_url,
  94. $ftp,
  95. $install_method,
  96. $manual_url,
  97. $access_rights, SORT_DESC, $services);
  98. ?>
  99. <div style="border-left:10px solid transparent;">
  100. <?php
  101. foreach( $services as $row )
  102. {
  103. if(!isset($_REQUEST['service_id']))
  104. {
  105. ?>
  106. <div style="float:left; border: 4px solid transparent;border-bottom: 25px solid transparent;">
  107. <form action="" method="POST">
  108. <input name="service_id" type="hidden" value="<?php echo $row['service_id'];?>" />
  109. <input type="image" src="<?php echo $row['img_url'] ;?>" width=280 height=132 border=0 alt="Bad Image" onsubmit="submit-form();" value="More Info" />
  110. <center><b><?php echo $row['service_name'];?></b></center>
  111. <center><em style="text-align:center;background-color:orange;color:blue;"><?php echo get_lang('starting_on') . " <b>" .
  112. floatval(round(($row['price_monthly']*$row['slot_min_qty']),2 )) . "</b>&nbsp;" . $settings['currency'] . "/" . get_lang('month') .
  113. " (" . $row['slot_min_qty'] . " " . get_lang('slots') . ").";?></em></center>
  114. </form>
  115. </div>
  116. <?php
  117. } else
  118. {
  119. ?>
  120. <div style="float:left; border: 4px solid transparent;border-bottom: 25px solid transparent;">
  121. <img src="<?php echo $row['img_url'] ;?>" width=280 height=132 border=0 alt="Bad Image">
  122. <center><b><?php echo $row['service_name']."</b></center>";
  123. $isAdmin = $db->isAdmin($_SESSION['user_id'] );
  124. if($isAdmin)
  125. {
  126. if(!isset($_POST['edit']))
  127. {
  128. echo "<p style='color:gray;width:280px;' >$row[description]<p>";
  129. echo "<form action='' method='post'>".
  130. "<input type='hidden' name='service_id' value='$row[service_id]' />".
  131. "<input type='submit' name='edit' value='" . get_lang('edit') . "' />".
  132. "</form>";
  133. }
  134. else
  135. {
  136. echo "<form action='' method='post'>".
  137. "<textarea style='resize:none;width:280px;height:132px;' name='description' >".str_replace("<br>", "\r\n", $row['description'])."</textarea><br>".
  138. "<input type='hidden' name='service_id' value='$row[service_id]' />".
  139. "<input type='submit' name='save' value='" . get_lang('save') . "' />".
  140. "</form>";
  141. }
  142. }
  143. else
  144. echo "<p style='color:gray;width:280px;' >$row[description]<p>";
  145. ?>
  146. </div>
  147. <table style="width:420px;float:left;">
  148. <form method="post" action="?m=simple-billing&p=add_to_cart<?php if(isset($_POST['service_id'])) echo "&service_id=".$_POST['service_id'];?>">
  149. <tr>
  150. <td align="right"><?php print_lang('service_name');?> ::</td>
  151. <td align="left">
  152. <input type="text" name="home_name" size="40" value="<?php echo $row['service_name'];?>">
  153. </td>
  154. <tr>
  155. <td align="right"><?php print_lang('rcon_pass');?> ::</td>
  156. <td align="left">
  157. <input type="text" name="remote_control_password" size="15" value="<?php echo genRandomString(10);?>">
  158. </td>
  159. </tr>
  160. <?php
  161. if($row['ftp'] == "enabled")
  162. {
  163. ?>
  164. <tr>
  165. <td align="right"><?php print_lang('ftp_pass');?> ::</td>
  166. <td align="left">
  167. <input type="text" name="ftp_password" size="15" value="<?php echo genRandomString(10);?>">
  168. </td>
  169. </tr>
  170. <?php
  171. }
  172. ?>
  173. <tr>
  174. <td align="right"><?php print_lang('available_ips');?> ::</td>
  175. <td align="left">
  176. <select name='ip_id'>
  177. <?php
  178. $qry_ip = "SELECT ip_id,ip FROM OGP_DB_PREFIXremote_server_ips WHERE remote_server_id=".$row['remote_server_id'];
  179. $ips = $db->resultQuery($qry_ip);
  180. foreach($ips as $ip)
  181. {
  182. printf("<option value='%s'>%s</option>", $ip['ip_id'], $ip['ip']);
  183. }?>
  184. </select>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td align="right"><?php print_lang('max_players');?> ::</td>
  189. <td align="left">
  190. <select name="max_players">
  191. <?php
  192. $players=$row['slot_min_qty'];
  193. while($players<=$row['slot_max_qty'])
  194. {
  195. echo "<option value='$players'>$players</option>";
  196. $players++;
  197. }
  198. ?>
  199. </select>
  200. </td>
  201. </tr>
  202. <tr>
  203. <td align="right"><?php print_lang('invoice_duration');?> ::</td>
  204. <td align="left">
  205. <select name="qty">
  206. <?php
  207. $qty=1;
  208. while($qty<=12)
  209. {
  210. echo "<option value='$qty'>$qty</option>";
  211. $qty++;
  212. }
  213. ?>
  214. </select>
  215. <select name="invoice_duration">
  216. <?php
  217. if( $settings['hourly'] == 1) echo '<option value="hour">'.get_lang('hours').'</option>';
  218. if( $settings['monthly'] == 1) echo '<option value="month">'.get_lang('months').'</option>';
  219. if( $settings['annually'] == 1) echo '<option value="year">'.get_lang('years').'</option>';
  220. ?>
  221. </select>
  222. </td>
  223. </tr>
  224. <tr>
  225. <td align="left" colspan="2">
  226. <input name="service_id" type="hidden" value="<?php echo $row['service_id'];?>"/>
  227. <input type="submit" name="add_to_cart" value="<?php print_lang('add_to_cart');?>"/>
  228. </form>
  229. </td>
  230. </tr>
  231. <tr>
  232. <td align="left" colspan="2">
  233. <form action ="?m=simple-billing&p=shop" method="POST">
  234. <button><< <?php print_lang('back_to_list');?></button>
  235. </form>
  236. </td>
  237. </tr>
  238. </table>
  239. <?php
  240. }
  241. }
  242. ?>
  243. </div>
  244. <?php
  245. }
  246. ?>