Passed
Push — master ( 08b589...961b46 )
by Michael
08:46
created

main.php ➔ edit()   F

Complexity

Conditions 54
Paths > 20000

Size

Total Lines 319
Code Lines 233

Duplication

Lines 12
Ratio 3.76 %

Importance

Changes 0
Metric Value
cc 54
eloc 233
nc 4294967295
nop 1
dl 12
loc 319
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Module: WF-Links
4
 * Version: v1.0.3
5
 * Release Date: 21 June 2005
6
 * Developer: John N
7
 * Team: WF-Projects
8
 * Licence: GNU
9
 */
10
11
use Xmf\Module\Admin;
12
use Xmf\Request;
13
use XoopsModules\Tag\FormTag;
14
use XoopsModules\Wflinks;
15
16
require_once __DIR__ . '/admin_header.php';
17
18
$mytree = new Wflinks\Tree($xoopsDB->prefix('wflinks_cat'), 'cid', 'pid');
19
20
$op  = Wflinks\Utility::cleanRequestVars($_REQUEST, 'op', '');
21
$lid = (int)Wflinks\Utility::cleanRequestVars($_REQUEST, 'lid', 0);
22
23
/**
24
 * @param int $lid
25
 * @return bool|null
26
 */
27
function edit($lid = 0)
28
{
29
    global $xoopsDB, $myts, $mytree, $imageArray, $xoopsConfig, $xoopsModule, $xoopsUser;
30
    /** @var Wflinks\Helper $helper */
31
    $helper = Wflinks\Helper::getInstance();
32
33
    $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE lid=' . $lid;
34
    if (!$result = $xoopsDB->query($sql)) {
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
35
        /** @var \XoopsLogger $logger */
36
        $logger = \XoopsLogger::getInstance();
37
        $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
38
39
        return false;
40
    }
41
    $link_array = $xoopsDB->fetchArray($xoopsDB->query($sql));
42
43
    $directory    = $helper->getConfig('screenshots');
44
    $lid          = $link_array['lid'] ?: 0;
45
    $cid          = $link_array['cid'] ?: 0;
46
    $title        = $link_array['title'] ? htmlspecialchars($link_array['title']) : '';
47
    $url          = $link_array['url'] ? htmlspecialchars($link_array['url']) : 'http://';
48
    $publisher    = $link_array['publisher'] ? htmlspecialchars($link_array['publisher']) : '';
49
    $submitter    = $link_array['submitter'] ? htmlspecialchars($link_array['submitter']) : '';
50
    $screenshot   = $link_array['screenshot'] ? htmlspecialchars($link_array['screenshot']) : '';
51
    $descriptionb = $link_array['description'] ? htmlspecialchars($link_array['description']) : '';
52
    $published    = $link_array['published'] ?: time();
53
    $expired      = $link_array['expired'] ?: 0;
54
    $updated      = $link_array['updated'] ?: 0;
55
    $offline      = $link_array['offline'] ?: 0;
56
    $forumid      = $link_array['forumid'] ?: 0;
57
    $ipaddress    = $link_array['ipaddress'] ?: 0;
58
    $notifypub    = $link_array['notifypub'] ?: 0;
59
    $country      = $link_array['country'] ? htmlspecialchars($link_array['country']) : '-';
60
    $keywords     = $link_array['keywords'] ? htmlspecialchars($link_array['keywords']) : '';
61
    $item_tag     = $link_array['item_tag'] ? htmlspecialchars($link_array['item_tag']) : '';
0 ignored issues
show
Unused Code introduced by
The assignment to $item_tag is dead and can be removed.
Loading history...
62
    $googlemap    = $link_array['googlemap'] ? htmlspecialchars($link_array['googlemap']) : 'http://maps.google.com';
63
    $yahoomap     = $link_array['yahoomap'] ? htmlspecialchars($link_array['yahoomap']) : 'http://maps.yahoo.com';
64
    $multimap     = $link_array['multimap'] ? htmlspecialchars($link_array['multimap']) : 'http://www.multimap.com';
65
    $street1      = $link_array['street1'] ? htmlspecialchars($link_array['street1']) : '';
66
    $street2      = $link_array['street2'] ? htmlspecialchars($link_array['street2']) : '';
67
    $town         = $link_array['town'] ? htmlspecialchars($link_array['town']) : '';
68
    $state        = $link_array['state'] ? htmlspecialchars($link_array['state']) : '';
69
    $zip          = $link_array['zip'] ? htmlspecialchars($link_array['zip']) : '';
70
    $tel          = $link_array['tel'] ? htmlspecialchars($link_array['tel']) : '';
71
    $mobile       = $link_array['mobile'] ? htmlspecialchars($link_array['mobile']) : '';
72
    $voip         = $link_array['voip'] ? htmlspecialchars($link_array['voip']) : '';
73
    $fax          = $link_array['fax'] ? htmlspecialchars($link_array['fax']) : '';
74
    $email        = $link_array['email'] ? htmlspecialchars($link_array['email']) : '';
75
    $vat          = $link_array['vat'] ? htmlspecialchars($link_array['vat']) : '';
76
77
    require_once __DIR__ . '/admin_header.php';
78
    xoops_cp_header();
79
    xoops_load('XoopsUserUtility');
80
81
    if ($lid > 0) {
82
        $_vote_data = Wflinks\Utility::getVoteDetails($lid);
83
        $text_info  = "<table style='width:100%;'>
84
             <tr>
85
              <td width='33%' valign='top'>
86
               <div><b>" . _AM_WFL_LINK_ID . ' </b>' . $lid . '</div>
87
               <div><b>' . _AM_WFL_MINDEX_SUBMITTED . ': </b>' . formatTimestamp($link_array['date'], $helper->getConfig('dateformat')) . '</div>
88
               <div><b>' . _AM_WFL_LINK_SUBMITTER . ' </b>' . \XoopsUserUtility::getUnameFromId($submitter) . '</div>
89
               <div><b>' . _AM_WFL_LINK_IP . ' </b>' . $ipaddress . '</div>
90
               <div><b>' . _AM_WFL_PAGERANK . ' </b>' . Wflinks\Utility::pagerank($link_array['url']) . '</div>
91
               <div><b>' . _AM_WFL_HITS . ' </b>' . $link_array['hits'] . "</div>
92
93
              </td>
94
              <td valign='top'>
95
               <div><b>" . _AM_WFL_VOTE_TOTALRATE . ': </b>' . Request::getInt('rate', 0, 'vote_data') . '</div>
96
               <div><b>' . _AM_WFL_VOTE_USERAVG . ': </b>' . (int)round($_vote_data['avg_rate'], 2) . '</div>
97
               <div><b>' . _AM_WFL_VOTE_MAXRATE . ': </b>' . Request::getInt('min_rate', 0, 'vote_data') . '</div>
98
               <div><b>' . _AM_WFL_VOTE_MINRATE . ': </b>' . Request::getInt('max_rate', 0, 'vote_data') . "</div>
99
              </td>
100
              <td valign='top'>
101
               <div><b>" . _AM_WFL_VOTE_MOSTVOTEDTITLE . ': </b>' . Request::getInt('max_title', 0, 'vote_data') . '</div>
102
                   <div><b>' . _AM_WFL_VOTE_LEASTVOTEDTITLE . ': </b>' . Request::getInt('min_title', 0, 'vote_data') . '</div>
103
               <div><b>' . _AM_WFL_VOTE_REGISTERED . ': </b>' . ($_vote_data['rate'] - $_vote_data['null_ratinguser']) . '</div>
104
               <div><b>' . _AM_WFL_VOTE_NONREGISTERED . ': </b>' . Request::getInt('null_ratinguser', 0, 'vote_data') . '</div>
105
              </td>
106
             </tr>
107
            </table>';
108
        echo "<fieldset style='border: #e8e8e8 1px solid;'><legend style='display: inline; font-weight: bold; color: #0A3760;'>" . _AM_WFL_INFORMATION . "</legend>\n
109
            <div style='padding: 8px;'>" . $text_info . "</div>\n
110
        <!--    <div style='padding: 8px;'><li>" . $imageArray['deleteimg'] . ' ' . _AM_WFL_VOTE_DELETEDSC . "</li></div>\n  -->
111
            </fieldset>\n
112
            <br>\n";
113
    }
114
    unset($_vote_data);
115
116
    $caption = $lid ? _AM_WFL_LINK_MODIFYFILE : _AM_WFL_LINK_CREATENEWFILE;
117
    $sform   = new \XoopsThemeForm($caption, 'storyform', xoops_getenv('SCRIPT_NAME'), 'post', true);
118
    $sform->setExtra('enctype="multipart / form - data"');
119
120
    if ('' === $submitter) {
121
        $sform->addElement(new \XoopsFormHidden('submitter', $submitter));
122
    }
123
124
    // Link publisher form
125
    if ($publisher) {
126
        $sform->addElement(new \XoopsFormText(_AM_WFL_LINK_PUBLISHER, 'publisher', 70, 255, $publisher));
127
        //$sform -> addElement( new \XoopsFormHidden( 'publisher', $publisher ) ) ;
128
    } else {
129
        $publisher = $xoopsUser->uname();
130
        $sform->addElement(new \XoopsFormHidden('publisher', $publisher));
131
    }
132
133
    // Link title form
134
    $sform->addElement(new \XoopsFormText(_AM_WFL_LINK_TITLE, 'title', 70, 255, $title), true);
135
136
    // Link url form
137
    $url_text = new \XoopsFormText('', 'url', 70, 255, $url);
138
    $url_tray = new \XoopsFormElementTray(_AM_WFL_LINK_DLURL, '');
139
    $url_tray->addElement($url_text, true);
140
    $url_tray->addElement(new \XoopsFormLabel("&nbsp;<img src='../assets/images/icon/world.png' onClick=\"window.open(document.storyform.url.value,'','');return(false);\" alt='Check URL'>"));
141
    $sform->addElement($url_tray);
142
143
    // Category form
144
    ob_start();
145
    $mytree->makeMySelBox('title', 'title', $cid, 0);
146
    $sform->addElement(new \XoopsFormLabel(_AM_WFL_LINK_CATEGORY, ob_get_clean()));
147
148
    // Link description form
149
    //    $editor = Wflinks\Utility::getWysiwygForm( _AM_WFL_LINK_DESCRIPTION, 'descriptionb', $descriptionb, 15, 60 );
150
    //    $sform -> addElement($editor, false);
151
    $optionsTrayNote = new \XoopsFormElementTray(_AM_WFL_LINK_DESCRIPTION, '<br>');
152
    if (class_exists('XoopsFormEditor')) {
153
        $options['name']   = 'descriptionb';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Loading history...
154
        $options['value']  = $descriptionb;
155
        $options['rows']   = 5;
156
        $options['cols']   = '100%';
157
        $options['width']  = '100%';
158
        $options['height'] = '200px';
159
        $descriptionb      = new \XoopsFormEditor('', $helper->getConfig('form_options'), $options, $nohtml = false, $onfailure = 'textarea');
160
        $optionsTrayNote->addElement($descriptionb);
161
    } else {
162
        $descriptionb = new \XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', '100%');
0 ignored issues
show
Bug introduced by
'100%' of type string is incompatible with the type integer expected by parameter $cols of XoopsFormDhtmlTextArea::__construct(). ( Ignorable by Annotation )

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

162
        $descriptionb = new \XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', /** @scrutinizer ignore-type */ '100%');
Loading history...
Bug introduced by
'100%' of type string is incompatible with the type integer expected by parameter $rows of XoopsFormDhtmlTextArea::__construct(). ( Ignorable by Annotation )

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

162
        $descriptionb = new \XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), /** @scrutinizer ignore-type */ '100%', '100%');
