Exemple #1
0
/**
 * Plugins admin page
 *
 * @param App $a
 * @return string
 */
function admin_page_plugins(&$a)
{
    /**
     * Single plugin
     */
    if ($a->argc == 3) {
        $plugin = $a->argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return '';
        }
        if (x($_GET, "a") && $_GET['a'] == "t") {
            check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
            // Toggle plugin status
            $idx = array_search($plugin, $a->plugins);
            if ($idx !== false) {
                unset($a->plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                $a->plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", $a->plugins));
            goaway($a->get_baseurl(true) . '/admin/plugins');
            return '';
            // NOTREACHED
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, $a->plugins)) {
            $status = "on";
            $action = t("Disable");
        } else {
            $status = "off";
            $action = t("Enable");
        }
        $readme = Null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = "";
        if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            $func = $plugin . '_plugin_admin';
            $func($a, $admin_form);
        }
        $t = get_markup_template("admin_plugins_details.tpl");
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token("admin_themes")));
    }
    /**
     * List plugins
     */
    $plugins = array();
    $files = glob("addon/*/");
    /* */
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map("trim", explode("/", $file));
                $info = get_plugin_info($id);
                $show_plugin = true;
                // If the addon is unsupported, then only show it, when it is enabled
                if (strtolower($info["status"]) == "unsupported" and !in_array($id, $a->plugins)) {
                    $show_plugin = false;
                }
                // Override the above szenario, when the admin really wants to see outdated stuff
                if (get_config("system", "show_unsupported_addons")) {
                    $show_plugin = true;
                }
                if ($show_plugin) {
                    $plugins[] = array($id, in_array($id, $a->plugins) ? "on" : "off", $info);
                }
            }
        }
    }
    $t = get_markup_template("admin_plugins.tpl");
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Save Settings'), '$baseurl' => $a->get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, '$form_security_token' => get_form_security_token("admin_themes")));
}
Exemple #2
0
     break;
 case 'inactive':
     $plugin_name = trim(gpc('plugin_name', 'G', ''));
     if ($plugin_name) {
         $ins = array('plugin_name' => $plugin_name, 'active' => 0);
         $sqls = "('{$ins[plugin_name]}','{$ins[active]}')";
         $db->query("replace into {$tpf}plugins(plugin_name,actived) values {$sqls} ;");
     }
     $sysmsg[] = __('plugins_inactived_success');
     redirect($_SERVER['HTTP_REFERER'], $sysmsg);
     break;
 case 'install':
     $plugin_name = trim(gpc('plugin_name', 'G', ''));
     if ($plugin_name) {
         include_once PD_PLUGINS_DIR . "{$plugin_name}/install.inc.php";
         install_plugin();
         write_file(PD_PLUGINS_DIR . "{$plugin_name}/install.lock", "PHPDISK {$plugin_name} plugin installed!");
     }
     $sysmsg[] = __('plugin_install_success');
     redirect($_SERVER['HTTP_REFERER'], $sysmsg);
     break;
 case 'uninstall':
     $plugin_name = trim(gpc('plugin_name', 'G', ''));
     if ($plugin_name) {
         include_once PD_PLUGINS_DIR . "{$plugin_name}/install.inc.php";
         uninstall_plugin();
         @unlink(PD_PLUGINS_DIR . "{$plugin_name}/install.lock");
         $ins = array('plugin_name' => $plugin_name, 'active' => 0);
         $sqls = "('{$ins[plugin_name]}','{$ins[active]}')";
         $db->query("replace into {$tpf}plugins(plugin_name,actived) values {$sqls} ;");
     }
