printPage()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 49
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 37
nc 8
nop 1
dl 0
loc 49
rs 9.328
c 0
b 0
f 0
1
<?php
2
/**
3
 * Module: Lexikon - glossary module
4
 * Author: hsalazar
5
 * Changes: Yerres
6
 * Licence: GNU
7
 */
8
9
use Xmf\Request;
10
use XoopsModules\Lexikon\{
11
    Helper,
12
    Utility
13
};
14
/** @var Helper $helper */
15
16
require __DIR__ . '/header.php';
17
18
19
$helper = Helper::getInstance();
20
21
//foreach ($_POST as $k => $v) {
22
//    ${$k} = $v;
23
//}
24
//
25
//foreach ($_GET as $k => $v) {
26
//    ${$k} = $v;
27
//}
28
29
$entryID = Request::getInt('entryID', '', 'GET');
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type integer expected by parameter $default of Xmf\Request::getInt(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
$entryID = Request::getInt('entryID', /** @scrutinizer ignore-type */ '', 'GET');
Loading history...
30
31
if (empty($entryID)) {
32
    redirect_header('index.php');
33
}
34
35
/**
36
 * @param $entryID
37
 */
38
function printPage($entryID)
39
{
40
    global $xoopsConfig, $xoopsDB, $xoopsModule, $myts;
41
42
    $helper  = Helper::getInstance();
43
    $result1 = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('lxentries') . " WHERE entryID = '$entryID' and submit = '0' order by datesub");
44
    $Ok      = $xoopsDB->getRowsNum($result1);
45
    if ($Ok <= 0) {
46
        redirect_header('<script>javascript:history.go(-1)</script>', 3, _ERRORS);
47
    }
48
    [$entryID, $categoryID, $term, $init, $definition, $ref, $url, $uid, $submit, $datesub, $counter, $html, $smiley, $xcodes, $breaks, $block, $offline, $notifypub] = $xoopsDB->fetchRow($result1);
49
50
    $result2 = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = '$categoryID'");
51
    [$name] = $xoopsDB->fetchRow($result2);
52
53
    $result3 = $xoopsDB->query('SELECT name, uname FROM ' . $xoopsDB->prefix('users') . " WHERE uid = '$uid'");
54
    [$authorname, $username] = $xoopsDB->fetchRow($result3);
55
56
    $datetime     = formatTimestamp($datesub, 'D, d-M-Y, H:i');
57
    $categoryname = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5);
58
    $term         = htmlspecialchars($term, ENT_QUOTES | ENT_HTML5);
59
    $definition   = str_replace('[pagebreak]', '<br style="page-break-after:always;">', $definition);
60
    $definition   = &$myts->displayTarea($definition, $html, $smiley, $xcodes, '', $breaks);
61
    if ('' == $authorname) {
62
        $authorname = htmlspecialchars($username, ENT_QUOTES | ENT_HTML5);
63
    } else {
64
        $authorname = htmlspecialchars($authorname, ENT_QUOTES | ENT_HTML5);
65
    }
66
    echo "<!DOCTYPE HTML>\n";
67
    echo "<html>\n<head>\n";
68
    echo '<title>' . $xoopsConfig['sitename'] . ' ' . $term . ' ' . _MD_LEXIKON_PRINTTERM . "</title>\n";
69
    echo "<meta http-equiv='Content-Type' content='text/html; charset=" . _CHARSET . "'>\n";
70
    echo "<meta name='keywords' content= $term >\n";
71
    echo "<meta name='AUTHOR' content='" . $xoopsConfig['sitename'] . "'>\n";
72
    echo "<meta name='COPYRIGHT' content='Copyright (c) 2004 by " . $xoopsConfig['sitename'] . "'>\n";
73
    echo "<meta name='DESCRIPTION' content='" . $xoopsConfig['slogan'] . "'>\n";
74
    echo "<meta name='GENERATOR' content='" . XOOPS_VERSION . "'>\n\n\n";
75
76
    echo "<body bgcolor='#ffffff' text='#000000'>
77
    <div style='width: 650px; border: 1px solid #000; padding: 20px;'>
78
    <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/lx_slogo.png' border='0' alt=''><h2 style='margin: 0;'>" . $term . '</h2></div>
79
    <div></div>';
80
    if (1 == $helper->getConfig('multicats')) {
81
        echo '<div>' . _MD_LEXIKON_ENTRYCATEGORY . '<b>' . $categoryname . '</b></div>';
82
    }
83
    echo "<div style='padding-bottom: 6px; border-bottom: 1px solid #ccc;'>" . _MD_LEXIKON_SUBMITTER . '<b>' . $authorname . "</b></div>
84
    <h3 style='margin: 0;'>" . $term . '</h3>
85
    <p>' . $definition . "</p>
86
    <div style='padding-top: 12px; border-top: 2px solid #ccc;'><b>" . _MD_LEXIKON_SENT . '</b>&nbsp;' . $datetime . '<br></div>
87
    </div>
88
    <br>
89
    </body>
90
    </html>';
91
}
92
93
printPage($entryID);
94