user_addons.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 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. global $db;
  26. $home_id = $_GET['home_id'];
  27. $mod_id = $_GET['mod_id'];
  28. $ip = $_GET['ip'];
  29. $port = $_GET['port'];
  30. $user_id = $_SESSION['user_id'];
  31. // Check if user has some games.
  32. $isAdmin = $db->isAdmin( $user_id );
  33. $query_groups = "";
  34. if($isAdmin)
  35. $home_info = $db->getGameHome($home_id);
  36. else
  37. {
  38. $home_info = $db->getUserGameHome($user_id,$home_id);
  39. $groups = $db->getUsersGroups($_SESSION['user_id']);
  40. $query_groups .= " AND (";
  41. foreach($groups as $group)
  42. $query_groups .= "group_id=".$group['group_id']." OR ";
  43. $query_groups .= "group_id=0 OR group_id IS NULL)";
  44. }
  45. if ($home_info)
  46. {
  47. $home_cfg_id = $home_info['home_cfg_id'];
  48. echo "<h2>".get_lang('user_addons').": ".htmlentities($home_info['home_name'])."</h2>\n".
  49. "<table class='center' >\n".
  50. "<tr><td>\n";
  51. $plugins = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name ".
  52. "FROM OGP_DB_PREFIXaddons ".
  53. "NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
  54. "WHERE addon_type='plugin' ".
  55. "AND home_cfg_id=".$home_cfg_id.$query_groups);
  56. $plugins_qty = $plugins ? count($plugins) : 0;
  57. if($plugins and $plugins_qty >= 1)
  58. echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
  59. "&amp;mod_id=".$mod_id."&amp;addon_type=plugin&amp;ip=".$ip.
  60. "&amp;port=".$port."'>".get_lang('install_plugin')."(".$plugins_qty.")</a>\n";
  61. $mappacks = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name ".
  62. "FROM OGP_DB_PREFIXaddons ".
  63. "NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
  64. "WHERE addon_type='mappack' ".
  65. "AND home_cfg_id=".$home_cfg_id.$query_groups);
  66. $mappacks_qty = $mappacks ? count($mappacks) : 0;
  67. if($mappacks and $mappacks_qty >= 1){
  68. echo "</td><td>";
  69. echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
  70. "&amp;mod_id=".$mod_id."&amp;addon_type=mappack&amp;ip=".$ip.
  71. "&amp;port=".$port."'>".get_lang('install_mappack')."(".$mappacks_qty.")</a>\n";
  72. }
  73. $configs = $db->resultQuery("SELECT DISTINCT addon_id, name, game_name ".
  74. "FROM OGP_DB_PREFIXaddons ".
  75. "NATURAL JOIN OGP_DB_PREFIXconfig_homes ".
  76. "WHERE addon_type='config' ".
  77. "AND home_cfg_id=".$home_cfg_id.$query_groups);
  78. $configs_qty = $configs ? count($configs) : 0;
  79. if($configs and $configs_qty >= 1){
  80. echo "</td><td>";
  81. echo "<a href='?m=addonsmanager&amp;p=addons&amp;home_id=".$home_id.
  82. "&amp;mod_id=".$mod_id."&amp;addon_type=config&amp;ip=".$ip.
  83. "&amp;port=".$port."'>".get_lang('install_config')."(".$configs_qty.")</a>\n";
  84. }
  85. echo "</td></tr>\n".
  86. "</table>\n".
  87. "<form action='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port' method='POST'>\n".
  88. "<input type='submit' value='".get_lang('back')."' />\n".
  89. "</form>\n".
  90. "<br>\n";
  91. }
  92. else
  93. print_failure(get_lang('no_games_servers_available'));
  94. }
  95. ?>