Exemple #3
0
 function check_plugins(&$a)
 {
     /**
      *
      * Synchronise plugins:
      *
      * $a->config['system']['addon'] contains a comma-separated list of names
      * of plugins/addons which are used on this system.
      * Go through the database list of already installed addons, and if we have
      * an entry, but it isn't in the config list, call the uninstall procedure
      * and mark it uninstalled in the database (for now we'll remove it).
      * Then go through the config list and if we have a plugin that isn't installed,
      * call the install procedure and add it to the database.
      *
      */
     $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
     if (count($r)) {
         $installed = $r;
     } else {
         $installed = array();
     }
     $plugins = get_config('system', 'addon');
     $plugins_arr = array();
     if ($plugins) {
         $plugins_arr = explode(',', str_replace(' ', '', $plugins));
     }
     $a->plugins = $plugins_arr;
     $installed_arr = array();
     if (count($installed)) {
         foreach ($installed as $i) {
             if (!in_array($i['name'], $plugins_arr)) {
                 uninstall_plugin($i['name']);
             } else {
                 $installed_arr[] = $i['name'];
             }
         }
     }
     if (count($plugins_arr)) {
         foreach ($plugins_arr as $p) {
             if (!in_array($p, $installed_arr)) {
                 install_plugin($p);
             }
         }
     }
     load_hooks();
     return;
 }
Exemple #4
0
 /**
  * Plugins admin page
  *
  * @param App $a
  * @return string
  */
 function admin_page_plugins(&$a)
 {
     /*
      * Single plugin
      */
     if (\App::$argc == 3) {
         $plugin = \App::$argv[2];
         if (!is_file("addon/{$plugin}/{$plugin}.php")) {
             notice(t("Item not found."));
             return '';
         }
         $enabled = in_array($plugin, \App::$plugins);
         $info = get_plugin_info($plugin);
         $x = check_plugin_versions($info);
         // disable plugins which are installed but incompatible versions
         if ($enabled && !$x) {
             $enabled = false;
             $idz = array_search($plugin, \App::$plugins);
             if ($idz !== false) {
                 unset(\App::$plugins[$idz]);
                 uninstall_plugin($plugin);
                 set_config("system", "addon", implode(", ", \App::$plugins));
             }
         }
         $info['disabled'] = 1 - intval($x);
         if (x($_GET, "a") && $_GET['a'] == "t") {
             check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
             // Toggle plugin status
             $idx = array_search($plugin, \App::$plugins);
             if ($idx !== false) {
                 unset(\App::$plugins[$idx]);
                 uninstall_plugin($plugin);
                 info(sprintf(t("Plugin %s disabled."), $plugin));
             } else {
                 \App::$plugins[] = $plugin;
                 install_plugin($plugin);
                 info(sprintf(t("Plugin %s enabled."), $plugin));
             }
             set_config("system", "addon", implode(", ", \App::$plugins));
             goaway(z_root() . '/admin/plugins');
         }
         // display plugin details
         require_once 'library/markdown.php';
         if (in_array($plugin, \App::$plugins)) {
             $status = 'on';
             $action = t('Disable');
         } else {
             $status = 'off';
             $action = t('Enable');
         }
         $readme = null;
         if (is_file("addon/{$plugin}/README.md")) {
             $readme = file_get_contents("addon/{$plugin}/README.md");
             $readme = Markdown($readme);
         } else {
             if (is_file("addon/{$plugin}/README")) {
                 $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
             }
         }
         $admin_form = '';
         $r = q("select * from addon where plugin_admin = 1 and name = '%s' limit 1", dbesc($plugin));
         if ($r) {
             @(require_once "addon/{$plugin}/{$plugin}.php");
             if (function_exists($plugin . '_plugin_admin')) {
                 $func = $plugin . '_plugin_admin';
                 $func($a, $admin_form);
             }
         }
         $t = get_markup_template('admin_plugins_details.tpl');
         return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => z_root(), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => $info, '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$str_minversion' => t('Minimum project version: '), '$str_maxversion' => t('Maximum project version: '), '$str_minphpversion' => t('Minimum PHP version: '), '$str_requires' => t('Requires: '), '$disabled' => t('Disabled - version incompatibility'), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token('admin_plugins')));
     }
     /*
      * List plugins
      */
     $plugins = array();
     $files = glob('addon/*/');
     if ($files) {
         foreach ($files as $file) {
             if (is_dir($file)) {
                 list($tmp, $id) = array_map('trim', explode('/', $file));
                 $info = get_plugin_info($id);
                 $enabled = in_array($id, \App::$plugins);
                 $x = check_plugin_versions($info);
                 // disable plugins which are installed but incompatible versions
                 if ($enabled && !$x) {
                     $enabled = false;
                     $idz = array_search($id, \App::$plugins);
                     if ($idz !== false) {
                         unset(\App::$plugins[$idz]);
                         uninstall_plugin($id);
                         set_config("system", "addon", implode(", ", \App::$plugins));
                     }
                 }
                 $info['disabled'] = 1 - intval($x);
                 $plugins[] = array($id, $enabled ? "on" : "off", $info);
             }
         }
     }
     usort($plugins, 'self::plugin_sort');
     $admin_plugins_add_repo_form = replace_macros(get_markup_template('admin_plugins_addrepo.tpl'), array('$post' => 'admin/plugins/addrepo', '$desc' => t('Enter the public git repository URL of the plugin repo.'), '$repoURL' => array('repoURL', t('Plugin repo git URL'), '', ''), '$repoName' => array('repoName', t('Custom repo name'), '', '', t('(optional)')), '$submit' => t('Download Plugin Repo')));
     $newRepoModalID = random_string(3);
     $newRepoModal = replace_macros(get_markup_template('generic_modal.tpl'), array('$id' => $newRepoModalID, '$title' => t('Install new repo'), '$ok' => t('Install'), '$cancel' => t('Cancel')));
     $reponames = $this->listAddonRepos();
     $addonrepos = [];
     foreach ($reponames as $repo) {
         $addonrepos[] = array('name' => $repo, 'description' => '');
         // TODO: Parse repo info to provide more information about repos
     }
     $t = get_markup_template('admin_plugins.tpl');
     return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$function' => 'plugins', '$plugins' => $plugins, '$disabled' => t('Disabled - version incompatibility'), '$form_security_token' => get_form_security_token('admin_plugins'), '$addrepo' => t('Add Plugin Repo'), '$expandform' => false, '$form' => $admin_plugins_add_repo_form, '$newRepoModal' => $newRepoModal, '$newRepoModalID' => $newRepoModalID, '$addonrepos' => $addonrepos, '$repoUpdateButton' => t('Update'), '$repoBranchButton' => t('Switch branch'), '$repoRemoveButton' => t('Remove')));
 }
