Completed
Push — master ( 1578b3...d900db )
by Michael
05:55 queued 02:54
created

index.php (9 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: index.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 'header.php';
28
29
$myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object
30
31
include_once XOOPS_ROOT_PATH . '/class/tree.php';
32
$mylinksCatHandler =& xoops_getmodulehandler('category', $xoopsModule->getVar('dirname'));
33
$catObjs           = $mylinksCatHandler->getAll();
34
$myCatTree         = new XoopsObjectTree($catObjs, 'cid', 'pid');
35
36
$xoopsOption['template_main'] = 'mylinks_index.html';
37
include XOOPS_ROOT_PATH . '/header.php';
38
39
//wanikoo
40
$xoTheme->addStylesheet('browse.php?' . mylinksGetStylePath('mylinks.css', 'include'));
41
$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
42
$xoTheme->addScript('browse.php?' . mylinksGetStylePath('mylinks.js', 'include'));
43
// get all top level categories (pid=0)
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
44
//$mylinksCatHandler =& xoops_getmodulehandler('category', $xoopsModule->getVar('dirname'));
45
$criteria = new CriteriaCompo();
46
$criteria->add(new Criteria('pid', 0, '='));
47
$criteria->setSort('title');
48
$catObjs = $mylinksCatHandler->getAll($criteria);
49
50
$subcatLimit = 5;
51
$count = 1;
52
foreach ($catObjs as $catObj) {
53
    $catImgUrl = '';
54 View Code Duplication
    if ( $catObj->getVar('imgurl') && (($catObj->getVar('imgurl') != 'http://') && ($catObj->getVar('imgurl') != '')) ) {
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...
55
//    if ( $catObj->getVar('imgurl') && ($catObj->getVar('imgurl') != "http://") ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
56
        $catImgUrl = $myts->htmlSpecialChars($catObj->getVar('imgurl', 'n'));
57
    }
58
    // get the total number of subcats for this category
59
    $criteria = new CriteriaCompo();
60
    $criteria->add(new Criteria('pid', $catObj->getVar('cid'), '='));
61
    $childCount = intval($mylinksCatHandler->getCount($criteria));
62
63
    //now retrieve the info for the first 'subcatLimit' categories
64
    $criteria->setLimit($subcatLimit);
65
    $criteria->setSort('title');
66
    $childFields = array('pid', 'title');
67
    $childTitleArray = $mylinksCatHandler->getAll($criteria, $childFields, false, false);
68
    $lpLimit = min(array($subcatLimit , count($childTitleArray)));
69
    $subcategories = '';
70
    for ($i=0; $i<$lpLimit; $i++) {
71
        $chtitle = $myts->htmlSpecialChars($childTitleArray[$i]['title']);
72
        $subcategories .= ($i>0) ? ', ' : '';
73
        $subcategories .= "<a href='" . XOOPSMYLINKURL . '/viewcat.php?cid=' . $childTitleArray[$i]['cid'] . "'>{$chtitle}</a>";
74
    }
75
    $subcategories = ($childCount > $subcatLimit) ? $subcategories . '...' : $subcategories;
76
77
    // get number of links in each subcategory
78
    $totalLink = getTotalItems($catObj->getVar('cid'), 0, '>');
79
    $xoopsTpl->append('categories', array('image'         => $catImgUrl,
80
                                          'id'            => $catObj->getVar('cid'),
81
                                          'title'         => $myts->htmlSpecialChars($catObj->getVar('title')),
82
                                          'subcategories' => $subcategories,
83
                                          'totallink'     => $totalLink,
84
                                          'count'         => $count));
85
    $count++;
86
}
87
88
$sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_links') . ' WHERE status>0';
89
list($numActiveLinks) = $xoopsDB->fetchRow($xoopsDB->query($sql));
90
$xoopsTpl->assign('lang_thereare', sprintf(_MD_MYLINKS_THEREARE, $numActiveLinks));
91
92
$xoopsTpl->assign('anontellafriend', $GLOBALS['xoopsModuleConfig']['anontellafriend']);
93
$useShots = $xoopsModuleConfig['useshots'];
94 View Code Duplication
if (1 == $useShots) {
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...
95
    $shotWidth = $xoopsModuleConfig['shotwidth'];
96
    $xoopsTpl->assign(array('shotwidth'         => $shotWidth . 'px',
97
                            //                            'tablewidth'        => ($shotWidth + 10) . "px",
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% 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...
98
                            'show_screenshot'   => true,
99
                            'lang_noscreenshot' => _MD_MYLINKS_NOSHOTS)
100
    );
101
} else {
102
    $xoopsTpl->assign('show_screenshot', false);
103
}
104
105
$xoopsTpl->assign(array('lang_description'    => _MD_MYLINKS_DESCRIPTIONC,
106
                        'lang_lastupdate'     => _MD_MYLINKS_LASTUPDATEC,
107
                        'lang_hits'           => _MD_MYLINKS_HITSC,
108
                        'lang_rating'         => _MD_MYLINKS_RATINGC,
109
                        'lang_ratethissite'   => _MD_MYLINKS_RATETHISSITE,
110
                        'lang_reportbroken'   => _MD_MYLINKS_REPORTBROKEN,
111
                        'lang_tellafriend'    => _MD_MYLINKS_TELLAFRIEND,
112
                        'lang_modify'         => _MD_MYLINKS_MODIFY,
113
                        'lang_latestlistings' => _MD_MYLINKS_LATESTLIST,
114
                        'lang_category'       => _MD_MYLINKS_CATEGORYC,
115
                        'lang_visit'          => _MD_MYLINKS_VISIT,
116
                        'lang_comments'       => _COMMENTS)
117
);
118
119
$shotAttribution = '';
120
$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.status>0 and l.lid=t.lid ORDER BY date DESC', $xoopsModuleConfig['newlinks'], 0);
121
while (list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result)) {
122 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...
123
        $isadmin   = true;
124
        $adminlink = "<a href='" . XOOPSMYLINKURL . "/admin/main.php?op=modLink&amp;&fct=mylinks&amp;lid={$lid}'><img src='" . mylinksGetIconURL('edit.png') . "' style='border-width: 0px;' alt='" . _MD_MYLINKS_EDITTHISLINK . "'></a>";
125
    } else {
126
        $isadmin   = false;
127
        $adminlink = '';
128
    }
