Completed
Push — master ( 786b6e...dc199a )
by Michael
01:38
created

singlelink.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
// $Id: singlelink.php 11819 2013-07-09 18:21:40Z zyspec $
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                    Copyright (c) 2000 XOOPS.org                           //
6
//                       <http://www.xoops.org/>                             //
7
// ------------------------------------------------------------------------- //
8
//  This program is free software; you can redistribute it and/or modify     //
9
//  it under the terms of the GNU General Public License as published by     //
10
//  the Free Software Foundation; either version 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
include __DIR__ . '/header.php';
28
$myts = MyTextSanitizer::getInstance();// MyTextSanitizer object
29
30
include_once XOOPS_ROOT_PATH . '/class/tree.php';
31
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname'));
32
$catObjs           = $mylinksCatHandler->getAll();
33
$myCatTree         = new XoopsObjectTree($catObjs, 'cid', 'pid');
34
35
include_once __DIR__ . '/class/utility.php';
36
37
$lid = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0));
0 ignored issues
show
'lid' is of type string, but the function expects a object<unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38
$cid = MylinksUtility::mylinks_cleanVars($_GET, 'cid', 0, 'int', array('min' => 0));
0 ignored issues
show
'cid' is of type string, but the function expects a object<unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
40
$xoopsOption['template_main'] = 'mylinks_singlelink.tpl';
41
include XOOPS_ROOT_PATH . '/header.php';
42
43
//wanikoo
44
$xoTheme->addStylesheet('browse.php?' . mylinksGetStylePath('mylinks.css', 'include'));
45
$xoTheme->addScript('browse.php?' . mylinksGetStylePath('mylinks.js', 'include'));
46
//
47
48
$result = $xoopsDB->query('SELECT l.lid, l.cid, l.title, l.url, l.logourl, l.status, l.date, l.hits, l.rating, l.votes, l.comments, t.description FROM ' . $xoopsDB->prefix('mylinks_links') . ' l, ' . $xoopsDB->prefix('mylinks_text') . " t WHERE l.lid={$lid} AND l.lid=t.lid AND status>0");
49
list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result);
50
51
$thisCatObj     = $mylinksCatHandler->get($cid);
52
$homePath       = "<a href='" . XOOPSMYLINKURL . "/index.php'>" . _MD_MYLINKS_MAIN . '</a>&nbsp;:&nbsp;';
53
$niceItemPath   = "<a href='" . XOOPSMYLINKURL . "/viewcat.php?cid={$cid}'>" . $thisCatObj->getVar('title') . '</a>';
54
$itemPath       = $thisCatObj->getVar('title');
55
$nicePathFromId = '';
56
$pathFromId     = '';
57
$myParent       = $thisCatObj->getVar('pid');
58
while ($myParent != 0) {
59
    $ancestorObj    = $myCatTree->getByKey($myParent);
60
    $nicePathFromId = "<a href='" . XOOPSMYLINKURL . '/viewcat.php?cid=' . $ancestorObj->getVar('cid') . "'>" . $ancestorObj->getVar('title') . "</a>&nbsp;:&nbsp;{$nicePathFromId}";
61
    $pathFromId     = $ancestorObj->getVar('title') . "/{$pathFromId}";
62
    $myParent       = $ancestorObj->getVar('pid');
63
}
64
65
$nicePathFromId = "{$homePath}{$nicePathFromId}{$niceItemPath}";
66
$nicePathFromId = str_replace('&nbsp;:&nbsp;', " <img src='" . mylinksGetIconURL('arrow.gif') . "' style='border-width: 0px;' alt=''> ", $nicePathFromId);
67
$pathFromId     = _MD_MYLINKS_MAIN . "/{$pathFromId}{$itemPath}";
68
$pathFromId     = str_replace('/', " <img src='" . mylinksGetIconURL('arrow.gif') . "' style='border-width: 0px;' alt=''> ", $pathFromId);
69
$xoopsTpl->assign('category_path', $nicePathFromId);
70
71
$xoopsTpl->assign('anontellafriend', $GLOBALS['xoopsModuleConfig']['anontellafriend']);
72
73 View Code Duplication
if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
74
    $adminlink = "<a href='" . XOOPSMYLINKURL . "/admin/main.php?op=modLink&amp;lid={$lid}'><img src='" . mylinksGetIconURL('edit.png') . "' style='border-width: 0px;' alt='" . _MD_MYLINKS_EDITTHISLINK . "' title='" . _MD_MYLINKS_EDITTHISLINK . "'></a>";
