1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
25 | { |
---|
26 | die ("Hacking attempt!"); |
---|
27 | } |
---|
28 | |
---|
29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
30 | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | // | Check Access and exit when user status is not ok | |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | |
---|
35 | check_status(ACCESS_ADMINISTRATOR); |
---|
36 | |
---|
37 | if (isset($_GET['action'])) |
---|
38 | { |
---|
39 | check_pwg_token(); |
---|
40 | } |
---|
41 | |
---|
42 | // +-----------------------------------------------------------------------+ |
---|
43 | // | actions | |
---|
44 | // +-----------------------------------------------------------------------+ |
---|
45 | |
---|
46 | $action = isset($_GET['action']) ? $_GET['action'] : ''; |
---|
47 | |
---|
48 | switch ($action) |
---|
49 | { |
---|
50 | case 'lock_gallery' : |
---|
51 | { |
---|
52 | conf_update_param('gallery_locked', 'true'); |
---|
53 | redirect(get_root_url().'admin.php?page=maintenance'); |
---|
54 | break; |
---|
55 | } |
---|
56 | case 'unlock_gallery' : |
---|
57 | { |
---|
58 | conf_update_param('gallery_locked', 'false'); |
---|
59 | $_SESSION['page_infos'] = array(l10n('Gallery unlocked')); |
---|
60 | redirect(get_root_url().'admin.php?page=maintenance'); |
---|
61 | break; |
---|
62 | } |
---|
63 | case 'categories' : |
---|
64 | { |
---|
65 | update_uppercats(); |
---|
66 | update_category('all'); |
---|
67 | update_global_rank(); |
---|
68 | invalidate_user_cache(true); |
---|
69 | break; |
---|
70 | } |
---|
71 | case 'images' : |
---|
72 | { |
---|
73 | update_path(); |
---|
74 | include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php'); |
---|
75 | update_rating_score(); |
---|
76 | break; |
---|
77 | } |
---|
78 | case 'delete_orphan_tags' : |
---|
79 | { |
---|
80 | delete_orphan_tags(); |
---|
81 | break; |
---|
82 | } |
---|
83 | case 'history_detail' : |
---|
84 | { |
---|
85 | $query = ' |
---|
86 | DELETE |
---|
87 | FROM '.HISTORY_TABLE.' |
---|
88 | ;'; |
---|
89 | pwg_query($query); |
---|
90 | break; |
---|
91 | } |
---|
92 | case 'history_summary' : |
---|
93 | { |
---|
94 | $query = ' |
---|
95 | DELETE |
---|
96 | FROM '.HISTORY_SUMMARY_TABLE.' |
---|
97 | ;'; |
---|
98 | pwg_query($query); |
---|
99 | break; |
---|
100 | } |
---|
101 | case 'sessions' : |
---|
102 | { |
---|
103 | pwg_session_gc(); |
---|
104 | break; |
---|
105 | } |
---|
106 | case 'feeds' : |
---|
107 | { |
---|
108 | $query = ' |
---|
109 | DELETE |
---|
110 | FROM '.USER_FEED_TABLE.' |
---|
111 | WHERE last_check IS NULL |
---|
112 | ;'; |
---|
113 | pwg_query($query); |
---|
114 | break; |
---|
115 | } |
---|
116 | case 'database' : |
---|
117 | { |
---|
118 | do_maintenance_all_tables(); |
---|
119 | break; |
---|
120 | } |
---|
121 | case 'c13y' : |
---|
122 | { |
---|
123 | include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php'); |
---|
124 | $c13y = new check_integrity(); |
---|
125 | $c13y->maintenance(); |
---|
126 | break; |
---|
127 | } |
---|
128 | case 'search' : |
---|
129 | { |
---|
130 | $query = ' |
---|
131 | DELETE |
---|
132 | FROM '.SEARCH_TABLE.' |
---|
133 | ;'; |
---|
134 | pwg_query($query); |
---|
135 | break; |
---|
136 | } |
---|
137 | case 'compiled-templates': |
---|
138 | { |
---|
139 | $template->delete_compiled_templates(); |
---|
140 | FileCombiner::clear_combined_files(); |
---|
141 | break; |
---|
142 | } |
---|
143 | case 'derivatives': |
---|
144 | { |
---|
145 | clear_derivative_cache($_GET['type']); |
---|
146 | break; |
---|
147 | } |
---|
148 | default : |
---|
149 | { |
---|
150 | break; |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | // +-----------------------------------------------------------------------+ |
---|
155 | // | template init | |
---|
156 | // +-----------------------------------------------------------------------+ |
---|
157 | |
---|
158 | $template->set_filenames(array('maintenance'=>'maintenance.tpl')); |
---|
159 | |
---|
160 | $url_format = get_root_url().'admin.php?page=maintenance&action=%s&pwg_token='.get_pwg_token(); |
---|
161 | |
---|
162 | $purge_urls[l10n('All')] = sprintf($url_format, 'derivatives').'&type=all'; |
---|
163 | foreach(ImageStdParams::get_defined_type_map() as $params) |
---|
164 | { |
---|
165 | $purge_urls[ l10n($params->type) ] = sprintf($url_format, 'derivatives').'&type='.$params->type; |
---|
166 | } |
---|
167 | $purge_urls[ l10n(IMG_CUSTOM) ] = sprintf($url_format, 'derivatives').'&type='.IMG_CUSTOM; |
---|
168 | |
---|
169 | $template->assign( |
---|
170 | array( |
---|
171 | 'U_MAINT_CATEGORIES' => sprintf($url_format, 'categories'), |
---|
172 | 'U_MAINT_IMAGES' => sprintf($url_format, 'images'), |
---|
173 | 'U_MAINT_ORPHAN_TAGS' => sprintf($url_format, 'delete_orphan_tags'), |
---|
174 | 'U_MAINT_HISTORY_DETAIL' => sprintf($url_format, 'history_detail'), |
---|
175 | 'U_MAINT_HISTORY_SUMMARY' => sprintf($url_format, 'history_summary'), |
---|
176 | 'U_MAINT_SESSIONS' => sprintf($url_format, 'sessions'), |
---|
177 | 'U_MAINT_FEEDS' => sprintf($url_format, 'feeds'), |
---|
178 | 'U_MAINT_DATABASE' => sprintf($url_format, 'database'), |
---|
179 | 'U_MAINT_C13Y' => sprintf($url_format, 'c13y'), |
---|
180 | 'U_MAINT_SEARCH' => sprintf($url_format, 'search'), |
---|
181 | 'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'), |
---|
182 | 'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'), |
---|
183 | 'purge_derivatives' => $purge_urls, |
---|
184 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance', |
---|
185 | ) |
---|
186 | ); |
---|
187 | |
---|
188 | |
---|
189 | if ($conf['gallery_locked']) |
---|
190 | { |
---|
191 | $template->assign( |
---|
192 | array( |
---|
193 | 'U_MAINT_UNLOCK_GALLERY' => sprintf($url_format, 'unlock_gallery'), |
---|
194 | ) |
---|
195 | ); |
---|
196 | } |
---|
197 | else |
---|
198 | { |
---|
199 | $template->assign( |
---|
200 | array( |
---|
201 | 'U_MAINT_LOCK_GALLERY' => sprintf($url_format, 'lock_gallery'), |
---|
202 | ) |
---|
203 | ); |
---|
204 | } |
---|
205 | |
---|
206 | // +-----------------------------------------------------------------------+ |
---|
207 | // | Define advanced features | |
---|
208 | // +-----------------------------------------------------------------------+ |
---|
209 | |
---|
210 | $advanced_features = array(); |
---|
211 | |
---|
212 | //$advanced_features is array of array composed of CAPTION & URL |
---|
213 | $advanced_features = trigger_event( |
---|
214 | 'get_admin_advanced_features_links', |
---|
215 | $advanced_features |
---|
216 | ); |
---|
217 | |
---|
218 | $template->assign('advanced_features', $advanced_features); |
---|
219 | |
---|
220 | // +-----------------------------------------------------------------------+ |
---|
221 | // | sending html code | |
---|
222 | // +-----------------------------------------------------------------------+ |
---|
223 | |
---|
224 | $template->assign_var_from_handle('ADMIN_CONTENT', 'maintenance'); |
---|
225 | ?> |
---|