Passed
Pull Request — master (#9)
by Michael
03:24
created

singlelink.php (2 issues)

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team
18
 */
19
20
use XoopsModules\Mylinks;
21
use XoopsModules\Mylinks\Providers;
22
use XoopsModules\Mylinks\Utility;
23
24
require_once __DIR__ . '/header.php';
25
26
/** @var Mylinks\Helper $helper */
27
$helper = Mylinks\Helper::getInstance();
28
$myts   = \MyTextSanitizer::getInstance(); // MyTextSanitizer object
29
30
require_once XOOPS_ROOT_PATH . '/class/tree.php';
31
$categoryHandler = $helper->getHandler('Category');
32
$catObjs           = $categoryHandler->getAll();
33
$myCatTree         = new \XoopsObjectTree($catObjs, 'cid', 'pid');
34
35
$lid = Mylinks\Utility::cleanVars($_GET, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
'lid' of type string is incompatible with the type XoopsModules\Mylinks\unknown_type expected by parameter $key of XoopsModules\Mylinks\Utility::cleanVars(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
$lid = Mylinks\Utility::cleanVars($_GET, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
36
$cid = Mylinks\Utility::cleanVars($_GET, 'cid', 0, 'int', ['min' => 0]);
37
38
$GLOBALS['xoopsOption']['template_main'] = 'mylinks_singlelink.tpl';
39
require_once XOOPS_ROOT_PATH . '/header.php';
40
41
//wanikoo
42
$xoTheme->addStylesheet('browse.php?' . Utility::getStylePath('mylinks.css', 'include'));
43
$xoTheme->addScript('browse.php?' . Utility::getStylePath('mylinks.js', 'include'));
44
45
$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");
46
list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result);
47
48
$thisCatObj     = $categoryHandler->get($cid);
49
$homePath       = "<a href='" . XOOPSMYLINKURL . "/index.php'>" . _MD_MYLINKS_MAIN . '</a>&nbsp;:&nbsp;';
50
$niceItemPath   = "<a href='" . XOOPSMYLINKURL . "/viewcat.php?cid={$cid}'>" . $thisCatObj->getVar('title') . '</a>';
51
$itemPath       = $thisCatObj->getVar('title');
52
$nicePathFromId = '';
53
$pathFromId     = '';
54
$myParent       = $thisCatObj->getVar('pid');
55
while (0 != $myParent) {
56
    $ancestorObj    = $myCatTree->getByKey($myParent);
57
    $nicePathFromId = "<a href='" . XOOPSMYLINKURL . '/viewcat.php?cid=' . $ancestorObj->getVar('cid') . "'>" . $ancestorObj->getVar('title') . "</a>&nbsp;:&nbsp;{$nicePathFromId}";
58
    $pathFromId     = $ancestorObj->getVar('title') . "/{$pathFromId}";
59
    $myParent       = $ancestorObj->getVar('pid');
60
}
61
62
$nicePathFromId = "{$homePath}{$nicePathFromId}{$niceItemPath}";
63
$nicePathFromId = str_replace('&nbsp;:&nbsp;', " <img src='" . Utility::getIconURL('arrow.gif') . "' style='border-width: 0px;' alt=''> ", $nicePathFromId);
64
$pathFromId     = _MD_MYLINKS_MAIN . "/{$pathFromId}{$itemPath}";
65
$pathFromId     = str_replace('/', " <img src='" . Utility::getIconURL('arrow.gif') . "' style='border-width: 0px;' alt=''> ", $pathFromId);
66
$xoopsTpl->assign('category_path', $nicePathFromId);
67
68
$xoopsTpl->assign('anontellafriend', $GLOBALS['xoopsModuleConfig']['anontellafriend']);
69
70
if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
71
    $adminlink = "<a href='" . XOOPSMYLINKURL . "/admin/main.php?op=modLink&amp;lid={$lid}'><img src='" . Utility::getIconURL('edit.png') . "' style='border-width: 0px;' alt='" . _MD_MYLINKS_EDITTHISLINK . "' title='" . _MD_MYLINKS_EDITTHISLINK . "'></a>";
72
} else {
73
    $adminlink = '';
74
}
75
$votestring = (1 == $votes) ? _MD_MYLINKS_ONEVOTE : sprintf(_MD_MYLINKS_NUMVOTES, $votes);
76
$new        = Utility::newLinkGraphic($time, $status);
77
$pop        = Utility::popGraphic($hits);
78
79
//$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)));
80
//by wanikoo
81
/* setup shot provider information */
82
$shotImgSrc = $shotImgHref = $shotAttribution = '';
83
$useShots   = $helper->getConfig('useshots');
84
if ($useShots) {
85
    $shotWidth = $helper->getConfig('shotwidth');
86
    $xoopsTpl->assign(
87
        [
88
            'shotwidth'         => $shotWidth . 'px',
89
            //                            'tablewidth'        => ($shotWidth + 10) . "px",
90
            'show_screenshot'   => true,
91
            'lang_noscreenshot' => _MD_MYLINKS_NOSHOTS,
92
        ]
93
    );
94
95
    $shotProvider = mb_strtolower($helper->getConfig('shotprovider'));
96
    $shotImgHref  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/visit.php?cid={$cid}&amp;lid={$lid}";
97
    $logourl      = trim($logourl);
98
    if (!empty($logourl)) {
99
        if (file_exists(XOOPSMYLINKIMGPATH . "/{$mylinks_theme}")) {
100
            $shotImgSrc = XOOPSMYLINKIMGURL . "/{$mylinks_theme}/shots/" . $myts->htmlSpecialChars($logourl);
101
        } else {
102
            $shotImgSrc = XOOPSMYLINKIMGURL . '/shots/' . $myts->htmlSpecialChars($logourl);
103
        }
104
    } elseif (_NONE != $shotProvider) {
105
        if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/class/Providers/' . mb_strtolower($shotProvider) . '.php')) {
106
            //            require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/class/providers/' . mb_strtolower($shotProvider) . '.php';
107
            $shotClass = ucfirst($xoopsModule->getVar('dirname')) . ucfirst($shotProvider);
108
            $shotObj   = new $shotClass();
109
            $shotObj->setProviderPublicKey($helper->getConfig('shotpubkey'));
110
            $shotObj->setProviderPrivateKey($helper->getConfig('shotprivkey'));
111
            $shotObj->setShotSize(['width' => $helper->getConfig('shotwidth')]);
112
            $shotObj->setSiteUrl($myts->htmlSpecialChars($url));
113
            $shotImgSrc = $shotObj->getProviderUrl();
114
            if ($helper->getConfig('shotattribution')) {
115
                $shotAttribution = $shotObj->getAttribution(true);
116
            } else {
117
                $shotAttribution = '';
118
            }
119
        }
120
    }
121
} else {
122
    $xoopsTpl->assign('show_screenshot', false);
123
}
124
$xoopsTpl->assign('shot_attribution', $shotAttribution);
125
$xoopsTpl->assign(
126
    'link',
127
    [
128
        'url'           => $myts->htmlSpecialChars($url),
129
        'id'            => $lid,
130
        'cid'           => $cid,
131
        'rating'        => number_format($rating, 2),
132
        'ltitle'        => $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)),
133
        'title'         => $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)) . $new . $pop,
