Passed
Push — master ( db4789...a75458 )
by Goffy
02:49
created

checkonline.php (4 issues)

Labels
Severity
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
/**
12
 * wgSitenotice module for xoops
13
 *
14
 * @copyright       XOOPS Project (https://xoops.org)
15
 * @license         GPL 2.0 or later
16
 * @package         wgsitenotice
17
 * @since           1.0
18
 * @min_xoops       2.5.11
19
 * @author          Goffy (xoops.wedega.com) - Email:<[email protected]> - Website:<https://xoops.wedega.com>
20
 */
21
22
use Xmf\Request;
0 ignored issues
show
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use XoopsModules\Wgsitenotice\Helper;
24
25
$helper = Helper::getInstance();
26
echo "<?xml version='1.0' encoding='utf-8'?>\n";
27
28
/* <?xml version="1.0" encoding="utf-8"?> */
29
echo "<document>\n";
30
echo "<status_connect>successful</status_connect>\n";
31
include \dirname(__DIR__, 2) . '/mainfile.php';
32
$dirname = \basename(__DIR__);
33
34
\defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
35
36
require_once \XOOPS_ROOT_PATH . '/modules/' . $dirname . '/header.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
37
38
$version_id = Request::getInt('version_id');
39
echo '<version_id>' . $version_id . "</version_id>\n";
40
41
$oc_allowed = $helper->getConfig('wgsitenotice_oc_allowed');
42
43
if (1 == $oc_allowed) {
44
    //download of my version is allowed
45
    echo "<status_access>allowed</status_access>\n";
46
    $version_crit = new \CriteriaCompo();
0 ignored issues
show
The type CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
47
    $version_crit->setSort('version_id ASC, version_name');
48
    $version_crit->setOrder('ASC');
49
    if ($version_id > 0) $version_crit->add(new \Criteria('version_id', $version_id));
0 ignored issues
show
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
50
    $version_crit->add(new \Criteria('version_online', '1'));
51
    $versions_rows = $versionsHandler->getCount($version_crit);
52
    echo '<versions_rows>' . $versions_rows . "</versions_rows>\n";
53
    $versions_arr = $versionsHandler->getAll($version_crit);
54
    unset($version_crit);
55
    if ($versions_rows > 0)
56
    {
57
        echo "<versions>\n";
58
        foreach (\array_keys($versions_arr) as $i) {
59
            echo "\t<version>\n";
60
            echo "\t<version_id>".$versions_arr[$i]->getVar('version_id')."</version_id>\n";
61
            echo "\t<version_name>".$versions_arr[$i]->getVar('version_name')."</version_name>\n";
62
            echo "\t<version_lang>".$versions_arr[$i]->getVar('version_lang')."</version_lang>\n";
63
            echo "\t<version_descr>".$versions_arr[$i]->getVar('version_descr')."</version_descr>\n";
64
            echo "\t<version_author>".$versions_arr[$i]->getVar('version_author')."</version_author>\n";
65
            echo "\t<version_date>".$versions_arr[$i]->getVar('version_date')."</version_date>\n";
66
67
            if ($version_id > 0) {
68
                echo "\t\t<contents>\n";
69
                $cont_crit = new \CriteriaCompo();
70
                $cont_crit->setSort('cont_weight');
71
                $cont_crit->setOrder('ASC');
72
                $cont_crit->add(new \Criteria('cont_version_id', $version_id));
73
                $contents_rows = $contentsHandler->getCount($cont_crit);
74
                $contents_arr = $contentsHandler->getAll($cont_crit);
75
                unset($cont_crit);
76
                if ($contents_rows > 0) {
77
                    foreach (\array_keys($contents_arr) as $j) {
78
                        echo "\t\t\t<content>\n";
79
                        echo "\t\t\t\t<cont_id>".$contents_arr[$j]->getVar('cont_id')."</cont_id>\n";
80
                        echo "\t\t\t\t<cont_version_id>".$contents_arr[$j]->getVar('cont_version_id')."</cont_version_id>\n";
81
                        $xml = $contents_arr[$j]->getVar('cont_header');
82
                        echo "\t\t\t\t<cont_header>".text2xml($xml)."</cont_header>\n";
83
                        $xml = $contents_arr[$j]->getVar('cont_text', 'n');
84
                        echo "\t\t\t\t<cont_text>".text2xml($xml)."</cont_text>\n";
85
                        echo "\t\t\t\t<cont_weight>".$contents_arr[$j]->getVar('cont_weight')."</cont_weight>\n";
86
                        echo "\t\t\t\t<cont_date>".$contents_arr[$j]->getVar('cont_date')."</cont_date>\n";
87
                        echo "\t\t\t</content>\n";
88
                    }
89
                }
90
                echo "\t\t</contents>\n";
91
            }
92
            echo "\t</version>\n";
93
        }
94
        echo "</versions>\n";
95
    }
96
} else {
97
    echo "<status_access>forbidden</status_access>\n";
98
}
99
echo "</document>\n";
100
101
function text2xml ($xml) {
102
    // replace html tags e.g. in case of links in the text
103
    $search = ['<', '>', '"'];
104
    $replace  = ['&lt;', '&gt;', '&quot;'];
105
106
    return \str_replace($search, $replace, (string)$xml);
107
}
108