Loading history...
Comprehensibility Best Practice introduced by
The variable $item seems to be never defined.
Loading history...
163
        $optionsTrayNote->addElement($descriptionb);
164
    }
165
166
    $sform->addElement($optionsTrayNote, false);
167
168
    // Meta keywords form
169
    $keywords = new \XoopsFormTextArea(_AM_WFL_KEYWORDS, 'keywords', $keywords, 7, 60, false);
0 ignored issues
show
Unused Code introduced by
The call to XoopsFormTextArea::__construct() has too many arguments starting with false. ( Ignorable by Annotation )

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

169
    $keywords = /** @scrutinizer ignore-call */ new \XoopsFormTextArea(_AM_WFL_KEYWORDS, 'keywords', $keywords, 7, 60, false);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
170
    $keywords->setDescription('<small>' . _AM_WFL_KEYWORDS_NOTE . '</small>');
171
    $sform->addElement($keywords);
172
173
    // Insert tags if Tag-module is installed
174
    if (Wflinks\Utility::isTagModuleIncluded()) {
175
        require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php';
176
        $text_tags = new FormTag('item_tag', 70, 255, $link_array['item_tag'], 0);
177
        $sform->addElement($text_tags);
178
    } else {
179
        $sform->addElement(new \XoopsFormHidden('item_tag', $link_array['item_tag']));
180
    }
