Issues (847)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

lib/plugins/revert/admin.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use dokuwiki\ChangeLog\PageChangeLog;
0 ignored issues
show
This use statement conflicts with another class in this namespace, PageChangeLog.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
5
/**
6
 * All DokuWiki plugins to extend the admin function
7
 * need to inherit from this class
8
 */
9
class admin_plugin_revert extends DokuWiki_Admin_Plugin
10
{
11
    protected $cmd;
12
    // some vars which might need tuning later
13
    protected $max_lines = 800; // lines to read from changelog
14
    protected $max_revs  = 20;  // numer of old revisions to check
15
16
17
    /**
18
     * Constructor
19
     */
20
    public function __construct()
21
    {
22
        $this->setupLocale();
23
    }
24
25
    /**
26
     * access for managers
27
     */
28
    public function forAdminOnly()
29
    {
30
        return false;
31
    }
32
33
    /**
34
     * return sort order for position in admin menu
35
     */
36
    public function getMenuSort()
37
    {
38
        return 40;
39
    }
40
41
    /**
42
     * handle user request
43
     */
44
    public function handle()
45
    {
46
    }
47
48
    /**
49
     * output appropriate html
50
     */
51
    public function html()
52
    {
53
        global $INPUT;
54
55
        echo $this->locale_xhtml('intro');
56
57
        $this->printSearchForm();
58
59
        if (is_array($INPUT->param('revert')) && checkSecurityToken()) {
60
            $this->revertEdits($INPUT->arr('revert'), $INPUT->str('filter'));
61
        } elseif ($INPUT->has('filter')) {
62
            $this->listEdits($INPUT->str('filter'));
63
        }
64
    }
65
66
    /**
67
     * Display the form for searching spam pages
68
     */
69
    protected function printSearchForm()
70
    {
71
        global $lang, $INPUT;
72
        echo '<form action="" method="post"><div class="no">';
73
        echo '<label>'.$this->getLang('filter').': </label>';
74
        echo '<input type="text" name="filter" class="edit" value="'.hsc($INPUT->str('filter')).'" /> ';
75
        echo '<button type="submit">'.$lang['btn_search'].'</button> ';
76
        echo '<span>'.$this->getLang('note1').'</span>';
77
        echo '</div></form><br /><br />';
78
    }
79
80
    /**
81
     * Start the reversion process
82
     */
83
    protected function revertEdits($revert, $filter)
84
    {
85
        echo '<hr /><br />';
86
        echo '<p>'.$this->getLang('revstart').'</p>';
87
88
        echo '<ul>';
89
        foreach ($revert as $id) {
90
            global $REV;
91
92
            // find the last non-spammy revision
93
            $data = '';
94
            $pagelog = new PageChangeLog($id);
95
            $old  = $pagelog->getRevisions(0, $this->max_revs);
96
            if (count($old)) {
97
                foreach ($old as $REV) {
98
                    $data = rawWiki($id, $REV);
99
                    if (strpos($data, $filter) === false) break;
100
                }
101
            }
102
103
            if ($data) {
104
                saveWikiText($id, $data, 'old revision restored', false);
105
                printf('<li><div class="li">'.$this->getLang('reverted').'</div></li>', $id, $REV);
106
            } else {
107
                saveWikiText($id, '', '', false);
108
                printf('<li><div class="li">'.$this->getLang('removed').'</div></li>', $id);
109
            }
110
            @set_time_limit(10);
111
            flush();
112
        }
113
        echo '</ul>';
114
115
        echo '<p>'.$this->getLang('revstop').'</p>';
116
    }
117
118
    /**
119
     * List recent edits matching the given filter
120
     */
121
    protected function listEdits($filter)
122
    {
123
        global $conf;
124
        global $lang;
125
        echo '<hr /><br />';
126
        echo '<form action="" method="post"><div class="no">';
127
        echo '<input type="hidden" name="filter" value="'.hsc($filter).'" />';
128
        formSecurityToken();
129
130
        $recents = getRecents(0, $this->max_lines);
131
        echo '<ul>';
132
133
        $cnt = 0;
134
        foreach ($recents as $recent) {
135
            if ($filter) {
136
                if (strpos(rawWiki($recent['id']), $filter) === false) continue;
137
            }
138
139
            $cnt++;
140
            $date = dformat($recent['date']);
141
142
            echo ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
143
            echo '<div class="li">';
144
            echo '<input type="checkbox" name="revert[]" value="'.hsc($recent['id']).
145
                '" checked="checked" id="revert__'.$cnt.'" />';
146
            echo ' <label for="revert__'.$cnt.'">'.$date.'</label> ';
147
148
            echo '<a href="'.wl($recent['id'], "do=diff").'">';
149
            $p = array();
150
            $p['src']    = DOKU_BASE.'lib/images/diff.png';
151
            $p['width']  = 15;
152
            $p['height'] = 11;
153
            $p['title']  = $lang['diff'];
154
            $p['alt']    = $lang['diff'];
155
            $att = buildAttributes($p);
156
            echo "<img $att />";
157
            echo '</a> ';
158
159
            echo '<a href="'.wl($recent['id'], "do=revisions").'">';
160
            $p = array();
161
            $p['src']    = DOKU_BASE.'lib/images/history.png';
162
            $p['width']  = 12;
163
            $p['height'] = 14;
164
            $p['title']  = $lang['btn_revs'];
165
            $p['alt']    = $lang['btn_revs'];
166
            $att = buildAttributes($p);
167
            echo "<img $att />";
168
            echo '</a> ';
169
170
            echo html_wikilink(':'.$recent['id'], (useHeading('navigation'))?null:$recent['id']);
171
            echo ' – '.htmlspecialchars($recent['sum']);
172
173
            echo ' <span class="user">';
174
                echo $recent['user'].' '.$recent['ip'];
175
            echo '</span>';
176
177
            echo '</div>';
178
            echo '</li>';
179
180
            @set_time_limit(10);
181
            flush();
182
        }
183
        echo '</ul>';
184
185
        echo '<p>';
186
        echo '<button type="submit">'.$this->getLang('revert').'</button> ';
187
        printf($this->getLang('note2'), hsc($filter));
188
        echo '</p>';
189
190
        echo '</div></form>';
191
    }
192
}
193
//Setup VIM: ex: et ts=4 :
194