Revision 1712
Added by Luisehahne about 13 years ago
| uninstall.php | ||
|---|---|---|
| 3 | 3 |
* |
| 4 | 4 |
* @category admin |
| 5 | 5 |
* @package modules |
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
| 6 |
* @author Ryan Djurovich,WebsiteBaker Project |
|
| 7 |
* @copyright 2009-2012, WebsiteBaker Org. e.V. |
|
| 9 | 8 |
* @link http://www.websitebaker2.org/ |
| 10 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
| 11 | 10 |
* @platform WebsiteBaker 2.8.x |
| ... | ... | |
| 27 | 26 |
} |
| 28 | 27 |
// After check print the header |
| 29 | 28 |
$admin->print_header(); |
| 29 |
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
|
| 30 |
$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS']); |
|
| 31 |
} else {
|
|
| 32 |
$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']); // fix secunia 2010-92-2
|
|
| 33 |
} |
|
| 30 | 34 |
|
| 35 |
// Check if the template exists |
|
| 36 |
if(!is_dir(WB_PATH.'/modules/'.$file)) {
|
|
| 37 |
$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']); |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
// Check if the template exists |
|
| 41 |
if(!is_readable(WB_PATH.'/modules/'.$file)) {
|
|
| 42 |
$admin->print_error($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']); |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
/* |
|
| 31 | 46 |
// Check if user selected module |
| 32 | 47 |
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
| 33 | 48 |
header("Location: index.php");
|
| ... | ... | |
| 42 | 57 |
exit(0); |
| 43 | 58 |
} |
| 44 | 59 |
|
| 45 |
// Include the WB functions file |
|
| 46 |
require_once(WB_PATH.'/framework/functions.php'); |
|
| 47 |
|
|
| 48 | 60 |
// Check if the module exists |
| 49 | 61 |
if(!is_dir(WB_PATH.'/modules/'.$file)) {
|
| 50 |
$admin->print_error($MESSAGE['GENERIC']['NOT_INSTALLED']);
|
|
| 62 |
$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
|
|
| 51 | 63 |
} |
| 64 |
*/ |
|
| 52 | 65 |
|
| 66 |
// Include the WB functions file |
|
| 67 |
require_once(WB_PATH.'/framework/functions.php'); |
|
| 68 |
|
|
| 53 | 69 |
if (!function_exists("replace_all")) {
|
| 54 | 70 |
function replace_all ($aStr = "", &$aArray ) {
|
| 55 | 71 |
foreach($aArray as $k=>$v) $aStr = str_replace("{{".$k."}}", $v, $aStr);
|
| ... | ... | |
| 60 | 76 |
$info = $database->query("SELECT section_id, page_id FROM ".TABLE_PREFIX."sections WHERE module='".$_POST['file']."'" );
|
| 61 | 77 |
|
| 62 | 78 |
if ( $info->numRows() > 0) {
|
| 63 |
|
|
| 79 |
|
|
| 64 | 80 |
/** |
| 65 | 81 |
* Modul is in use, so we have to warn the user |
| 66 | 82 |
*/ |
| ... | ... | |
| 69 | 85 |
$msg_template_str = "<br /><br />{{type}} <b>{{type_name}}</b> could not be uninstalled because it is still in use on {{pages}}";
|
| 70 | 86 |
$msg_template_str .= ":<br /><i>click for editing.</i><br /><br />"; |
| 71 | 87 |
} else {
|
| 72 |
$msg_template_str = $MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE_TMPL'];
|
|
| 73 |
$temp = explode(";",$MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE_TMPL_PAGES']);
|
|
| 88 |
$msg_template_str = $MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE_TMPL'];
|
|
| 89 |
$temp = explode(";",$MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE_TMPL_PAGES']);
|
|
| 74 | 90 |
$add = $info->numRows() == 1 ? $temp[0] : $temp[1]; |
| 75 | 91 |
} |
| 76 | 92 |
/** |
| 77 | 93 |
* The template-string for displaying the Page-Titles ... in this case as a link |
| 78 | 94 |
*/ |
| 79 | 95 |
$page_template_str = "- <b><a href='../pages/sections.php?page_id={{id}}'>{{title}}</a></b><br />";
|
| 80 |
|
|
| 96 |
|
|
| 81 | 97 |
$values = array ('type' => 'Modul', 'type_name' => $file, 'pages' => $add );
|
| 82 | 98 |
$msg = replace_all ( $msg_template_str, $values ); |
| 83 |
|
|
| 99 |
|
|
| 84 | 100 |
$page_names = ""; |
| 85 |
|
|
| 101 |
|
|
| 86 | 102 |
while ($data = $info->fetchRow() ) {
|
| 87 |
|
|
| 103 |
|
|
| 88 | 104 |
$temp = $database->query("SELECT page_title from ".TABLE_PREFIX."pages where page_id=".$data['page_id']);
|
| 89 | 105 |
$temp_title = $temp->fetchRow(); |
| 90 |
|
|
| 106 |
|
|
| 91 | 107 |
$page_info = array( |
| 92 |
'id' => $data['page_id'],
|
|
| 108 |
'id' => $data['page_id'], |
|
| 93 | 109 |
'title' => $temp_title['page_title'] |
| 94 | 110 |
); |
| 95 |
|
|
| 111 |
|
|
| 96 | 112 |
$page_names .= replace_all ( $page_template_str, $page_info ); |
| 97 | 113 |
} |
| 98 |
|
|
| 114 |
|
|
| 99 | 115 |
/** |
| 100 | 116 |
* Printing out the error-message and die(). |
| 101 | 117 |
*/ |
| 102 |
$admin->print_error(str_replace ($TEXT['FILE'], "Modul", $MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']).$msg.$page_names);
|
|
| 118 |
$admin->print_error(str_replace ($TEXT['FILE'], "Modul", $MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']).$msg.$page_names);
|
|
| 103 | 119 |
} |
| 104 | 120 |
|
| 105 | 121 |
// Check if we have permissions on the directory |
| 106 | 122 |
if(!is_writable(WB_PATH.'/modules/'.$file)) {
|
| 107 |
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
|
|
| 123 |
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
|
|
| 108 | 124 |
} |
| 109 | 125 |
|
| 110 | 126 |
// Run the modules uninstall script if there is one |
| 111 |
if(file_exists(WB_PATH.'/modules/'.$file.'/uninstall.php')) {
|
|
| 127 |
if(is_readable(WB_PATH.'/modules/'.$file.'/uninstall.php')) {
|
|
| 112 | 128 |
require(WB_PATH.'/modules/'.$file.'/uninstall.php'); |
| 113 | 129 |
} |
| 114 | 130 |
|
| 115 | 131 |
// Try to delete the module dir |
| 116 | 132 |
if(!rm_full_dir(WB_PATH.'/modules/'.$file)) {
|
| 117 |
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
|
|
| 133 |
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
|
|
| 118 | 134 |
} else {
|
| 119 | 135 |
// Remove entry from DB |
| 120 | 136 |
$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE directory = '".$file."' AND type = 'module'");
|
| 121 | 137 |
} |
| 122 | 138 |
|
| 123 | 139 |
// Print success message |
| 124 |
$admin->print_success($MESSAGE['GENERIC']['UNINSTALLED']);
|
|
| 140 |
$admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
|
|
| 125 | 141 |
|
| 126 | 142 |
// Print admin footer |
| 127 | 143 |
$admin->print_footer(); |
| 128 |
|
|
| 129 |
?> |
|
Also available in: Unified diff
! update folder admin/addons admin/skel/htt