181
182
    // Screenshot
183
    $graph_array       = Wflinks\Lists::getListTypeAsArray(XOOPS_ROOT_PATH . '/' . $helper->getConfig('screenshots'), $type = 'images');
184
    $indeximage_select = new \XoopsFormSelect('', 'screenshot', $screenshot);
185
    $indeximage_select->addOptionArray($graph_array);
186
    $indeximage_select->setExtra("onchange = 'showImgSelected(\"image\", \"screenshot\", \"" . $helper->getConfig('screenshots') . '", "", "' . XOOPS_URL . "\")'");
187
    $indeximage_tray = new \XoopsFormElementTray(_AM_WFL_LINK_SHOTIMAGE, '&nbsp;');
188
    $indeximage_tray->setDescription(sprintf(_AM_WFL_LINK_MUSTBEVALID, '<b>' . $directory . '</b>'));
189
    $indeximage_tray->addElement($indeximage_select);
190
    if (!empty($imgurl)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $imgurl seems to never exist and therefore empty should always be true.
Loading history...
191
        $indeximage_tray->addElement(new \XoopsFormLabel('', " <br><br>< img src='" . XOOPS_URL . '/' . $helper->getConfig('screenshots') . '/' . $screenshot . "' name = 'image' id = 'image' alt = '' / > "));
192
    } else {
193
        $indeximage_tray->addElement(new \XoopsFormLabel('', " <br><br><img src='" . XOOPS_URL . "/uploads/blank.gif' name='image' id='image' alt='' / > "));
194
    }
195
    $sform->addElement($indeximage_tray);
196
197
    if ($helper->getConfig('useaddress')) {
198
        $sform->insertBreak(_AM_WFL_LINK_CREATEADDRESS, 'bg3');
199
        // Google Maps
200
        $googlemap_text = new \XoopsFormText('', 'googlemap', 70, 1024, $googlemap);
201
        $googlemap_tray = new \XoopsFormElementTray(_AM_WFL_LINK_GOOGLEMAP, '');
202
        $googlemap_tray->addElement($googlemap_text, false);
203
        $googlemap_tray->addElement(new \XoopsFormLabel("&nbsp;<img src='../assets/images/icon/google_map.png' onClick=\"window.open(document.storyform.googlemap.value,'','');return(false);\" alt='" . _AM_WFL_LINK_CHECKMAP . "'>"));
204
        $sform->addElement($googlemap_tray);
205
        // Yahoo Maps
206
        $yahoomap_text = new \XoopsFormText('', 'yahoomap', 70, 1024, $yahoomap);
207
        $yahoomap_tray = new \XoopsFormElementTray(_AM_WFL_LINK_YAHOOMAP, '');
208
        $yahoomap_tray->addElement($yahoomap_text, false);
209
        $yahoomap_tray->addElement(new \XoopsFormLabel("&nbsp;<img src='../assets/images/icon/yahoo_map.png' onClick=\"window.open(document.storyform.yahoomap.value,'','');return(false);\" alt='" . _AM_WFL_LINK_CHECKMAP . "'>"));
210
        $sform->addElement($yahoomap_tray);
211
        // MS Live Maps
212
        $multimap_text = new \XoopsFormText('', 'multimap', 70, 1024, $multimap);
213
        $multimap_tray = new \XoopsFormElementTray(_AM_WFL_LINK_MULTIMAP, '');
214
        $multimap_tray->addElement($multimap_text, false);
215
        $multimap_tray->addElement(new \XoopsFormLabel("&nbsp;<img src='../assets/images/icon/multimap.png' onClick=\"window.open(document.storyform.multimap.value,'','');return(false);\" alt='" . _AM_WFL_LINK_CHECKMAP . "'>"));
216
        $sform->addElement($multimap_tray);
217
218
        // Address
219
        $street1 = new \XoopsFormText(_AM_WFL_STREET1, 'street1', 70, 255, $street1);
220
        $sform->addElement($street1, false);
221
        $street2 = new \XoopsFormText(_AM_WFL_STREET2, 'street2', 70, 255, $street2);
222
        $sform->addElement($street2, false);
223
        $town = new \XoopsFormText(_AM_WFL_TOWN, 'town', 70, 255, $town);
224
        $sform->addElement($town, false);
225
        $state = new \XoopsFormText(_AM_WFL_STATE, 'state', 70, 255, $state);
226
        $sform->addElement($state, false);
227
        $zip = new \XoopsFormText(_AM_WFL_ZIPCODE, 'zip', 25, 25, $zip);
228
        $sform->addElement($zip, false);
229
        $tel = new \XoopsFormText(_AM_WFL_TELEPHONE, 'tel', 25, 25, $tel);
230
        $sform->addElement($tel, false);
231
        $mobile = new \XoopsFormText(_AM_WFL_MOBILE, 'mobile', 25, 25, $mobile);
232
        $sform->addElement($mobile, false);
233
        $voip = new \XoopsFormText(_AM_WFL_VOIP, 'voip', 25, 25, $voip);
234
        $sform->addElement($voip, false);
235
        $fax = new \XoopsFormText(_AM_WFL_FAX, 'fax', 25, 25, $fax);
236
        $sform->addElement($fax, false);
237
        $email = new \XoopsFormText(_AM_WFL_EMAIL, 'email', 25, 60, $email);
238
        $sform->addElement($email, false);
239
        $vat = new \XoopsFormText(_AM_WFL_VAT, 'vat', 25, 25, $vat);
240
        $vat->setDescription(_AM_WFL_VATWIKI);
241
        $sform->addElement($vat, false);
242
        //  $sform -> addElement( new \XoopsFormHidden( 'vat', $link_array['vat'] ) ); /* If you don't want to use the VAT form,  */
243
        /* use this line and comment-out the 3 lines above  */
244
    }
245
246
    // Country form
