/plugins/jojo_core/json/admin-install-plugin.php
PHP | 73 lines | 39 code | 9 blank | 25 comment | 6 complexity | ef2e9c7c51533b5dee5ea6ab5b84579f MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, MIT
- <?php
- /**
- * Jojo CMS
- * ================
- *
- * Copyright 2007-2008 Harvey Kane <code@ragepank.com>
- * Copyright 2007-2008 Michael Holt <code@gardyneholt.co.nz>
- * Copyright 2007 Melanie Schulz <mel@gardyneholt.co.nz>
- *
- * See the enclosed file license.txt for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Harvey Kane <code@ragepank.com>
- * @author Michael Cochrane <mikec@jojocms.org>
- * @author Melanie Schulz <mel@gardyneholt.co.nz>
- * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
- * @link http://www.jojocms.org JojoCMS
- * @package jojo_core
- */
- /* Ensure users of this function have access to the admin page */
- $page = Jojo_Plugin::getPage(Jojo::uriToPageID('admin/plugins', null, null, null));
- if (!$page->perms->hasPerm($_USERGROUPS, 'view')) {
- echo json_encode(
- array('result' => false,
- 'message' => "You do not have permission to use this function"));
- exit;
- }
- $plugin = basename(Jojo::getFormData('plugin', ''));
- if (!$plugin) {
- echo json_encode(
- array('result' => false,
- 'message' => "No plugin selected."));
- exit;
- }
- /* Enable this plugin */
- Jojo::insertQuery("REPLACE INTO {plugin} SET name = ?, active = 'yes'", $plugin);
- /* Force the plugin cache to be refreshed */
- Jojo::findFiles('setup.php', true);
- /* Run setup */
- $isAdmin = true;
- ob_start();
- include(_BASEDIR . '/includes/setup.php');
- ob_end_clean();
- /* Clear cache files */
- if (Jojo::fileExists(_CACHEDIR . '/api.txt')) {
- unlink(_CACHEDIR . '/api.txt');
- }
- if (Jojo::fileExists(_CACHEDIR . '/listPlugins.txt')) {
- unlink(_CACHEDIR . '/listPlugins.txt');
- }
- if (Jojo::fileExists(_CACHEDIR . '/listThemes.txt')) {
- unlink(_CACHEDIR . '/listThemes.txt');
- }
- /* Clear all compiled templates */
- foreach (Jojo::scanDirectory(_CACHEDIR . '/dwoo/templates_c') as $filename) {
- if (Jojo::fileExists(_CACHEDIR . '/dwoo/templates_c/' . $filename)) {
- unlink(_CACHEDIR . '/dwoo/templates_c/' . $filename);
- }
- }
- /* Let the user know */
- echo json_encode(
- array('result' => true,
- 'message' => ucwords(str_replace('_', ' ', $plugin)) . " installed."));
- exit;