134
        'category'      => $pathFromId,
135
        'logourl'       => $myts->htmlSpecialChars(trim($logourl)),
136
        'updated'       => formatTimestamp($time, 'm'),
137
        'description'   => $myts->displayTarea($myts->stripSlashesGPC($description), 0),
138
        'adminlink'     => $adminlink,
139
        'hits'          => $hits,
140
        'votes'         => $votestring,
141
        'comments'      => $comments,
142
        'mail_subject'  => rawurlencode(sprintf(_MD_MYLINKS_INTRESTLINK, $xoopsConfig['sitename'])),
143
        'mail_body'     => rawurlencode(sprintf(_MD_MYLINKS_INTLINKFOUND, $xoopsConfig['sitename']) . ':  ' . XOOPSMYLINKURL . "/singlelink.php?lid={$lid}"),
144
        'shot_img_src'  => $shotImgSrc,
145
        'shot_img_href' => $shotImgHref,
146
    ]
147
);
148
149
$xoopsTpl->assign(
150
    [
151
        'lang_description'  => _MD_MYLINKS_DESCRIPTIONC,
152
        'lang_lastupdate'   => _MD_MYLINKS_LASTUPDATEC,
153
        'lang_hits'         => _MD_MYLINKS_HITSC,
154
        'lang_rating'       => _MD_MYLINKS_RATINGC,
155
        'lang_ratethissite' => _MD_MYLINKS_RATETHISSITE,
156
        'lang_reportbroken' => _MD_MYLINKS_REPORTBROKEN,
157
        'lang_tellafriend'  => _MD_MYLINKS_TELLAFRIEND,
158
        'lang_modify'       => _MD_MYLINKS_MODIFY,
159
        'lang_category'     => _MD_MYLINKS_CATEGORYC,
160
        'lang_visit'        => _MD_MYLINKS_VISIT,
161
        'lang_comments'     => _COMMENTS,
162
    ]
163
);
164
//wanikoo
165
/*
166
if (file_exists(XOOPS_ROOT_PATH."/include/moremetasearch.php")&&$mylinks_show_externalsearch) {
167
  require_once XOOPS_ROOT_PATH."/include/moremetasearch.php";
168
  $thisltitle = $myts->htmlSpecialChars($ltitle);
169
  $_REQUEST['query']= $thisltitle;
170
  $engineblocktitle = _MD_MYLINKS_EXTERNALSEARCH;
171
  $engineblocktitle .= sprintf(_MD_MYLINKS_EXTERNALSEARCH_KEYWORD, _MD_MYLINKS_TITLE, $thisltitle);
172
  $location_list=moremeta("meta_page","on");
173
  $metaresult = more_meta_page($location_list, $target="_blank", $display = false, $engineblocktitle);
174
  $xoopsTpl->assign('moremetasearch', "<br><br>".$metaresult);
175
} else {
176
  $xoopsTpl->assign('moremetasearch', '');
177
}
178
*/
179
$xoopsTpl->assign('moremetasearch', '');
180
181
//wanikoo theme changer
182
$xoopsTpl->assign('lang_themechanger', _MD_MYLINKS_THEMECHANGER);
183
$mymylinkstheme_options = '';
184
185
foreach ($GLOBALS['mylinks_allowed_theme'] as $mymylinkstheme) {
186
    $mymylinkstheme_options .= "<option value='{$mymylinkstheme}'";
187
    if ($mymylinkstheme == $GLOBALS['mylinks_theme']) {
188
        $mymylinkstheme_options .= ' selected';
189
    }
190
    $mymylinkstheme_options .= ">{$mymylinkstheme}</option>";
191
}
192
193
$mylinkstheme_select = "<select name='mylinks_theme_select' onchange='submit();' size='1'>{$mymylinkstheme_options}</select>";
194
195
$xoopsTpl->assign('mylinksthemeoption', $mylinkstheme_select);
196
//wanikoo end
197
198
//wanikoo search
199
if (file_exists(XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php')) {
200
    require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php';
201
} else {
202
    require_once XOOPS_ROOT_PATH . '/language/english/search.php';
203
}
204
$xoopsTpl->assign('lang_all', _SR_ALL);
205
$xoopsTpl->assign('lang_any', _SR_ANY);
206
$xoopsTpl->assign('lang_exact', _SR_EXACT);
207
$xoopsTpl->assign('lang_search', _SR_SEARCH);
208
$xoopsTpl->assign('module_id', $xoopsModule->getVar('mid'));
209
//
210
//category head
211
$catarray = [];
212
if ($mylinks_show_letters) {
213
    $catarray['letters'] = Utility::letters();
214
}
215
if ($mylinks_show_toolbar) {
216
    $catarray['toolbar'] = Utility::toolbar();
217
}
218
$xoopsTpl->assign('catarray', $catarray);
219
//pagetitle (module name - singlelink)
220
$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name') . ' - ' . $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)));
221
//category jump box
222
$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";
0 ignored issues
show
Deprecated Code introduced by
The function XoopsObjectTree::makeSelBox() has been deprecated: since 2.5.9, please use makeSelectElement() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

222
$catjumpbox = "<form name='catjumpbox' method='get' action='viewcat.php'>\n" . '  <strong>' . _MD_MYLINKS_CATEGORYC . "</strong>&nbsp;\n" . '  ' . /** @scrutinizer ignore-deprecated */ $myCatTree->makeSelBox('title', 'title', $cid) . "&nbsp;\n" . "  <input type='submit' value='" . _SUBMIT . "'>\n" . "</form>\n";

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
223
$xoopsTpl->assign('mylinksjumpbox', $catjumpbox);
224
225
require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
226
require_once XOOPSMYLINKPATH . '/footer.php';
227