247
    $country_select = new \XoopsFormSelectCountry(_AM_WFL_COUNTRY, 'country', $country);
248
    $sform->addElement($country_select, false);
249
250
    // Miscellaneous Link settings
251
    $sform->insertBreak(_AM_WFL_LINK_MISCLINKSETTINGS, 'bg3');
252
253
    // Set Publish date
254
    $sform->addElement(new \XoopsFormDateTime(_AM_WFL_LINK_SETPUBLISHDATE, 'was_published', $size = 15, $published));
255
256
    if ($lid) {
257
        $sform->addElement(new \XoopsFormHidden('was_published', $published));
258
        $sform->addElement(new \XoopsFormHidden('was_expired', $expired));
259
    }
260
261
    // Set Expire date
262
    $isexpired           = ($expired > time()) ? 1 : 0;
263
    $expiredates         = ($expired > time()) ? _AM_WFL_LINK_EXPIREDATESET . formatTimestamp($expired, $helper->getConfig('dateformat')) : _AM_WFL_LINK_SETDATETIMEEXPIRE;
264
    $warning             = ($published > $expired && $expired > time()) ? _AM_WFL_LINK_EXPIREWARNING : '';
265
    $expiredate_checkbox = new \XoopsFormCheckBox('', 'expiredateactivate', $isexpired);
266
    $expiredate_checkbox->addOption(1, $expiredates . ' <br> <br> ');
267
268
    $expiredate_tray = new \XoopsFormElementTray(_AM_WFL_LINK_EXPIREDATE . $warning, '');
269
    $expiredate_tray->addElement($expiredate_checkbox);
270
    $expiredate_tray->addElement(new \XoopsFormDateTime(_AM_WFL_LINK_SETEXPIREDATE . ' <br> ', 'expired', 15, $expired));
271
    $expiredate_tray->addElement(new \XoopsFormRadioYN(_AM_WFL_LINK_CLEAREXPIREDATE, 'clearexpire', 0, ' ' . _YES . '', ' ' . _NO . ''));
272
    $sform->addElement($expiredate_tray);
273
274
    // Set Link offline
275
    $linkstatus_radio = new \XoopsFormRadioYN(_AM_WFL_LINK_FILESSTATUS, 'offline', $offline, ' ' . _YES . '', ' ' . _NO . '');
276
    $sform->addElement($linkstatus_radio);
277
278
    // Set Link updated
279
    $up_dated           = (0 == $updated) ? 0 : 1;
280
    $link_updated_radio = new \XoopsFormRadioYN(_AM_WFL_LINK_SETASUPDATED, 'up_dated', $up_dated, ' ' . _YES . '', ' ' . _NO . '');
281
    $sform->addElement($link_updated_radio);
282
283
    $result = $xoopsDB->query('SELECT COUNT( * ) FROM ' . $xoopsDB->prefix('wflinks_broken') . ' WHERE lid = ' . $lid);
284
    list($broken_count) = $xoopsDB->fetchRow($result);
285
    if ($broken_count > 0) {
286
        $link_updated_radio = new \XoopsFormRadioYN(_AM_WFL_LINK_DELEDITMESS, 'delbroken', 1, ' ' . _YES . '', ' ' . _NO . '');
287
        $sform->addElement($link_updated_radio);
288
    }
289
290
    // Select forum
291
    ob_start();
292
    Wflinks\Lists::getForum($helper->getConfig('selectforum'), $forumid);
293
    $sform->addElement(new \XoopsFormLabel(_AM_WFL_LINK_DISCUSSINFORUM, ob_get_clean()));
294
295
    //Create News Story
296
    if (Wflinks\Utility::isNewsModuleIncluded()) {
297
        $sform->insertBreak(_AM_WFL_LINK_CREATENEWSSTORY, 'bg3');
298
        $submitNews_radio = new \XoopsFormRadioYN(_AM_WFL_LINK_SUBMITNEWS, 'submitnews', 0, ' ' . _YES . '', ' ' . _NO . '');
299
        $sform->addElement($submitNews_radio);
300
301
        require_once XOOPS_ROOT_PATH . '/class/xoopstopic.php';
302
        $xt = new \XoopsTopic($xoopsDB->prefix('news_topics'));
303
        ob_start();
304
        $xt->makeTopicSelBox(1, 0, 'newstopicid');
305
        $sform->addElement(new \XoopsFormLabel(_AM_WFL_LINK_NEWSCATEGORY, ob_get_clean()));
306
        $sform->addElement(new \XoopsFormText(_AM_WFL_LINK_NEWSTITLE, 'topic_id', 70, 255, ''), false);
307
    }
308
309
    if ($lid && 0 == $published) {
310
        $approved         = (0 == $published) ? 0 : 1;
0 ignored issues
show
Unused Code introduced by
The assignment to $approved is dead and can be removed.
Loading history...
311
        $approve_checkbox = new \XoopsFormCheckBox(_AM_WFL_LINK_EDITAPPROVE, 'approved', 1);
312
        $approve_checkbox->addOption(1, ' ');
313
        $sform->addElement($approve_checkbox);
314
    }
315
316
    if ($lid) {
317
        $buttonTray = new \XoopsFormElementTray('', '');
318
        $buttonTray->addElement(new \XoopsFormHidden('lid', $lid));
319
        $buttonTray->addElement(new \XoopsFormHidden('status', 2));
320
        $hidden = new \XoopsFormHidden('op', 'save');
321
        $buttonTray->addElement($hidden);
322
323
        $butt_dup = new \XoopsFormButton('', '', _AM_WFL_BMODIFY, 'submit');
324
        $butt_dup->setExtra('onclick="this . form . elements . op . value = \'save\'"');
325
        $buttonTray->addElement($butt_dup);
326
        $butt_dupct = new \XoopsFormButton('', '', _AM_WFL_BDELETE, 'submit');
327
        $butt_dupct->setExtra('onclick="this.form.elements.op.value=\'delete\'"');
328
        $buttonTray->addElement($butt_dupct);
329
        $butt_dupct2 = new \XoopsFormButton('', '', _AM_WFL_BCANCEL, 'submit');
330
        $butt_dupct2->setExtra('onclick="this.form.elements.op.value=\'linksConfigMenu\'"');
331
        $buttonTray->addElement($butt_dupct2);
332
        $sform->addElement($buttonTray);
333
    } else {
334
        $buttonTray = new \XoopsFormElementTray('', '');
335
        $buttonTray->addElement(new \XoopsFormHidden('status', 1));
336
        $buttonTray->addElement(new \XoopsFormHidden('notifypub', $notifypub));
337
        $buttonTray->addElement(new \XoopsFormHidden('op', 'save'));
338
        $buttonTray->addElement(new \XoopsFormButton('', '', _AM_WFL_BSAVE, 'submit'));
339
        $sform->addElement($buttonTray);
340
    }
