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 | * CBB 4.0, or newbb, the forum module for XOOPS project |
||
| 4 | * |
||
| 5 | * @copyright XOOPS Project (http://xoops.org) |
||
| 6 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license |
||
| 7 | * @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
||
| 8 | * @since 4.00 |
||
| 9 | * @package module::newbb |
||
| 10 | */ |
||
| 11 | |||
| 12 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 13 | |||
| 14 | defined('NEWBB_FUNCTIONS_INI') || include __DIR__ . '/functions.ini.php'; |
||
| 15 | define('NEWBB_FUNCTIONS_RENDER_LOADED', true); |
||
| 16 | |||
| 17 | if (!defined('NEWBB_FUNCTIONS_RENDER')): |
||
| 18 | define('NEWBB_FUNCTIONS_RENDER', 1); |
||
| 19 | |||
| 20 | /* |
||
| 21 | * Sorry, we have to use the stupid solution unless there is an option in MyTextSanitizer:: htmlspecialchars(); |
||
| 22 | */ |
||
| 23 | /** |
||
| 24 | * @param $text |
||
| 25 | * @return mixed |
||
| 26 | */ |
||
| 27 | function sf_htmlSpecialChars($text) |
||
| 28 | { |
||
| 29 | return preg_replace(array('/&/i', '/ /i'), array('&', '&nbsp;'), htmlspecialchars($text)); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param $text |
||
| 34 | * @param int $html |
||
| 35 | * @param int $smiley |
||
| 36 | * @param int $xcode |
||
| 37 | * @param int $image |
||
| 38 | * @param int $br |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | function &sf_displayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1) |
||
| 42 | { |
||
| 43 | global $myts; |
||
| 44 | |||
| 45 | if ($html != 1) { |
||
| 46 | // html not allowed |
||
| 47 | $text = sf_htmlSpecialChars($text); |
||
| 48 | } |
||
| 49 | $text = $myts->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 50 | $text = $myts->makeClickable($text); |
||
| 51 | if ($smiley != 0) { |
||
| 52 | // process smiley |
||
| 53 | $text = $myts->smiley($text); |
||
| 54 | } |
||
| 55 | if ($xcode != 0) { |
||
| 56 | // decode xcode |
||
| 57 | if ($image != 0) { |
||
| 58 | // image allowed |
||
| 59 | $text =& $myts->xoopsCodeDecode($text); |
||
| 60 | } else { |
||
| 61 | // image not allowed |
||
| 62 | $text =& $myts->xoopsCodeDecode($text, 0); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | if ($br != 0) { |
||
| 66 | $text =& $myts->nl2Br($text); |
||
| 67 | } |
||
| 68 | $text = $myts->codeConv($text, $xcode, $image); // Ryuji_edit(2003-11-18) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 69 | |||
| 70 | return $text; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @param $document |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | function sf_html2text($document) |
||
| 78 | { |
||
| 79 | $text = strip_tags($document); |
||
| 80 | |||
| 81 | return $text; |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Display forrum button |
||
| 86 | * |
||
| 87 | * @param $link |
||
| 88 | * @param $button image/button name, without extension |
||
| 89 | * @param string $alt alt message |
||
| 90 | * @param boolean $asImage true for image mode; false for text mode |
||
| 91 | * @param string $extra extra attribute for the button |
||
| 92 | * @return mixed |
||
| 93 | */ |
||
| 94 | function sf_getButton($link, $button, $alt = '', $asImage = true, $extra = "class='forum_button'") |
||
| 95 | { |
||
| 96 | $button = "<input type='button' name='{$button}' {$extra} value='{$alt}' onclick='window.location.href={$link}' />"; |
||
| 97 | if (empty($asImage)) { |
||
| 98 | $button = "<a href='{$link}' title='{$alt}' {$extra}>" . sf_displayImage($button, $alt, true) . '</a>'; |
||
| 99 | } |
||
| 100 | |||
| 101 | return $button; |
||
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Display forrum images |
||
| 106 | * |
||
| 107 | * @param string $image image name, without extension |
||
| 108 | * @param string $alt alt message |
||
| 109 | * @param boolean $display true for return image anchor; faulse for assign to $xoopsTpl |
||
| 110 | * @param string $extra extra attribute for the image |
||
| 111 | * @return mixed |
||
| 112 | */ |
||
| 113 | function sf_displayImage($image, $alt = '', $display = true, $extra = "class='forum_icon'") |
||
| 114 | { |
||
| 115 | $iconHandler = sf_getIconHandler(); |
||
| 116 | // START hacked by irmtfan |
||
| 117 | // to show text links instead of buttons - func_num_args()==2 => only when $image, $alt is set and optional $display not set |
||
| 118 | global $xoopsModuleConfig; |
||
| 119 | if (func_num_args() == 2) { |
||
| 120 | // overall setting |
||
| 121 | if (!empty($xoopsModuleConfig['display_text_links'])) { |
||
| 122 | $display = false; |
||
| 123 | } |
||
| 124 | // if set for each link => overwrite $display |
||
| 125 | if (isset($xoopsModuleConfig['display_text_each_link'][$image])) { |
||
| 126 | $display = empty($xoopsModuleConfig['display_text_each_link'][$image]); |
||
| 127 | } |
||
| 128 | } |
||
| 129 | // END hacked by irmtfan |
||
| 130 | if (empty($display)) { |
||
| 131 | return $iconHandler->assignImage($image, $alt, $extra); |
||
| 132 | } else { |
||
| 133 | return $iconHandler->getImage($image, $alt, $extra); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @return NewbbIconHandler |
||
| 139 | */ |
||
| 140 | function sf_getIconHandler() |
||
| 141 | { |
||
| 142 | global $xoTheme, $xoopsConfig; |
||
| 143 | static $iconHandler; |
||
| 144 | |||
| 145 | if (isset($iconHandler)) { |
||
| 146 | return $iconHandler; |
||
| 147 | } |
||
| 148 | |||
| 149 | if (!class_exists('NewbbIconHandler')) { |
||
| 150 | require_once dirname(__DIR__) . '/class/icon.php'; |
||
| 151 | } |
||
| 152 | |||
| 153 | $iconHandler = NewbbIconHandler::instance(); |
||
| 154 | $iconHandler->template = $xoTheme->template; |
||
| 155 | $iconHandler->init($xoopsConfig['language']); |
||
| 156 | |||
| 157 | return $iconHandler; |
||
| 158 | } |
||
| 159 | |||
| 160 | endif; |
||
| 161 |
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.