shop.php 8.0 KB

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