341
    $sform->display();
342
    unset($hidden);
343
    require_once __DIR__ . '/admin_footer.php';
344
345
    return null;
346
}
347
348
/**
349
 * @param     $url
350
 * @param int $timeout
351
 *
352
 * @return float|null|string
353
 */
354
function fetchURL($url, $timeout = 2)
355
{
356
    /** @var Wflinks\Helper $helper */
357
    $helper     = Wflinks\Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
358
    $url        = urldecode($url);
359
    $url_parsed = parse_url($url);
360
    if (!isset($url_parsed['host'])) {
361
        return '';
362
    }
363
364
    $host = $url_parsed['host'];
365
    $host = preg_replace('#http://#', '', $host);
366
    $port = $url_parsed['port'] ?? 80;
367
    // Open the socket
368
    $handle = @fsockopen('http://' . $host, $port, $errno, $errstr, $timeout);
369
    if (!$handle) {
0 ignored issues
show
introduced by
$handle is of type false|resource, thus it always evaluated to false.
Loading history...
370
        return null;
371
    }
372
373
    // Set read timeout
374
    stream_set_timeout($handle, $timeout);
375
    for ($i = 0; $i < 1; ++$i) {
0 ignored issues
show
Unused Code introduced by
++$i is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
376
        // Time the responce
377
        list($usec, $sec) = explode(' ', microtime(true));
378
        $start = (float)$usec + (float)$sec;
379
        // send somthing
380
        $write = fwrite($handle, "return ping\n");
381
        if (!$write) {
382
            return '';
383
        }
384
        fread($handle, 1024);
385
        // Work out if we got a responce and time it
386
        list($usec, $sec) = explode(' ', microtime(true));
387
        $laptime = ((float)$usec + (float)$sec) - $start;
388
        if ($laptime > $timeout) {
389
            return 'No Reply';
390
        }
391
392
        return round($laptime, 3);
393
    }
394
    fclose($handle);
395
396
    return null;
397
}
398
399
switch (mb_strtolower($op)) {
400
    case 'pingtime':
401
    case 'is_broken':
402
403
        $_type = ('pingtime' === $op) ? 'is_broken' : 'pingtime';
404
405
        $start = Wflinks\Utility::cleanRequestVars($_REQUEST, 'start', 0);
406
        $ping  = Wflinks\Utility::cleanRequestVars($_REQUEST, 'ping', 0);
407
        $cid   = Wflinks\Utility::cleanRequestVars($_REQUEST, 'cid', 0);
408
409
        $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links');
410
        if ($cid > 0) {
411
            $sql .= ' WHERE cid=' . $cid;
412
        }
413
        $sql .= ' ORDER BY lid DESC';
414
        if (!$result = $xoopsDB->query($sql)) {
415
            /** @var \XoopsLogger $logger */
416
            $logger = \XoopsLogger::getInstance();
417
            $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
418
419
            return false;
420
        }
421
        $broken_array       = $xoopsDB->query($sql, $helper->getConfig('admin_perpage'), $start);
422
        $broken_array_count = $xoopsDB->getRowsNum($result);
423
424
        $heading = ('pingtime' === $op) ? _AM_WFL_PINGTIMES : _AM_WFL_LISTBROKEN;
425
426
        require_once __DIR__ . '/admin_header.php';
427
        xoops_cp_header();
428
429
        echo "
430
            <table width='100%' cellspacing='1' cellpadding='2' border='0' class='outer'>\n
431
            <tr>\n
432
            <th class='txtcenter;'>" . _AM_WFL_MINDEX_ID . "</th>\n
433
            <th style='text-align: left;'>" . _AM_WFL_MINDEX_TITLE . "</th>\n
434
            <th class='txtcenter;'>" . _AM_WFL_MINDEX_POSTER . "</th>\n
435
            <th class='txtcenter;'>" . _AM_WFL_MINDEX_PUBLISHED . "</th>\n
436
                    <th class='txtcenter;'>" . _AM_WFL_MINDEX_RESPONSE . "</th>\n
437
                        <th class='txtcenter;'>PR</th>\n
438
                    <th class='txtcenter;'>" . _AM_WFL_MINDEX_ACTION . "</th>\n
439
            </tr>\n
440
        ";
441
442
        if ($broken_array_count > 0) {
443
            while (false !== ($published = $xoopsDB->fetchArray($broken_array))) {
444
                $_ping_results = fetchURL($published['url']);
445
446
                if ($_ping_results) {
447
                    $_ping_results .= '(s)';
448
                } else {
449
                    $_ping_results = _AM_WFL_LINK_NORESPONSE;
450
                }
451
452
                $lid   = $published['lid'];
453
                $cid   = $published['cid'];
454
                $title = "<a href='../singlelink.php?cid=" . $published['cid'] . '&amp;lid=' . $published['lid'] . "'>" . htmlspecialchars(trim($published['title'])) . '</a>';
455
456
                $maintitle = urlencode(htmlspecialchars(trim($published['title'])));
457
                $submitter = \XoopsUserUtility::getUnameFromId($published['submitter']);
458
                $publish   = formatTimestamp($published['published'], $helper->getConfig('dateformatadmin'));
459
                $status    = ($published['published'] > 0) ? $imageArray['online'] : "<a href='newlinks.php'>" . $imageArray['offline'] . '</a>';
460
                $icon      = "<a href='main.php?op=edit&amp;lid=" . $lid . "'>" . $imageArray['editimg'] . '</a>&nbsp;';
461
                $icon      .= "<a href='main.php?op=delete&amp;lid=" . $lid . "'>" . $imageArray['deleteimg'] . '</a>';
462
                echo "<tr class='txtcenter;'>\n
463
                        <td class='head'><small>" . $lid . "</small></td>\n
464
                        <td class='even' style='text-align: left;'><small>" . $title . "</small></td>\n
465
                        <td class='even'><small>" . $submitter . "</small></td>\n
466
                        <td class='even'><small>" . $publish . "</small></td>\n
467
                        <td class='even'><small>" . $_ping_results . "</small></td>\n
468
                        <td class='even'><small>" . Wflinks\Utility::pagerank($published['url']) . "</small></td>\n
469
                        <td class='even'>$icon</td>\n
470
                        </tr>\n";
471
                unset($published);
472
            }
473
        } else {
474
            Wflinks\Utility::getLinkListFooter();
475
        }
476
        Wflinks\Utility::getLinkListPageNav($broken_array_count, $start, 'art', 'op=' . $op);
477
        require_once __DIR__ . '/admin_footer.php';
478
        break;
479
    case 'edit':
480
        edit($lid);
481
        break;
482
    case 'save':
483
        $groups    = $_POST['groups'] ?? [];
484
        $lid       = !empty($_POST['lid']) ? $_POST['lid'] : 0;
485
        $cid       = !empty($_POST['cid']) ? $_POST['cid'] : 0;
486
        $urlrating = !empty($_POST['urlrating']) ? $_POST['urlrating'] : 6;
487
        $status    = !empty($_POST['status']) ? $_POST['status'] : 2;
488
        $url       = ('http://' !== $_POST['url']) ? $myts->addSlashes($_POST['url']) : '';
489
        $title     = $myts->addSlashes(trim($_POST['title']));
490
491
        // Get data from form
492
        $screenshot   = ('blank.gif' !== $_POST['screenshot']) ? $myts->addSlashes($_POST['screenshot']) : '';
493
        $descriptionb = $myts->addSlashes(trim($_POST['descriptionb']));
494
        $country      = $myts->addSlashes(trim($_POST['country']));
495
        $keywords     = $myts->addSlashes(trim(mb_substr($_POST['keywords'], 0, $helper->getConfig('keywordlength'))));
496
        $item_tag     = $myts->addSlashes(trim($_POST['item_tag']));
497
        $forumid      = (isset($_POST['forumid']) && $_POST['forumid'] > 0) ? Request::getInt('forumid', 0, 'POST') : 0;
498
        if ($helper->getConfig('useaddress')) {
499
            $googlemap = ('http://maps.google.com' !== $_POST['googlemap']) ? $myts->addSlashes($_POST['googlemap']) : '';
500
            $yahoomap  = ('http://maps.yahoo.com' !== $_POST['yahoomap']) ? $myts->addSlashes($_POST['yahoomap']) : '';
501
            $multimap  = ('http://www.multimap.com' !== $_POST['multimap']) ? $myts->addSlashes($_POST['multimap']) : '';
502
            $street1   = $myts->addSlashes(trim($_POST['street1']));
503
            $street2   = $myts->addSlashes(trim($_POST['street2']));
504
            $town      = $myts->addSlashes(trim($_POST['town']));
505
            $state     = $myts->addSlashes(trim($_POST['state']));
506
            $zip       = $myts->addSlashes(trim($_POST['zip']));
507
            $tel       = $myts->addSlashes(trim($_POST['tel']));
508
            $fax       = $myts->addSlashes(trim($_POST['fax']));
509
            $voip      = $myts->addSlashes(trim($_POST['voip']));
510
            $mobile    = $myts->addSlashes(trim($_POST['mobile']));
511
            $email     = Wflinks\Utility::convertEmail($myts->addSlashes(trim($_POST['email'])));
512
            $vat       = $myts->addSlashes(trim($_POST['vat']));
513
        } else {
514
            $googlemap = $yahoomap = $multimap = $street1 = $street2 = $town = $state = $zip = $tel = $fax = $voip = $mobile = $email = $vat = '';
515
        }
516
517
        $submitter = $xoopsUser->uid();
518
        $publisher = $myts->addSlashes(trim($_POST['publisher']));
519
520
        $published = strtotime($_POST['published']['date']) + $_POST['published']['time'];
521
        $updated   = (isset($_POST['was_published']) && 0 == $_POST['was_published']) ? 0 : time();
522
        if (0 == $_POST['up_dated']) {
523
            $updated = 0;
524
            $status  = 1;
525
        }
526
        $offline   = (1 == $_POST['offline']) ? 1 : 0;
527
        $approved  = (isset($_POST['approved']) && 1 == $_POST['approved']) ? 1 : 0;
528
        $notifypub = (isset($_POST['notifypub']) && 1 == $_POST['notifypub']);
529
        if ($lid) {
530
            $publishdate = $_POST['was_published'];
531
            $expiredate  = $_POST['was_expired'];
532
        } else {
533
            $date        = time();
534
            $publishdate = time();
535
            $expiredate  = '0';
536
        }
537
        if (1 == $approved && empty($publishdate)) {
538
            $publishdate = time();
539
        }
540
        if (Request::hasVar('expiredateactivate', 'POST')) {
541
            $expiredate = strtotime($_POST['expired']['date']) + $_POST['expired']['time'];
542
        }
543
        if ($_POST['clearexpire']) {
544
            $expiredate = '0';
545
        }
546
547
        // Update or insert linkload data into database
548
        if ($lid) {
549
            $sql = 'UPDATE '
550
                   . $xoopsDB->prefix('wflinks_links')
551
                   . " SET cid = $cid, title='$title', url='$url', screenshot='$screenshot', publisher='$publisher', status='$status', forumid='$forumid', published='$published', expired='$expiredate', updated='$updated', offline='$offline', description='$descriptionb', urlrating='$urlrating', country='$country', keywords='$keywords', item_tag='$item_tag', googlemap='$googlemap', yahoomap='$yahoomap', multimap='$multimap', street1='$street1', street2='$street2', town='$town', state='$state',  zip='$zip', tel='$tel', fax='$fax', voip='$voip', mobile='$mobile', email='$email', vat='$vat' WHERE lid="
552
                   . $lid;
553
        } else {
554
            $date        = time();
555
            $publishdate = time();
556
            $ipaddress   = $_SERVER['REMOTE_ADDR'];
557
            $sql         = 'INSERT INTO '
558
                           . $xoopsDB->prefix('wflinks_links')
559
                           . ' (lid, cid, title, url, screenshot, submitter, publisher, status, date, hits, rating, votes, comments, forumid, published, expired, updated, offline, description, ipaddress, notifypub, urlrating, country, keywords, item_tag, googlemap, yahoomap, multimap, street1, street2, town, state, zip, tel, fax, voip, mobile, email, vat )';
560
            $sql         .= " VALUES    (0, $cid, '$title', '$url', '$screenshot', '$submitter', '$publisher','$status', '$date', 0, 0, 0, 0, '$forumid', '$published', '$expiredate', '$updated', '$offline', '$descriptionb', '$ipaddress', '0', '$urlrating', '$country', '$keywords', '$item_tag', '$googlemap', '$yahoomap', '$multimap', '$street1', '$street2', '$town', '$state', '$zip', '$tel', '$fax', '$voip', '$mobile', '$email', '$vat' )";
561
            // $newid = $xoopsDB -> getInsertId();
562
        }
563
        if (!$result = $xoopsDB->queryF($sql)) {
564
            $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
565
566
            return false;
567
        }
568
569
        $newid = $GLOBALS['xoopsDB']->getInsertId();
570
571
        // Add item_tag to Tag-module
572
        if ($lid) {
573
            $tagupdate = Wflinks\Utility::updateTag($lid, $item_tag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $tagupdate is correct as XoopsModules\Wflinks\Uti...ateTag($lid, $item_tag) targeting XoopsModules\Wflinks\Utility::updateTag() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
574
        } else {
575
            $tagupdate = Wflinks\Utility::updateTag($newid, $item_tag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $tagupdate is correct as XoopsModules\Wflinks\Uti...eTag($newid, $item_tag) targeting XoopsModules\Wflinks\Utility::updateTag() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
576
        }
577
578
        // Send notifications
579
        if (!$lid) {
580
            $tags                  = [];
581
            $tags['LINK_NAME']     = $title;
582
            $tags['LINK_URL']      = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $cid . '&amp;lid=' . $newid;
583
            $sql                   = 'SELECT title FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid=' . $cid;
584
            $result                = $xoopsDB->query($sql);
585
            $row                   = $xoopsDB->fetchArray($xoopsDB->query($sql));
586
            $tags['CATEGORY_NAME'] = $row['title'];
587
            $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
588
            $notificationHandler   = xoops_getHandler('notification');
589
            $notificationHandler->triggerEvent('global', 0, 'new_link', $tags);
0 ignored issues
show
Bug introduced by
The method triggerEvent() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsNotificationHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

589
            $notificationHandler->/** @scrutinizer ignore-call */ 
590
                                  triggerEvent('global', 0, 'new_link', $tags);
Loading history...
590
            $notificationHandler->triggerEvent('category', $cid, 'new_link', $tags);
591
        }
592
        if ($lid && $approved && $notifypub) {
593
            $tags                  = [];
594
            $tags['LINK_NAME']     = $title;
595
            $tags['LINK_URL']      = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $cid . '&amp;lid=' . $lid;
596
            $sql                   = 'SELECT title FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid=' . $cid;
597
            $result                = $xoopsDB->query($sql);
598
            $row                   = $xoopsDB->fetchArray($result);
599
            $tags['CATEGORY_NAME'] = $row['title'];
600
            $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
601
            $notificationHandler   = xoops_getHandler('notification');
602
            $notificationHandler->triggerEvent('global', 0, 'new_link', $tags);
603
            $notificationHandler->triggerEvent('category', $cid, 'new_link', $tags);
604
            $notificationHandler->triggerEvent('link', $lid, 'approve', $tags);
605
        }
606
        $message = (!$lid) ? _AM_WFL_LINK_NEWFILEUPLOAD : _AM_WFL_LINK_FILEMODIFIEDUPDATE;
607
        $message = ($lid && !$_POST['was_published'] && $approved) ? _AM_WFL_LINK_FILEAPPROVED : $message;
608
        if (Wflinks\Utility::cleanRequestVars($_REQUEST, 'delbroken', 0)) {
609
            $sql = 'DELETE FROM ' . $xoopsDB->prefix('wflinks_broken') . ' WHERE lid=' . $lid;
610
            if (!$result = $xoopsDB->queryF($sql)) {
611
                $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
612
613
                return false;
614
            }
615
        }
616
        if (Wflinks\Utility::cleanRequestVars($_REQUEST, 'submitnews', 0)) {
617
            require_once __DIR__ . '/newstory.php';
618
        }
619
        redirect_header('main.php', 1, $message);
620
        break;
621
    case 'delete':
622
        if (Wflinks\Utility::cleanRequestVars($_REQUEST, 'confirm', 0)) {
623
            $title = Wflinks\Utility::cleanRequestVars($_REQUEST, 'title', 0);
624
            /** @var \XoopsLogger $logger */
625
            $logger = \XoopsLogger::getInstance();
626
627
            // delete link
628
            $sql = 'DELETE FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE lid=' . $lid;
629
            if (!$result = $xoopsDB->query($sql)) {
630
                $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
631
632
                return false;
633
            }
634
635
            // delete from altcat
636
            $sql = 'DELETE FROM ' . $xoopsDB->prefix('wflinks_altcat') . ' WHERE lid=' . $lid;
637
            if (!$result = $xoopsDB->query($sql)) {
638
                $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
639
640
                return false;
641
            }
642
643
            // delete vote data
644
            $sql = 'DELETE FROM ' . $xoopsDB->prefix('wflinks_votedata') . ' WHERE lid=' . $lid;
645
            if (!$result = $xoopsDB->query($sql)) {
646
                $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
647
648
                return false;
649
            }
650
651
            // delete comments
652
            xoops_comment_delete($xoopsModule->getVar('mid'), $lid);
653
            redirect_header('main.php', 1, sprintf(_AM_WFL_LINK_FILEWASDELETED, $title));
654
        } else {
655
            $sql = 'SELECT lid, title, item_tag, url FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE lid=' . $lid;
656
            if (!$result = $xoopsDB->query($sql)) {
657
                $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
658
659
                return false;
660
            }
661
            list($lid, $title) = $xoopsDB->fetchRow($result);
662
            $item_tag = $result->fetchArray['item_tag'];
663
            require_once __DIR__ . '/admin_header.php';
664
            xoops_cp_header();
665
666
            xoops_confirm(['op' => 'delete', 'lid' => $lid, 'confirm' => 1, 'title' => $title], 'main.php', _AM_WFL_LINK_REALLYDELETEDTHIS . '<br><br>' . $title, _DELETE);
667
668
            // Remove item_tag from Tag-module
669
            $tagupdate = Wflinks\Utility::updateTag($lid, $item_tag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $tagupdate is correct as XoopsModules\Wflinks\Uti...ateTag($lid, $item_tag) targeting XoopsModules\Wflinks\Utility::updateTag() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
670
671
            require_once __DIR__ . '/admin_footer.php';
672
        }
673
        break;
674
    case 'delvote':
675
        $rid = Wflinks\Utility::cleanRequestVars($_REQUEST, 'rid', 0);
676
        $sql = 'DELETE FROM ' . $xoopsDB->prefix('wflinks_votedata') . ' WHERE ratingid=' . $rid;
677
        if (!$result = $xoopsDB->queryF($sql)) {
678
            $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
679
680
            return false;
681
        }
682
        Wflinks\Utility::updateRating($rid);
683
        redirect_header('main.php', 1, _AM_WFL_VOTE_VOTEDELETED);
684
        break;
685
    case 'main':
686
    default:
687
        $start     = Wflinks\Utility::cleanRequestVars($_REQUEST, 'start', 0);
688
        $start1    = Wflinks\Utility::cleanRequestVars($_REQUEST, 'start1', 0);
689
        $start2    = Wflinks\Utility::cleanRequestVars($_REQUEST, 'start2', 0);
690
        $start3    = Wflinks\Utility::cleanRequestVars($_REQUEST, 'start3', 0);
691
        $start4    = Wflinks\Utility::cleanRequestVars($_REQUEST, 'start4', 0);
692
        $totalcats = Wflinks\Utility::getTotalCategory();
693
694
        $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_broken'));
695
        list($totalbrokenlinks) = $xoopsDB->fetchRow($result);
0 ignored issues
show
Comprehensibility Best Practice introduced by
This list assign is not used and could be removed.
Loading history...
696
        $result2 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_mod'));
697
        list($totalmodrequests) = $xoopsDB->fetchRow($result2);
0 ignored issues
show
Comprehensibility Best Practice introduced by
This list assign is not used and could be removed.
Loading history...
698
        $result3 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published = 0');
699
        list($totalnewlinks) = $xoopsDB->fetchRow($result3);
0 ignored issues
show
Comprehensibility Best Practice introduced by
This list assign is not used and could be removed.
Loading history...
700
        $result4 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0');
701
        list($totallinks) = $xoopsDB->fetchRow($result4);
702
703
        xoops_cp_header();
704
705
        $adminObject = Admin::getInstance();
706
        $adminObject->displayNavigation(basename(__FILE__));
707
        $adminObject->addItemButton(_MI_WFL_ADD_LINK, 'main.php?op=edit', 'add', '');
708
        $adminObject->addItemButton(_MI_WFL_ADD_CATEGORY, 'category.php', 'add', '');
709
        $adminObject->displayButton('left', '');
710
711
        //        echo "
712
        //          <fieldset style='border: #e8e8e8 1px solid;'><legend style='display: inline; font-weight: bold; color: #0A3760;'>" . _AM_WFL_MINDEX_LINKSUMMARY . "</legend>\n
713
        //          <div style='padding: 8px;'><small>\n
714
        //          <a href='category.php'>" . _AM_WFL_SCATEGORY . "</a><b>" . $totalcats . "</b> | \n
715
        //          <a href='main.php'>" . _AM_WFL_SFILES . "</a><b>" . $totallinks . "</b> | \n
716
        //          <a href='newlinks.php'>" . _AM_WFL_SNEWFILESVAL . "</a><b>" . $totalnewlinks . "</b> | \n
717
        //          <a href='modifications.php'>" . _AM_WFL_SMODREQUEST . "</a><b>" . $totalmodrequests . "</b> | \n
718
        //          <a href='brokenlink.php'>" . _AM_WFL_SBROKENSUBMIT . "</a><b>" . $totalbrokenlinks . "</b>\n
719
        //          </small></div></fieldset><br>\n
720
        //      ";
721
722
        //        if ($totalcats > 0) {
723
        //            $sform = new \XoopsThemeForm( _AM_WFL_CCATEGORY_MODIFY, "category", "category.php" );
724
        //            ob_start();
725
        //            $mytree -> makeMySelBox( "title", "title" );
726
        //            $sform -> addElement( new \XoopsFormLabel( _AM_WFL_CCATEGORY_MODIFY_TITLE, ob_get_contents() ) );
727
        //            ob_end_clean();
728
        //            $dup_tray = new \XoopsFormElementTray( '', '' );
729
        //            $dup_tray -> addElement( new \XoopsFormHidden( 'op', 'modCat' ) );
730
        //            $butt_dup = new \XoopsFormButton( '', '', _AM_WFL_BMODIFY, 'submit' );
731
        //            $butt_dup -> setExtra( 'onclick="this.form.elements.op.value=\'modCat\'"' );
732
        //            $dup_tray -> addElement( $butt_dup );
733
        //            $butt_dupct = new \XoopsFormButton( '', '', _AM_WFL_BDELETE, 'submit' );
734
        //            $butt_dupct -> setExtra( 'onclick="this.form.elements.op.value=\'del\'"' );
735
        //            $dup_tray -> addElement( $butt_dupct );
736
        //            $sform -> addElement( $dup_tray );
737
        //            $sform -> display();
738
        //        }
739
740
        if ($totallinks > 0) {
741
            $sql                   = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0  ORDER BY lid DESC';
742
            $published_array       = $xoopsDB->query($sql, $helper->getConfig('admin_perpage'), $start);
743
            $published_array_count = $xoopsDB->getRowsNum($xoopsDB->query($sql));
744
            Wflinks\Utility::getLinkListHeader(_AM_WFL_MINDEX_PUBLISHEDLINK);
745
            Wflinks\Utility::getLinkListPageNavLeft($published_array_count, $start, 'art');
746
            if ($published_array_count > 0) {
747
                while (false !== ($published = $xoopsDB->fetchArray($published_array))) {
748
                    Wflinks\Utility::getLinkListBody($published);
749
                }
750
            } else {
751
                Wflinks\Utility::getLinkListFooter();
752
            }
753
            Wflinks\Utility::getLinkListPageNav($published_array_count, $start, 'art');
754
        }
755
        require_once __DIR__ . '/admin_footer.php';
756
        break;
757
}
758