[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 ----------------------------------------- |
---|
| 12 | if (!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 | |
---|
| 17 | if ($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 | } |
---|
| 36 | elseif ($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 | } |
---|
| 45 | elseif ($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 | } |
---|
| 54 | elseif ($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> |
---|
[1299] | 71 | <h2><?php echo __('Plugins').' › <span class="page-title">'.__('Maintenance').'</span></h2>'; ?> |
---|
[0] | 72 | |
---|
| 73 | <?php |
---|
| 74 | if (!empty($_GET['vacuum'])) { |
---|
[907] | 75 | dcPage::message(__('Optimization successful.')); |
---|
[0] | 76 | } |
---|
| 77 | if (!empty($_GET['commentscount'])) { |
---|
[907] | 78 | dcPage::message(__('Comments and trackback counted.')); |
---|
[0] | 79 | } |
---|
| 80 | if (!empty($_GET['empty_cache'])) { |
---|
[907] | 81 | dcPage::message(__('Templates cache directory emptied.')); |
---|
[0] | 82 | } |
---|
| 83 | if (!empty($_GET['delete_logs'])) { |
---|
[907] | 84 | dcPage::message(__('Logs deleted.')); |
---|
[0] | 85 | } |
---|
| 86 | |
---|
| 87 | if ($action == 'index' && !empty($_GET['indexposts'])) |
---|
| 88 | { |
---|
| 89 | $limit = 1000; |
---|
| 90 | echo '<p>'.sprintf(__('Indexing entry %d to %d.'),$start,$start+$limit).'</p>'; |
---|
| 91 | |
---|
| 92 | $new_start = $core->indexAllPosts($start,$limit); |
---|
| 93 | |
---|
| 94 | if ($new_start) |
---|
| 95 | { |
---|
| 96 | $new_url = $p_url.'&action=index&indexposts=1&start='.$new_start; |
---|
| 97 | echo |
---|
| 98 | '<script type="text/javascript">'."\n". |
---|
| 99 | "//<![CDATA\n". |
---|
| 100 | "window.location = '".$new_url."'\n". |
---|
| 101 | "//]]>\n". |
---|
| 102 | '</script>'. |
---|
| 103 | '<noscript><p><a href="'.html::escapeURL($new_url).'">'.__('next').'</a></p></noscript>'; |
---|
| 104 | } |
---|
| 105 | else |
---|
| 106 | { |
---|
[907] | 107 | dcPage::message(__('Entries index done.')); |
---|
[0] | 108 | echo '<p><a class="back" href="'.$p_url.'">'.__('Back').'</a></p>'; |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | elseif ($action == 'index' && !empty($_GET['indexcomments'])) |
---|
| 112 | { |
---|
| 113 | $limit = 1000; |
---|
| 114 | echo '<p>'.sprintf(__('Indexing comment %d to %d.'),$start,$start+$limit).'</p>'; |
---|
| 115 | |
---|
| 116 | $new_start = $core->indexAllComments($start,$limit); |
---|
| 117 | |
---|
| 118 | if ($new_start) |
---|
| 119 | { |
---|
| 120 | $new_url = $p_url.'&action=index&indexcomments=1&start='.$new_start; |
---|
| 121 | echo |
---|
| 122 | '<script type="text/javascript">'."\n". |
---|
| 123 | "//<![CDATA\n". |
---|
| 124 | "window.location = '".$new_url."'\n". |
---|
| 125 | "//]]>\n". |
---|
| 126 | '</script>'. |
---|
| 127 | '<noscript><p><a href="'.html::escapeURL($new_url).'">'.__('next').'</a></p></noscript>'; |
---|
| 128 | } |
---|
| 129 | else |
---|
| 130 | { |
---|
[907] | 131 | dcPage::message(__('Comments index done.')); |
---|
[0] | 132 | echo '<p><a class="back" href="'.$p_url.'">'.__('Back').'</a></p>'; |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | else |
---|
| 136 | { |
---|
| 137 | echo |
---|
| 138 | '<h3>'.__('Optimize database room').'</h3>'. |
---|
| 139 | '<form action="plugin.php" method="post">'. |
---|
| 140 | '<p><input type="submit" value="'.__('Vacuum tables').'" /> '. |
---|
| 141 | $core->formNonce(). |
---|
| 142 | form::hidden(array('action'),'vacuum'). |
---|
| 143 | form::hidden(array('p'),'maintenance').'</p>'. |
---|
| 144 | '</form>'; |
---|
| 145 | |
---|
| 146 | echo |
---|
| 147 | '<h3>'.__('Counters').'</h3>'. |
---|
| 148 | '<form action="plugin.php" method="post">'. |
---|
| 149 | '<p><input type="submit" value="'.__('Reset comments and ping counters').'" /> '. |
---|
| 150 | $core->formNonce(). |
---|
| 151 | form::hidden(array('action'),'commentscount'). |
---|
| 152 | form::hidden(array('p'),'maintenance').'</p>'. |
---|
| 153 | '</form>'; |
---|
| 154 | |
---|
| 155 | echo |
---|
| 156 | '<h3>'.__('Search engine index').' ('.__('This may take a very long time').')</h3>'. |
---|
| 157 | '<form action="plugin.php" method="get">'. |
---|
| 158 | '<p><input type="submit" name="indexposts" value="'.__('Index all posts').'" /> '. |
---|
| 159 | '<input type="submit" name="indexcomments" value="'.__('Index all comments').'" /> '. |
---|
| 160 | form::hidden(array('action'),'index'). |
---|
| 161 | form::hidden(array('p'),'maintenance').'</p>'. |
---|
| 162 | '</form>'; |
---|
| 163 | |
---|
| 164 | echo |
---|
| 165 | '<h3>'.__('Vacuum logs').'</h3>'. |
---|
| 166 | '<form action="plugin.php" method="post">'. |
---|
| 167 | '<p><input type="submit" value="'.__('Delete all logs').'" /> '. |
---|
| 168 | $core->formNonce(). |
---|
| 169 | form::hidden(array('action'),'log'). |
---|
| 170 | form::hidden(array('p'),'maintenance').'</p>'. |
---|
| 171 | '</form>'; |
---|
| 172 | |
---|
| 173 | echo |
---|
| 174 | '<h3>'.__('Empty templates cache directory').'</h3>'. |
---|
| 175 | '<form action="plugin.php" method="post">'. |
---|
| 176 | '<p><input type="submit" value="'.__('Empty directory').'" /> '. |
---|
| 177 | $core->formNonce(). |
---|
| 178 | form::hidden(array('action'),'empty_cache'). |
---|
| 179 | form::hidden(array('p'),'maintenance').'</p>'. |
---|
| 180 | '</form>'; |
---|
| 181 | } |
---|
[186] | 182 | dcPage::helpBlock('maintenance'); |
---|
[0] | 183 | ?> |
---|
| 184 | |
---|
| 185 | </body> |
---|
| 186 | </html> |
---|