Project

General

Profile

« Previous | Next » 

Revision 1712

Added by Dietmar about 12 years ago

! update folder admin/addons admin/skel/htt

View differences:

uninstall.php
3 3
 *
4 4
 * @category        admin
5 5
 * @package         templates
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
......
28 27
}
29 28
// After check print the header
30 29
$admin->print_header();
30
if(!isset($_POST['file']) OR $_POST['file'] == "") {
31
	$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS']);
32
} else {
33
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-2
34
}
31 35

  
36
// Check if the template exists
37
if(!is_dir(WB_PATH.'/templates/'.$file)) {
38
	$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
39
}
40

  
41
// Check if the template exists
42
if(!is_readable(WB_PATH.'/templates/'.$file)) {
43
	$admin->print_error($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
44
}
45

  
32 46
// Check if user selected template
47
/*
33 48
if(!isset($_POST['file']) OR $_POST['file'] == "") {
34 49
	header("Location: index.php");
35 50
	exit(0);
......
42 57
	header("Location: index.php");
43 58
	exit(0);
44 59
}
60
*/
45 61

  
46 62
// Include the WB functions file
47 63
require_once(WB_PATH.'/framework/functions.php');
48

  
49
// Check if the template exists
50
if(!is_dir(WB_PATH.'/templates/'.$file)) {
51
	$admin->print_error($MESSAGE['GENERIC']['NOT_INSTALLED']);
52
}
53

  
54 64
if (!function_exists("replace_all")) {
55 65
	function replace_all ($aStr = "", &$aArray ) {
56 66
		foreach($aArray as $k=>$v) $aStr = str_replace("{{".$k."}}", $v, $aStr);
......
62 72
*	Check if the template is the standard-template or still in use
63 73
*/
64 74
if (!array_key_exists('CANNOT_UNINSTALL_IS_DEFAULT_TEMPLATE', $MESSAGE['GENERIC'] ) )
65
	$MESSAGE['GENERIC']['CANNOT_UNINSTALL_IS_DEFAULT_TEMPLATE'] = "Can't uninstall this template <b>{{name}}</b> because it's the standardtemplate!";
75
	$MESSAGE['GENERIC_CANNOT_UNINSTALL_IS_DEFAULT_TEMPLATE'] = "Can't uninstall this template <b>{{name}}</b> because it's the standardtemplate!";
66 76

  
67 77
// check whether the template is used as default wb theme
68 78
if($file == DEFAULT_THEME) {
69 79
	$temp = array ('name' => $file );
70
	$msg = replace_all( $MESSAGE['GENERIC']['CANNOT_UNINSTALL_IS_DEFAULT_TEMPLATE'], $temp );
80
	$msg = replace_all( $MESSAGE['GENERIC_CANNOT_UNINSTALL_IS_DEFAULT_TEMPLATE'], $temp );
71 81
	$admin->print_error( $msg );
72 82
}
73 83

  
74 84
if ($file == DEFAULT_TEMPLATE) {
75 85
	$temp = array ('name' => $file );
76
	$msg = replace_all( $MESSAGE['GENERIC']['CANNOT_UNINSTALL_IS_DEFAULT_TEMPLATE'], $temp );
86
	$msg = replace_all( $MESSAGE['GENERIC_CANNOT_UNINSTALL_IS_DEFAULT_TEMPLATE'], $temp );
77 87
	$admin->print_error( $msg );
78 88

  
79 89
} else {
80
	
90

  
81 91
	/**
82 92
	*	Check if the template is still in use by a page ...
83 93
	*/
84 94
	$info = $database->query("SELECT page_id, page_title FROM ".TABLE_PREFIX."pages WHERE template='".$file."' order by page_title");
85
	
95

  
86 96
	if ($info->numRows() > 0) {
87 97
		/**
88 98
		*	Template is still in use, so we're collecting the page-titles
89 99
		*/
90
		
100

  
91 101
		/**
92 102
		*	The base-message template-string for the top of the message
93 103
		*/
......
96 106
			$msg_template_str  = "<br /><br />{{type}} <b>{{type_name}}</b> could not be uninstalled because it is still in use by {{pages}}";
97 107
			$msg_template_str .= ":<br /><i>click for editing.</i><br /><br />";
98 108
		} else {
99
			$msg_template_str = $MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE_TMPL'];
100
			$temp = explode(";",$MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE_TMPL_PAGES']);
109
			$msg_template_str = $MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE_TMPL'];
110
			$temp = explode(";",$MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE_TMPL_PAGES']);
101 111
			$add = $info->numRows() == 1 ? $temp[0] : $temp[1];
102 112
		}
103 113
		/**
104 114
		*	The template-string for displaying the Page-Titles ... in this case as a link
105 115
		*/
106 116
		$page_template_str = "- <b><a href='../pages/settings.php?page_id={{id}}'>{{title}}</a></b><br />";
107
		
117

  
108 118
		$values = array ('type' => 'Template', 'type_name' => $file, 'pages' => $add);
109 119
		$msg = replace_all ( $msg_template_str,  $values );
110
		
120

  
111 121
		$page_names = "";
112
		
122

  
113 123
		while ($data = $info->fetchRow() ) {
114
			
124

  
115 125
			$page_info = array(
116
				'id'	=> $data['page_id'], 
126
				'id'	=> $data['page_id'],
117 127
				'title' => $data['page_title']
118 128
			);
119
			
129

  
120 130
			$page_names .= replace_all ( $page_template_str, $page_info );
121 131
		}
122
		
132

  
123 133
		/**
124 134
		*	Printing out the error-message and die().
125 135
		*/
126
		$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE'].$msg.$page_names);
136
		$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE'].$msg.$page_names);
127 137
	}
128 138
}
129 139

  
130 140
// Check if we have permissions on the directory
131 141
if(!is_writable(WB_PATH.'/templates/'.$file)) {
132
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL'].WB_PATH.'/templates/'.$file);
142
	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL'].WB_PATH.'/templates/'.$file);
133 143
}
134 144

  
135 145
// Try to delete the template dir
136 146
if(!rm_full_dir(WB_PATH.'/templates/'.$file)) {
137
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
147
	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
138 148
} else {
139 149
	// Remove entry from DB
140 150
	$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE directory = '".$file."' AND type = 'template'");
......
145 155
$database->query("UPDATE ".TABLE_PREFIX."pages SET template = '".DEFAULT_TEMPLATE."' WHERE template = '$file'");
146 156

  
147 157
// Print success message
148
$admin->print_success($MESSAGE['GENERIC']['UNINSTALLED']);
158
$admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
149 159

  
150 160
// Print admin footer
151 161
$admin->print_footer();
152

  
153
?>

Also available in: Unified diff