Exemple #5
0
 function check_config(&$a)
 {
     $build = get_config('system', 'build');
     if (!x($build)) {
         $build = set_config('system', 'build', DB_UPDATE_VERSION);
     }
     $url = get_config('system', 'url');
     // if the url isn't set or the stored url is radically different
     // than the currently visited url, store the current value accordingly.
     // "Radically different" ignores common variations such as http vs https
     // and www.example.com vs example.com.
     if (!x($url) || !link_compare($url, $a->get_baseurl())) {
         $url = set_config('system', 'url', $a->get_baseurl());
     }
     if ($build != DB_UPDATE_VERSION) {
         $stored = intval($build);
         $current = intval(DB_UPDATE_VERSION);
         if ($stored < $current && file_exists('update.php')) {
             load_config('database');
             // We're reporting a different version than what is currently installed.
             // Run any existing update scripts to bring the database up to current.
             require_once 'update.php';
             // make sure that boot.php and update.php are the same release, we might be
             // updating right this very second and the correct version of the update.php
             // file may not be here yet. This can happen on a very busy site.
             if (DB_UPDATE_VERSION == UPDATE_VERSION) {
                 for ($x = $stored; $x < $current; $x++) {
                     if (function_exists('update_' . $x)) {
                         // There could be a lot of processes running or about to run.
                         // We want exactly one process to run the update command.
                         // So store the fact that we're taking responsibility
                         // after first checking to see if somebody else already has.
                         // If the update fails or times-out completely you may need to
                         // delete the config entry to try again.
                         if (get_config('database', 'update_' . $x)) {
                             break;
                         }
                         set_config('database', 'update_' . $x, '1');
                         // call the specific update
                         $func = 'update_' . $x;
                         $retval = $func();
                         if ($retval) {
                             //send the administrator an e-mail
                             $email_tpl = get_intltext_template("update_fail_eml.tpl");
                             $email_msg = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$update' => $x, '$error' => sprintf(t('Update %s failed. See error logs.'), $x)));
                             $subject = sprintf(t('Update Error at %s'), $a->get_baseurl());
                             mail($a->config['admin_email'], $subject, $email_msg, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
                             //try the logger
                             logger('CRITICAL: Update Failed: ' . $x);
                         } else {
                             set_config('database', 'update_' . $x, 'success');
                         }
                     }
                 }
                 set_config('system', 'build', DB_UPDATE_VERSION);
             }
         }
     }
     /**
      *
      * Synchronise plugins:
      *
      * $a->config['system']['addon'] contains a comma-separated list of names
      * of plugins/addons which are used on this system.
      * Go through the database list of already installed addons, and if we have
      * an entry, but it isn't in the config list, call the uninstall procedure
      * and mark it uninstalled in the database (for now we'll remove it).
      * Then go through the config list and if we have a plugin that isn't installed,
      * call the install procedure and add it to the database.
      *
      */
     $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
     if (count($r)) {
         $installed = $r;
     } else {
         $installed = array();
     }
     $plugins = get_config('system', 'addon');
     $plugins_arr = array();
     if ($plugins) {
         $plugins_arr = explode(',', str_replace(' ', '', $plugins));
     }
     $a->plugins = $plugins_arr;
     $installed_arr = array();
     if (count($installed)) {
         foreach ($installed as $i) {
             if (!in_array($i['name'], $plugins_arr)) {
                 uninstall_plugin($i['name']);
             } else {
                 $installed_arr[] = $i['name'];
             }
         }
     }
     if (count($plugins_arr)) {
         foreach ($plugins_arr as $p) {
             if (!in_array($p, $installed_arr)) {
                 install_plugin($p);
             }
         }
     }
     load_hooks();
     return;
 }
Exemple #6
0
/**
 * Plugins admin page
 *
 * @param App $a
 * @return string
 */
function admin_page_plugins(&$a)
{
    /*
     * Single plugin
     */
    if ($a->argc == 3) {
        $plugin = $a->argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return '';
        }
        if (x($_GET, "a") && $_GET['a'] == "t") {
            check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
            // Toggle plugin status
            $idx = array_search($plugin, $a->plugins);
            if ($idx !== false) {
                unset($a->plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                $a->plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", $a->plugins));
            goaway($a->get_baseurl(true) . '/admin/plugins');
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, $a->plugins)) {
            $status = 'on';
            $action = t('Disable');
        } else {
            $status = 'off';
            $action = t('Enable');
        }
        $readme = null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = '';
        if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            if (function_exists($plugin . '_plugin_admin')) {
                $func = $plugin . '_plugin_admin';
                $func($a, $admin_form);
            }
        }
        $t = get_markup_template('admin_plugins_details.tpl');
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token('admin_plugins')));
    }
    /*
     * List plugins
     */
    $plugins = array();
    $files = glob('addon/*/');
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map('trim', explode('/', $file));
                $info = get_plugin_info($id);
                $plugins[] = array($id, in_array($id, $a->plugins) ? "on" : "off", $info);
            }
        }
    }
    $t = get_markup_template('admin_plugins.tpl');
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, '$form_security_token' => get_form_security_token('admin_plugins')));
}
Exemple #7
0
 public static function commit_saisie(&$tab_new_values, $session)
 {
     $PHP_SELF = $_SERVER['PHP_SELF'];
     $return = '';
     if ($session == "") {
         $URL = "{$PHP_SELF}";
     } else {
         $URL = "{$PHP_SELF}?session={$session}";
     }
     $timeout = 2;
     // temps d'attente pour rafraichir l'écran après l'update !
     foreach ($tab_new_values as $key => $value) {
         // CONTROLE gestion_conges_exceptionnels
         // si désactivation les conges exceptionnels, on verif s'il y a des conges exceptionnels enregistres ! si oui : changement impossible !
         if ($key == "gestion_conges_exceptionnels" && $value == "FALSE") {
             $sql_abs = "SELECT ta_id, ta_libelle FROM conges_type_absence WHERE ta_type='conges_exceptionnels' ";
             $ReqLog_abs = \includes\SQL::query($sql_abs);
             if ($ReqLog_abs->num_rows != 0) {
                 $return .= '<b>' . _('config_abs_desactive_cong_excep_impossible') . '</b><br>';
                 $value = "TRUE";
                 $timeout = 5;
             }
         }
         // CONTROLE jour_mois_limite_reliquats
         // si modif de jour_mois_limite_reliquats, on verifie le format ( 0 ou jj-mm) , sinon : changement impossible !
         if ($key == "jour_mois_limite_reliquats" && $value != "0") {
             $t = explode("-", $value);
             if (checkdate($t[1], $t[0], date("Y")) == FALSE) {
                 $return .= '<b>' . _('config_jour_mois_limite_reliquats_modif_impossible') . '</b><br>';
                 $sql_date = "SELECT conf_valeur FROM conges_config WHERE conf_nom='jour_mois_limite_reliquats' ";
                 $ReqLog_date = \includes\SQL::query($sql_date);
                 $data = $ReqLog_date->fetch_row();
                 $value = $data[0];
                 $timeout = 5;
             }
         }
         if (preg_match("/_installed\$/", $key) && $value == "1") {
             $plugin = explode("_", $key);
             $plugin = $plugin[0];
             install_plugin($plugin);
         } elseif (preg_match("/_installed\$/", $key) && $value == "0") {
             $plugin = explode("_", $key);
             $plugin = $plugin[0];
             uninstall_plugin($plugin);
         }
         if (preg_match("/_activated\$/", $key) && $value == "1") {
             $plugin = explode("_", $key);
             $plugin = $plugin[0];
             activate_plugin($plugin);
         } elseif (preg_match("/_activated\$/", $key) && $value == "0") {
             $plugin = explode("_", $key);
             $plugin = $plugin[0];
             disable_plugin($plugin);
         }
         // Mise à jour
         $sql2 = 'UPDATE conges_config SET conf_valeur = \'' . addslashes($value) . '\' WHERE conf_nom ="' . \includes\SQL::quote($key) . '" ';
         $ReqLog2 = \includes\SQL::query($sql2);
     }
     $_SESSION['config'] = init_config_tab();
     // on re-initialise le tableau des variables de config
     // enregistrement dans les logs
     $comment_log = "nouvelle configuration de php_conges ";
     log_action(0, "", "", $comment_log);
     $return .= '<span class="messages">' . _('form_modif_ok') . '</span><br>';
     $return .= '<META HTTP-EQUIV=REFRESH CONTENT="' . $timeout . '; URL=' . $URL . '">';
     return $return;
 }
