Revision 1306
Added by Luisehahne over 15 years ago
| branches/2.8.x/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
|
| 13 | 13 |
------------------------------------- 2.8.1 ------------------------------------- |
| 14 |
19-Mar-2010 Dietmar Woellbrink (Luisehahne) |
|
| 15 |
! rework admin/pages/save.php so that modules can use it |
|
| 16 |
! fixed missing global install variable to work in modules |
|
| 14 | 17 |
17-Mar-2010 Dietmar Woellbrink (Luisehahne) |
| 15 | 18 |
# Ticket #957 Wrong status returned for visibility |
| 16 | 19 |
17-Mar-2010 Dietmar Woellbrink (Luisehahne) |
| branches/2.8.x/wb/admin/pages/save.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
|
|
| 3 |
// $Id$ |
|
| 4 |
|
|
| 5 |
/* |
|
| 6 |
|
|
| 7 |
Website Baker Project <http://www.websitebaker.org/> |
|
| 8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
| 9 |
|
|
| 10 |
Website Baker is free software; you can redistribute it and/or modify |
|
| 11 |
it under the terms of the GNU General Public License as published by |
|
| 12 |
the Free Software Foundation; either version 2 of the License, or |
|
| 13 |
(at your option) any later version. |
|
| 14 |
|
|
| 15 |
Website Baker is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License |
|
| 21 |
along with Website Baker; if not, write to the Free Software |
|
| 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 23 |
|
|
| 24 |
*/ |
|
| 25 |
|
|
| 26 |
// Get page & section id |
|
| 27 |
if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) {
|
|
| 28 |
header("Location: index.php");
|
|
| 29 |
exit(0); |
|
| 30 |
} else {
|
|
| 31 |
$page_id = $_POST['page_id']; |
|
| 32 |
} |
|
| 33 |
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) {
|
|
| 34 |
header("Location: index.php");
|
|
| 35 |
exit(0); |
|
| 36 |
} else {
|
|
| 37 |
$section_id = $_POST['section_id']; |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
// Create new admin object |
|
| 41 |
require('../../config.php');
|
|
| 42 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 43 |
$admin = new admin('Pages', 'pages_modify');
|
|
| 44 |
|
|
| 45 |
// Get perms |
|
| 46 |
$database = new database(); |
|
| 47 |
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
|
|
| 48 |
$results_array = $results->fetchRow(); |
|
| 49 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
|
|
| 50 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
|
|
| 51 |
$in_old_group = FALSE; |
|
| 52 |
foreach($admin->get_groups_id() as $cur_gid){
|
|
| 53 |
if (in_array($cur_gid, $old_admin_groups)) {
|
|
| 54 |
$in_old_group = TRUE; |
|
| 55 |
} |
|
| 56 |
} |
|
| 57 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
|
| 58 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
// Get page module |
|
| 62 |
$database = new database(); |
|
| 63 |
$query = "SELECT module FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 64 |
$results = $database->query($query); |
|
| 65 |
if($database->is_error()) {
|
|
| 66 |
$admin->print_error($database->get_error()); |
|
| 67 |
} |
|
| 68 |
if($results->numRows() == 0) {
|
|
| 69 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 70 |
} |
|
| 71 |
$results_array = $results->fetchRow(); |
|
| 72 |
$module = $results_array['module']; |
|
| 73 |
|
|
| 74 |
// Update the pages table |
|
| 75 |
$now = time(); |
|
| 76 |
$query = "UPDATE ".TABLE_PREFIX."pages SET modified_when = '$now', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'"; |
|
| 77 |
$database->query($query); |
|
| 78 |
|
|
| 79 |
// Include the modules saving script if it exists |
|
| 80 |
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php')) {
|
|
| 81 |
require(WB_PATH.'/modules/'.$module.'/save.php'); |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
// Check if there is a db error, otherwise say successful |
|
| 85 |
if($database->is_error()) {
|
|
| 86 |
$admin->print_error($database->get_error(), $js_back); |
|
| 87 |
} else {
|
|
| 88 |
$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
| 89 |
} |
|
| 90 |
|
|
| 91 |
// Print admin footer |
|
| 92 |
$admin->print_footer(); |
|
| 93 |
|
|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category admin |
|
| 5 |
* @package pages |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 8 |
* @copyright 2009-2010, Website Baker Org. e.V. |
|
| 9 |
* @link http://www.websitebaker2.org/ |
|
| 10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 11 |
* @platform WebsiteBaker 2.8.x |
|
| 12 |
* @requirements PHP 4.3.4 and higher |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
// Get page & section id |
|
| 20 |
if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) {
|
|
| 21 |
header("Location: index.php");
|
|
| 22 |
exit(0); |
|
| 23 |
} else {
|
|
| 24 |
$page_id = intval($_POST['page_id']); |
|
| 25 |
} |
|
| 26 |
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) {
|
|
| 27 |
header("Location: index.php");
|
|
| 28 |
exit(0); |
|
| 29 |
} else {
|
|
| 30 |
$section_id = intval($_POST['section_id']); |
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
// Create new admin object |
|
| 34 |
require('../../config.php');
|
|
| 35 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 36 |
$admin = new admin('Pages', 'pages_modify');
|
|
| 37 |
|
|
| 38 |
// Get perms |
|
| 39 |
$sql = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` '; |
|
| 40 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
| 41 |
$results = $database->query($sql); |
|
| 42 |
$results_array = $results->fetchRow(); |
|
| 43 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
|
|
| 44 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
|
|
| 45 |
$in_old_group = FALSE; |
|
| 46 |
foreach($admin->get_groups_id() as $cur_gid) |
|
| 47 |
{
|
|
| 48 |
if (in_array($cur_gid, $old_admin_groups)) |
|
| 49 |
{
|
|
| 50 |
$in_old_group = TRUE; |
|
| 51 |
} |
|
| 52 |
} |
|
| 53 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) |
|
| 54 |
{
|
|
| 55 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
| 56 |
} |
|
| 57 |
// Get page module |
|
| 58 |
$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` '; |
|
| 59 |
$sql .= 'WHERE `page_id`='.$page_id.' AND `section_id`='.$section_id; |
|
| 60 |
$module = $database->get_one($sql); |
|
| 61 |
if(!$module) |
|
| 62 |
{
|
|
| 63 |
$admin->print_error( $database->is_error() ? $database->get_error() : $MESSAGE['PAGES']['NOT_FOUND']); |
|
| 64 |
} |
|
| 65 |
//$results = $database->query($sql); |
|
| 66 |
//if($database->is_error()) {
|
|
| 67 |
// $admin->print_error($database->get_error()); |
|
| 68 |
//} |
|
| 69 |
//if($results->numRows() == 0) {
|
|
| 70 |
// $admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 71 |
//} |
|
| 72 |
//$results_array = $results->fetchRow(); |
|
| 73 |
//$module = $results_array['module']; |
|
| 74 |
|
|
| 75 |
// Update the pages table |
|
| 76 |
$now = time(); |
|
| 77 |
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET '; |
|
| 78 |
$sql .= '`modified_when` = '.$now.', `modified_by` = '.$admin->get_user_id().' '; |
|
| 79 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
| 80 |
$database->query($sql); |
|
| 81 |
|
|
| 82 |
// Include the modules saving script if it exists |
|
| 83 |
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php')) |
|
| 84 |
{
|
|
| 85 |
include_once(WB_PATH.'/modules/'.$module.'/save.php'); |
|
| 86 |
} |
|
| 87 |
// Check if there is a db error, otherwise say successful |
|
| 88 |
if($database->is_error()) |
|
| 89 |
{
|
|
| 90 |
$admin->print_error($database->get_error(), $js_back); |
|
| 91 |
} else {
|
|
| 92 |
$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
// Print admin footer |
|
| 96 |
$admin->print_footer(); |
|
| 97 |
|
|
| 94 | 98 |
?> |
| 95 | 99 | |
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 52 | 52 |
|
| 53 | 53 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 54 | 54 |
if(!defined('VERSION')) define('VERSION', '2.8.x');
|
| 55 |
if(!defined('REVISION')) define('REVISION', '1305');
|
|
| 55 |
if(!defined('REVISION')) define('REVISION', '1306');
|
|
| 56 | 56 |
|
| 57 | 57 |
?> |
| branches/2.8.x/wb/admin/modules/manual_install.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* $Id$ |
|
| 4 |
* Website Baker Manual module installation |
|
| 5 |
* |
|
| 6 |
* This file contains the function to invoke the module install or upgrade |
|
| 7 |
* scripts update the Add-on information from the |
|
| 8 |
* database with the ones stored in the Add-on files (e.g. info.php or EN.php) |
|
| 9 |
* |
|
| 10 |
* LICENSE: GNU Lesser General Public License 3.0 |
|
| 11 |
* |
|
| 12 |
* @author Christian Sommer |
|
| 13 |
* @copyright (c) 2009 |
|
| 14 |
* @license http://www.gnu.org/copyleft/lesser.html |
|
| 15 |
* @version 0.2.0 |
|
| 16 |
* @platform Website Baker 2.7 |
|
| 17 |
* |
|
| 18 |
* Website Baker Project <http://www.websitebaker.org/> |
|
| 19 |
* Copyright (C) 2004-2009, Ryan Djurovich |
|
| 20 |
* |
|
| 21 |
* Website Baker is free software; you can redistribute it and/or modify |
|
| 22 |
* it under the terms of the GNU General Public License as published by |
|
| 23 |
* the Free Software Foundation; either version 2 of the License, or |
|
| 24 |
* (at your option) any later version. |
|
| 25 |
* |
|
| 26 |
* Website Baker is distributed in the hope that it will be useful, |
|
| 27 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 28 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 29 |
* GNU General Public License for more details. |
|
| 30 |
* |
|
| 31 |
* You should have received a copy of the GNU General Public License |
|
| 32 |
* along with Website Baker; if not, write to the Free Software |
|
| 33 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 34 |
*/ |
|
| 35 |
|
|
| 36 |
/** |
|
| 37 |
* check if there is anything to do |
|
| 38 |
*/ |
|
| 39 |
if (!(isset($_POST['action']) && in_array($_POST['action'], array('install', 'upgrade', 'uninstall')))) die(header('Location: index.php?advanced'));
|
|
| 40 |
if (!(isset($_POST['file']) && $_POST['file'] != '' && (strpos($_POST['file'], '..') === false))) die(header('Location: index.php?advanced'));
|
|
| 41 |
|
|
| 42 |
/** |
|
| 43 |
* check if user has permissions to access this file |
|
| 44 |
*/ |
|
| 45 |
// include WB configuration file and WB admin class |
|
| 46 |
require_once('../../config.php');
|
|
| 47 |
require_once('../../framework/class.admin.php');
|
|
| 48 |
|
|
| 49 |
// check user permissions for admintools (redirect users with wrong permissions) |
|
| 50 |
$admin = new admin('Admintools', 'admintools', false, false);
|
|
| 51 |
if ($admin->get_permission('admintools') == false) die(header('Location: ../../index.php'));
|
|
| 52 |
|
|
| 53 |
// check if the referer URL if available |
|
| 54 |
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : |
|
| 55 |
(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : ''); |
|
| 56 |
|
|
| 57 |
// if referer is set, check if script was invoked from "admin/modules/index.php" |
|
| 58 |
$required_url = ADMIN_URL . '/modules/index.php'; |
|
| 59 |
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) |
|
| 60 |
die(header('Location: ../../index.php'));
|
|
| 61 |
|
|
| 62 |
// include WB functions file |
|
| 63 |
require_once(WB_PATH . '/framework/functions.php'); |
|
| 64 |
|
|
| 65 |
// load WB language file |
|
| 66 |
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php'); |
|
| 67 |
|
|
| 68 |
// create Admin object with admin header |
|
| 69 |
$admin = new admin('Addons', '', true, false);
|
|
| 70 |
$js_back = ADMIN_URL . '/modules/index.php?advanced'; |
|
| 71 |
|
|
| 72 |
/** |
|
| 73 |
* Manually execute the specified module file (install.php, upgrade.php or uninstall.php) |
|
| 74 |
*/ |
|
| 75 |
// check if specified module folder exists |
|
| 76 |
$mod_path = WB_PATH . '/modules/' . basename(WB_PATH . '/' . $_POST['file']); |
|
| 77 |
if (!file_exists($mod_path . '/' . $_POST['action'] . '.php')) $admin->print_error($TEXT['NOT_FOUND'] . ': <tt>"' . htmlentities(basename($mod_path)) . '/' . $_POST['action'] . '.php"</tt> ', $js_back); |
|
| 78 |
|
|
| 79 |
// include modules install.php script |
|
| 80 |
require($mod_path . '/' . $_POST['action'] . '.php'); |
|
| 81 |
|
|
| 82 |
// load module info into database and output status message |
|
| 83 |
load_module($mod_path, false); |
|
| 84 |
$msg = $TEXT['EXECUTE'] . ': <tt>"' . htmlentities(basename($mod_path)) . '/' . $_POST['action'] . '.php"</tt>'; |
|
| 85 |
|
|
| 86 |
switch ($_POST['action']) {
|
|
| 87 |
case 'install': |
|
| 88 |
$admin->print_success($msg, $js_back); |
|
| 89 |
break; |
|
| 90 |
|
|
| 91 |
case 'upgrade': |
|
| 92 |
$admin->print_success($msg, $js_back); |
|
| 93 |
break; |
|
| 94 |
|
|
| 95 |
case 'uninstall': |
|
| 96 |
$admin->print_success($msg, $js_back); |
|
| 97 |
break; |
|
| 98 |
} |
|
| 99 |
|
|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category admin |
|
| 5 |
* @package modules |
|
| 6 |
* @author Christian Sommer |
|
| 7 |
* @author WebsiteBaker Project |
|
| 8 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 9 |
* @copyright 2009-2010, Website Baker Org. e.V. |
|
| 10 |
* @link http://www.websitebaker2.org/ |
|
| 11 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 12 |
* @platform WebsiteBaker 2.8.x |
|
| 13 |
* @requirements PHP 4.4.9 and higher |
|
| 14 |
* @version $Id$ |
|
| 15 |
* @filesource $HeadURL$ |
|
| 16 |
* @lastmodified $Date$ |
|
| 17 |
* |
|
| 18 |
*/ |
|
| 19 |
|
|
| 20 |
/** |
|
| 21 |
* check if there is anything to do |
|
| 22 |
*/ |
|
| 23 |
|
|
| 24 |
if (!(isset($_POST['action']) && in_array($_POST['action'], array('install', 'upgrade', 'uninstall')))) { die(header('Location: index.php?advanced')); }
|
|
| 25 |
if (!(isset($_POST['file']) && $_POST['file'] != '' && (strpos($_POST['file'], '..') === false))){ die(header('Location: index.php?advanced')); }
|
|
| 26 |
|
|
| 27 |
/** |
|
| 28 |
* check if user has permissions to access this file |
|
| 29 |
*/ |
|
| 30 |
// include WB configuration file and WB admin class |
|
| 31 |
require_once('../../config.php');
|
|
| 32 |
require_once('../../framework/class.admin.php');
|
|
| 33 |
|
|
| 34 |
// check user permissions for admintools (redirect users with wrong permissions) |
|
| 35 |
$admin = new admin('Admintools', 'admintools', false, false);
|
|
| 36 |
if ($admin->get_permission('admintools') == false) { die(header('Location: ../../index.php')); }
|
|
| 37 |
|
|
| 38 |
// check if the referer URL if available |
|
| 39 |
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : |
|
| 40 |
(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : ''); |
|
| 41 |
|
|
| 42 |
// if referer is set, check if script was invoked from "admin/modules/index.php" |
|
| 43 |
$required_url = ADMIN_URL . '/modules/index.php'; |
|
| 44 |
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) |
|
| 45 |
{ die(header('Location: ../../index.php')); }
|
|
| 46 |
|
|
| 47 |
// include WB functions file |
|
| 48 |
require_once(WB_PATH . '/framework/functions.php'); |
|
| 49 |
|
|
| 50 |
// load WB language file |
|
| 51 |
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php'); |
|
| 52 |
|
|
| 53 |
// create Admin object with admin header |
|
| 54 |
$admin = new admin('Addons', '', true, false);
|
|
| 55 |
$js_back = ADMIN_URL . '/modules/index.php?advanced'; |
|
| 56 |
|
|
| 57 |
/** |
|
| 58 |
* Manually execute the specified module file (install.php, upgrade.php or uninstall.php) |
|
| 59 |
*/ |
|
| 60 |
// check if specified module folder exists |
|
| 61 |
$mod_path = WB_PATH . '/modules/' . basename(WB_PATH . '/' . $_POST['file']); |
|
| 62 |
|
|
| 63 |
// let the old variablename if module use it |
|
| 64 |
$module_dir = $mod_path; |
|
| 65 |
if (!file_exists($mod_path . '/' . $_POST['action'] . '.php')) |
|
| 66 |
{
|
|
| 67 |
$admin->print_error($TEXT['NOT_FOUND'].': <tt>"'.htmlentities(basename($mod_path)).'/'.$_POST['action'].'.php"</tt> ', $js_back); |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
// include modules install.php script |
|
| 71 |
require($mod_path . '/' . $_POST['action'] . '.php'); |
|
| 72 |
|
|
| 73 |
// load module info into database and output status message |
|
| 74 |
load_module($mod_path, false); |
|
| 75 |
$msg = $TEXT['EXECUTE'] . ': <tt>"' . htmlentities(basename($mod_path)) . '/' . $_POST['action'] . '.php"</tt>'; |
|
| 76 |
|
|
| 77 |
switch ($_POST['action']) |
|
| 78 |
{
|
|
| 79 |
case 'install': |
|
| 80 |
$admin->print_success($msg, $js_back); |
|
| 81 |
break; |
|
| 82 |
|
|
| 83 |
case 'upgrade': |
|
| 84 |
$admin->print_success($msg, $js_back); |
|
| 85 |
break; |
|
| 86 |
|
|
| 87 |
case 'uninstall': |
|
| 88 |
$admin->print_success($msg, $js_back); |
|
| 89 |
break; |
|
| 90 |
} |
|
| 91 |
|
|
| 100 | 92 |
?> |
| 101 | 93 | |
| branches/2.8.x/wb/admin/modules/install.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
|
|
| 3 |
// $Id$ |
|
| 4 |
|
|
| 5 |
/* |
|
| 6 |
|
|
| 7 |
Website Baker Project <http://www.websitebaker.org/> |
|
| 8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
| 9 |
|
|
| 10 |
Website Baker is free software; you can redistribute it and/or modify |
|
| 11 |
it under the terms of the GNU General Public License as published by |
|
| 12 |
the Free Software Foundation; either version 2 of the License, or |
|
| 13 |
(at your option) any later version. |
|
| 14 |
|
|
| 15 |
Website Baker is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License |
|
| 21 |
along with Website Baker; if not, write to the Free Software |
|
| 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 23 |
|
|
| 24 |
*/ |
|
| 25 |
|
|
| 26 |
// Check if user uploaded a file |
|
| 27 |
if(!isset($_FILES['userfile'])) {
|
|
| 28 |
header("Location: index.php");
|
|
| 29 |
exit(0); |
|
| 30 |
} |
|
| 31 |
|
|
| 32 |
// do not display notices and warnings during installation |
|
| 33 |
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); |
|
| 34 |
|
|
| 35 |
// Setup admin object |
|
| 36 |
require('../../config.php');
|
|
| 37 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 38 |
$admin = new admin('Addons', 'modules_install');
|
|
| 39 |
|
|
| 40 |
// Include the WB functions file |
|
| 41 |
require_once(WB_PATH.'/framework/functions.php'); |
|
| 42 |
|
|
| 43 |
// Set temp vars |
|
| 44 |
$temp_dir = WB_PATH.'/temp/'; |
|
| 45 |
$temp_file = $temp_dir . $_FILES['userfile']['name']; |
|
| 46 |
$temp_unzip = WB_PATH.'/temp/unzip/'; |
|
| 47 |
|
|
| 48 |
// Try to upload the file to the temp dir |
|
| 49 |
if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $temp_file)) {
|
|
| 50 |
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UPLOAD']); |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
// Include the PclZip class file (thanks to |
|
| 54 |
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php'); |
|
| 55 |
|
|
| 56 |
// Remove any vars with name "module_directory" |
|
| 57 |
unset($module_directory); |
|
| 58 |
|
|
| 59 |
// Setup the PclZip object |
|
| 60 |
$archive = new PclZip($temp_file); |
|
| 61 |
// Unzip the files to the temp unzip folder |
|
| 62 |
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip); |
|
| 63 |
|
|
| 64 |
// Check if uploaded file is a valid Add-On zip file |
|
| 65 |
if (!($list && file_exists($temp_unzip . 'index.php'))) $admin->print_error($MESSAGE['GENERIC']['INVALID_ADDON_FILE']); |
|
| 66 |
|
|
| 67 |
// Include the modules info file |
|
| 68 |
require($temp_unzip.'info.php'); |
|
| 69 |
|
|
| 70 |
// Perform Add-on requirement checks before proceeding |
|
| 71 |
require(WB_PATH . '/framework/addon.precheck.inc.php'); |
|
| 72 |
preCheckAddon($temp_file); |
|
| 73 |
|
|
| 74 |
// Delete the temp unzip directory |
|
| 75 |
rm_full_dir($temp_unzip); |
|
| 76 |
|
|
| 77 |
// Check if the file is valid |
|
| 78 |
if(!isset($module_directory)) {
|
|
| 79 |
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
|
| 80 |
$admin->print_error($MESSAGE['GENERIC']['INVALID']); |
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
// Check if this module is already installed |
|
| 84 |
// and compare versions if so |
|
| 85 |
$new_module_version=$module_version; |
|
| 86 |
$action="install"; |
|
| 87 |
if(is_dir(WB_PATH.'/modules/'.$module_directory)) {
|
|
| 88 |
if(file_exists(WB_PATH.'/modules/'.$module_directory.'/info.php')) {
|
|
| 89 |
require(WB_PATH.'/modules/'.$module_directory.'/info.php'); |
|
| 90 |
// Version to be installed is older than currently installed version |
|
| 91 |
if (versionCompare($module_version, $new_module_version, '>=')) {
|
|
| 92 |
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
|
| 93 |
$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']); |
|
| 94 |
} |
|
| 95 |
$action="upgrade"; |
|
| 96 |
} |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
// Check if module dir is writable |
|
| 100 |
if(!is_writable(WB_PATH.'/modules/')) {
|
|
| 101 |
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
|
| 102 |
$admin->print_error($MESSAGE['GENERIC']['BAD_PERMISSIONS']); |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
// Set module directory |
|
| 106 |
$module_dir = WB_PATH.'/modules/'.$module_directory; |
|
| 107 |
|
|
| 108 |
// Make sure the module dir exists, and chmod if needed |
|
| 109 |
make_dir($module_dir); |
|
| 110 |
|
|
| 111 |
// Unzip module to the module dir |
|
| 112 |
$list = $archive->extract(PCLZIP_OPT_PATH, $module_dir); |
|
| 113 |
if(!$list) {
|
|
| 114 |
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNZIP']); |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
// Delete the temp zip file |
|
| 118 |
if(file_exists($temp_file)) { unlink($temp_file); }
|
|
| 119 |
|
|
| 120 |
// Chmod all the uploaded files |
|
| 121 |
$dir = dir($module_dir); |
|
| 122 |
while (false !== $entry = $dir->read()) {
|
|
| 123 |
// Skip pointers |
|
| 124 |
if(substr($entry, 0, 1) != '.' AND $entry != '.svn' AND !is_dir($module_dir.'/'.$entry)) {
|
|
| 125 |
// Chmod file |
|
| 126 |
change_mode($module_dir.'/'.$entry, 'file'); |
|
| 127 |
} |
|
| 128 |
} |
|
| 129 |
|
|
| 130 |
// Run the modules install // upgrade script if there is one |
|
| 131 |
if(file_exists(WB_PATH.'/modules/'.$module_directory.'/'.$action.'.php')) {
|
|
| 132 |
require(WB_PATH.'/modules/'.$module_directory.'/'.$action.'.php'); |
|
| 133 |
} |
|
| 134 |
|
|
| 135 |
// Print success message |
|
| 136 |
if ($action=="install") {
|
|
| 137 |
// Load module info into DB |
|
| 138 |
load_module(WB_PATH.'/modules/'.$module_directory, false); |
|
| 139 |
$admin->print_success($MESSAGE['GENERIC']['INSTALLED']); |
|
| 140 |
} else if ($action=="upgrade") {
|
|
| 141 |
upgrade_module($module_directory, false); |
|
| 142 |
$admin->print_success($MESSAGE['GENERIC']['UPGRADED']); |
|
| 143 |
} |
|
| 144 |
|
|
| 145 |
// Print admin footer |
|
| 146 |
$admin->print_footer(); |
|
| 147 |
|
|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category admin |
|
| 5 |
* @package modules |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 8 |
* @copyright 2009-2010, Website Baker Org. e.V. |
|
| 9 |
* @link http://www.websitebaker2.org/ |
|
| 10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 11 |
* @platform WebsiteBaker 2.8.x |
|
| 12 |
* @requirements PHP 4.4.9 and higher |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
// Check if user uploaded a file |
|
| 20 |
if(!isset($_FILES['userfile'])) {
|
|
| 21 |
header("Location: index.php");
|
|
| 22 |
exit(0); |
|
| 23 |
} |
|
| 24 |
|
|
| 25 |
// do not display notices and warnings during installation |
|
| 26 |
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); |
|
| 27 |
|
|
| 28 |
// Setup admin object |
|
| 29 |
require('../../config.php');
|
|
| 30 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 31 |
$admin = new admin('Addons', 'modules_install');
|
|
| 32 |
|
|
| 33 |
// Include the WB functions file |
|
| 34 |
require_once(WB_PATH.'/framework/functions.php'); |
|
| 35 |
|
|
| 36 |
// Set temp vars |
|
| 37 |
$temp_dir = WB_PATH.'/temp/'; |
|
| 38 |
$temp_file = $temp_dir . $_FILES['userfile']['name']; |
|
| 39 |
$temp_unzip = WB_PATH.'/temp/unzip/'; |
|
| 40 |
|
|
| 41 |
// Try to upload the file to the temp dir |
|
| 42 |
if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $temp_file)) |
|
| 43 |
{
|
|
| 44 |
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UPLOAD']); |
|
| 45 |
} |
|
| 46 |
|
|
| 47 |
// Include the PclZip class file (thanks to |
|
| 48 |
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php'); |
|
| 49 |
|
|
| 50 |
// Remove any vars with name "module_directory" |
|
| 51 |
unset($module_directory); |
|
| 52 |
|
|
| 53 |
// Setup the PclZip object |
|
| 54 |
$archive = new PclZip($temp_file); |
|
| 55 |
// Unzip the files to the temp unzip folder |
|
| 56 |
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip); |
|
| 57 |
|
|
| 58 |
// Check if uploaded file is a valid Add-On zip file |
|
| 59 |
if (!($list && file_exists($temp_unzip . 'index.php'))) |
|
| 60 |
{
|
|
| 61 |
$admin->print_error($MESSAGE['GENERIC']['INVALID_ADDON_FILE']); |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
// Include the modules info file |
|
| 65 |
require($temp_unzip.'info.php'); |
|
| 66 |
|
|
| 67 |
// Perform Add-on requirement checks before proceeding |
|
| 68 |
require(WB_PATH . '/framework/addon.precheck.inc.php'); |
|
| 69 |
preCheckAddon($temp_file); |
|
| 70 |
|
|
| 71 |
// Delete the temp unzip directory |
|
| 72 |
rm_full_dir($temp_unzip); |
|
| 73 |
|
|
| 74 |
// Check if the file is valid |
|
| 75 |
if(!isset($module_directory)) |
|
| 76 |
{
|
|
| 77 |
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
|
| 78 |
$admin->print_error($MESSAGE['GENERIC']['INVALID']); |
|
| 79 |
} |
|
| 80 |
|
|
| 81 |
// Check if this module is already installed |
|
| 82 |
// and compare versions if so |
|
| 83 |
$new_module_version=$module_version; |
|
| 84 |
$action="install"; |
|
| 85 |
if(is_dir(WB_PATH.'/modules/'.$module_directory)) |
|
| 86 |
{
|
|
| 87 |
if(file_exists(WB_PATH.'/modules/'.$module_directory.'/info.php')) |
|
| 88 |
{
|
|
| 89 |
require(WB_PATH.'/modules/'.$module_directory.'/info.php'); |
|
| 90 |
// Version to be installed is older than currently installed version |
|
| 91 |
if (versionCompare($module_version, $new_module_version, '>=')) |
|
| 92 |
{
|
|
| 93 |
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
|
| 94 |
$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']); |
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
$action="upgrade"; |
|
| 98 |
|
|
| 99 |
} |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
// Check if module dir is writable |
|
| 103 |
if(!is_writable(WB_PATH.'/modules/')) |
|
| 104 |
{
|
|
| 105 |
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
|
| 106 |
$admin->print_error($MESSAGE['GENERIC']['BAD_PERMISSIONS']); |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
// Set module directory |
|
| 110 |
$module_dir = WB_PATH.'/modules/'.$module_directory; |
|
| 111 |
|
|
| 112 |
// Make sure the module dir exists, and chmod if needed |
|
| 113 |
make_dir($module_dir); |
|
| 114 |
|
|
| 115 |
// Unzip module to the module dir |
|
| 116 |
$list = $archive->extract(PCLZIP_OPT_PATH, $module_dir); |
|
| 117 |
if(!$list) |
|
| 118 |
{
|
|
| 119 |
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNZIP']); |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
// Delete the temp zip file |
|
| 123 |
if(file_exists($temp_file)) { unlink($temp_file); }
|
|
| 124 |
|
|
| 125 |
// Chmod all the uploaded files |
|
| 126 |
$dir = dir($module_dir); |
|
| 127 |
while (false !== $entry = $dir->read()) |
|
| 128 |
{
|
|
| 129 |
// Skip pointers |
|
| 130 |
if(substr($entry, 0, 1) != '.' AND $entry != '.svn' AND !is_dir($module_dir.'/'.$entry)) |
|
| 131 |
{
|
|
| 132 |
// Chmod file |
|
| 133 |
change_mode($module_dir.'/'.$entry, 'file'); |
|
| 134 |
} |
|
| 135 |
} |
|
| 136 |
|
|
| 137 |
// Run the modules install // upgrade script if there is one |
|
| 138 |
if(file_exists($module_dir.'/'.$action.'.php')) |
|
| 139 |
{
|
|
| 140 |
require($module_dir.'/'.$action.'.php'); |
|
| 141 |
} |
|
| 142 |
|
|
| 143 |
// Print success message |
|
| 144 |
if ($action=="install") |
|
| 145 |
{
|
|
| 146 |
// Load module info into DB |
|
| 147 |
load_module(WB_PATH.'/modules/'.$module_directory, false); |
|
| 148 |
$admin->print_success($MESSAGE['GENERIC']['INSTALLED']); |
|
| 149 |
} elseif ($action=="upgrade") |
|
| 150 |
{
|
|
| 151 |
upgrade_module($module_directory, false); |
|
| 152 |
$admin->print_success($MESSAGE['GENERIC']['UPGRADED']); |
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
// Print admin footer |
|
| 156 |
$admin->print_footer(); |
|
| 157 |
|
|
| 148 | 158 |
?> |
| 149 | 159 | |
Also available in: Unified diff
rework admin/pages/save.php so that modules can use it
fixed missing global variable in install to work in modules