These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * Module: Lexikon - glossary module |
||
4 | * Author: hsalazar |
||
5 | * Changes: Yerres |
||
6 | * Licence: GNU |
||
7 | */ |
||
8 | |||
9 | include __DIR__ . '/header.php'; |
||
10 | |||
11 | foreach ($_POST as $k => $v) { |
||
12 | ${$k} = $v; |
||
13 | } |
||
14 | |||
15 | foreach ($_GET as $k => $v) { |
||
16 | ${$k} = $v; |
||
17 | } |
||
18 | |||
19 | if (empty($entryID)) { |
||
20 | redirect_header('index.php'); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @param $entryID |
||
25 | */ |
||
26 | function printPage($entryID) |
||
27 | { |
||
28 | global $xoopsConfig, $xoopsDB, $xoopsModule, $xoopsModuleConfig, $myts; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
29 | $result1 = $xoopsDB->query('SELECT * FROM ' |
||
30 | . $xoopsDB->prefix('lxentries') |
||
31 | . " WHERE entryID = '$entryID' and submit = '0' order by datesub"); |
||
32 | $Ok = $xoopsDB->getRowsNum($result1); |
||
33 | if ($Ok <= 0) { |
||
34 | redirect_header('javascript:history.go(-1)', 3, _ERRORS); |
||
35 | } |
||
36 | list($entryID, $categoryID, $term, $init, $definition, $ref, $url, $uid, $submit, $datesub, $counter, $html, $smiley, $xcodes, $breaks, $block, $offline, $notifypub) = $xoopsDB->fetchrow($result1); |
||
0 ignored issues
–
show
The assignment to
$entryID is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$init is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$ref is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$url is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$submit is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$counter is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$block is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$offline is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() The assignment to
$notifypub is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
37 | |||
38 | $result2 = $xoopsDB->query('SELECT name FROM ' |
||
39 | . $xoopsDB->prefix('lxcategories') |
||
40 | . " WHERE categoryID = '$categoryID'"); |
||
41 | list($name) = $xoopsDB->fetchRow($result2); |
||
42 | |||
43 | $result3 = $xoopsDB->query('SELECT name, uname FROM ' |
||
44 | . $xoopsDB->prefix('users') |
||
45 | . " WHERE uid = '$uid'"); |
||
46 | list($authorname, $username) = $xoopsDB->fetchRow($result3); |
||
47 | |||
48 | $datetime = formatTimestamp($datesub, 'D, d-M-Y, H:i'); |
||
49 | $categoryname = $myts->htmlSpecialChars($name); |
||
50 | $term = $myts->htmlSpecialChars($term); |
||
51 | $definition = str_replace('[pagebreak]', "<br style=\"page-break-after:always;\">", $definition); |
||
52 | $definition = $myts->displayTarea($definition, $html, $smiley, $xcodes, '', $breaks); |
||
53 | if ($authorname == '') { |
||
54 | $authorname = $myts->htmlSpecialChars($username); |
||
55 | } else { |
||
56 | $authorname = $myts->htmlSpecialChars($authorname); |
||
57 | } |
||
58 | echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"; |
||
59 | echo "<html>\n<head>\n"; |
||
60 | echo '<title>' |
||
61 | . $xoopsConfig['sitename'] |
||
62 | . ' ' |
||
63 | . $term |
||
64 | . ' ' |
||
65 | . _MD_LEXIKON_PRINTTERM |
||
66 | . "</title>\n"; |
||
67 | echo "<meta http-equiv='Content-Type' content='text/html; charset=" |
||
68 | . _CHARSET |
||
69 | . "' />\n"; |
||
70 | echo "<meta name='keywords' content= $term />\n"; |
||
71 | echo "<meta name='AUTHOR' content='" |
||
72 | . $xoopsConfig['sitename'] |
||
73 | . "' />\n"; |
||
74 | echo "<meta name='COPYRIGHT' content='Copyright (c) 2004 by " |
||
75 | . $xoopsConfig['sitename'] |
||
76 | . "' />\n"; |
||
77 | echo "<meta name='DESCRIPTION' content='" |
||
78 | . $xoopsConfig['slogan'] |
||
79 | . "' />\n"; |
||
80 | echo "<meta name='GENERATOR' content='" |
||
81 | . XOOPS_VERSION |
||
82 | . "' />\n\n\n"; |
||
83 | |||
84 | echo "<body bgcolor='#ffffff' text='#000000'> |
||
85 | <div style='width: 650px; border: 1px solid #000; padding: 20px;'> |
||
86 | <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'><img src='" |
||
87 | . XOOPS_URL |
||
88 | . '/modules/' |
||
89 | . $xoopsModule->dirname() |
||
90 | . "/assets/images/lx_slogo.png' border='0' alt='' /><h2 style='margin: 0;'>" |
||
91 | . $term |
||
92 | . '</h2></div> |
||
93 | <div></div>'; |
||
94 | if ($xoopsModuleConfig['multicats'] == 1) { |
||
95 | echo '<div>' . _MD_LEXIKON_ENTRYCATEGORY . '<b>' . $categoryname . '</b></div>'; |
||
96 | } |
||
97 | echo "<div style='padding-bottom: 6px; border-bottom: 1px solid #ccc;'>" |
||
98 | . _MD_LEXIKON_SUBMITTER |
||
99 | . '<b>' |
||
100 | . $authorname |
||
101 | . "</b></div> |
||
102 | <h3 style='margin: 0;'>" |
||
103 | . $term |
||
104 | . '</h3><p>' |
||
105 | . $definition |
||
106 | . "</p> |
||
107 | <div style='padding-top: 12px; border-top: 2px solid #ccc;'><b>" |
||
108 | . _MD_LEXIKON_SENT |
||
109 | . '</b> ' |
||
110 | . $datetime |
||
111 | . '<br></div> |
||
112 | </div><br> |
||
113 | </body> |
||
114 | </html>'; |
||
115 | } |
||
116 | |||
117 | printPage($entryID); |
||
118 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.