Exemple #8
0
function admin_page_plugins(&$a)
{
    /**
     * Single plugin
     */
    if ($a->argc == 3) {
        $plugin = $a->argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return;
        }
        if (x($_GET, "a") && $_GET['a'] == "t") {
            // Toggle plugin status
            $idx = array_search($plugin, $a->plugins);
            if ($idx !== false) {
                unset($a->plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                $a->plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", $a->plugins));
            goaway($a->get_baseurl() . '/admin/plugins');
            return;
            // NOTREACHED
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, $a->plugins)) {
            $status = "on";
            $action = t("Disable");
        } else {
            $status = "off";
            $action = t("Enable");
        }
        $readme = Null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = "";
        if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            $func = $plugin . '_plugin_admin';
            $func($a, $admin_form);
        }
        $t = get_markup_template("admin_plugins_details.tpl");
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$admin_form' => $admin_form, '$readme' => $readme));
    }
    /**
     * List plugins
     */
    $plugins = array();
    $files = glob("addon/*/");
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map("trim", explode("/", $file));
                $info = get_plugin_info($id);
                $plugins[] = array($id, in_array($id, $a->plugins) ? "on" : "off", $info);
            }
        }
    }
    $t = get_markup_template("admin_plugins.tpl");
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(), '$plugins' => $plugins));
}
Exemple #9
0
function hs_s2installurl()
{
    if ($_POST['wpfresh_installplugin'] == 'checked') {
        $url = $_POST['s2_url'];
        $newurls = explode(',', $url);
        //echo ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
        /** Load WordPress Bootstrap 
        	require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );*/
        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
        require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
        /*require_once( ABSPATH . 'wp-includes/wp-db.php' );*/
        for ($i = 0; $i < count($newurls); $i++) {
            install_plugin($newurls[$i]);
        }
        echo "done14";
    }
    die;
}
/**
 * Install basic plugins.
 *
 * This gets called separately on fresh installs.
 *
 * {@internal
 * NOTE: this won't call the "AfterInstall" method on the plugin nor install its DB schema.
 *       This get done in the plugins controller, on manually installing a plugin.
 *
 * If you change the plugins here, please also adjust {@link InstallUnitTestCase::basic_plugins}.
 * }}
 *
 * @param integer Old DB version, so that only new plugins gets installed
 */
