mambax7 /
wflinks
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * |
||
| 4 | * Module: WF-Links |
||
| 5 | * Version: v1.0.3 |
||
| 6 | * Release Date: 21 June 2005 |
||
| 7 | * Developer: John N |
||
| 8 | * Team: WF-Projects |
||
| 9 | * Licence: GNU |
||
| 10 | */ |
||
| 11 | |||
| 12 | $module_link = ''; |
||
| 13 | |||
| 14 | $link['id'] = (int)$link_arr['lid']; |
||
| 15 | $link['cid'] = (int)$link_arr['cid']; |
||
| 16 | $link['published'] = (int)$link_arr['published'] ? true : false; |
||
| 17 | |||
| 18 | $path = $mytree->getPathFromId($link_arr['cid'], 'title'); |
||
| 19 | $path = substr($path, 1); |
||
| 20 | $path = basename($path); |
||
| 21 | $path = str_replace('/', '', $path); |
||
| 22 | $link['category'] = $path; |
||
| 23 | |||
| 24 | $rating = round(number_format($link_arr['rating'], 0) / 2); |
||
| 25 | $link['rateimg'] = 'rate' . $rating . '.gif'; |
||
| 26 | unset($rating); |
||
| 27 | |||
| 28 | $link['votes'] = ($link_arr['votes'] == 1) ? _MD_WFL_ONEVOTE : sprintf(_MD_WFL_NUMVOTES, $link_arr['votes']); |
||
| 29 | $link['hits'] = sprintf(_MD_WFL_LINKHITS, (int)$link_arr['hits']); |
||
| 30 | $xoopsTpl->assign('lang_dltimes', $link['hits']); |
||
| 31 | |||
| 32 | $link['title'] = $link_arr['title']; |
||
| 33 | $link['url'] = $link_arr['url']; |
||
| 34 | |||
| 35 | // Get Google Pagerank |
||
| 36 | if (isset($xoopsModuleConfig['showpagerank']) && $xoopsModuleConfig['showpagerank'] == 1) { |
||
| 37 | $link['pagerank'] = WfLinksUtility::pagerank($link['url']); |
||
| 38 | } |
||
| 39 | |||
| 40 | if (isset($link_arr['screenshot'])) { |
||
| 41 | $link['screenshot_full'] = $wfmyts->htmlSpecialCharsStrip($link_arr['screenshot']); |
||
| 42 | if (!empty($link_arr['screenshot']) |
||
| 43 | && file_exists(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['screenshots'] . '/' . xoops_trim($link_arr['screenshot']))) { |
||
| 44 | if (isset($xoopsModuleConfig['usethumbs']) && $xoopsModuleConfig['usethumbs'] == 1) { |
||
| 45 | $_thumb_image = new WfThumbsNails($link['screenshot_full'], $xoopsModuleConfig['screenshots'], 'thumbs'); |
||
| 46 | View Code Duplication | if ($_thumb_image) { |
|
|
0 ignored issues
–
show
|
|||
| 47 | $_thumb_image->setUseThumbs(1); |
||
| 48 | $_thumb_image->setImageType('gd2'); |
||
| 49 | $_image = $_thumb_image->createThumb($xoopsModuleConfig['shotwidth'], $xoopsModuleConfig['shotheight'], $xoopsModuleConfig['imagequality'], $xoopsModuleConfig['updatethumbs'], $xoopsModuleConfig['keepaspect']); |
||
| 50 | } |
||
| 51 | $link['screenshot_thumb'] = XOOPS_URL . "/{$xoopsModuleConfig['screenshots']}/$_image"; |
||
| 52 | } else { |
||
| 53 | $link['screenshot_thumb'] = XOOPS_URL . "/{$xoopsModuleConfig['screenshots']}/" . xoops_trim($link_arr['screenshot']); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | if ($moderate == 0) { |
||
| 59 | $time = ($link_arr['updated'] != 0) ? $link_arr['updated'] : $link_arr['published']; |
||
| 60 | $is_updated = ($link_arr['updated'] != 0) ? _MD_WFL_UPDATEDON : _MD_WFL_PUBLISHDATE; |
||
| 61 | $xoopsTpl->assign('lang_subdate', $is_updated); |
||
| 62 | } else { |
||
| 63 | $time = $link_arr['date']; |
||
| 64 | $is_updated = _MD_WFL_SUBMITDATE; |
||
| 65 | $xoopsTpl->assign('lang_subdate', $is_updated); |
||
| 66 | } |
||
| 67 | |||
| 68 | $link['updated'] = formatTimestamp($time, $xoopsModuleConfig['dateformat']); |
||
| 69 | $description = $wfmyts->displayTarea($link_arr['description'], 1, 1, 1, 1, 1); |
||
| 70 | |||
| 71 | $link['description'] = xoops_substr($description, 0, $xoopsModuleConfig['totalchars'], '...'); |
||
| 72 | xoops_load('XoopsUserUtility'); |
||
| 73 | $link['submitter'] = XoopsUserUtility::getUnameFromId($link_arr['submitter']); |
||
| 74 | $link['publisher'] = (isset($link_arr['publisher']) |
||
| 75 | && !empty($link_arr['publisher'])) ? $wfmyts->htmlSpecialCharsStrip($link_arr['publisher']) : _MD_WFL_NOTSPECIFIED; |
||
| 76 | |||
| 77 | $country = $link_arr['country']; |
||
| 78 | $link['country'] = XOOPS_URL . '/' . $xoopsModuleConfig['flagimage'] . '/' . $country . '.gif'; |
||
| 79 | $link['countryname'] = WfLinksUtility::getCountryName($link_arr['country']); |
||
| 80 | |||
| 81 | $mail_subject = rawurlencode(sprintf(_MD_WFL_INTFILEFOUND, $xoopsConfig['sitename'])); |
||
| 82 | $mail_body = rawurlencode(sprintf(_MD_WFL_INTFILEFOUND, $xoopsConfig['sitename']) . ': ' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $link_arr['cid'] . '&lid=' . $link_arr['lid']); |
||
| 83 | $link['isadmin'] = ((is_object($xoopsUser) && !empty($xoopsUser)) |
||
| 84 | && $xoopsUser->isAdmin($xoopsModule->mid())); |
||
| 85 | $link['comments'] = $link_arr['comments']; |
||
| 86 | $whoisurl = str_replace('http://', '', $link['url']); |
||
| 87 | |||
| 88 | $link['adminlink'] = ''; |
||
| 89 | if (0 == $moderate && $link['isadmin'] === true) { |
||
| 90 | $link['adminlink'] = '<a href="' |
||
| 91 | . XOOPS_URL |
||
| 92 | . '/modules/' |
||
| 93 | . $xoopsModule->getVar('dirname') |
||
| 94 | . '/admin/index.php"><img src="' |
||
| 95 | . XOOPS_URL |
||
| 96 | . '/modules/' |
||
| 97 | . $xoopsModule->getVar('dirname') |
||
| 98 | . '/assets/images/icon/computer.png" alt="' |
||
| 99 | . _MD_WFL_ADMINSECTION |
||
| 100 | . '" title="' |
||
| 101 | . _MD_WFL_ADMINSECTION |
||
| 102 | . '" align="absmiddle"></a> '; |
||
| 103 | $link['adminlink'] .= '<a href="' |
||
| 104 | . XOOPS_URL |
||
| 105 | . '/modules/' |
||
| 106 | . $xoopsModule->getVar('dirname') |
||
| 107 | . '/admin/main.php?op=edit&lid=' |
||
| 108 | . $link_arr['lid'] |
||
| 109 | . '"><img src="' |
||
| 110 | . \Xmf\Module\Admin::iconUrl('', 16) |
||
| 111 | . '/edit.png" alt="' |
||
| 112 | . _MD_WFL_EDIT |
||
| 113 | . '" title="' |
||
| 114 | . _MD_WFL_EDIT |
||
| 115 | . '" align="absmiddle"></a> '; |
||
| 116 | $link['adminlink'] .= '<a href="' |
||
| 117 | . XOOPS_URL |
||
| 118 | . '/modules/' |
||
| 119 | . $xoopsModule->getVar('dirname') |
||
| 120 | . '/admin/main.php?op=delete&lid=' |
||
| 121 | . $link_arr['lid'] |
||
| 122 | . '"><img src="' |
||
| 123 | . \Xmf\Module\Admin::iconUrl('', 16) |
||
| 124 | . '/delete.png" alt="' |
||
| 125 | . _MD_WFL_DELETE |
||
| 126 | . '" title="' |
||
| 127 | . _MD_WFL_DELETE |
||
| 128 | . '" align="absmiddle"></a> '; |
||
| 129 | $link['adminlink'] .= '<a href="http://whois.domaintools.com/' . $whoisurl . '" target="_blank"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/domaintools.png" alt="WHOIS" title="WHOIS" align="absmiddle"></a>'; |
||
| 130 | } else { |
||
| 131 | $link['adminlink'] = '[ <a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php?op=edit&lid=' . $link_arr['lid'] . '&approve=1">' . _MD_WFL_APPROVE . '</a> | '; |
||
| 132 | $link['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php?op=delete&lid=' . $link_arr['lid'] . '">' . _MD_WFL_DELETE . '</a> ]'; |
||
| 133 | } |
||
| 134 | |||
| 135 | $votestring = ($link_arr['votes'] == 1) ? _MD_WFL_ONEVOTE : sprintf(_MD_WFL_NUMVOTES, $link_arr['votes']); |
||
| 136 | |||
| 137 | $link['useradminlink'] = 0; |
||
| 138 | if (is_object($xoopsUser) && !empty($xoopsUser)) { |
||
| 139 | $_user_submitter = $xoopsUser->getvar('uid') == $link_arr['submitter']; |
||
| 140 | if (true === WfLinksUtility::checkGroups($cid)) { |
||
| 141 | $link['useradminlink'] = 1; |
||
| 142 | if ($xoopsUser->getVar('uid') == $link_arr['submitter']) { |
||
| 143 | $link['usermodify'] = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php?lid=' . $link_arr['lid'] . '"> ' . _MD_WFL_MODIFY . '</a> |'; |
||
| 144 | } |
||
| 145 | } |
||
| 146 | } |
||
| 147 | |||
| 148 | switch ($xoopsModuleConfig['selectforum']) { |
||
| 149 | case '1': |
||
| 150 | $forum = 'newbb'; |
||
| 151 | $forum_path_prefix = '/modules/newbb/viewforum.php?forum='; |
||
| 152 | break; |
||
| 153 | case '2': |
||
| 154 | $forum = 'ipboard'; |
||
| 155 | $forum_path_prefix = '/modules/ipboard/index.php?showforum='; |
||
| 156 | break; |
||
| 157 | case '3': |
||
| 158 | $forum = 'pbboard'; |
||
| 159 | $forum_path_prefix = '/modules/pbboard/viewforum.php?f='; |
||
| 160 | break; |
||
| 161 | case '4': |
||
| 162 | $forum = 'newbbex'; |
||
| 163 | $forum_path_prefix = '/modules/newbbex/viewforum.php?forum='; |
||
| 164 | break; |
||
| 165 | } |
||
| 166 | $xoopsforumModule = $xoopsModule->getByDirname($forum); |
||
| 167 | if (is_object($xoopsforumModule) && $xoopsforumModule->getVar('isactive')) { |
||
| 168 | $link['forumid'] = ($link_arr['forumid'] > 0) ? $link_arr['forumid'] : 0; |
||
| 169 | $link['forum_path'] = $forum_path_prefix . "{$link['forumid']}"; |
||
| 170 | } |
||
| 171 | |||
| 172 | $xoopsTpl->assign('ratethislink', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/ratelink.php?cid=' . $link_arr['cid'] . '&lid=' . $link_arr['lid'] . '">' . _MD_WFL_RATETHISFILE . '</a>'); |
||
| 173 | |||
| 174 | $xoopsTpl->assign('reportbroken', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/brokenlink.php?lid=' . $link_arr['lid'] . '">' . _MD_WFL_REPORTBROKEN . '</a>'); |
||
| 175 | |||
| 176 | $xoopsTpl->assign('mailto', '<a href="mailto:?subject=' . $mail_subject . '&body=' . $mail_body . '" target="_top">' . _MD_WFL_TELLAFRIEND . '</a>'); |
||
| 177 | |||
| 178 | $xoopsTpl->assign('commentz', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $link_arr['cid'] . '&lid=' . $link_arr['lid'] . '">' . _COMMENTS . ' (' . $link_arr['comments'] . ')</a>'); |
||
| 179 | |||
| 180 | $xoopsTpl->assign('print', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/print.php?lid=' . $link_arr['lid'] . '" target="_blank">' . _MD_WFL_PRINT . '</a>'); |
||
| 181 | |||
| 182 | $link['icons'] = WfLinksUtility::displayIcons($link_arr['published'], $link_arr['status'], $link_arr['hits']); |
||
| 183 | $link['allow_rating'] = WfLinksUtility::checkGroups($cid, 'WFLinkRatePerms') ? true : false; |
||
| 184 | $link['total_chars'] = $xoopsModuleConfig['totalchars']; |
||
| 185 | $link['module_dir'] = $xoopsModule->getVar('dirname'); |
||
| 186 | $link['otherlinx'] = $xoopsModuleConfig['otherlinks']; |
||
| 187 | $link['showpagerank'] = $xoopsModuleConfig['showpagerank']; |
||
| 188 | $link['quickview'] = $xoopsModuleConfig['quickview']; |
||
| 189 | $link['comment_rules'] = $xoopsModuleConfig['com_rule']; |
||
| 190 | $link['autoscrshot'] = $xoopsModuleConfig['useautothumb']; |
||
| 191 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.