75
} else {
76
    $adminlink = '';
77
}
78
$votestring = (1 == $votes) ? _MD_MYLINKS_ONEVOTE : sprintf(_MD_MYLINKS_NUMVOTES, $votes);
79
$new        = newlinkgraphic($time, $status);
80
$pop        = popgraphic($hits);
81
82
//$xoopsTpl->assign('link', array('id' => $lid, 'cid' => $cid, 'rating' => number_format($rating, 2), 'title' => $myts->htmlSpecialChars($ltitle).$new.$pop, 'category' => $path, 'logourl' => $myts->htmlSpecialChars($logourl), 'updated' => formatTimestamp($time,"m"), 'description' => $myts->displayTarea($description,0), 'adminlink' => $adminlink, 'hits' => $hits, 'votes' => $votestring, 'comments' => $comments, 'mail_subject' => rawurlencode(sprintf(_MD_MYLINKS_INTRESTLINK,$xoopsConfig['sitename'])), 'mail_body' => rawurlencode(sprintf(_MD_MYLINKS_INTLINKFOUND,$xoopsConfig['sitename']).':  '.XOOPSMYLINKURL.'/singlelink.php?lid='.$lid)));
83
//by wanikoo
84
/* setup shot provider information */
85
$shotImgSrc = $shotImgHref = $shotAttribution = '';
86
$useShots   = $xoopsModuleConfig['useshots'];
87
if ($useShots) {
88
    $shotWidth = $xoopsModuleConfig['shotwidth'];
89
    $xoopsTpl->assign(array(
90
                          'shotwidth'         => $shotWidth . 'px',
91
                          //                            'tablewidth'        => ($shotWidth + 10) . "px",
92
                          'show_screenshot'   => true,
93
                          'lang_noscreenshot' => _MD_MYLINKS_NOSHOTS
94
                      ));
95
96
    $shotProvider = mb_strtolower($xoopsModuleConfig['shotprovider']);
97
    $shotImgHref  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/visit.php?cid={$cid}&amp;lid={$lid}";
98
    $logourl      = trim($logourl);
99
    if (!empty($logourl)) {
100
        if (file_exists(XOOPSMYLINKIMGPATH . "/{$mylinks_theme}")) {
101
            $shotImgSrc = XOOPSMYLINKIMGURL . "/{$mylinks_theme}/shots/" . $myts->htmlSpecialChars($logourl);
102
        } else {
103
            $shotImgSrc = XOOPSMYLINKIMGURL . '/shots/' . $myts->htmlSpecialChars($logourl);
104
        }
105
    } elseif (_NONE != $shotProvider) {
106
        if (file_exists(XOOPS_ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $xoopsModule->getVar('dirname') . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'providers' . DIRECTORY_SEPARATOR . mb_strtolower($shotProvider) . '.php')) {
107
            include_once XOOPS_ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $xoopsModule->getVar('dirname') . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'providers' . DIRECTORY_SEPARATOR . mb_strtolower($shotProvider) . '.php';
108
            $shotClass = ucfirst($xoopsModule->getVar('dirname')) . ucfirst($shotProvider);
109
            $shotObj   = new $shotClass;
110
            $shotObj->setProviderPublicKey($xoopsModuleConfig['shotpubkey']);
111
            $shotObj->setProviderPrivateKey($xoopsModuleConfig['shotprivkey']);
112
            $shotObj->setShotSize(array('width' => $xoopsModuleConfig['shotwidth']));
113
            $shotObj->setSiteUrl($myts->htmlSpecialChars($url));
114
            $shotImgSrc = $shotObj->getProviderUrl();
115
            if ($xoopsModuleConfig['shotattribution']) {
116
                $shotAttribution = $shotObj->getAttribution(true);
117
            } else {
118
                $shotAttribution = '';
119
            }
120
        }
121
    }
122
} else {
123
    $xoopsTpl->assign('show_screenshot', false);
124
}
125
$xoopsTpl->assign('shot_attribution', $shotAttribution);
126
$xoopsTpl->assign('link', array(
127
    'url'           => $myts->htmlSpecialChars($url),
128
    'id'            => $lid,
129
    'cid'           => $cid,
130
    'rating'        => number_format($rating, 2),
131
    'ltitle'        => $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)),
132
    'title'         => $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)) . $new . $pop,
133
    'category'      => $pathFromId,
134
    'logourl'       => $myts->htmlSpecialChars(trim($logourl)),
135
    'updated'       => formatTimestamp($time, 'm'),
136
    'description'   => $myts->displayTarea($myts->stripSlashesGPC($description), 0),
137
    'adminlink'     => $adminlink,
138
    'hits'          => $hits,
139
    'votes'         => $votestring,
140
    'comments'      => $comments,
141
    'mail_subject'  => rawurlencode(sprintf(_MD_MYLINKS_INTRESTLINK, $xoopsConfig['sitename'])),
142
    'mail_body'     => rawurlencode(sprintf(_MD_MYLINKS_INTLINKFOUND, $xoopsConfig['sitename']) . ':  ' . XOOPSMYLINKURL . "/singlelink.php?lid={$lid}"),
