source: branches/2.3/admin/maintenance.php @ 23375

Last change on this file since 23375 was 11827, checked in by rvelices, 13 years ago

feature 2384: improve average rating calculation (still need to update language files)

  • Property svn:eol-style set to LF
File size: 5.6 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  default :
131  {
132    break;
133  }
134}
135
136// +-----------------------------------------------------------------------+
137// |                             template init                             |
138// +-----------------------------------------------------------------------+
139
140$template->set_filenames(array('maintenance'=>'maintenance.tpl'));
141
142$url_format = get_root_url().'admin.php?page=maintenance&amp;action=%s&amp;pwg_token='.get_pwg_token();
143
144$template->assign(
145  array(
146    'U_MAINT_CATEGORIES' => sprintf($url_format, 'categories'),
147    'U_MAINT_IMAGES' => sprintf($url_format, 'images'),
148    'U_MAINT_ORPHAN_TAGS' => sprintf($url_format, 'delete_orphan_tags'),
149    'U_MAINT_HISTORY_DETAIL' => sprintf($url_format, 'history_detail'),
150    'U_MAINT_HISTORY_SUMMARY' => sprintf($url_format, 'history_summary'),
151    'U_MAINT_SESSIONS' => sprintf($url_format, 'sessions'),
152    'U_MAINT_FEEDS' => sprintf($url_format, 'feeds'),
153    'U_MAINT_DATABASE' => sprintf($url_format, 'database'),
154    'U_MAINT_C13Y' => sprintf($url_format, 'c13y'),
155    'U_MAINT_SEARCH' => sprintf($url_format, 'search'),
156    'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'),
157    'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance',
158    )
159  );
160
161// +-----------------------------------------------------------------------+
162// | Define advanced features                                              |
163// +-----------------------------------------------------------------------+
164
165$advanced_features = array();
166
167//$advanced_features is array of array composed of CAPTION & URL
168$advanced_features = trigger_event(
169  'get_admin_advanced_features_links',
170  $advanced_features
171  );
172
173$template->assign('advanced_features', $advanced_features);
174
175// +-----------------------------------------------------------------------+
176// |                           sending html code                           |
177// +-----------------------------------------------------------------------+
178
179$template->assign_var_from_handle('ADMIN_CONTENT', 'maintenance');
180?>
Note: See TracBrowser for help on using the repository browser.