Exemple #1
0
$err = '';
$tool_url = '';
# Liste des thèmes
$plugins_root = dirname(__FILE__) . '/../';
$plugins = new plugins($plugins_root);
$plugins->getPlugins(false);
$plugins_list = $plugins->getPluginsList();
$is_writable = is_writable($plugins_root);
# Installation d'un thème
if ($is_writable && !empty($_GET['tool_url'])) {
    $tool_url = $_GET['tool_url'];
    $parsed_url = parse_url($tool_url);
    if (empty($parsed_url['scheme']) || !preg_match('/^http|ftp$/', $parsed_url['scheme']) || empty($parsed_url['host']) || empty($parsed_url['path'])) {
        $err = __('URL is not valid.');
    } else {
        if (($err = $plugins->install($tool_url)) === true) {
            header('Location: tools.php?p=toolsmng');
            exit;
        }
    }
}
# Changement de status d'un plugin
$switch = !empty($_GET['switch']) ? $_GET['switch'] : '';
if ($is_writable && $switch != '' && in_array($switch, array_keys($plugins_list)) && $switch != 'toolsmng') {
    $plugins->switchStatus($switch);
    header('Location: tools.php?p=toolsmng');
    exit;
}
# Suppression d'un thème
$delete = !empty($_GET['delete']) ? $_GET['delete'] : '';
if ($is_writable && $delete != '' && in_array($delete, array_keys($plugins_list)) && $delete != 'toolsmng') {