Issues (207)

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.

include/update.php (3 issues)

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
 * update.php - initializations on module update
4
 *
5
 * This file is part of gwiki - geekwright wiki
6
 *
7
 * @copyright  Copyright © 2013 geekwright, LLC. All rights reserved.
8
 * @license    gwiki/docs/license.txt  GNU General Public License (GPL)
9
 * @since      1.0
10
 * @author     Richard Griffith <[email protected]>
11
 * @package    gwiki
12
 */
13
14
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
15
16
/**
17
 * @param XoopsModule $module
18
 * @param             $old_version
19
 *
20
 * @return bool
21
 */
22
function xoops_module_update_gwiki(XoopsModule $module, $old_version)
23
{
24
    global $xoopsDB;
25
26
    $error = false;
27
28
    // recompile namespace templates
29
    $tplfileHandler = xoops_getHandler('tplfile');
30
31
    $dir = basename(dirname(__DIR__));
32
    $mid = $module->getVar('mid');
33
34
    $sql = 'SELECT * FROM ' . $xoopsDB->prefix('gwiki_prefix') . ', ' . $xoopsDB->prefix('gwiki_template');
35
    $sql .= ' WHERE prefix_template_id = template_id ';
36
37
    $result = $xoopsDB->query($sql);
38
39
    //$rows=$xoopsDB->getRowsNum($result);
40
    while ($template = $xoopsDB->fetchArray($result)) {
41
        $pid  = $template['prefix_id'];
42
        $file = $dir . '_prefix_' . $pid . '.tpl';
43
44
        $tplfiles = $tplfileHandler->find('default', 'module', $mid, $dir, $file, false);
45 View Code Duplication
        if (count($tplfiles)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
            $tplfile = $tplfiles[0];
47
            $isnew   = false;
48
        } else {
49
            $tplfile = $tplfileHandler->create();
50
            $isnew   = true;
51
        }
52
53
        $tplfile->setVar('tpl_source', $template['template_body'], true);
54
        $tplfile->setVar('tpl_refid', $mid);
55
        $tplfile->setVar('tpl_tplset', 'default');
56
        $tplfile->setVar('tpl_file', $file);
57
        $tplfile->setVar('tpl_desc', $template['template'], true);
58
        $tplfile->setVar('tpl_module', $dir);
59
        $tplfile->setVar('tpl_lastmodified', time());
60
        $tplfile->setVar('tpl_lastimported', 0);
61
        $tplfile->setVar('tpl_type', 'module');
62
63
        if ($isnew) {
64 View Code Duplication
            if (!$tplfileHandler->insert($tplfile)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
                $module->setErrors('ERROR: Could not insert template ' . htmlspecialchars($file) . ' to the database.');
66
                $error = true;
67
            }
68 View Code Duplication
        } else {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
            if (!$tplfileHandler->forceUpdate($tplfile)) {
70
                $module->setErrors('ERROR: Could not update template ' . htmlspecialchars($file) . ' in the database.');
71
                $error = true;
72
            }
73
        }
74
    }
75
76
    // table alterations - these will quietly fail if already done
77
    // these are all to bring development versions to current
78
    if ($old_version < 100) {
79
        //  trigger_error($old_version);
80
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . ' ADD COLUMN toc_cache TEXT NOT NULL AFTER search_body';
81
        $xoopsDB->queryF($sql);
82
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . ' ADD COLUMN show_in_index TINYINT NOT NULL DEFAULT 1 AFTER toc_cache';
83
        $xoopsDB->queryF($sql);
84
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . ' DROP PRIMARY KEY, ADD PRIMARY KEY(gwiki_id, active)';
85
        $xoopsDB->queryF($sql);
86
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_prefix') . ' ADD COLUMN prefix_auto_name TINYINT NOT NULL DEFAULT 0 AFTER prefix_home';
87
        $xoopsDB->queryF($sql);
88
89
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pageids') . " CHANGE keyword  keyword VARCHAR(128) NOT NULL DEFAULT ''";
90
        $xoopsDB->queryF($sql);
91
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . " CHANGE keyword  keyword VARCHAR(128) NOT NULL DEFAULT ''";
92
        $xoopsDB->queryF($sql);
93
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_prefix') . " CHANGE prefix  prefix VARCHAR(128) NOT NULL DEFAULT '', " . " CHANGE prefix_home  prefix_home VARCHAR(128) NOT NULL DEFAULT ''";
94
        $xoopsDB->queryF($sql);
95
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_template') . " CHANGE template  template VARCHAR(128) NOT NULL DEFAULT ''";
96
        $xoopsDB->queryF($sql);
97
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_page_images') . " CHANGE keyword  keyword VARCHAR(128) NOT NULL DEFAULT '', "
98
               . " CHANGE image_name  image_name VARCHAR(128) NOT NULL DEFAULT ''";
99
        $xoopsDB->queryF($sql);
100
101
        $sql = 'CREATE TABLE ' . $xoopsDB->prefix('gwiki_page_files') . " (file_id int(10) NOT NULL AUTO_INCREMENT, keyword varchar(128) NOT NULL DEFAULT '',"
102
               . " file_name varchar(128) NOT NULL DEFAULT '', file_path varchar(255) NOT NULL DEFAULT '', "
103
               . " file_type varchar(128) NOT NULL DEFAULT '', file_icon varchar(64) NOT NULL DEFAULT '', " . " file_size int(10) NOT NULL DEFAULT '0', file_upload_date int(10) NOT NULL DEFAULT '0',"
104
               . " file_description text, file_uid int(10) NOT NULL DEFAULT '0', " . ' PRIMARY KEY (file_id), UNIQUE KEY (keyword, file_name) ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;';
105
        $xoopsDB->queryF($sql);
106
107
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_page_files') . " ADD COLUMN file_type varchar(128) NOT NULL DEFAULT ''" . ", ADD COLUMN file_icon varchar(64) NOT NULL DEFAULT '', "
108
               . " ADD COLUMN file_size int(10) NOT NULL DEFAULT '0'" . ", ADD COLUMN file_upload_date int(10) NOT NULL DEFAULT '0', ADD COLUMN file_description text"
109
               . ", ADD COLUMN file_uid int(10) NOT NULL DEFAULT '0' ";
110
        $xoopsDB->queryF($sql);
111
112
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_page_files') . " ADD COLUMN file_uid int(10) NOT NULL DEFAULT '0' ";
113
        $xoopsDB->queryF($sql);
114
115
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pageids') . " ADD COLUMN hit_count int(10) NOT NULL DEFAULT '0' ";
116
        $xoopsDB->queryF($sql);
117
118
        // shift all tables to MyISAM
119
        $tabs = array(
120
            'gwiki_pages',
121
            'gwiki_pageids',
122
            'gwiki_group_prefix',
123
            'gwiki_prefix',
124
            'gwiki_template',
125
            'gwiki_page_images',
126
            'gwiki_page_files'
127
        );
128
        foreach ($tabs as $v) {
129
            $sql = 'ALTER TABLE ' . $xoopsDB->prefix($v) . ' ENGINE = MyISAM';
130
            $xoopsDB->queryF($sql);
131
        }
132
133
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pageids') . ' ENGINE = MyISAM';
134
        $xoopsDB->queryF($sql);
135
136
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . " CHANGE parent_page  parent_page VARCHAR(128) NOT NULL DEFAULT ''";
137
        $xoopsDB->queryF($sql);
138
139
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . " CHANGE page_set_home  page_set_home VARCHAR(128) NOT NULL DEFAULT ''";
140
        $xoopsDB->queryF($sql);
141
142
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . " CHANGE active active tinyint NOT NULL DEFAULT '0'";
143
        $xoopsDB->queryF($sql);
144
145
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . " CHANGE admin_lock admin_lock tinyint NOT NULL DEFAULT '0'";
146
        $xoopsDB->queryF($sql);
147
148
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . " CHANGE display_keyword  display_keyword VARCHAR(128) NOT NULL DEFAULT ''";
149
        $xoopsDB->queryF($sql);
150
151
        // drop all indexes except PRIMARY
152
        $tabs   = array();
153
        $sql    = 'SHOW INDEX FROM ' . $xoopsDB->prefix('gwiki_pages');
154
        $result = $xoopsDB->queryF($sql);
155
        while ($row = $xoopsDB->fetchArray($result)) {
156
            if ($row['Key_name'] !== 'PRIMARY') {
157
                $tabs[$row['Key_name']] = $row['Non_unique'];
158
            }
159
        }
160
        $xoopsDB->freeRecordSet($result);
161
        if (!empty($tabs)) {
162
            $sql = '';
163
            foreach ($tabs as $i => $v) {
164
                if (empty($sql)) {
165
                    $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages') . ' DROP KEY ' . $i;
166
                } else {
167
                    $sql .= ' , DROP KEY ' . $i;
168
                }
169
            }
170
            $xoopsDB->queryF($sql);
171
        }
172
173
        $sql = 'ALTER TABLE ' . $xoopsDB->prefix('gwiki_pages');
174
        $sql .= ' ADD KEY activekey (active,keyword), ADD KEY keyword (keyword), ' . ' ADD KEY parent (active,parent_page), ADD KEY pageset (active,page_set_home), '
175
                . ' ADD KEY lastmod (active,lastmodified), ADD KEY pageindex (active,show_in_index,display_keyword) ';
176
        $xoopsDB->queryF($sql);
177
    }
178
    if ($old_version < 101) {
179
        $sql = 'CREATE TABLE IF NOT EXISTS ' . $xoopsDB->prefix('gwiki_pagelinks') . ' (';
180
        $sql .= ' from_keyword varchar(128) NOT NULL DEFAULT \'\',';
181
        $sql .= ' to_keyword varchar(128) NOT NULL DEFAULT \'\',';
182
        $sql .= ' PRIMARY KEY (from_keyword, to_keyword),';
183
        $sql .= ' KEY (to_keyword),';
184
        $sql .= ' KEY (from_keyword)';
185
        $sql .= ') ENGINE=MyISAM  DEFAULT CHARSET=utf8;';
186
        $xoopsDB->queryF($sql);
187
    }
188
189
    return !$error;
190
}
191