Dotclear

source: plugins/maintenance/index.php @ 1553:e42635c9dc4a

Revision 1553:e42635c9dc4a, 4.9 KB checked in by Anne Kozlika <kozlika@…>, 11 years ago (diff)

Replace class="message" by class="success" where it is needed.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : null;
15$start = !empty($_GET['start']) ? abs((integer) $_GET['start']) : 0;
16
17if ($action == 'vacuum')
18{
19     try
20     {
21          $schema = dbSchema::init($core->con);
22          $db_tables = $schema->getTables();
23         
24          foreach ($db_tables as $t) {
25               if (strpos($t,$core->prefix) === 0) {
26                    $core->con->vacuum($t);
27               }
28          }
29          http::redirect($p_url.'&vacuum=1');
30     }
31     catch (Exception $e)
32     {
33          $core->error->add($e->getMessage());
34     }
35}
36elseif ($action == 'commentscount')
37{
38     try {
39          $core->countAllComments();
40          http::redirect($p_url.'&commentscount=1');
41     } catch (Exception $e) {
42          $core->error->add($e->getMessage());
43     }
44}
45elseif ($action == 'empty_cache')
46{
47     try {
48          $core->emptyTemplatesCache();
49          http::redirect($p_url.'&empty_cache=1');
50     } catch (Exception $e) {
51          $core->error->add($e->getMessage());
52     }
53}
54elseif ($action == 'log')
55{
56     try {
57          $core->log->delLogs(null,true);
58          http::redirect($p_url.'&delete_logs=1');
59     } catch (Exception $e) {
60          $core->error->add($e->getMessage());
61     }
62}
63
64?>
65<html>
66<head>
67  <title><?php echo __('Maintenance'); ?></title>
68</head>
69
70<body>
71<?php
72     echo dcPage::breadcrumb(
73          array(
74               __('Plugins') => '',
75               '<span class="page-title">'.__('Maintenance').'</span>' => ''
76          ));
77?>
78
79<?php
80if (!empty($_GET['vacuum'])) {
81     dcPage::success(__('Optimization successful.'));
82}
83if (!empty($_GET['commentscount'])) {
84     dcPage::success(__('Comments and trackback counted.'));
85}
86if (!empty($_GET['empty_cache'])) {
87     dcPage::success(__('Templates cache directory emptied.'));
88}
89if (!empty($_GET['delete_logs'])) {
90     dcPage::success(__('Logs deleted.'));
91}
92
93if ($action == 'index' && !empty($_GET['indexposts']))
94{
95     $limit = 1000;
96     echo '<p>'.sprintf(__('Indexing entry %d to %d.'),$start,$start+$limit).'</p>';
97     
98     $new_start = $core->indexAllPosts($start,$limit);
99     
100     if ($new_start)
101     {
102          $new_url = $p_url.'&action=index&indexposts=1&start='.$new_start;
103          echo
104          '<script type="text/javascript">'."\n".
105          "//<![CDATA\n".
106          "window.location = '".$new_url."'\n".
107          "//]]>\n".
108          '</script>'.
109          '<noscript><p><a href="'.html::escapeURL($new_url).'">'.__('next').'</a></p></noscript>';
110     }
111     else
112     {
113          dcPage::message(__('Entries index done.'));
114          echo '<p><a class="back" href="'.$p_url.'">'.__('Back').'</a></p>';
115     }
116}
117elseif ($action == 'index' && !empty($_GET['indexcomments']))
118{
119     $limit = 1000;
120     echo '<p>'.sprintf(__('Indexing comment %d to %d.'),$start,$start+$limit).'</p>';
121     
122     $new_start = $core->indexAllComments($start,$limit);
123     
124     if ($new_start)
125     {
126          $new_url = $p_url.'&action=index&indexcomments=1&start='.$new_start;
127          echo
128          '<script type="text/javascript">'."\n".
129          "//<![CDATA\n".
130          "window.location = '".$new_url."'\n".
131          "//]]>\n".
132          '</script>'.
133          '<noscript><p><a href="'.html::escapeURL($new_url).'">'.__('next').'</a></p></noscript>';
134     }
135     else
136     {
137          dcPage::message(__('Comments index done.'));
138          echo '<p><a class="back" href="'.$p_url.'">'.__('Back').'</a></p>';
139     }
140}
141else
142{
143     echo
144     '<h3>'.__('Optimize database room').'</h3>'.
145     '<form action="plugin.php" method="post">'.
146     '<p><input type="submit" value="'.__('Vacuum tables').'" /> '.
147     $core->formNonce().
148     form::hidden(array('action'),'vacuum').
149     form::hidden(array('p'),'maintenance').'</p>'.
150     '</form>';
151     
152     echo
153     '<h3>'.__('Counters').'</h3>'.
154     '<form action="plugin.php" method="post">'.
155     '<p><input type="submit" value="'.__('Reset comments and ping counters').'" /> '.
156     $core->formNonce().
157     form::hidden(array('action'),'commentscount').
158     form::hidden(array('p'),'maintenance').'</p>'.
159     '</form>';
160     
161     echo
162     '<h3>'.__('Search engine index').' ('.__('This may take a very long time').')</h3>'.
163     '<form action="plugin.php" method="get">'.
164     '<p><input type="submit" name="indexposts" value="'.__('Index all posts').'" /> '.
165     '<input type="submit" name="indexcomments" value="'.__('Index all comments').'" /> '.
166     form::hidden(array('action'),'index').
167     form::hidden(array('p'),'maintenance').'</p>'.
168     '</form>';
169     
170     echo
171     '<h3>'.__('Vacuum logs').'</h3>'.
172     '<form action="plugin.php" method="post">'.
173     '<p><input type="submit" value="'.__('Delete all logs').'" /> '.
174     $core->formNonce().
175     form::hidden(array('action'),'log').
176     form::hidden(array('p'),'maintenance').'</p>'.
177     '</form>';
178     
179     echo
180     '<h3>'.__('Empty templates cache directory').'</h3>'.
181     '<form action="plugin.php" method="post">'.
182     '<p><input type="submit" value="'.__('Empty directory').'" /> '.
183     $core->formNonce().
184     form::hidden(array('action'),'empty_cache').
185     form::hidden(array('p'),'maintenance').'</p>'.
186     '</form>';
187}
188dcPage::helpBlock('maintenance');
189?>
190
191</body>
192</html>
Note: See TracBrowser for help on using the repository browser.

Sites map