| 1 | <?php |
||
| 2 | |||
| 3 | use dokuwiki\Extension\AdminPlugin; |
||
|
0 ignored issues
–
show
|
|||
| 4 | |||
| 5 | /* |
||
| 6 | * Copyright (c) 2008-2015 Mark C. Prins <[email protected]> |
||
| 7 | * |
||
| 8 | * Permission to use, copy, modify, and distribute this software for any |
||
| 9 | * purpose with or without fee is hereby granted, provided that the above |
||
| 10 | * copyright notice and this permission notice appear in all copies. |
||
| 11 | * |
||
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||
| 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||
| 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||
| 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||
| 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||
| 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||
| 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||
| 19 | * |
||
| 20 | * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps |
||
| 21 | */ |
||
| 22 | /** |
||
| 23 | * DokuWiki Plugin openlayersmap (Admin Component). |
||
| 24 | * This component purges the cached tiles and maps. |
||
| 25 | * |
||
| 26 | * @author Mark Prins |
||
| 27 | */ |
||
| 28 | class admin_plugin_openlayersmap_purge extends AdminPlugin |
||
| 29 | { |
||
| 30 | /** |
||
| 31 | * (non-PHPdoc) |
||
| 32 | * @see DokuWiki_Admin_Plugin::getMenuSort() |
||
| 33 | */ |
||
| 34 | public function getMenuSort(): int |
||
| 35 | { |
||
| 36 | return 800; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function getMenuIcon(): string |
||
| 40 | { |
||
| 41 | $plugin = $this->getPluginName(); |
||
| 42 | return DOKU_PLUGIN . $plugin . '/admin/purge.svg'; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * (non-PHPdoc) |
||
| 47 | * @see DokuWiki_Admin_Plugin::handle() |
||
| 48 | */ |
||
| 49 | public function handle(): void |
||
| 50 | { |
||
| 51 | global $conf; |
||
| 52 | if (!isset($_REQUEST['continue']) || !checkSecurityToken()) { |
||
| 53 | return; |
||
| 54 | } |
||
| 55 | if (isset($_REQUEST['purgetiles'])) { |
||
| 56 | $path = $conf['cachedir'] . '/olmaptiles'; |
||
| 57 | if ($this->rrmdir($path)) { |
||
| 58 | msg($this->getLang('admin_purged_tiles'), 0); |
||
| 59 | } |
||
| 60 | } |
||
| 61 | if (isset($_REQUEST['purgemaps'])) { |
||
| 62 | $path = $conf['mediadir'] . '/olmapmaps'; |
||
| 63 | if ($this->rrmdir($path)) { |
||
| 64 | msg($this->getLang('admin_purged_maps'), 0); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Recursively delete the directory. |
||
| 71 | * @param string $sDir directory path |
||
| 72 | * @return boolean true when succesful |
||
| 73 | */ |
||
| 74 | private function rrmdir(string $sDir): bool |
||
| 75 | { |
||
| 76 | if (is_dir($sDir)) { |
||
| 77 | dbglog($sDir, 'admin_plugin_openlayersmap_purge::rrmdir: recursively removing path: '); |
||
| 78 | $sDir = rtrim($sDir, '/'); |
||
| 79 | $oDir = dir($sDir); |
||
| 80 | while (($sFile = $oDir->read()) !== false) { |
||
| 81 | if ($sFile !== '.' && $sFile !== '..') { |
||
| 82 | (!is_link("$sDir/$sFile") && is_dir("$sDir/$sFile")) ? |
||
| 83 | $this->rrmdir("$sDir/$sFile") : unlink("$sDir/$sFile"); |
||
| 84 | } |
||
| 85 | } |
||
| 86 | $oDir->close(); |
||
| 87 | rmdir($sDir); |
||
| 88 | return true; |
||
| 89 | } |
||
| 90 | return false; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * (non-PHPdoc) |
||
| 95 | * @see DokuWiki_Admin_Plugin::html() |
||
| 96 | */ |
||
| 97 | public function html(): void |
||
| 98 | { |
||
| 99 | echo $this->locale_xhtml('admin_intro'); |
||
| 100 | $form = new Doku_Form(['id' => 'olmap_purgeform', 'method' => 'post']); |
||
| 101 | $form->addHidden('continue', 'go'); |
||
| 102 | |||
| 103 | $form->startFieldset($this->getLang('admin_tiles')); |
||
| 104 | $form->addElement('<p>'); |
||
| 105 | $form->addElement( |
||
| 106 | '<input id="purgetiles" name="purgetiles" type="checkbox" value="1" class="checkbox" />' |
||
| 107 | ); |
||
| 108 | $form->addElement( |
||
| 109 | '<label for="purgetiles" class="label">' . $this->getLang('admin_purge_tiles') |
||
| 110 | . '</label>' |
||
| 111 | ); |
||
| 112 | $form->addElement('</p>'); |
||
| 113 | $form->endFieldset(); |
||
| 114 | |||
| 115 | $form->startFieldset($this->getLang('admin_maps')); |
||
| 116 | $form->addElement('<p>'); |
||
| 117 | $form->addElement('<input id="purgemaps" name="purgemaps" type="checkbox" value="1" class="checkbox" />'); |
||
| 118 | $form->addElement( |
||
| 119 | '<label for="purgemaps" class="label">' . $this->getLang('admin_purge_maps') . '</label>' |
||
| 120 | ); |
||
| 121 | $form->addElement('</p>'); |
||
| 122 | $form->endFieldset(); |
||
| 123 | |||
| 124 | $form->addElement( |
||
| 125 | form_makeButton( |
||
| 126 | 'submit', |
||
| 127 | 'admin', |
||
| 128 | $this->getLang('admin_submit'), |
||
| 129 | ['accesskey' => 'p', 'title' => $this->getLang('admin_submit')] |
||
| 130 | ) |
||
| 131 | ); |
||
| 132 | $form->printForm(); |
||
| 133 | } |
||
| 134 | } |
||
| 135 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths