source: trunk/admin/maintenance.php @ 12576

Last change on this file since 12576 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
RevLine 
[809]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[8728]5// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[809]23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
[1072]29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30
[809]31// +-----------------------------------------------------------------------+
[1072]32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
[8765]34
[1072]35check_status(ACCESS_ADMINISTRATOR);
36
[8765]37if (isset($_GET['action']))
38{
39  check_pwg_token();
40}
41
[1072]42// +-----------------------------------------------------------------------+
[809]43// |                                actions                                |
44// +-----------------------------------------------------------------------+
45
[8126]46$action = isset($_GET['action']) ? $_GET['action'] : '';
[809]47
48switch ($action)
49{
50  case 'categories' :
51  {
52    update_uppercats();
53    update_category('all');
54    update_global_rank();
[2890]55    invalidate_user_cache(true);
[809]56    break;
57  }
58  case 'images' :
59  {
60    update_path();
[11827]61                include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
62    update_rating_score();
[809]63    break;
64  }
[8762]65  case 'delete_orphan_tags' :
66  {
67    delete_orphan_tags();
68    break;
69  }
[2062]70  case 'history_detail' :
[809]71  {
72    $query = '
73DELETE
[2062]74  FROM '.HISTORY_TABLE.'
[1987]75;';
76    pwg_query($query);
[2062]77    break;
78  }
79  case 'history_summary' :
80  {
[1987]81    $query = '
82DELETE
[2062]83  FROM '.HISTORY_SUMMARY_TABLE.'
[809]84;';
85    pwg_query($query);
86    break;
87  }
88  case 'sessions' :
89  {
[1080]90    pwg_session_gc();
[809]91    break;
92  }
[833]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  }
[1111]103  case 'database' :
104  {
105    do_maintenance_all_tables();
106    break;
107  }
[2208]108  case 'c13y' :
109  {
[2232]110    include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
111    $c13y = new check_integrity();
112    $c13y->maintenance();
[2208]113    break;
114  }
[3517]115  case 'search' :
116  {
117    $query = '
118DELETE
119  FROM '.SEARCH_TABLE.'
120;';
121    pwg_query($query);
122    break;
123  }
[2251]124  case 'compiled-templates' :
125  {
[2278]126    $template->delete_compiled_templates();
[8634]127    FileCombiner::clear_combined_files();
[2251]128    break;
129  }
[809]130  default :
131  {
132    break;
133  }
134}
135
136// +-----------------------------------------------------------------------+
137// |                             template init                             |
138// +-----------------------------------------------------------------------+
139
[2530]140$template->set_filenames(array('maintenance'=>'maintenance.tpl'));
[809]141
[8765]142$url_format = get_root_url().'admin.php?page=maintenance&amp;action=%s&amp;pwg_token='.get_pwg_token();
[809]143
[2251]144$template->assign(
[1111]145  array(
[8765]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'),
[5920]157    'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance',
[1111]158    )
159  );
[1080]160
[809]161// +-----------------------------------------------------------------------+
[5745]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// +-----------------------------------------------------------------------+
[809]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.