Passed
Push — master ( 81ba93...c6c854 )
by Michael
03:30
created

admin/docbook_export.php (2 issues)

Severity
1
<?php
2
3
/**
4
 * Module: SmartFAQ
5
 * Author: mariuss
6
 * Licence: GNU
7
 */
8
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
9
10
$op = 'go'; //'start';
11
12
if ('go' === \Xmf\Request::getCmd('op', 'start', 'POST')) {
13
    $op = 'go';
14
}
15
16
if ('start' === $op) {
0 ignored issues
show
The condition 'start' === $op is always false.
Loading history...
17
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
18
19
    xoops_cp_header();
20
21
    xoops_cp_footer();
22
    exit();
23
}
24
25
if ('go' === $op) {
0 ignored issues
show
The condition 'go' === $op is always true.
Loading history...
26
    header('Content-Disposition: attachment; filename=smartfaq.xml');
27
    header('Connection: close');
28
    header('Content-Type: text/xml; name=smartfaq.xml');
29
30
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
31
    echo "<!DOCTYPE qandaset PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">\r\n";
32
    echo "<qandaset defaultlabel=\"qanda\" Conformance=\"1.0 {module version}\">\r\n";
33
34
    echo "  <blockinfo>\r\n";
35
    echo "    <publisher>\r\n";
36
    echo "      <publishername>\r\n";
37
    echo "        {site name}\r\n";
38
    echo "        <ulink url=\"{site url}\">\r\n";
39
    echo "      </publishername>\r\n";
40
    echo "    </publisher>\r\n";
41
    echo "    <date>{time of export}</date>\r\n";
42
    echo "  </blockinfo>\r\n";
43
44
    echo "  <title>{module title}</title>\r\n";
45
46
    $resultC = $xoopsDB->queryF('SELECT * FROM ' . $xoopsDB->prefix('smartfaq_categories'));
47
    while (false !== ($arrC = $xoopsDB->fetchArray($resultC))) {
48
        extract($arrC, EXTR_PREFIX_ALL, 'c');
49
50
        echo "  <qandadiv ID=\"c$c_categoryid\" Revision=\"$c_created\">\r\n";
51
        echo '    <title>' . encodeText($c_name) . "</title>\r\n";
52
        echo '    <para>' . encodeText($c_description) . "</para>\r\n";
53
54
        $resultQ = $xoopsDB->queryF('select * from ' . $xoopsDB->prefix('smartfaq_faq') . " where categoryid=$c_categoryid");
55
        while (false !== ($arrQ = $xoopsDB->fetchArray($resultQ))) {
56
            extract($arrQ, EXTR_PREFIX_ALL, 'q');
57
58
            echo "    <qandaentry ID=\"q$q_faqid\" Revision=\"$q_datesub\" Condition=\"$q_html $q_smiley $q_xcodes\" XrefLabel=\"$q_modulelink $q_contextpage\" Vendor=\"" . getUserFullName($q_uid) . "\">\r\n";
59
            echo "      <question>\r\n";
60
            echo '        <para>' . encodeText($q_question) . "</para>\r\n";
61
            if (!empty($q_howdoi)) {
62
                echo "        <note Conformance=\"howdoi\">\r\n";
63
                echo "          <title>{'How do I' from language file}</title>\r\n";
64
                echo '          <para>' . encodeText($q_howdoi) . "</para>\r\n";
65
                echo "        </note>\r\n";
66
            }
67
            if (!empty($q_diduno)) {
68
                echo "        <note Conformance=\"diduno\">\r\n";
69
                echo "          <title>{'Did you know' from language file}</title>\r\n";
70
                echo '          <para>' . encodeText($q_diduno) . "</para>\r\n";
71
                echo "        </note>\r\n";
72
            }
73
            echo "      </question>\r\n";
74
75
            $resultA = $xoopsDB->queryF('select * from ' . $xoopsDB->prefix('smartfaq_answers') . " where answerid=$q_answerid");
76
            while (false !== ($arrA = $xoopsDB->fetchArray($resultA))) {
77
                extract($arrA, EXTR_PREFIX_ALL, 'a');
78
79
                echo "      <answer ID=\"a$a_answerid\" Revision=\"$a_datesub\" Vendor=\"" . getUserFullName($a_uid) . "\">\r\n";
80
                echo '        <para>' . encodeText($a_answer) . "</para>\r\n";
81
                echo "      </answer>\r\n";
82
            }
83
            $xoopsDB->freeRecordSet($resultA);
84
85
            echo "    </qandaentry>\r\n";
86
        }
87
        $xoopsDB->freeRecordSet($resultQ);
88
89
        echo "  </qandadiv>\r\n";
90
    }
91
92
    echo "</qandaset>\r\n";
93
94
    exit();
95
}
96
97
/**
98
 * @param $text
99
 * @return string
100
 */
101
function encodeText($text)
102
{
103
    return utf8_encode(htmlspecialchars($text, ENT_QUOTES));
104
}
105
106
/**
107
 * @param $uid
108
 * @return mixed
109
 */
110
function getUserFullName($uid)
111
{
112
    global $xoopsDB;
113
114
    return $uid;
115
}
116