129
130
    $votestring = (1 == $votes) ? _MD_MYLINKS_ONEVOTE : sprintf(_MD_MYLINKS_NUMVOTES, $votes);
131
    $ltitle     = $myts->htmlSpecialChars($ltitle);
132
    $thisCatObj = $mylinksCatHandler->get($cid);
133
    $homePath   = _MD_MYLINKS_MAIN . '&nbsp;:&nbsp;';
134
    $itemPath    = "<a href='" . XOOPSMYLINKURL . "/viewcat.php?cid={$cid}'>" . $thisCatObj->getVar('title') . '</a>';
135
    $path       = '';
136
    $myParentID = $thisCatObj->getVar('pid');
137 View Code Duplication
    while ( $myParentID != 0 ) {
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...
138
        $ancestorObj = $myCatTree->getByKey($myParentID);
139
        $path  = "<a href='" . XOOPSMYLINKURL . '/viewcat.php?cid=' . $ancestorObj->getVar('cid') . "'>" . $ancestorObj->getVar('title') . "</a>&nbsp;:&nbsp;{$path}";
140
        $myParentID = $ancestorObj->getVar('pid');
141
    }
142
143
    $path = "{$homePath}{$path}{$itemPath}";
144
    $path = str_replace('&nbsp;:&nbsp;', " <img src='" . mylinksGetIconURL('arrow.gif') . "' style='border-width: 0px;' alt=''> ", $path);
145
    $new = newlinkgraphic($time, $status);
146
    $pop = popgraphic($hits);
147
    //by wanikoo
148
    /* setup shot provider information */
149
    $shotImgSrc = $shotImgHref = $shotAttribution = '';
150 View Code Duplication
    if ($useShots) {
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...
151
        $shotProvider = mb_strtolower($xoopsModuleConfig['shotprovider']);
152
        $shotImgHref = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/visit.php?cid={$cid}&amp;lid={$lid}";
153
        $logourl = trim($logourl);
154
        if (!empty($logourl)) {
155
            if (file_exists(XOOPSMYLINKIMGPATH . "/{$mylinks_theme}")) {
156
                $shotImgSrc = XOOPSMYLINKIMGURL . "/{$mylinks_theme}/shots/" . $myts->htmlSpecialChars($logourl);
157
            } else {
158
                $shotImgSrc = XOOPSMYLINKIMGURL . '/shots/' . $myts->htmlSpecialChars($logourl);
159
            }
160
        } elseif (_NONE != $shotProvider) {
161
            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')) {
162
                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';
163
                $shotClass = ucfirst($xoopsModule->getVar('dirname')) . ucfirst($shotProvider);
164
                $shotObj = new $shotClass;
165
                $shotObj->setProviderPublicKey($xoopsModuleConfig['shotpubkey']);
166
                $shotObj->setProviderPrivateKey($xoopsModuleConfig['shotprivkey']);
167
                $shotObj->setShotSize(array('width' => $xoopsModuleConfig['shotwidth']));
168
                $shotObj->setSiteUrl($myts->htmlSpecialChars($url));
169
                $shotImgSrc = $shotObj->getProviderUrl();
170
                if ($xoopsModuleConfig['shotattribution']) {
171
                    $shotAttribution = $shotObj->getAttribution(true);
172
                } else {
173
                    $shotAttribution = '';
174
                }
175
            }
176
        }