function install_basic_plugins($old_db_version = 0)
{
    /**
     * @var Plugins_admin
     */
    global $Plugins_admin, $test_install_all_features;
    $Plugins_admin =& get_Plugins_admin();
    // Create global $Plugins instance, which is required during installation of basic plugins,
    // not only for the ones getting installed, but also during e.g. count_regs(), which instantiates
    // each plugin (which may then use (User)Settings in PluginInit (through Plugin::__get)).
    $GLOBALS['Plugins'] =& $Plugins_admin;
    if ($old_db_version < 9100) {
        // Toolbars:
        install_plugin('quicktags_plugin');
        // Renderers:
        install_plugin('auto_p_plugin');
        install_plugin('autolinks_plugin');
        install_plugin('texturize_plugin');
        // SkinTags:
        install_plugin('calendar_plugin');
        install_plugin('archives_plugin');
    }
    if ($old_db_version < 9290) {
        if ($test_install_all_features) {
            install_plugin('smilies_plugin');
        }
        install_plugin('videoplug_plugin');
    }
    if ($old_db_version < 9330) {
        // Upgrade to 1.9-beta
        install_plugin('ping_b2evonet_plugin');
        install_plugin('ping_pingomatic_plugin');
    }
    if ($old_db_version < 9930) {
        // Upgrade to 3.1.0
        install_plugin('tinymce_plugin');
    }
    if ($old_db_version < 9940) {
        // Upgrade to 3.2.0
        install_plugin('twitter_plugin');
    }
    if ($old_db_version < 10300) {
        // Upgrade to 5.0.0
        install_plugin('flowplayer_plugin');
        if ($test_install_all_features) {
            install_plugin('google_maps_plugin');
        }
    }
    if ($old_db_version < 11000) {
        // Upgrade to 5.0.0-alpha-4
        if ($test_install_all_features) {
            $captcha_qstn_plugin_settings = array('questions' => T_('What is the color of the sky? blue|grey|gray|dark') . "\r\n" . T_('What animal is Bugs Bunny? rabbit|a rabbit') . "\r\n" . T_('What color is a carrot? orange|yellow') . "\r\n" . T_('What color is a tomato? red'));
        } else {
            $captcha_qstn_plugin_settings = array();
        }
        install_plugin('captcha_qstn_plugin', true, $captcha_qstn_plugin_settings);
    }
    if ($old_db_version < 11100) {
        // Upgrade to 5.0.0-alpha-5
        // antispam
        install_plugin('basic_antispam_plugin');
        install_plugin('geoip_plugin');
        // files
        install_plugin('html5_mediaelementjs_plugin');
        install_plugin('html5_videojs_plugin');
        install_plugin('watermark_plugin', $test_install_all_features);
        // ping
        install_plugin('generic_ping_plugin');
        // rendering
        install_plugin('escapecode_plugin');
        install_plugin('bbcode_plugin', $test_install_all_features);
        install_plugin('star_plugin', $test_install_all_features);
        install_plugin('prism_plugin', $test_install_all_features);
        install_plugin('code_highlight_plugin', $test_install_all_features);
        install_plugin('gmcode_plugin');
        install_plugin('wacko_plugin');
        install_plugin('wikilinks_plugin');
        install_plugin('wikitables_plugin');
        install_plugin('markdown_plugin');
        install_plugin('infodots_plugin', $test_install_all_features);
        install_plugin('widescroll_plugin');
        // widget
        install_plugin('facebook_plugin');
        install_plugin('whosonline_plugin');
        // Unclassified
        install_plugin('bookmarklet_plugin');
    }
    if ($old_db_version < 11200) {
        // Upgrade to 5.1.3-stable
        install_plugin('shortcodes_plugin');
    }
}
Exemple #11
0
/**
 * Plugins admin page
 *
 * @param App $a
 * @return string
 */
