source: trunk/admin/maintenance.php @ 5123

Last change on this file since 5123 was 5094, checked in by ddtddt, 14 years ago

[trunk] merge 5093 bug:986

  • Property svn:eol-style set to LF
File size: 4.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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// +-----------------------------------------------------------------------+
34check_status(ACCESS_ADMINISTRATOR);
35
36// +-----------------------------------------------------------------------+
37// |                                actions                                |
38// +-----------------------------------------------------------------------+
39
40$action = (isset($_GET['action']) and !is_adviser()) ? $_GET['action'] : '';
41
42switch ($action)
43{
44  case 'categories' :
45  {
46    update_uppercats();
47    update_category('all');
48    update_global_rank();
49    invalidate_user_cache(true);
50    break;
51  }
52  case 'images' :
53  {
54    update_path();
55    update_average_rate();
56    break;
57  }
58  case 'history_detail' :
59  {
60    $query = '
61DELETE
62  FROM '.HISTORY_TABLE.'
63;';
64    pwg_query($query);
65    break;
66  }
67  case 'history_summary' :
68  {
69    $query = '
70DELETE
71  FROM '.HISTORY_SUMMARY_TABLE.'
72;';
73    pwg_query($query);
74    break;
75  }
76  case 'sessions' :
77  {
78    pwg_session_gc();
79    break;
80  }
81  case 'feeds' :
82  {
83    $query = '
84DELETE
85  FROM '.USER_FEED_TABLE.'
86  WHERE last_check IS NULL
87;';
88    pwg_query($query);
89    break;
90  }
91  case 'database' :
92  {
93    do_maintenance_all_tables();
94    break;
95  }
96  case 'c13y' :
97  {
98    include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
99    $c13y = new check_integrity();
100    $c13y->maintenance();
101    break;
102  }
103  case 'search' :
104  {
105    $query = '
106DELETE
107  FROM '.SEARCH_TABLE.'
108;';
109    pwg_query($query);
110    break;
111  }
112  case 'compiled-templates' :
113  {
114    $template->delete_compiled_templates();
115    break;
116  }
117  default :
118  {
119    break;
120  }
121}
122
123// +-----------------------------------------------------------------------+
124// |                             template init                             |
125// +-----------------------------------------------------------------------+
126
127$template->set_filenames(array('maintenance'=>'maintenance.tpl'));
128
129$start_url = get_root_url().'admin.php?page=maintenance&amp;action=';
130
131$template->assign(
132  array(
133    'U_MAINT_CATEGORIES' => $start_url.'categories',
134    'U_MAINT_IMAGES' => $start_url.'images',
135    'U_MAINT_HISTORY_DETAIL' => $start_url.'history_detail',
136    'U_MAINT_HISTORY_SUMMARY' => $start_url.'history_summary',
137    'U_MAINT_SESSIONS' => $start_url.'sessions',
138    'U_MAINT_FEEDS' => $start_url.'feeds',
139    'U_MAINT_DATABASE' => $start_url.'database',
140    'U_MAINT_C13Y' => $start_url.'c13y',
141        'U_MAINT_SEARCH' => $start_url.'search',
142    'U_MAINT_COMPILED_TEMPLATES' => $start_url.'compiled-templates',
143    'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=maintenance',
144    )
145  );
146
147// +-----------------------------------------------------------------------+
148// |                           sending html code                           |
149// +-----------------------------------------------------------------------+
150
151$template->assign_var_from_handle('ADMIN_CONTENT', 'maintenance');
152?>
Note: See TracBrowser for help on using the repository browser.