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