insanelyBlog/includes/admin/plugins.php

52 lines
2.0 KiB
PHP
Raw Permalink Normal View History

<?php
if (isset($_POST['pluginId']) && is_numeric($_POST['pluginId']))
{
if ($_sql->query("UPDATE plugins SET pluginStatus = ".(isset($_POST['pluginEnable']) ? 1 : 0)." WHERE pluginId = $_POST[pluginId]"))
redirect(get_current_link());
else
array_push($error, $_locale['plugin_not_updated']);
}
echo "<h1>$_locale[plugins]</h1>";
$pluginsQuery = $_sql->query("SELECT * FROM plugins ORDER BY pluginStatus DESC");
$plugins = array();
if ($pluginsQuery->num_rows)
{
echo "<table class='designed plugins'>";
echo "<thead><tr><th>{locale:plugin_name}</th><th>{locale:description}</th><th>{locale:scope}</th><th>{locale:status}</th></tr></thead><tbody>";
while ($data = $pluginsQuery->fetch_assoc())
{
$pinfo = './plugins/'.$data['pluginLib'].'/info.json';
if (file_exists($pinfo))
{
$pinfo = (array)json_decode(file_get_contents($pinfo));
if (!isset($pinfo['enabler']) || (isset($pinfo['enabler']) && in_array($pinfo['enabler'], ['true', '1', 'yes', 'y'])))
if ($data['pluginStatus']) $button = "<button name='pluginDisable' class='orange'>{locale:disable}</button>";
else $button = "<button name='pluginEnable'>{locale:enable}</button>";
else $button = "{locale:plugin_noenable}";
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>";
}
array_push($plugins, $data['pluginLib']);
}
echo "</tbody></table>";
} else
echo "<p>$_locale[plugins_empty]</p>";
if ($handle = opendir('./plugins')) {
while (false !== ($entry = readdir($handle)))
{
if (!in_array($entry, $plugins) && file_exists('./plugins/'.$entry.'/info.json'))
if ($_sql->query("INSERT INTO plugins (pluginLib, pluginStatus) VALUES ('$entry', 0)"))
array_push($info, $_locale['plugin_added'].$entry);
else
array_push($error, $_locale['plugin_not_added'].$entry);
}
closedir($handle);
2016-06-18 10:07:35 +02:00
}