source: trunk/admin/maintenance.php @ 11493

Last change on this file since 11493 was 8765, checked in by plg, 14 years ago

feature 1289 updated: add pwg_token on the delete_orphan_tags maintenance action
(and all other maintenace actions as well)

  • Property svn:eol-style set to LF
File size: 5.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30
31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34
35check_status(ACCESS_ADMINISTRATOR);
36
37if (isset($_GET['action']))
38{
39  check_pwg_token();
40}
41
42// +-----------------------------------------------------------------------+
43// |                                actions                                |
44// +-----------------------------------------------------------------------+
45
46$action = isset($_GET['action']) ? $_GET['action'] : '';
47
48switch ($action)
49{
50  case 'categories' :
51  {
52    update_uppercats();
53    update_category('all');
54    update_global_rank();
55    invalidate_user_cache(true);
56    break;
57  }
58  case 'images' :
59  {
60    update_path();
61    update_average_rate();
62    break;
63  }
64  case 'delete_orphan_tags' :
65  {
66    delete_orphan_tags();
67    break;
68  }
69  case 'history_detail' :
70  {
71    $query = '
72DELETE
73  FROM '.HISTORY_TABLE.'
74;';
75    pwg_query($query);
76    break;
77  }
78  case 'history_summary' :
79  {
80    $query = '
81DELETE
82  FROM '.HISTORY_SUMMARY_TABLE.'
83;';
84    pwg_query($query);
85    break;
86  }
87  case 'sessions' :
88  {
89    pwg_session_gc();
90    break;
91  }
92  case 'feeds' :
93  {
94    $query = '
95DELETE
96  FROM '.USER_FEED_TABLE.'
97  WHERE last_check IS NULL
98;';
99    pwg_query($query);
100    break;
101  }
102  case 'database' :
103  {
104    do_maintenance_all_tables();
105    break;
106  }
107  case 'c13y' :
108  {
109    include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
110    $c13y = new check_integrity();
111    $c13y->maintenance();
112    break;
113  }
114  case 'search' :
115  {
116    $query = '
117DELETE
118  FROM '.SEARCH_TABLE.'
119;';
120    pwg_query($query);
121    break;
122  }
123  case 'compiled-templates' :
124  {
125    $template->delete_compiled_templates();
126    FileCombiner::clear_combined_files();
127    break;
128  }
129  default :
130  {
131    break;
132  }
133}
134
135// +-----------------------------------------------------------------------+
136// |                             template init                             |
137// +-----------------------------------------------------------------------+
138
139$template->set_filenames(array('maintenance'=>'maintenance.tpl'));
140
141$url_format = get_root_url().'admin.php?page=maintenance&amp;action=%s&amp;pwg_token='.get_pwg_token();
142
143$template->assign(
144  array(
145    'U_MAINT_CATEGORIES' => sprintf($url_format, 'categories'),
146    'U_MAINT_IMAGES' => sprintf($url_format, 'images'),
147    'U_MAINT_ORPHAN_TAGS' => sprintf($url_format, 'delete_orphan_tags'),
148    'U_MAINT_HISTORY_DETAIL' => sprintf($url_format, 'history_detail'),
149    'U_MAINT_HISTORY_SUMMARY' => sprintf($url_format, 'history_summary'),
150    'U_MAINT_SESSIONS' => sprintf($url_format, 'sessions'),
151    'U_MAINT_FEEDS' => sprintf($url_format, 'feeds'),
152    'U_MAINT_DATABASE' => sprintf($url_format, 'database'),
153    'U_MAINT_C13Y' => sprintf($url_format, 'c13y'),
154    'U_MAINT_SEARCH' => sprintf($url_format, 'search'),
155    'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'),
156    'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance',
157    )
158  );
159
160// +-----------------------------------------------------------------------+
161// | Define advanced features                                              |
162// +-----------------------------------------------------------------------+
163
164$advanced_features = array();
165
166//$advanced_features is array of array composed of CAPTION & URL
167$advanced_features = trigger_event(
168  'get_admin_advanced_features_links',
169  $advanced_features
170  );
171
172$template->assign('advanced_features', $advanced_features);
173
174// +-----------------------------------------------------------------------+
175// |                           sending html code                           |
176// +-----------------------------------------------------------------------+
177
178$template->assign_var_from_handle('ADMIN_CONTENT', 'maintenance');
179?>
Note: See TracBrowser for help on using the repository browser.