shop.php 7.9 KB

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