143
    'shot_img_src'  => $shotImgSrc,
144
    'shot_img_href' => $shotImgHref
145
));
146
147
$xoopsTpl->assign(array(
148
                      'lang_description'  => _MD_MYLINKS_DESCRIPTIONC,
149
                      'lang_lastupdate'   => _MD_MYLINKS_LASTUPDATEC,
150
                      'lang_hits'         => _MD_MYLINKS_HITSC,
151
                      'lang_rating'       => _MD_MYLINKS_RATINGC,
152
                      'lang_ratethissite' => _MD_MYLINKS_RATETHISSITE,
153
                      'lang_reportbroken' => _MD_MYLINKS_REPORTBROKEN,
154
                      'lang_tellafriend'  => _MD_MYLINKS_TELLAFRIEND,
155
                      'lang_modify'       => _MD_MYLINKS_MODIFY,
156
                      'lang_category'     => _MD_MYLINKS_CATEGORYC,
157
                      'lang_visit'        => _MD_MYLINKS_VISIT,
158
                      'lang_comments'     => _COMMENTS
159
                  ));
160
//wanikoo
161
/*
162
if (file_exists(XOOPS_ROOT_PATH."/include/moremetasearch.php")&&$mylinks_show_externalsearch) {
163
  include_once XOOPS_ROOT_PATH."/include/moremetasearch.php";
164
  $thisltitle = $myts->htmlSpecialChars($ltitle);
165
  $_REQUEST['query']= $thisltitle;
166
  $engineblocktitle = _MD_MYLINKS_EXTERNALSEARCH;
167
  $engineblocktitle .= sprintf(_MD_MYLINKS_EXTERNALSEARCH_KEYWORD, _MD_MYLINKS_TITLE, $thisltitle);
168
  $location_list=moremeta("meta_page","on");
169
  $metaresult = more_meta_page($location_list, $target="_blank", $display = false, $engineblocktitle);
170
  $xoopsTpl->assign('moremetasearch', "<br><br>".$metaresult);
171
} else {
172
  $xoopsTpl->assign('moremetasearch', '');
173
}
174
*/
175
$xoopsTpl->assign('moremetasearch', '');
176
177
//wanikoo theme changer
178
$xoopsTpl->assign('lang_themechanger', _MD_MYLINKS_THEMECHANGER);
179
$mymylinkstheme_options = '';
180
181 View Code Duplication
foreach ($GLOBALS['mylinks_allowed_theme'] as $mymylinkstheme) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
182
    $mymylinkstheme_options .= "<option value='{$mymylinkstheme}'";
183
    if ($mymylinkstheme == $GLOBALS['mylinks_theme']) {
184
        $mymylinkstheme_options .= ' selected="selected"';
185
    }
186
    $mymylinkstheme_options .= ">{$mymylinkstheme}</option>";
187
}
188
189
$mylinkstheme_select = "<select name='mylinks_theme_select' onchange='submit();' size='1'>{$mymylinkstheme_options}</select>";
190
191
$xoopsTpl->assign('mylinksthemeoption', $mylinkstheme_select);
192
//wanikoo end
193
194
//wanikoo search
195 View Code Duplication
if (file_exists(XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php')) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
196
    include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php';
197
} else {
198
    include_once XOOPS_ROOT_PATH . '/language/english/search.php';
199
}
200
$xoopsTpl->assign('lang_all', _SR_ALL);
201
$xoopsTpl->assign('lang_any', _SR_ANY);
202
$xoopsTpl->assign('lang_exact', _SR_EXACT);
203
$xoopsTpl->assign('lang_search', _SR_SEARCH);
204
$xoopsTpl->assign('module_id', $xoopsModule->getVar('mid'));
205
//
206
//category head
207
$catarray = array();
208
if ($mylinks_show_letters) {
209
    $catarray['letters'] = ml_wfd_letters();
210
}
211
if ($mylinks_show_toolbar) {
212
    $catarray['toolbar'] = ml_wfd_toolbar();
213
}
214
$xoopsTpl->assign('catarray', $catarray);
215
//pagetitle (module name - singlelink)
216
$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name') . ' - ' . $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)));
217
//category jump box
218
$catjumpbox = "<form name='catjumpbox' method='get' action='viewcat.php'>\n" . '  <strong>' . _MD_MYLINKS_CATEGORYC . "</strong>&nbsp;\n" . '  ' . $myCatTree->makeSelBox('title', 'title', $cid) . "&nbsp;\n" . "  <input type='submit' value='" . _SUBMIT . "'>\n" . "</form>\n";
219
$xoopsTpl->assign('mylinksjumpbox', $catjumpbox);
220
221
include XOOPS_ROOT_PATH . '/include/comment_view.php';
222
include_once XOOPSMYLINKPATH . '/footer.php';
223