modulemanager.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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;
  27. print "<h2>".get_lang('modules')."</h2>";
  28. print '<a href="?m=modulemanager&amp;p=update">'.get_lang('update_modules').'</a>';
  29. $modules = $db->getInstalledModules();
  30. if ( $modules === FALSE )
  31. {
  32. print_failure(get_lang('no_installed_modules'));
  33. return;
  34. }
  35. print "<p class='note'>".get_lang("not_complete")."</p>";
  36. $coreHTML = "<h3>" . get_lang("core_mods_installed") . "</h3>"; // Core Modules Installed:
  37. $nonCoreHTML = "<h3>" . get_lang("custom_mods_installed") . "</h3>"; // Custom Modules Installed:
  38. $coreHTML .= "<table class='center'><tr class='first_row'><td>".get_lang('module_id')."</td>
  39. <td>".get_lang('module_name')."</td><td>".get_lang('module_folder')."</td>
  40. <td>".get_lang('module_version')."</td><td>".get_lang('db_version')."</td>
  41. <td></td></tr>";
  42. $nonCoreHTML .= "<table class='center'><tr class='first_row'><td>".get_lang('module_id')."</td>
  43. <td>".get_lang('module_name')."</td><td>".get_lang('module_folder')."</td>
  44. <td>".get_lang('module_version')."</td><td>".get_lang('db_version')."</td>
  45. <td></td></tr>";
  46. require_once('modules/modulemanager/module_handling.php');
  47. $installed_modules = array();
  48. $i = 0;
  49. foreach ( $modules as $row )
  50. {
  51. $html = "";
  52. $coreModule = true;
  53. $html .= "<tr class='tr".($i++%2)."'><td>".$row['id']."</td>";
  54. $html .= "<td>".$row['title']."</td><td>".$row['folder']."</td><td>".$row['version']."</td><td>".$row['db_version']."</td>";
  55. $html .= "<td>";
  56. // Don't allow the deletion of core modules
  57. if(!isCoreModule($row['folder'])){
  58. $html .= "<a href='?m=modulemanager&amp;p=del&amp;id=".$row['id']."&amp;module=".$row['folder']."'>";
  59. $html .= get_lang('uninstall');
  60. $html .= "</a>";
  61. $coreModule = false;
  62. }
  63. $html .= "</td>";
  64. $html .= "</tr>\n";
  65. // Append HTML to correct table
  66. if($coreModule){
  67. $coreHTML .= $html;
  68. }else{
  69. $nonCoreHTML .= $html;
  70. }
  71. array_push( $installed_modules, $row['folder'] );
  72. }
  73. // End the table
  74. $coreHTML .= "</table>";
  75. $nonCoreHTML .= "</table>";
  76. // Print out installed modules tables
  77. echo $coreHTML . "\n";
  78. echo $nonCoreHTML . "\n";
  79. // Show available custom addons available for install
  80. $not_installed = array_diff( list_available_modules(), $installed_modules );
  81. if ( empty($not_installed) )
  82. return;
  83. print "<h3>".get_lang('modules_available_for_install')."</h3>";
  84. echo "<table class='center'><tr class='first_row'><td>".get_lang('module_folder')."</td><td></td></tr>";
  85. foreach ( $not_installed as $available_module )
  86. {
  87. echo "<tr><td>".$available_module."</td><td>";
  88. echo "<a href='?m=modulemanager&amp;p=add&amp;module=".$available_module."'>";
  89. echo get_lang('install')."</a></td></tr>";
  90. }
  91. echo "</table>";
  92. }
  93. ?>