source: trunk/admin/maintenance.php @ 12797

Last change on this file since 12797 was 12797, checked in by rvelices, 9 years ago

feature 2541 multisize

  • nicer presentation on picture.php
  • added a maintenance purge derivatives action
  • Property svn:eol-style set to LF
File size: 5.7 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                include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
62    update_rating_score();
63    break;
64  }
65  case 'delete_orphan_tags' :
66  {
67    delete_orphan_tags();
68    break;
69  }
70  case 'history_detail' :
71  {
72    $query = '
73DELETE
74  FROM '.HISTORY_TABLE.'
75;';
76    pwg_query($query);
77    break;
78  }
79  case 'history_summary' :
80  {
81    $query = '
82DELETE
83  FROM '.HISTORY_SUMMARY_TABLE.'
84;';
85    pwg_query($query);
86    break;
87  }
88  case 'sessions' :
89  {
90    pwg_session_gc();
91    break;
92  }
93  case 'feeds' :
94  {
95    $query = '
96DELETE
97  FROM '.USER_FEED_TABLE.'
98  WHERE last_check IS NULL
99;';
100    pwg_query($query);
101    break;
102  }
103  case 'database' :
104  {
105    do_maintenance_all_tables();
106    break;
107  }
108  case 'c13y' :
109  {
110    include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
111    $c13y = new check_integrity();
112    $c13y->maintenance();
113    break;
114  }
115  case 'search' :
116  {
117    $query = '
118DELETE
119  FROM '.SEARCH_TABLE.'
120;';
121    pwg_query($query);
122    break;
123  }
124  case 'compiled-templates':
125  {
126    $template->delete_compiled_templates();
127    FileCombiner::clear_combined_files();
128    break;
129  }
130  case 'derivatives':
131  {
132    clear_derivative_cache();
133    break;
134  }
135  default :
136  {
137    break;
138  }
139}
140
141// +-----------------------------------------------------------------------+
142// |                             template init                             |
143// +-----------------------------------------------------------------------+
144
145$template->set_filenames(array('maintenance'=>'maintenance.tpl'));
146
147$url_format = get_root_url().'admin.php?page=maintenance&amp;action=%s&amp;pwg_token='.get_pwg_token();
148
149$template->assign(
150  array(
151    'U_MAINT_CATEGORIES' => sprintf($url_format, 'categories'),
152    'U_MAINT_IMAGES' => sprintf($url_format, 'images'),
153    'U_MAINT_ORPHAN_TAGS' => sprintf($url_format, 'delete_orphan_tags'),
154    'U_MAINT_HISTORY_DETAIL' => sprintf($url_format, 'history_detail'),
155    'U_MAINT_HISTORY_SUMMARY' => sprintf($url_format, 'history_summary'),
156    'U_MAINT_SESSIONS' => sprintf($url_format, 'sessions'),
157    'U_MAINT_FEEDS' => sprintf($url_format, 'feeds'),
158    'U_MAINT_DATABASE' => sprintf($url_format, 'database'),
159    'U_MAINT_C13Y' => sprintf($url_format, 'c13y'),
160    'U_MAINT_SEARCH' => sprintf($url_format, 'search'),
161    'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'),
162    'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'),
163    'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance',
164    )
165  );
166
167// +-----------------------------------------------------------------------+
168// | Define advanced features                                              |
169// +-----------------------------------------------------------------------+
170
171$advanced_features = array();
172
173//$advanced_features is array of array composed of CAPTION & URL
174$advanced_features = trigger_event(
175  'get_admin_advanced_features_links',
176  $advanced_features
177  );
178
179$template->assign('advanced_features', $advanced_features);
180
181// +-----------------------------------------------------------------------+
182// |                           sending html code                           |
183// +-----------------------------------------------------------------------+
184
185$template->assign_var_from_handle('ADMIN_CONTENT', 'maintenance');
186?>
Note: See TracBrowser for help on using the repository browser.