function admin_page_plugins(&$a)
{
    /*
     * Single plugin
     */
    if (App::$argc == 3) {
        $plugin = App::$argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return '';
        }
        $enabled = in_array($plugin, App::$plugins);
        $info = get_plugin_info($plugin);
        $x = check_plugin_versions($info);
        // disable plugins which are installed but incompatible versions
        if ($enabled && !$x) {
            $enabled = false;
            $idz = array_search($plugin, App::$plugins);
            if ($idz !== false) {
                unset(App::$plugins[$idz]);
                uninstall_plugin($plugin);
                set_config("system", "addon", implode(", ", App::$plugins));
            }
        }
        $info['disabled'] = 1 - intval($x);
        if (x($_GET, "a") && $_GET['a'] == "t") {
            check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
            // Toggle plugin status
            $idx = array_search($plugin, App::$plugins);
            if ($idx !== false) {
                unset(App::$plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                App::$plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", App::$plugins));
            goaway(z_root() . '/admin/plugins');
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, App::$plugins)) {
            $status = 'on';
            $action = t('Disable');
        } else {
            $status = 'off';
            $action = t('Enable');
        }
        $readme = null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = '';
        $r = q("select * from addon where plugin_admin = 1 and name = '%s' limit 1", dbesc($plugin));
        if ($r) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            if (function_exists($plugin . '_plugin_admin')) {
                $func = $plugin . '_plugin_admin';
                $func($a, $admin_form);
            }
        }
        $t = get_markup_template('admin_plugins_details.tpl');
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => z_root(), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => $info, '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$str_minversion' => t('Minimum project version: '), '$str_maxversion' => t('Maximum project version: '), '$str_minphpversion' => t('Minimum PHP version: '), '$str_requires' => t('Requires: '), '$disabled' => t('Disabled - version incompatibility'), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token('admin_plugins')));
    }
    /*
     * List plugins
     */
    $plugins = array();
    $files = glob('addon/*/');
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map('trim', explode('/', $file));
                $info = get_plugin_info($id);
                $enabled = in_array($id, App::$plugins);
                $x = check_plugin_versions($info);
                // disable plugins which are installed but incompatible versions
                if ($enabled && !$x) {
                    $enabled = false;
                    $idz = array_search($id, App::$plugins);
                    if ($idz !== false) {
                        unset(App::$plugins[$idz]);
                        uninstall_plugin($id);
                        set_config("system", "addon", implode(", ", App::$plugins));
                    }
                }
                $info['disabled'] = 1 - intval($x);
                $plugins[] = array($id, $enabled ? "on" : "off", $info);
            }
        }
    }
    $t = get_markup_template('admin_plugins.tpl');
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$function' => 'plugins', '$plugins' => $plugins, '$disabled' => t('Disabled - version incompatibility'), '$form_security_token' => get_form_security_token('admin_plugins')));
}