source: branches/1.7/admin/maintenance.php @ 27218

Last change on this file since 27218 was 2307, checked in by rvelices, 17 years ago

merge r 2306 from trunk to branch-1_7

  • merged function ordering() with update_global_rank() and also optimized the queries
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: maintenance.php 2307 2008-04-20 22:25:40Z rvelices $
8// | last update   : $Date: 2008-04-20 22:25:40 +0000 (Sun, 20 Apr 2008) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2307 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27if (!defined('PHPWG_ROOT_PATH'))
28{
29  die ("Hacking attempt!");
30}
31
32include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
33
34// +-----------------------------------------------------------------------+
35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37check_status(ACCESS_ADMINISTRATOR);
38
39// +-----------------------------------------------------------------------+
40// |                                actions                                |
41// +-----------------------------------------------------------------------+
42
43$action = (isset($_GET['action']) and !is_adviser()) ? $_GET['action'] : '';
44
45switch ($action)
46{
47  case 'categories' :
48  {
49    update_uppercats();
50    update_category('all');
51    update_global_rank();
52    invalidate_user_cache();
53    break;
54  }
55  case 'images' :
56  {
57    update_path();
58    update_average_rate();
59    break;
60  }
61  case 'history_detail' :
62  {
63    $query = '
64DELETE
65  FROM '.HISTORY_TABLE.'
66;';
67    pwg_query($query);
68    break;
69  }
70  case 'history_summary' :
71  {
72    $query = '
73DELETE
74  FROM '.HISTORY_SUMMARY_TABLE.'
75;';
76    pwg_query($query);
77    break;
78  }
79  case 'sessions' :
80  {
81    pwg_session_gc();
82    break;
83  }
84  case 'feeds' :
85  {
86    $query = '
87DELETE
88  FROM '.USER_FEED_TABLE.'
89  WHERE last_check IS NULL
90;';
91    pwg_query($query);
92    break;
93  }
94  case 'database' :
95  {
96    do_maintenance_all_tables();
97    break;
98  }
99  default :
100  {
101    break;
102  }
103}
104
105// +-----------------------------------------------------------------------+
106// |                             template init                             |
107// +-----------------------------------------------------------------------+
108
109$template->set_filenames(array('maintenance'=>'admin/maintenance.tpl'));
110
111$start_url = PHPWG_ROOT_PATH.'admin.php?page=maintenance&amp;action=';
112
113$template->assign_vars(
114  array(
115    'U_MAINT_CATEGORIES' => $start_url.'categories',
116    'U_MAINT_IMAGES' => $start_url.'images',
117    'U_MAINT_HISTORY_DETAIL' => $start_url.'history_detail',
118    'U_MAINT_HISTORY_SUMMARY' => $start_url.'history_summary',
119    'U_MAINT_SESSIONS' => $start_url.'sessions',
120    'U_MAINT_FEEDS' => $start_url.'feeds',
121    'U_MAINT_DATABASE' => $start_url.'database',
122    'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=maintenance',
123    )
124  );
125
126// +-----------------------------------------------------------------------+
127// |                           sending html code                           |
128// +-----------------------------------------------------------------------+
129
130$template->assign_var_from_handle('ADMIN_CONTENT', 'maintenance');
131?>
Note: See TracBrowser for help on using the repository browser.