177
    }
178
    $xoopsTpl->assign('shot_attribution', $shotAttribution);
179
    $xoopsTpl->append('links', array('url'           => $myts->htmlSpecialChars($url),
180
                                     'id'            => $lid,
181
                                     'cid'           => $cid,
182
                                     'rating'        => number_format($rating, 2),
183
                                     'ltitle'        => $ltitle,
184
                                     'title'         => $myts->htmlSpecialChars($myts->stripSlashesGPC($ltitle)).$new.$pop,
185
                                     'category'      => $path,
186
                                     'logourl'       => $myts->htmlSpecialChars(trim($logourl)),
187
                                     'updated'       => formatTimestamp($time, 'm'),
188
                                     'description'   => $myts->displayTarea($myts->stripSlashesGPC($description), 0),
189
                                     'adminlink'     => $adminlink,
190
                                     'hits'          => $hits,
191
                                     'votes'         => $votestring,
192
                                     'comments'      => $comments,
193
                                     'mail_subject'  => rawurlencode(sprintf(_MD_MYLINKS_INTRESTLINK, $xoopsConfig['sitename'])),
194
                                     'mail_body'     => rawurlencode(sprintf(_MD_MYLINKS_INTLINKFOUND, $xoopsConfig['sitename']) . ':  ' . XOOPSMYLINKURL  ."/singlelink.php?cid={$cid}&amp;lid={$lid}"),
195
                                     'shot_img_src'  => $shotImgSrc,
196
                                     'shot_img_href' => $shotImgHref)
197
    );
198
}
199
//wanikoo
200
$xoopsTpl->assign('lang_feed', _MD_MYLINKS_FEED);
201
//wanikoo theme changer
202
$xoopsTpl->assign('lang_themechanger', _MD_MYLINKS_THEMECHANGER);
203
$mymylinkstheme_options = '';
204
205 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...
206
    $mymylinkstheme_options .= "<option value='{$mymylinkstheme}'";
207
    if ($mymylinkstheme == $GLOBALS['mylinks_theme']) {
208
        $mymylinkstheme_options .= " selected='selected'";
209
    }
210
    $mymylinkstheme_options .= ">{$mymylinkstheme}</option>";
211
}
212
213
$mylinkstheme_select = "<select name='mylinks_theme_select' onchange='submit();' size='1'>{$mymylinkstheme_options}</select>";
214
215
$xoopsTpl->assign('mylinksthemeoption', $mylinkstheme_select);
216
217
//wanikoo search
218
if (file_exists(XOOPS_ROOT_PATH . "/language/{$xoopsConfig['language']}/search.php")) {
219
   include_once XOOPS_ROOT_PATH . "/language/{$xoopsConfig['language']}/search.php";
220
} else {
221
   include_once XOOPS_ROOT_PATH . '/language/english/search.php';
222
}
223
$xoopsTpl->assign('lang_all', _SR_ALL);
224
$xoopsTpl->assign('lang_any', _SR_ANY);
225
$xoopsTpl->assign('lang_exact', _SR_EXACT);
226
$xoopsTpl->assign('lang_search', _SR_SEARCH);
227
$xoopsTpl->assign('module_id', $xoopsModule->getVar('mid'));
228
229
//category head
230
$catarray = array();
231
if ($mylinks_show_letters) {
232
    $catarray['letters'] = ml_wfd_letters();
233
}
234
if ($mylinks_show_toolbar) {
235
    $catarray['toolbar'] = ml_wfd_toolbar();
236
}
237
$xoopsTpl->assign('catarray', $catarray);
238
239
include_once XOOPSMYLINKPATH . '/footer.php';
240