You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7 KiB

6 years ago
  1. <?php
  2. if (isset($_POST['pluginId']) && isnum($_POST['pluginId']))
  3. {
  4. if ($_sql->query("UPDATE plugins SET pluginStatus = ".(isset($_POST['pluginEnable']) ? 1 : 0)." WHERE pluginId = $_POST[pluginId]"))
  5. redirect(get_current_link());
  6. else
  7. array_push($error, $_locale['plugin_not_updated']);
  8. }
  9. echo "<h1>$_locale[plugins]</h1>";
  10. $pluginsQuery = $_sql->query("SELECT * FROM plugins ORDER BY pluginStatus DESC");
  11. $plugins = array();
  12. if ($pluginsQuery->num_rows)
  13. {
  14. echo "<table class='designed plugins'>";
  15. echo "<tr><td>{locale:plugin_name}</td><td>{locale:description}</td><td>{locale:scope}</td><td>{locale:status}</td></tr>";
  16. while ($data = $pluginsQuery->fetch_assoc())
  17. {
  18. $pinfo = './plugins/'.$data['pluginLib'].'/info.json';
  19. if (file_exists($pinfo))
  20. {
  21. $pinfo = (array)json_decode(file_get_contents($pinfo));
  22. if ($data['pluginStatus'])
  23. $button = "<button name='pluginDisable' class='orange'>{locale:disable}</button>";
  24. else $button = "<button name='pluginEnable'>{locale:enable}</button>";
  25. echo "<tr><td>$pinfo[name]</td><td>$pinfo[description]<td>$pinfo[paths]</td><td><form action='".get_current_link()."' method='post'><input type='hidden' name='pluginId' value='$data[pluginId]'/>$button</form></td></tr>";
  26. }
  27. array_push($plugins, $data['pluginLib']);
  28. }
  29. echo "</table>";
  30. } else
  31. echo "<p>$_locale[plugins_empty]</p>";
  32. if ($handle = opendir('./plugins')) {
  33. while (false !== ($entry = readdir($handle)))
  34. {
  35. if (!in_array($entry, $plugins) && file_exists('./plugins/'.$entry.'/info.json'))
  36. if ($_sql->query("INSERT INTO plugins (pluginLib, pluginStatus) VALUES ('$entry', 0)"))
  37. array_push($info, $_locale['plugin_added'].$entry);
  38. else
  39. array_push($error, $_locale['plugin_not_added'].$entry);
  40. }
  41. closedir($handle);
  42. }