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

extractFragments()   A

Complexity

Conditions 4

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 4
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       mylinks
16
 * @since
17
 * @author        XOOPS Development Team
18
 * @author        Thatware - http://thatware.org/
19
 */
20
21
//use GorHill\FineDiff\FineDiff;
22
//use GorHill\FineDiff\FineDiffHTML;
23
//use Horde\Diff;
24
use XoopsModules\Mylinks;
25
use XoopsModules\Mylinks\Utility;
26
27
require_once __DIR__ . '/admin_header.php';
28
29
xoops_loadLanguage('main', $xoopsModule->getVar('dirname'));
30
// require_once  dirname(__DIR__) . '/class/Utility.php';
31
//xoops_load('utility', $xoopsModule->getVar('dirname'));
32
33
require_once XOOPS_ROOT_PATH . '/class/tree.php';
34
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
35
require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php';
36
//require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php';
37
38
/** @var \XoopsModules\Mylinks\Helper $helper */
39
$helper = \XoopsModules\Mylinks\Helper::getInstance();
40
41
if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
42
    require_once $GLOBALS['xoops']->path('class/theme.php');
43
    $GLOBALS['xoTheme'] = new \xos_opal_Theme();
44
}
45
$GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/gwiki/assets/css/module.css');
46
47
$myts = \MyTextSanitizer::getInstance();
48
//$eh = new ErrorHandler;
49
50
$categoryHandler = $helper->getHandler('Category');
51
$catObjs           = $categoryHandler->getAll();
52
$myCatTree         = new \XoopsObjectTree($catObjs, 'cid', 'pid');
53
54
function listNewLinks()
55
{
56
    global $xoopsDB, $myts, $myCatTree, $xoopsModule;
57
    // List links waiting for validation
58
    $linkimg_array = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/shots/');
59
    $result        = $xoopsDB->query('SELECT lid, cid, title, url, logourl, submitter FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE status='0' ORDER BY date DESC");
60
    $numrows       = $xoopsDB->getRowsNum($result);
61
    xoops_cp_header();
62
63
    $adminObject = \Xmf\Module\Admin::getInstance();
64
    $adminObject->displayNavigation('main.php?op=listNewLinks');
65
66
    //@TODO: change to use XoopsForm
67
    echo "<table  class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . "  <tr><th colspan='7'>" . sprintf(_MD_MYLINKS_LINKSWAITING, $numrows) . "<br></th></tr>\n";
68
    if ($numrows > 0) {
69
        while (list($lid, $cid, $title, $url, $logourl, $submitterid) = $xoopsDB->fetchRow($result)) {
70
            $result2 = $xoopsDB->query('SELECT description FROM ' . $xoopsDB->prefix('mylinks_text') . " WHERE lid='{$lid}'");
71
            list($description) = $xoopsDB->fetchRow($result2);
72
            $title = $myts->htmlSpecialChars($title);
73
            $url   = $myts->htmlSpecialChars($url);
74
            //      $url = urldecode($url);
75
            //      $logourl = $myts->htmlSpecialChars($logourl);
76
            //      $logourl = urldecode($logourl);
77
            $description = $myts->htmlSpecialChars($description);
78
            $submitter   = \XoopsUser::getUnameFromId($submitterid);
79
            echo "  <tr><td>\n"
80
                 . "    <form action='main.php' method='post'>\n"
81
                 . "        <table style='width: 80%;'>\n"
82
                 . "          <tr><td style='text-align: right; nowrap='nowrap'>"
83
                 . _MD_MYLINKS_SUBMITTER
84
                 . "</td>\n"
85
                 . '            <td><a href="'
86
                 . XOOPS_URL
87
                 . '/userinfo.php?uid='
88
                 . $submitterid
89
                 . "\">$submitter</a></td>\n"
90
                 . "          </tr>\n"
91
                 . "          <tr><td style='text-align: right;' nowrap='nowrap'>"
92
                 . _MD_MYLINKS_SITETITLE
93
                 . "</td>\n"
94
                 . "            <td><input type='text' name='title' size='50' maxlength='100' value='{$title}'></td>\n"
95
                 . "          </tr>\n"
96
                 . "          <tr><td style='text-align: right;' nowrap='nowrap'>"
97
                 . _MD_MYLINKS_SITEURL
98
                 . "</td>\n"
99
                 . "            <td><input type='text' name='url' size='50' maxlength='250' value='{$url}'>&nbsp;\n"
100
                 . "              [&nbsp;<a href='"
101
                 . preg_replace('/javascript:/si', 'java script:', $url)
102
                 . "' target='_blank'>"
103
                 . _MD_MYLINKS_VISIT
104
                 . "</a>&nbsp;]\n"
105
                 . "            </td>\n"
106
                 . "          </tr>\n"
107
                 . "          <tr><td style='text-align: right;' nowrap'nowrap'>"
108
                 . _MD_MYLINKS_CATEGORYC
109
                 . "</td>\n"
110
                 . '            <td>'
111
                 . $myCatTree->makeSelBox('cid', 'title', '- ', $cid)
112
                 . "</td>\n"
113
                 . "          </tr>\n"
114
                 . "        <tr><td style='text-align: right; vertical-align: top;' nowrap='nowrap'>"
115
                 . _MD_MYLINKS_DESCRIPTIONC
116
                 . "</td>\n"
117
                 . "          <td><textarea name='description' cols='60' rows='5'>{$description}</textarea></td>\n"
118
                 . "        </tr>\n"
119
                 . "        <tr><td style='text-align: right; nowrap='nowrap'>"
120
                 . _MD_MYLINKS_SHOTIMAGE
121
                 . "</td>\n"
122
                 . "            <td><select size='1' name='logourl'><option value=' '>------</option>";
123
            foreach ($linkimg_array as $image) {
124
                echo "<option value='{$image}'>{$image}</option>";
125
            }
126
            $shotdir = '<strong>' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/shots/</strong>';
127
            echo "</select></td>\n"
128
                 . "        </tr>\n"
129
                 . '        <tr><td></td><td>'
130
                 . sprintf(_MD_MYLINKS_SHOTMUST, $shotdir)
131
                 . "</td></tr>\n"
132
                 . "      </table>\n"
133
                 . "      <br><input type='hidden' name='op' value='approve'>\n"
134
                 . "      <input type='hidden' name='lid' value='{$lid}'>\n"
135
                 . "      <input type='submit' value='"
136
                 . _MD_MYLINKS_APPROVE
137
                 . "'>\n"
138
                 . "    </form>\n";
139
            echo "    <form action='main.php?op=delNewLink&amp;lid={$lid}' method='post'><input type='submit' value='" . _DELETE . "'></form>\n" . "    <br><br>\n" . "  </td></tr>\n";
140
        }
141
    } else {
142
        echo "  <tr><td colspan='7' class='odd bold italic'>" . _MD_MYLINKS_NOSUBMITTED . "</td></tr>\n";
143
    }
144
    echo "</table>\n";
145
146
    require_once __DIR__ . '/admin_footer.php';
147
}
148
149
function linksConfigMenu()
150
{
151
    global $xoopsDB, $myts, $myCatTree, $xoopsModule;
152
    /** @var \XoopsModules\Mylinks\Helper $helper */
153
    $helper            = \XoopsModules\Mylinks\Helper::getInstance();
154
    $categoryHandler = $helper->getHandler('Category');
155
    $catCount          = $categoryHandler->getCount();
156
    $linkimg_array     = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/shots/');
157
158
    xoops_cp_header();
159
    $adminObject = \Xmf\Module\Admin::getInstance();
160
    $adminObject->displayNavigation('main.php?op=linksConfigMenu');
161
162
    //    echo "<h4>" . _MD_MYLINKS_WEBLINKSCONF . "</h4>\n";
163
164
    // If there is a category, display add a New Link table
165
    //@TODO:  change to use XoopsForm
166
    if ($catCount) {
167
        echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n"
168
             . "  <tr><th style='font-size: larger;'>"
169
             . _MD_MYLINKS_ADDNEWLINK
170
             . "</th></tr>\n"
171
             . "  <tr class='odd'><td style='padding: 0 10em;'>\n"
172
             . "    <form method='post' action='main.php'>\n"
173
             . "      <table style='width: 80%;'>\n"
174
             . "        <tr>\n"
175
             . "          <td style='text-align: right;'>"
176
             . _MD_MYLINKS_SITETITLE
177
             . "</td>\n"
178
             . "            <td><input type='text' name='title' size='50' maxlength='100'></td>\n"
179
             . "          </tr>\n"
180
             . "        <tr>\n"
181
             . "          <td style='text-align: right;' nowrap='nowrap'>"
182
             . _MD_MYLINKS_SITEURL
183
             . "</td>\n"
184
             . "          <td><input type='text' name='url' size='50' maxlength='250' value='http://'></td>\n"
185
             . "        </tr>\n"
186
             . "        <tr>\n"
187
             . "          <td style='text-align: right;' nowrap='nowrap'>"
188
             . _MD_MYLINKS_CATEGORYC
189
             . "</td>\n"
190
             . "          <td>\n"
191
             . '            '
192
             . $myCatTree->makeSelBox('cid', 'title')
193
             . "\n"
194
             . "            </td>\n"
195
             . "          </tr>\n"
196
             . "          <tr>\n"
197
             . "          <td style='text-align: right; vertical-align: top;' nowrap='nowrap'>"
198
             . _MD_MYLINKS_DESCRIPTIONC
199
             . "</td>\n"
200
             . '          <td>';
201
        xoopsCodeTarea('descarea', 60, 8);
202
        xoopsSmilies('descarea');
203
        echo "          </td>\n" . "        </tr>\n" . "        <tr>\n" . "          <td style='text-align: right; nowrap='nowrap'>" . _MD_MYLINKS_SHOTIMAGE . "</td>\n" . "          <td><select size='1' name='logourl'><option value=' '>------</option>";
204
        foreach ($linkimg_array as $image) {
205
            echo "<option value='{$image}'>{$image}</option>";
206
        }
207
        echo "</select></td>\n" . "        </tr>\n";
208
        $shotdir = '<strong>' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/shots/</strong>';
209
        echo '        <tr><td></td><td>'
210
             . sprintf(_MD_MYLINKS_SHOTMUST, $shotdir)
211
             . "</td></tr>\n"
212
             . "      </table><br>\n"
213
             . "      <div class='center;'>\n"
214
             . "        <input type='hidden' name='op' value='addLink'>\n"
215
             . "        <input type='submit' class='button' value='"
216
             . _ADD
217
             . "'>\n"
218
             . "      </div>\n"
219
             . "    </form>\n"
220
             . "  </td></tr>\n"
221
             . "</table>\n"
222
             . "<br>\n";
223
224
        // Modify Link
225
        $result2 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_links') . '');
226
        list($numLinks) = $xoopsDB->fetchRow($result2);
227
        if ($numLinks) {
228
            echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n"
229
                 . "  <tr><th style='font-size: larger;'>"
230
                 . _MD_MYLINKS_MODLINK
231
                 . "</th></tr>\n"
232
                 . "  <tr class='odd'><td class='center;'>\n"
233
                 . "    <form method='get' action='main.php'>\n"
234
                 . '      '
235
                 . _MD_MYLINKS_LINKID
236
                 . "\n"
237
                 . "      <input type='text' name='lid' size='12' maxlength='11'>\n"
238
                 . "      <input type='hidden' name='fct' value='mylinks'>\n"
239
                 . "      <input type='hidden' name='op' value='modLink'><br><br>\n"
240
                 . "      <input type='submit' value='"
241
                 . _MD_MYLINKS_MODIFY
242
                 . "'>\n"
243
                 . "    </form>\n"
244
                 . "  </td></tr>\n"
245
                 . '</table>';
246
        }
247
    }
248
249
    // Add a New Main Category
250
    echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n"
251
         . "  <tr><th style='font-size: larger;'>"
252
         . _MD_MYLINKS_ADDMAIN
253
         . "</th></tr>\n"
254
         . "  <tr class='odd'><td class='center;'>\n"
255
         . "    <form method='post' action='main.php'>\n"
256
         . '      '
257
         . _MD_MYLINKS_TITLEC
258
         . "\n"
259
         . "      <input type='text' name='title' size='30' maxlength='50'><br>\n"
260
         . '      '
261
         . _MD_MYLINKS_IMGURL
262
         . "<br>\n"
263
         . "      <input type='text' name='imgurl' size='100' maxlength='150' value='http://'><br><br>\n"
264
         . "      <input type='hidden' name='cid' value='0'>\n"
265
         . "      <input type='hidden' name='op' value='addCat'>\n"
266
         . "      <input type='submit' value='"
267
         . _ADD
268
         . "'><br>\n"
269
         . "    </form>\n"
270
         . "  </td></tr>\n";
271
    if (!$catCount) {
272
        echo "  <tr><th style='font-size: larger;'>"
273
             . _MD_MYLINKS_IMPORTCATHDR
274
             . "</th></tr>\n"
275
             . "  <tr class='even'><td class='center;'>\n"
276
             . "    <form method='post' action='main.php'>\n"
277
             . '      '
278
             . _MD_MYLINKS_IMPORTCATS
279
             . "<br>\n"
280
             . "      <input type='hidden' name='op' value='importCats'>\n"
281
             . "      <input type='hidden' name='ok' value='0'>\n"
282
             . "      <input style='margin: .5em 0em;' type='submit' value='"
283
             . _SUBMIT
284
             . "'><br>\n"
285
             . "    </form>\n"
286
             . '  </td></tr>'
287
             . "</table>\n"
288
             . "<br>\n";
289
    }
290
    // Add a New Sub-Category
291
    if ($catCount) {
292
        echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n"
293
             . "  <tr><th style='font-size: larger;'>"
294
             . _MD_MYLINKS_ADDSUB
295
             . "</th></tr>\n"
296
             . "  <tr class='odd'><td class='center;'>\n"
297
             . "    <form method='post' action='main.php'>\n"
298
             . '      '
299
             . _MD_MYLINKS_TITLEC
300
             . "\n"
301
             . "      <input type='text' name='title' size='30' maxlength='50'>&nbsp;"
302
             . _MD_MYLINKS_IN
303
             . "&nbsp;\n"
304
             . '      '
305
             . $myCatTree->makeSelBox('pid', 'title')
306
             . "\n"
307
             . "      <input type='hidden' name='op' value='addCat'><br><br>\n"
308
             . "      <input type='submit' value='"
309
             . _ADD
310
             . "'><br>\n"
311
             . "    </form>\n"
312
             . "  </td></tr>\n"
313
             . "</table>\n"
314
             . '<br>';
315
    }
316
317
    // Modify Category Table Display
318
    if ($catCount) {
319
        echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n"
320
             . "  <tr><th style='font-size: larger;'>"
321
             . _MD_MYLINKS_MODCAT
322
             . "</th></tr>\n"
323
             . "  <tr class='odd'><td class='center;'>\n"
324
             . "    <form method='get' action='main.php'>\n"
325
             //            ."      <h4>" . _MD_MYLINKS_MODCAT . "</h4><br>\n"
326
             . '      '
327
             . _MD_MYLINKS_CATEGORYC
328
             . "\n"
329
             . '      '
330
             . $myCatTree->makeSelBox('cid', 'title')
331
             . "\n"
332
             . "      <br><br>\n"
333
             . "      <input type='hidden' name='op' value='modCat'>\n"
334
             . "      <input type='submit' value='"
335
             . _MD_MYLINKS_MODIFY
336
             . "'>\n"
337
             . "    </form>\n"
338
             . "  </td></tr>\n"
339
             . "</table>\n"
340
             . "<br>\n";
341
    }
342
    require_once __DIR__ . '/admin_footer.php';
343
}
344
345
function modLink()
346
{
347
    global $xoopsDB, $myts, $myCatTree, $xoopsModule;
348
349
    $linkimg_array = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/shots/');
350
    $lid           = Mylinks\Utility::cleanVars($_GET, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'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

350
    $lid           = Mylinks\Utility::cleanVars($_GET, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
351
    $bknrptid      = Mylinks\Utility::cleanVars($_GET, 'bknrptid', 0, 'int', ['min' => 0]);
352
353
    xoops_cp_header();
354
355
    $result = $xoopsDB->query('SELECT cid, title, url, logourl FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE lid={$lid}");
356
    if (!$result) {
357
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

357
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
358
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
359
    }
360
    list($cid, $title, $url, $logourl) = $xoopsDB->fetchRow($result);
361
362
    $title   = $myts->htmlSpecialChars($myts->stripSlashesGPC($title));
363
    $url     = $myts->htmlSpecialChars($myts->stripSlashesGPC($url));
364
    $logourl = $myts->htmlSpecialChars($myts->stripSlashesGPC($logourl));
365
    //$url                    = urldecode($url);
366
    //$logourl                = urldecode($logourl);
367
    $result2 = $xoopsDB->query('SELECT description FROM ' . $xoopsDB->prefix('mylinks_text') . " WHERE lid={$lid}");
368
    list($description) = $xoopsDB->fetchRow($result2);
369
    $GLOBALS['description'] = $myts->htmlSpecialChars($myts->stripSlashesGPC($description));
370
371
    echo '<h4>'
372
         . _MD_MYLINKS_WEBLINKSCONF
373
         . '</h4>'
374
         . "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>"
375
         . "  <tr><th colspan='2'>"
376
         . _MD_MYLINKS_MODLINK
377
         . "</th></tr>\n"
378
         . "  <tr class='odd'>\n"
379
         . "    <td>\n"
380
         . "      <form method='post' action='main.php' style='display: inline;'>\n"
381
         . "        <table>\n"
382
         . '          <tr><td>'
383
         . _MD_MYLINKS_LINKID
384
         . "</td><td style='font-weight: bold;'>{$lid}</td></tr>\n"
385
         . '          <tr><td>'
386
         . _MD_MYLINKS_SITETITLE
387
         . "</td><td><input type='text' name='title' value='{$title}' size='50' maxlength='100'></td></tr>\n"
388
         . '          <tr><td>'
389
         . _MD_MYLINKS_SITEURL
390
         . "</td><td><input type='text' name='url' value='{$url}' size='50' maxlength='250'></td></tr>\n"
391
         . "          <tr><td style='vertical-align: top;'>"
392
         . _MD_MYLINKS_DESCRIPTIONC
393
         . '</td><td>';
394
    xoopsCodeTarea('description', 60, 8);
395
    xoopsSmilies('description');
396
    echo "</td></tr>\n"
397
         . '          <tr><td>'
398
         . _MD_MYLINKS_CATEGORYC
399
         . '</td><td>'
400
         . ''
401
         . $myCatTree->makeSelBox('cid', 'title', '- ', $cid)
402
         . ''
403
         . "          </td></tr>\n"
404
         . '          <tr><td>'
405
         . _MD_MYLINKS_SHOTIMAGE
406
         . '</td><td>'
407
         . "<select size='1' name='logourl'>"
408
         . "<option value=' '>------</option>";
409
    foreach ($linkimg_array as $image) {
410
        $opt_selected = ($image == $logourl) ? ' selected' : '';
411
        echo "<option value='{$image}'{$opt_selected}>{$image}</option>";
412
    }
413
    echo '</select>' . "</td></tr>\n";
414
415
    $shotdir = '<strong>' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/shots/</strong>';
416
    echo '          <tr><td>&nbsp;</td><td>'
417
         . sprintf(_MD_MYLINKS_SHOTMUST, $shotdir)
418
         . "</td></tr>\n"
419
         . '        </table>'
420
         . "        <br><br><input type='hidden' name='lid' value='{$lid}'>\n"
421
         . "        <input type='hidden' name='bknrptid' value='{$bknrptid}'>\n"
422
         . "        <input type='hidden' name='op' value='modLinkS'>\n"
423
         . "        <input type='submit' value='"
424
         . _MD_MYLINKS_MODIFY
425
         . "'>"
426
         . "      </form>\n"
427
         . "      <form action='main.php?op=delLink&amp;lid={$lid}' method='post' style='margin-left: 1em; display: inline;'><input type='submit' value='"
428
         . _DELETE
429
         . "'></form>\n"
430
         . "      <form action='main.php?op=linksConfigMenu' method='post' style='margin-left: 1em; display: inline;'><input type='submit' value='"
431
         . _CANCEL
432
         . "'></form>\n"
433
         . '      <hr>';
434
435
    $result5 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE lid='{$lid}'");
436
    list($totalvotes) = $xoopsDB->fetchRow($result5);
437
    echo "      <table style='width: 100%;'>\n" . "        <tr><td colspan='7' style='font-weight: bold;'>" . sprintf(_MD_MYLINKS_TOTALVOTES, $totalvotes) . "<br><br></td></tr>\n";
438
    // Show Registered Users Votes
439
    $result5 = $xoopsDB->query('SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE lid='{$lid}' AND ratinguser >0 ORDER BY ratingtimestamp DESC");
440
    $votes   = $xoopsDB->getRowsNum($result5);
441
    echo "        <tr><td colspan='7' style='font-weight: bold;'><br><br>" . sprintf(_MD_MYLINKS_USERTOTALVOTES, $votes) . "<br><br></td></tr>\n";
442
    echo "        <tr>\n"
443
         . '          <th>'
444
         . _MD_MYLINKS_USER
445
         . "  </th>\n"
446
         . '          <th>'
447
         . _MD_MYLINKS_IP
448
         . "  </th>\n"
449
         . '          <th>'
450
         . _MD_MYLINKS_RATING
451
         . "  </th>\n"
452
         . '          <th>'
453
         . _MD_MYLINKS_USERAVG
454
         . "  </th>\n"
455
         . '          <th>'
456
         . _MD_MYLINKS_TOTALRATE
457
         . "  </th>\n"
458
         . '          <th>'
459
         . _MD_MYLINKS_DATE
460
         . "  </th>\n"
461
         . '          <th>'
462
         . _DELETE
463
         . "</td>\n"
464
         . "        </tr>\n";
465
    if (0 == $votes) {
466
        echo "        <tr><td class='center;' colspan='7'>" . _MD_MYLINKS_NOREGVOTES . "<br></td></tr>\n";
467
    }
468
469
    $x           = 0;
470
    $colorswitch = '#DDDDDD';
471
472
    while (list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp) = $xoopsDB->fetchRow($result5)) {
473
        //  $ratingtimestamp = formatTimestamp($ratingtimestamp);
474
        //Individual user information
475
        //v3.11 changed to let SQL do calculations instead of PHP
476
        $result2 = $xoopsDB->query('SELECT COUNT(), FORMAT(AVG(rating),2) FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE ratinguser = '$ratinguser'");
477
        list($uservotes, $useravgrating) = $xoopsDB->fetchRow($result2);
478
        //        $useravgrating = ($rating2) ? sprintf("%01.2f", ($useravgrating / $uservotes)): 0;
479
        /*
480
                $result2=$xoopsDB->query("SELECT rating FROM ".$xoopsDB->prefix("mylinks_votedata")." WHERE ratinguser = '$ratinguser'");
481
                $uservotes = $xoopsDB->getRowsNum($result2);
482
                $useravgrating = 0;
483
                while ( list($rating2) = $xoopsDB->fetchRow($result2) ) {
484
                    $useravgrating = $useravgrating + $rating2;
485
                }
486
                $useravgrating = sprintf("%01.2f", ($useravgrating / $uservotes));
487
        */
488
        $ratingusername = \XoopsUser::getUnameFromId($ratinguser);
489
        echo "        <tr>\n"
490
             . "          <td style='background-color: {$colorswitch};'>{$ratingusername}</td>\n"
491
             . "          <td style='background-color: {$colorswitch};'>{$ratinghostname}</td>\n"
492
             . "          <td style='background-color: {$colorswitch};'>{$rating}</td>\n"
493
             . "          <td style='background-color: {$colorswitch};'>{$useravgrating}</td>\n"
494
             . "          <td style='background-color: {$colorswitch};'>{$uservotes}</td>\n"
495
             . "          <td style='background-color: {$colorswitch};'>{$ratingtimestamp}</td>\n"
496
             . "          <td style='background-color: {$colorswitch}; text-align: center; font-weight: bold;'>\n"
497
             . "            <form action='main.php?op=delVote&amp;lid={$lid}&amp;rid={$ratingid}' method='post'><input type='submit' value='X'></form>\n"
498
             . "          </td>\n"
499
             . "        </tr>\n";
500
        ++$x;
501
        $colorswitch = ('#DDDDDD' === $colorswitch) ? '#FFFFFF' : '#DDDDDD';
502
    }
503
    // Show Unregistered Users Votes
504
    $result5 = $xoopsDB->query('SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE lid ='{$lid}' AND ratinguser='0' ORDER BY ratingtimestamp DESC");
505
    $votes   = $xoopsDB->getRowsNum($result5);
506
    echo "        <tr><td colspan='7' style='font-weight: bold;'><br><br>"
507
         . sprintf(_MD_MYLINKS_ANONTOTALVOTES, $votes)
508
         . "<br><br></td></tr>\n"
509
         . "        <tr>\n"
510
         . "          <th colspan='2'>"
511
         . _MD_MYLINKS_IP
512
         . "  </th>\n"
513
         . "          <th colspan='3' style='font-weight: bold;'>"
514
         . _MD_MYLINKS_RATING
515
         . "  </th>\n"
516
         . "          <th style='font-weight: bold;'>"
517
         . _MD_MYLINKS_DATE
518
         . "  </th>\n"
519
         . "          <th style='text-align: center; font-weight: bold;'>"
520
         . _DELETE
521
         . "<br></th>\n"
522
         . "        </tr>\n";
523
    if (0 == $votes) {
524
        echo "        <tr><td colspan='7' class='center;'>" . _MD_MYLINKS_NOUNREGVOTES . "<br></td></tr>\n";
525
    }
526
    $x           = 0;
527
    $colorswitch = '#DDDDDD';
528
    while (list($ratingid, $rating, $ratinghostname, $ratingtimestamp) = $xoopsDB->fetchRow($result5)) {
529
        $formatted_date = formatTimestamp($ratingtimestamp);
530
        echo "        <tr>\n"
531
             . "          <td colspan='2' style='background-color: {$colorswitch}'>{$ratinghostname}</td>\n"
532
             . "          <td colspan='3' style='background-color: {$colorswitch}'>{$rating}</td>\n"
533
             . "          <td style='background-color: {$colorswitch}'>{$formatted_date}</td>\n"
534
             . "          <td style='background-color: {$colorswitch} text-align: center; font-weight: bold;'>\n"
535
             . "            <form action='main.php?op=delVote&amp;lid={$lid}&amp;rid={$ratingid}' method='post'><input type='submit' value='X'></form>\n"
536
             . '          </td>'
537
             . '        </tr>';
538
        ++$x;
539
        $colorswitch = ('#DDDDDD' === $colorswitch) ? '#FFFFFF' : '#DDDDDD';
540
    }
541
    echo "        <tr><td colspan='7'>&nbsp;<br></td></tr>\n" . "      </table>\n" . "    </td>\n" . "  </tr>\n" . "</table>\n";
542
    require_once __DIR__ . '/admin_footer.php';
543
}
544
545
function delVote()
546
{
547
    global $xoopsDB;
548
    $lid = Mylinks\Utility::cleanVars($_POST, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'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

548
    $lid = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
549
    $rid = Mylinks\Utility::cleanVars($_POST, 'rid', 0, 'int', ['min' => 0]);
550
551
    $sql    = sprintf('DELETE FROM `%s` WHERE ratingid = %u', $xoopsDB->prefix('mylinks_votedata'), $rid);
552
    $result = $xoopsDB->query($sql);
553
    if (!$result) {
554
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

554
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
555
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
556
    }
557
    updaterating($lid);
0 ignored issues
show
Bug introduced by
The function updaterating was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

557
    /** @scrutinizer ignore-call */ 
558
    updaterating($lid);
Loading history...
558
    redirect_header('index.php', 2, _MD_MYLINKS_VOTEDELETED);
559
}
560
561
function listBrokenLinks()
562
{
563
    global $xoopsDB, $xoopsModule, $pathIcon16, $myts;
564
565
    $result           = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('mylinks_broken') . ' GROUP BY lid ORDER BY reportid DESC');
566
    $totalBrokenLinks = $xoopsDB->getRowsNum($result);
567
    xoops_cp_header();
568
569
    $adminObject = \Xmf\Module\Admin::getInstance();
570
    $adminObject->displayNavigation('main.php?op=listBrokenLinks');
571
    $GLOBALS['xoTheme']->addStylesheet(Utility::getStylePath('mylinks.css', 'include'));
572
    //    echo "<link rel='stylesheet' href='" . $GLOBALS['xoops']->url('browse.php?modules/mylinks/include/mylinks.css') . "' type='text/css'>";
573
574
    echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . '  <tr><th>' . sprintf(_MD_MYLINKS_BROKENREPORTS, $totalBrokenLinks) . "<br></th></tr>\n" . "  <tr class='odd'><td>\n";
575
576
    if (0 == $totalBrokenLinks) {
577
        echo "    <span class='italic bold'>" . _MD_MYLINKS_NOBROKEN . '</span>';
578
    } else {
579
        $colorswitch = '#DDDDDD';
580
        echo "<img src='{$pathIcon16}/on.png'> = "
581
             . _MD_MYLINKS_IGNOREDESC
582
             . '<br>'
583
             . "<img src='{$pathIcon16}/edit.png'> = "
584
             . _MD_MYLINKS_EDITDESC
585
             . '<br>'
586
             . "<img src='{$pathIcon16}/delete.png'> = "
587
             . _MD_MYLINKS_DELETEDESC
588
             . '<br>'
589
             . "   <table class='center width100'>\n"
590
             //           ."      <tr><th colspan='6'>" . _MD_MYLINKS_DELETEDESC . "</th><tr>"
591
             . "      <tr>\n"
592
             . '        <th>'
593
             . _MD_MYLINKS_LINKNAME
594
             . "</th>\n"
595
             . '        <th>'
596
             . _MD_MYLINKS_REPORTER
597
             . "</th>\n"
598
             . '        <th>'
599
             . _MD_MYLINKS_LINKSUBMITTER
600
             . "</th>\n"
601
             . '        <th>'
602
             . _MD_MYLINKS_ACTIONS
603
             . "</th>\n"
604
             . "      </tr>\n";
605
606
        $formToken = $GLOBALS['xoopsSecurity']->getTokenHTML();
607
608
        while (list($reportid, $lid, $sender, $ip) = $xoopsDB->fetchRow($result)) {
609
            $result2 = $xoopsDB->query('SELECT title, url, submitter FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE lid={$lid}");
610
            if (0 != $sender) {
611
                $result3 = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid={$sender}");
612
                list($uname, $email) = $xoopsDB->fetchRow($result3);
613
            }
614
            list($title, $url, $ownerid) = $xoopsDB->fetchRow($result2);
615
            $title = $myts->stripSlashesGPC($title);
616
            //          $url=urldecode($url);
617
            $result4 = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid='{$ownerid}'");
618
            list($owner, $owneremail) = $xoopsDB->fetchRow($result4);
619
            echo "      <tr>\n" . "        <td style='background-color: {$colorswitch}'><a href=$url target='_blank'>{$title}</a></td>\n";
620
            if ('' == $email) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $email does not seem to be defined for all execution paths leading up to this point.
Loading history...
621
                echo "        <td style='background-color: {$colorswitch};'>{$sender} ({$ip})";
622
            } else {
623
                echo "        <td style='background-color: {$colorswitch};'><a href='mailto:{$email}'>{$uname}</a> ({$ip})";
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $uname does not seem to be defined for all execution paths leading up to this point.
Loading history...
624
            }
625
            echo "        </td>\n";
626
            if ('' == $owneremail) {
627
                echo "        <td style='background-color: {$colorswitch};'>{$owner}";
628
            } else {
629
                echo "        <td style='background-color: {$colorswitch};'><a href='mailto:{$owneremail}'>{$owner}</a>\n";
630
            }
631
            echo "        <td style='text-align: center; background-color: {$colorswitch};'>\n"
632
                 //                ."          <a href='main.php?op=ignoreBrokenLinks&amp;lid={$lid}'><img src=". $pathIcon16 ."/on.png alt='" . _AM_MYLINKS_IGNORE . "' title='" . _AM_MYLINKS_IGNORE . "'></a>\n"
633
                 //                ."          <a href='main.php?op=modLink&amp;lid={$lid}&amp;bknrptid={$reportid}'><img src=". $pathIcon16 ."/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a>\n"
634
                 //                ."          <a href='main.php?op=delBrokenLinks&amp;lid={$lid}'><img src=". $pathIcon16 ."/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a>\n"
635
                 . "          <form class='inline' action='"
636
                 . $_SERVER['SCRIPT_NAME']
637
                 . "' method='post'>\n"
638
                 . "             <input type='hidden' name='op' value='ignoreBrokenLinks'>\n"
639
                 . "             <input type='hidden' name='bknrptid' value='{$reportid}'>\n"
640
                 . "            {$formToken}\n"
641
                 . "            <input type='button' title='"
642
                 . _MD_MYLINKS_IGNOREDESC
643
                 . "' alt='"
644
                 . _AM_MYLINKS_IGNORE
645
                 . "' id='image-button-on' onclick='this.form.submit();'></input>\n"
646
                 . "          </form>\n"
647
                 . "          <form class='inline' action='"
648
                 . $_SERVER['SCRIPT_NAME']
649
                 . "'?op=modLink&amp;lid={$lid} method='get'>\n"
650
                 . "            <input type='hidden' name='op' value='modLink'>\n"
651
                 . "            <input type='hidden' name='bknrptid' value='{$reportid}'>\n"
652
                 . "            <input type='hidden' name='lid' value={$lid}>\n"
653
                 . "            <input type='button' title='"
654
                 . _MD_MYLINKS_EDITDESC
655
                 . "' alt='"
656
                 . _EDIT
657
                 . "' id='image-button-edit' onclick='this.form.submit();'></input>\n"
658
                 . "          </form>\n"
659
                 . "          <form class='inline' action='"
660
                 . $_SERVER['SCRIPT_NAME']
661
                 . "' method='post'>\n"
662
                 . "             <input type='hidden' name='op' value='delBrokenLinks'>\n"
663
                 . "             <input type='hidden' name='lid' value='{$lid}'>\n"
664
                 . "            {$formToken}\n"
665
                 . "            <input type='button' title='"
666
                 . _MD_MYLINKS_DELETEDESC
667
                 . "' alt='"
668
                 . _DELETE
669
                 . "' id='image-button-delete' onclick='this.form.submit();'></input>\n"
670
                 . "          </form>\n"
671
                 . "        </td>\n"
672
                 . "      </tr>\n";
673
674
            $colorswitch = ('#DDDDDD' === $colorswitch) ? '#FFFFFF' : '#DDDDDD';
675
        }
676
        echo "    </table>\n";
677
    }
678
679
    echo '</td></tr></table>';
680
    require_once __DIR__ . '/admin_footer.php';
681
}
682
683
function delBrokenLinks()
684
{
685
    global $xoopsDB;
686
687
    $lid = Mylinks\Utility::cleanVars($_GET, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'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

687
    $lid = Mylinks\Utility::cleanVars($_GET, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
688
689
    $sql    = sprintf('DELETE FROM `%s` WHERE lid = %u', $xoopsDB->prefix('mylinks_broken'), $lid);
690
    $result = $xoopsDB->queryF($sql);
691
    if (!$result) {
692
        Mylinks\Utility::show_message(_MD_MYLINKS_NOBROKEN);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

692
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NOBROKEN);
Loading history...
693
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
694
    }
695
696
    $sql    = sprintf('DELETE FROM `%s` WHERE lid = %u', $xoopsDB->prefix('mylinks_links'), $lid);
697
    $result = $xoopsDB->queryF($sql);
698
    if (!$result) {
699
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

699
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
700
    } else {
701
        Mylinks\Utility::show_message(_MD_MYLINKS_LINKDELETED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

701
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_LINKDELETED);
Loading history...
702
    }
703
    exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
704
}
705
706
function ignoreBrokenLinks()
707
{
708
    global $xoopsDB;
709
710
    $bknrptid = Mylinks\Utility::cleanVars($_POST, 'bknrptid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'bknrptid' 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

710
    $bknrptid = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'bknrptid', 0, 'int', ['min' => 0]);
Loading history...
711
    $sql      = sprintf('DELETE FROM `%s` WHERE reportid = %u', $xoopsDB->prefix('mylinks_broken'), $bknrptid);
712
    $result   = $xoopsDB->queryF($sql);
713
    if (!$result) {
714
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

714
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
715
    } else {
716
        Mylinks\Utility::show_message(_MD_MYLINKS_BROKENDELETED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

716
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_BROKENDELETED);
Loading history...
717
    }
718
    exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
719
}
720
721
function listModReq()
722
{
723
    global $xoopsDB, $myts, $xoopsModule;
724
    /** @var Mylinks\Helper $helper */
725
    $helper = Mylinks\Helper::getInstance();
726
    //    $from = '';
727
    //    $to = '';
728
729
    $result           = $xoopsDB->query('SELECT requestid, lid, cid, title, url, logourl, description, modifysubmitter FROM ' . $xoopsDB->prefix('mylinks_mod') . ' ORDER BY requestid');
730
    $totalModRequests = $xoopsDB->getRowsNum($result);
731
    xoops_cp_header();
732
    $adminObject = \Xmf\Module\Admin::getInstance();
733
    $adminObject->displayNavigation('main.php?op=listModReq');
734
735
    $categoryHandler = $helper->getHandler('Category');
736
737
    //echo "<h4>" . _MD_MYLINKS_WEBLINKSCONF . "</h4>\n";
738
    echo "<table class='outer' style='width: 100%; border-weight: 0px; margin: 1px;'>\n" . "  <tr class='even'><th>" . sprintf(_MD_MYLINKS_MODREQUESTS, $totalModRequests) . "</th></tr>\n" . "  <tr class='odd'>\n" . "    <td>\n";
739
    if ($totalModRequests > 0) {
740
        echo "  <table style='width: 95%;'>\n" . "    <tr>\n" . "      <td>\n";
741
        $lookup_lid = [];
742
        while (list($requestid, $lid, $cid, $title, $url, $logourl, $description, $submitterid) = $xoopsDB->fetchRow($result)) {
743
            $catObj                 = $categoryHandler->get($cid);
744
            $lookup_lid[$requestid] = $lid;
745
            $result2                = $xoopsDB->query('SELECT cid, title, url, logourl, submitter FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE lid='{$lid}'");
746
            list($origcid, $origtitle, $origurl, $origlogourl, $ownerid) = $xoopsDB->fetchRow($result2);
747
            $origCatObj = $categoryHandler->get($origcid);
748
            $result2    = $xoopsDB->query('SELECT description FROM ' . $xoopsDB->prefix('mylinks_text') . " WHERE lid='{$lid}'");
749
            list($origdescription) = $xoopsDB->fetchRow($result2);
750
            $result7      = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid='{$submitterid}'");
751
            $result8      = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid='{$ownerid}'");
752
            $cidtitle     = $catObj->getVar('title');
753
            $cidtitle     = $myts->htmlSpecialChars($cidtitle);
754
            $origcidtitle = $origCatObj->getVar('title');
755
            $origcidtitle = $myts->htmlSpecialChars($origcidtitle);
756
            /*
757
                        $cidtitle     = $catObj->getPathFromID();
758
                        $origcidtitle = $origCatObj->getPathFromID();
759
            */
760
            list($submitter, $submitteremail) = $xoopsDB->fetchRow($result7);
761
            list($owner, $owneremail) = $xoopsDB->fetchRow($result8);
762
            $title = $myts->htmlSpecialChars($title);
763
            $url   = $myts->htmlSpecialChars($url);
764
            //$url   = urldecode($url);
765
766
            // use original image file to prevent users from changing screen shots file
767
            $origlogourl = $myts->htmlSpecialChars($origlogourl);
768
            $logourl     = $origlogourl;
769
770
            //$logourl     = urldecode($logourl);
771
            $description = $myts->displayTarea($myts->stripSlashesGPC($description), 0);
772
            $origurl     = $myts->htmlSpecialChars($origurl);
773
            //$origurl     = urldecode($origurl);
774
            //$origlogourl = urldecode($origlogourl);
775
            $origdescription = $myts->displayTarea($myts->stripSlashesGPC($origdescription), 0);
776
777
            $from = $origdescription;
778
            $to   = $description;
779
780
            /* Load the lines of each file. */
781
            echo '<br><br> ==============================context<br><br>';
782
            /* Create the Diff object. */
783
            $diff = new Horde_Text_Diff('auto', [[$origdescription], [$description]]);
0 ignored issues
show
Bug introduced by
The type Horde_Text_Diff was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
784
785
            /* Output the diff in unified format. */
786
            $renderer     = new Horde_Text_Diff_Renderer_Unified();
0 ignored issues
show
Bug introduced by
The type Horde_Text_Diff_Renderer_Unified was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
787
            $diff0unified = $renderer->render($diff);
788
789
            $renderer    = new Horde_Text_Diff_Renderer_Inline();
0 ignored issues
show
Bug introduced by
The type Horde_Text_Diff_Renderer_Inline was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
790
            $diff0inline = $renderer->render($diff);
791
792
            $renderer     = new Horde_Text_Diff_Renderer_Context();
0 ignored issues
show
Bug introduced by
The type Horde_Text_Diff_Renderer_Context was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
793
            $diff0context = $renderer->render($diff);
794
795
            echo $diff0unified . ' <br><br>----------- unified<br><br>';
796
            echo $diff0inline . '<br><br>----- inline<br><br>';
797
            echo $diff0context . '<br><br>------  context<br><br>';
798
799
            //diff-multibyte
800
            /*
801
                        echo  '<br><br> ======== MULTIBYTE  ==========context<br><br>';
802
                        $opcodes = FineDiff::getDiffOpcodes($origdescription, $description );
803
                        $bingo1 =  FineDiffHTML::renderDiffToHTMLFromOpcodes($origdescription, $opcodes);
804
                        echo '<br>--------------<br>' . $bingo1;
805
            */
806
            echo '<br><br> ============== GWIKI ================context<br><br>';
807
            //gwiki
808
            $diff2 = new \XoopsModules\Mylinks\Diff\Gwiki\Diff();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Mylinks\Diff\Gwiki\Diff was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
809
810
            $body = $diff2->printPrettyDiff($origdescription, $description);
811
            echo $body;
812
813
            echo '<br><br> ============== STANDARD ================context<br><br>';
814
815
            $owner = ('' == $owner) ? 'administration' : $owner;
816
            echo "        <table style='border-width: 1px; border-color: black; padding: 5px; margin: auto; text-align: center; width: 800px;'>\n"
817
                 . "          <tr><td>\n"
818
                 . "            <table style='width: 100%; background-color: #DDDDDD'>\n"
819
                 . "              <tr>\n"
820
                 . "                <td style='vertical-align: top; width: 45%; font-weight: bold;'>"
821
                 . _MD_MYLINKS_ORIGINAL
822
                 . "</td>\n"
823
                 . "                <td rowspan='14' style='vertical-align: top; text-align: left; font-size: small;'><br>"
824
                 . _MD_MYLINKS_DESCRIPTIONC
825
                 . "<br>{$origdescription}</td>\n"
826
                 . "              </tr>\n"
827
                 . "              <tr><td style='vertical-align: top; width: 45%; font-size: small;'>"
828
                 . _MD_MYLINKS_SITETITLE
829
                 . "{$myts->stripSlashesGPC($origtitle)}</td></tr>\n"
830
                 . "              <tr><td style='vertical-align: top; width: 45%; font-size: small;'>"
831
                 . _MD_MYLINKS_SITEURL
832
                 . "{$origurl}</td></tr>\n"
833
                 . "              <tr><td style='vertical-align= top; width: 45%; font-size: small;'>"
834
                 . _MD_MYLINKS_CATEGORYC
835
                 . "{$origcidtitle}</td></tr>\n"
836
                 . "              <tr><td style='vertical-align: top; width: 45%; font-size: small;'>"
837
                 . _MD_MYLINKS_SHOTIMAGE
838
                 . '';
839
            if ($helper->getConfig('useshots') && !empty($origlogourl)) {
840
                echo "<img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/shots/{$origlogourl}' style='width: " . $helper->getConfig('shotwidth') . ";'>";
841
            } else {
842
                echo '&nbsp;';
843
            }
844
            echo "</td></tr>\n"
845
                 . "        </table>\n"
846
                 . "      </td></tr>\n"
847
                 . "      <tr><td>\n"
848
                 . "        <table style='width: 100%; background-color: #DDDDDD'>\n"
849
                 . "          <tr>\n"
850
                 . "            <td style='vertical-align: top; width: 45%; font-weight: bold;'>"
851
                 . _MD_MYLINKS_PROPOSED
852
                 . "</td>\n"
853
                 . "            <td rowspan='14' style='vertical-align: top; text-align: left; font-size: small;'><br>"
854
                 . _MD_MYLINKS_DESCRIPTIONC
855
                 . "<br>{$description}<br><br></td>\n"
856
                 . "          </tr>\n"
857
                 . "          <tr><td style='vertical-align: top; width: 45%; font-size: small;'>"
858
                 . _MD_MYLINKS_SITETITLE
859
                 . "{$title}</td></tr>\n"
860
                 . "          <tr><td style='vertical-align: top; width: 45%; font-size: small;'>"
861
                 . _MD_MYLINKS_SITEURL
862
                 . "{$url}</td></tr>\n"
863
                 . "          <tr><td style='vertical-align: top; width: 45%; font-size: small;'>"
864
                 . _MD_MYLINKS_CATEGORYC
865
                 . "{$cidtitle}</td></tr>\n"
866
                 . "          <tr><td style='vertical-align: top; width: 45%; font-size: small;'>"
867
                 . _MD_MYLINKS_SHOTIMAGE
868
                 . '';
869
            if (1 == $helper->getConfig('useshots') && !empty($logourl)) {
870
                echo "<img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/shots/{$logourl}' style='width: " . $helper->getConfig('shotwidth') . ";' alt=''>";
871
            } else {
872
                echo '&nbsp;';
873
            }
874
            echo "</td></tr>\n" . "        </table>\n" . "      </td></tr>\n" . "    </table>\n" . "    <table style='text-align: center; width: 800px; margin: auto;'>\n" . "      <tr>\n";
875
            if ('' == $submitteremail) {
876
                echo "      <td style='text-align: center; font-weight: bold;'>" . _MD_MYLINKS_SUBMITTER . "{$submitter}</td>\n";
877
            } else {
878
                echo "      <td style='text-align: center; font-size: small;'>" . _MD_MYLINKS_SUBMITTER . "<a href='mailto:{$submitteremail}'>{$submitter}</a></td>\n";
879
            }
880
            if ('' == $owneremail) {
881
                echo "      <td style='text-align: center; font-size: small;'>" . _MD_MYLINKS_OWNER . "{$owner}</td>\n";
882
            } else {
883
                echo "      <td style='text-align: center; font-size: small;'>" . _MD_MYLINKS_OWNER . "<a href='mailto:{$owneremail}'>{$owner}</a></td>\n";
884
            }
885
            echo "      <td style='text-align: center; font-size: small;'>\n"
886
                 //                ."        <form style='display: inline; margin-right: 1.5em;' action='main.php?op=changeModReq&amp;requestid={$requestid}' method='get'>\n"
887
                 . "        <form style='display: inline; margin-right: 1.5em;' action='main.php' method='post'>\n"
888
                 . "          <input type='hidden' name='op' value='changeModReq'>\n"
889
                 . "          <input type='hidden' name='requestid' value='{$requestid}'>\n"
890
                 . "          <input type='submit' value='"
891
                 . _MD_MYLINKS_APPROVE
892
                 . "'>\n"
893
                 . "        </form>\n"
894
                 //                ."        <form style='display: inline; margin-right: 1.5em;' action='main.php?op=modLink&amp;lid={$lid}' method='get'>\n"
895
                 . "        <form style='display: inline; margin-right: 1.5em;' action='main.php' method='get'>\n"
896
                 . "          <input type='hidden' name='op' value='modLink'>\n"
897
                 . "          <input type='hidden' name='lid' value='{$lid}'>\n"
898
                 . "          <input type='submit' value='"
899
                 . _EDIT
900
                 . "'></form>\n"
901
                 //                ."        <form style='display: inline;' action='main.php?op=ignoreModReq&amp;requestid={$requestid}' method='post'><input type='submit' value='" . _MD_MYLINKS_IGNORE . "'></form>\n"
902
                 . "        <form style='display: inline;' action='main.php' method='post'>\n"
903
                 . "          <input type='hidden' name='op' value='ignoreModReq'>\n"
904
                 . "          <input type='hidden' name='requestid' value='{$requestid}'>\n"
905
                 . "          <input type='submit' value='"
906
                 . _MD_MYLINKS_IGNORE
907
                 . "'>\n"
908
                 . "        </form>\n"
909
                 . "      </td>\n"
910
                 . "    </tr>\n"
911
                 . "  </table><br><br>\n";
912
913
            //            $from        = '';
914
            //            $to          = '';
915
            $granularity = 2;
916
            if (isset($_REQUEST['granularity']) && ctype_digit($_REQUEST['granularity'])) {
917
                $granularity = max(min((int)$_REQUEST['granularity'], 4), 0);
918
            }
919
            $rendered_diff = '';
920
            if (!empty($_REQUEST['from']) || !empty($_REQUEST['to'])) {
921
                if (!empty($_REQUEST['from'])) {
922
                    $from = $_REQUEST['from'];
923
                }
924
                if (!empty($_REQUEST['to'])) {
925
                    $to = $_REQUEST['to'];
926
                }
927
            } elseif (!empty($_REQUEST['sample'])) { // use sample text?
928
                // Sample text:
929
                // http://en.wikipedia.org/w/index.php?title=Universe&action=historysubmit&diff=414830579&oldid=378547111
930
                $from = file_get_contents('sample_from.txt');
931
                $to   = file_get_contents('sample_to.txt');
932
            }
933
934
            $from_len        = mb_strlen($from);
935
            $to_len          = mb_strlen($to);
936
            $use_stdlib_diff = !empty($_REQUEST['stdlib']) && ctype_digit($_REQUEST['stdlib']) && 1 === (int)$_REQUEST['stdlib'];
937
938
            //require_once 'Text/Diff.php';
939
940
            $start_time = gettimeofday(true);
941
            if ($use_stdlib_diff) {
942
                if ($granularity < 3) {
943
                    $delimiters = [
944
                        FineDiff::paragraphDelimiters,
0 ignored issues
show
Bug introduced by
The type FineDiff was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
945
                        FineDiff::sentenceDelimiters,
946
                        FineDiff::wordDelimiters,
947
                        FineDiff::characterDelimiters,
948
                        FineDiff::characterDelimiters,
949
                    ];
950
                    function extractFragments($text, $delimiter)
951
                    {
952
                        $text      = str_replace(["\n", "\r"], ["\1", "\2"], $text);
953
                        $delimiter = str_replace(["\n", "\r"], ["\1", "\2"], $delimiter);
954
                        if (empty($delimiter)) {
955
                            return str_split($text, 1);
956
                        }
957
                        $fragments = [];
958
                        $start     = $end = 0;
959
                        for (; ;) {
960
                            $end += strcspn($text, $delimiter, $end);
961
                            $end += strspn($text, $delimiter, $end);
962
                            if ($end === $start) {
963
                                break;
964
                            }
965
                            $fragments[] = mb_substr($text, $start, $end - $start);
966
                            $start       = $end;
967
                        }
968
969
                        return $fragments;
970
                    }
971
972
                    $from_fragments = extractFragments($from, $delimiters[$granularity]);
973
                    $to_fragments   = extractFragments($to, $delimiters[$granularity]);
974
                    $diff           = new Text_Diff('native', [$from_fragments, $to_fragments]);
0 ignored issues
show
Bug introduced by
The type Text_Diff was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
975
                    $exec_time      = sprintf('%.3f sec', gettimeofday(true) - $start_time);
0 ignored issues
show
Unused Code introduced by
The assignment to $exec_time is dead and can be removed.
Loading history...
976
                    $edits          = [];
977
                    ob_start();
978
                    foreach ($diff->getDiff() as $edit) {
979
                        if ($edit instanceof Text_Diff_Op_copy) {
0 ignored issues
show
Bug introduced by
The type Text_Diff_Op_copy was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
980
                            $orig    = str_replace(["\1", "\2"], ["\n", "\r"], implode('', $edit->orig));
981
                            $edits[] = new fineDiffCopyOp(mb_strlen($orig));
0 ignored issues
show
Bug introduced by
The type fineDiffCopyOp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
982
                            echo htmlentities($orig);
983
                        } elseif ($edit instanceof Text_Diff_Op_delete) {
0 ignored issues
show
Bug introduced by
The type Text_Diff_Op_delete was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
984
                            $orig    = str_replace(["\1", "\2"], ["\n", "\r"], implode('', $edit->orig));
985
                            $edits[] = new fineDiffDeleteOp(mb_strlen($orig));
0 ignored issues
show
Bug introduced by
The type fineDiffDeleteOp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
986
                            echo '<del>', htmlentities($orig), '</del>';
987
                        } elseif ($edit instanceof Text_Diff_Op_add) {
0 ignored issues
show
Bug introduced by
The type Text_Diff_Op_add was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
988
                            $final   = str_replace(["\1", "\2"], ["\n", "\r"], implode('', $edit->final));
989
                            $edits[] = new fineDiffInsertOp($final);
0 ignored issues
show
Bug introduced by
The type fineDiffInsertOp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
990
                            echo '<ins>', htmlentities($final), '</ins>';
991
                        } elseif ($edit instanceof Text_Diff_Op_change) {
0 ignored issues
show
Bug introduced by
The type Text_Diff_Op_change was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
992
                            $orig    = str_replace(["\1", "\2"], ["\n", "\r"], implode('', $edit->orig));
993
                            $final   = str_replace(["\1", "\2"], ["\n", "\r"], implode('', $edit->final));
994
                            $edits[] = new fineDiffReplaceOp(mb_strlen($orig), $final);
0 ignored issues
show
Bug introduced by
The type fineDiffReplaceOp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
995
                            echo '<del>', htmlentities($orig), '</del>';
996
                            echo '<ins>', htmlentities($final), '</ins>';
997
                        }
998
                    }
999
                    $rendered_diff  = ob_get_clean();
0 ignored issues
show
Unused Code introduced by
The assignment to $rendered_diff is dead and can be removed.
Loading history...
1000
                    $rendering_time = sprintf('%.3f sec', gettimeofday(true) - $start_time);
0 ignored issues
show
Unused Code introduced by
The assignment to $rendering_time is dead and can be removed.
Loading history...
1001
                } // character-level granularity not allowed
1002
                else {
1003
                    $edits          = false;
0 ignored issues
show
Unused Code introduced by
The assignment to $edits is dead and can be removed.
Loading history...
1004
                    $exec_time      = '?';
1005
                    $rendering_time = '?';
1006
                    $rendered_diff  = '<span style="color:gray">Character-level granularity not allowed when using <code>Text_Diff</code>, due to performance issues.</span>';
1007
                }
1008
            } else {
1009
                $granularityStacks = [
1010
                    FineDiff::$paragraphGranularity,
1011
                    FineDiff::$sentenceGranularity,
1012
                    FineDiff::$wordGranularity,
1013
                    FineDiff::$characterGranularity,
1014
                    FineDiff::$characterGranularity,
1015
                ];
1016
1017
                $diff           = new FineDiffHTML($from, $to, $granularityStacks[$granularity]);
0 ignored issues
show
Bug introduced by
The type FineDiffHTML was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1018
                $edits          = $diff->getOps();
1019
                $exec_time      = sprintf('%.3f sec', gettimeofday(true) - $start_time);
1020
                $rendered_diff  = $diff->renderDiffToHTML((4 != $granularity));
1021
                $rendering_time = sprintf('%.3f sec', gettimeofday(true) - $start_time);
1022
            }
1023
1024
            //        $opcodes = FineDiff::getDiffOpcodes($from, $to);
1025
            //        $to_text = FineDiff::renderToTextFromOpcodes($origdescription, $opcodes);
1026
1027
            $diff           = new FineDiffHTML($from, $to, $granularityStacks[$granularity]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $granularityStacks does not seem to be defined for all execution paths leading up to this point.
Loading history...
1028
            $edits          = $diff->getOps();
1029
            $exec_time      = sprintf('%.3f sec', gettimeofday(true) - $start_time);
1030
            $rendered_diff  = $diff->renderDiffToHTML((4 != $granularity));
1031
            $rendering_time = sprintf('%.3f sec', gettimeofday(true) - $start_time);
1032
1033
            if (false !== $edits) {
1034
                $opcodes     = [];
1035
                $opcodes_len = 0;
1036
                foreach ($edits as $edit) {
1037
                    $opcode      = $edit->getOpcode();
1038
                    $opcodes_len += mb_strlen($opcode);
1039
                    $opcode      = htmlentities($opcode);
1040
                    if ($edit instanceof FineDiffCopyOp) {
0 ignored issues
show
Bug introduced by
The type FineDiffCopyOp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1041
                        $opcodes[] = (string)($opcode);
1042
                    } elseif ($edit instanceof FineDiffDeleteOp) {
0 ignored issues
show
Bug introduced by
The type FineDiffDeleteOp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1043
                        $opcodes[] = "<span class=\"del\">{$opcode}</span>";
1044
                    } elseif ($edit instanceof FineDiffInsertOp) {
0 ignored issues
show
Bug introduced by
The type FineDiffInsertOp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1045
                        $opcodes[] = "<span class=\"ins\">{$opcode}</span>";
1046
                    } else /* if ( $edit instanceof FineDiffReplaceOp ) */ {
1047
                        $opcodes[] = "<span class=\"rep\">{$opcode}</span>";
1048
                    }
1049
                }
1050
                $opcodes     = implode('', $opcodes);
1051
                $opcodes_len = sprintf('%d bytes (%.1f %% of &quot;To&quot;)', $opcodes_len, $to_len ? $opcodes_len * 100 / $to_len : 0);
1052
            } else {
1053
                $opcodes     = '?';
1054
                $opcodes_len = '?';
1055
            }
1056
1057
            //    $granularity = 2;
1058
1059
            echo (string)($opcodes);
1060
            echo '<br><br>=================================================<br><br>';
1061
            echo $opcodes_len;
1062
            echo '<br><br>=================================================<br><br>'; ?>
1063
1064
1065
            <form action="main.php?op=listModReq" method="post">
1066
                <div class="panecontainer"><p>From:</p>
1067
                    <div><textarea name="from" class="pane"><?php
1068
1069
                            //                            $bingo = '<div><pre>';
1070
                            $bingo .= '<span style="color:red">WARNING! Once these categories are set and users have entered data, you should not change them.</span>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $bingo seems to be never defined.
Loading history...
1071
                            $bingo .= $from;
1072
                            //                            $bingo .= '</pre></div>';
1073
                            echo $bingo;
1074
1075
                            //                            echo htmlentities($from);?></textarea></div>
1076
1077
                </div>
1078
                <div class="panecontainer"><p>To:</p>
1079
                    <div><textarea name="to" class="pane"><?php echo htmlentities($to); ?></textarea></div>
1080
                </div>
1081
                <p id="params">Granularity:<input name="granularity" type="radio" value="0"<?php if (0 === $granularity) {
1082
                        echo ' checked="checked"';
1083
                    } ?>>&thinsp;Paragraph/lines&ensp;<input name="granularity" type="radio" value="1"<?php if (1 === $granularity) {
1084
                        echo ' checked="checked"';
1085
                    } ?>>&thinsp;Sentence&ensp;<input name="granularity" type="radio" value="2"<?php if (2 === $granularity) {
1086
                        echo ' checked="checked"';
1087
                    } ?>>&thinsp;Word&ensp;<input name="granularity" type="radio" value="3"<?php if (3 === $granularity) {
1088
                        echo ' checked="checked"';
1089
                    } ?>>&thinsp;Character&ensp;<input name="granularity" type="radio" value="4"<?php if (4 === $granularity) {
1090
                        echo ' checked="checked"';
1091
                    } ?>>&thinsp;Binary&emsp;<!-- <input name="XDEBUG_PROFILE" type="hidden" value=""> --><input type="submit" value="Compute diff">&emsp;<input name="stdlib" type="checkbox" value="1"<?php if ($use_stdlib_diff) {
1092
                        echo ' checked="checked"';
1093
                    } ?>><a href="http://pear.php.net/package/Text_Diff/"><code>Text_Diff</code></a> lib (for comparison purpose) <sup style="font-size:x-small"><a href="#notes">see notes</a></sup></p>
1094
            </form>
1095
            <div class="panecontainer"><p>Diff stats:</p>
1096
                <div>
1097
                    <div class="pane">
1098
                        <b>Diff execution time:</b> <?php echo $exec_time; ?><br>
1099
                        <b>Diff execution + rendering time:</b> <?php echo $rendering_time; ?><br>
1100
                        <b>&quot;From&quot; size:</b> <?php echo $from_len; ?> bytes<br>
1101
                        <b>&quot;To&quot; size:</b> <?php echo $to_len; ?> bytes<br>
1102
                        <b>Diff opcodes size:</b> <?php echo $opcodes_len; ?><br>
1103
                        <b>Diff opcodes (<span style="border:1px solid #ccc;display:inline-block;width:16px">&nbsp;</span>=copy, <span class="del" style="display:inline-block;width:16px">&nbsp;</span>=delete, <span class="ins" style="display:inline-block;width:16px">&nbsp;</span>=insert, <span
1104
                                    class="rep" style="display:inline-block;width:16px">&nbsp;</span>=replace):</b>
1105
                        <div style="margin:2px 0 2px 0;border:0;border-top:1px dotted #aaa;padding-top:4px;word-wrap:break-word"><?php echo $opcodes; ?></div>
1106
                    </div>
1107
                </div>
1108
            </div>
1109
            <div class="panecontainer"><p>Rendered Diff:&emsp;<span style="font-size:smaller">Show <input type="radio" name="htmldiffshow" onclick="setHTMLDiffVisibility('deletions');">Deletions only&ensp;<input type="radio" name="htmldiffshow" checked="checked" onclick="setHTMLDiffVisibility();">All&ensp;<input
1110
                                type="radio" name="htmldiffshow" onclick="setHTMLDiffVisibility('insertions');">Insertions only</span></p>
1111
                <div id="htmldiff">
1112
                    <div class="pane" style="white-space:pre-wrap"><?php echo $rendered_diff; ?></div>
1113
                </div>
1114
            </div>
1115
            <script type="text/javascript">
1116
                <!--
1117
                function setHTMLDiffVisibility(what) {
1118
                    var htmldiffEl = document.getElementById('htmldiff');
1119
                    if (what === 'deletions') {
1120
                        htmldiffEl.className = 'onlyDeletions';
1121
                    } else if (what === 'insertions') {
1122
                        htmldiffEl.className = 'onlyInsertions';
1123
                    } else {
1124
                        htmldiffEl.className = '';
1125
                    }
1126
                }
1127
1128
                // -->
1129
            </script>
1130
            </div>
1131
1132
            <?php
1133
        }
1134
1135
        echo '    </td></tr></table>';
1136
    } else {
1137
        echo '      <em>' . _MD_MYLINKS_NOMODREQ . "</em>\n";
1138
    }
1139
    echo "    </td>\n" . "  </tr>\n" . "</table>\n";
1140
1141
    echo $bingo;
1142
    echo $from;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $from does not seem to be defined for all execution paths leading up to this point.
Loading history...
1143
    echo $to;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $to does not seem to be defined for all execution paths leading up to this point.
Loading history...
1144
1145
    require_once __DIR__ . '/admin_footer.php';
1146
}
1147
1148
function changeModReq()
1149
{
1150
    global $xoopsDB, $myts;
1151
1152
    $requestid = Mylinks\Utility::cleanVars($_POST, 'requestid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'requestid' 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

1152
    $requestid = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'requestid', 0, 'int', ['min' => 0]);
Loading history...
1153
    $query     = 'SELECT lid, cid, title, url, logourl, description FROM ' . $xoopsDB->prefix('mylinks_mod') . " WHERE requestid='{$requestid}'";
1154
    $result    = $xoopsDB->query($query);
1155
    while (list($lid, $cid, $title, $url, $logourl, $description) = $xoopsDB->fetchRow($result)) {
1156
        $url         = addslashes($url);
1157
        $logourl     = addslashes($logourl);
1158
        $title       = addslashes($title);
1159
        $description = addslashes($description);
1160
1161
        $sql    = sprintf("UPDATE `%s` SET cid = %u, title = '%s', url = '%s', logourl = '%s', STATUS = 1, DATE = %u WHERE lid = %u", $xoopsDB->prefix('mylinks_links'), $cid, $title, $url, $logourl, time(), $lid);
1162
        $result = $xoopsDB->query($sql);
1163
        if (!$result) {
1164
            Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1164
            /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
Loading history...
1165
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1166
        }
1167
        $sql    = sprintf("UPDATE `%s` SET description = '%s' WHERE lid = %u", $xoopsDB->prefix('mylinks_text'), $description, $lid);
1168
        $result = $xoopsDB->query($sql);
1169
        if (!$result) {
1170
            Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1170
            /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
Loading history...
1171
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1172
        }
1173
        $sql = sprintf('DELETE FROM `%s` WHERE requestid = %u', $xoopsDB->prefix('mylinks_mod'), $requestid);
1174
        $xoopsDB->query($sql);
1175
        if (!$result) {
1176
            Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1176
            /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
Loading history...
1177
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1178
        }
1179
    }
1180
    redirect_header('index.php', 2, _MD_MYLINKS_DBUPDATED);
1181
}
1182
1183
function ignoreModReq()
1184
{
1185
    global $xoopsDB;
1186
1187
    $requestid = Mylinks\Utility::cleanVars($_POST, 'requestid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'requestid' 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

1187
    $requestid = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'requestid', 0, 'int', ['min' => 0]);
Loading history...
1188
    $sql       = sprintf('DELETE FROM `%s` WHERE requestid = %u', $xoopsDB->prefix('mylinks_mod'), $requestid);
1189
    $result    = $xoopsDB->query($sql);
1190
    if (!$result) {
1191
        Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1191
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
Loading history...
1192
    } else {
1193
        Mylinks\Utility::show_message(_MD_MYLINKS_MODREQDELETED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1193
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_MODREQDELETED);
Loading history...
1194
    }
1195
    exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1196
}
1197
1198
function modLinkS()
1199
{
1200
    global $xoopsDB, $myts;
1201
1202
    $cid         = Mylinks\Utility::cleanVars($_POST, 'cid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'cid' 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

1202
    $cid         = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'cid', 0, 'int', ['min' => 0]);
Loading history...
1203
    $lid         = Mylinks\Utility::cleanVars($_POST, 'lid', 0, 'int', ['min' => 0]);
1204
    $bknrptid    = Mylinks\Utility::cleanVars($_POST, 'bknrptid', 0, 'int', ['min' => 0]);
1205
    $url         = Mylinks\Utility::cleanVars($_POST, 'url', '', 'string');
1206
    $logourl     = Mylinks\Utility::cleanVars($_POST, 'logourl', '', 'string');
1207
    $title       = Mylinks\Utility::cleanVars($_POST, 'title', '', 'string');
1208
    $description = Mylinks\Utility::cleanVars($_POST, 'description', '', 'string');
1209
    /*
1210
        $url     = $myts->addSlashes($url);
1211
        $logourl = $myts->addSlashes($_POST['logourl']);
1212
        $title   = $myts->addSlashes($_POST['title']);
1213
        $description = $myts->addSlashes($_POST['description']);
1214
    */
1215
    $xoopsDB->query('UPDATE ' . $xoopsDB->prefix('mylinks_links') . " SET cid='{$cid}', title='{$title}', url='{$url}', logourl='{$logourl}', status='2', date=" . time() . " WHERE lid='{$lid}'");
1216
    $result = $xoopsDB->query('UPDATE ' . $xoopsDB->prefix('mylinks_text') . " SET description='{$description}' where lid='{$lid}'");
1217
    if (!$result) {
1218
        redirect_header('main.php', 2, _MD_MYLINKS_DBNOTUPDATED);
1219
    }
1220
    if ($bknrptid) {
1221
        // edit came after following link from a broken report, so delete broken report too
1222
        $sql    = sprintf('DELETE FROM `%s` WHERE reportid = %u', $xoopsDB->prefix('mylinks_broken'), $bknrptid);
1223
        $result = $xoopsDB->query($sql);
1224
        if (!$result) {
1225
            Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1225
            /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
Loading history...
1226
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1227
        }
1228
    }
1229
    redirect_header('index.php', 1, _MD_MYLINKS_DBUPDATED);
1230
}
1231
1232
function delLink()
1233
{
1234
    global $xoopsDB, $xoopsModule;
1235
    $lid = Mylinks\Utility::cleanVars($_GET, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'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

1235
    $lid = Mylinks\Utility::cleanVars($_GET, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
1236
1237
    $dbTables = ['links', 'text', 'votedata', 'broken', 'mod'];
1238
    foreach ($dbTables as $thisTable) {
1239
        $sql    = sprintf('DELETE FROM `%s` WHERE lid = %u', $xoopsDB->prefix("mylinks_{$thisTable}"), $lid);
1240
        $result = $xoopsDB->query($sql);
1241
        if (!$result) {
1242
            Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1242
            /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
Loading history...
1243
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1244
        }
1245
    }
1246
    // delete comments & notifications
1247
    xoops_comment_delete($xoopsModule->getVar('mid'), $lid);
1248
    xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $lid);
1249
1250
    redirect_header('index.php', 2, _MD_MYLINKS_LINKDELETED);
1251
}
1252
1253
function modCat()
1254
{
1255
    global $xoopsDB, $myts, $xoopsModule;
1256
1257
    $cid = Mylinks\Utility::cleanVars($_GET, 'cid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'cid' 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

1257
    $cid = Mylinks\Utility::cleanVars($_GET, /** @scrutinizer ignore-type */ 'cid', 0, 'int', ['min' => 0]);
Loading history...
1258
    xoops_cp_header();
1259
1260
    /** @var \XoopsModules\Mylinks\Helper $helper */
1261
    $helper = \XoopsModules\Mylinks\Helper::getInstance();
1262
    echo '<h4>' . _MD_MYLINKS_WEBLINKSCONF . "</h4>\n" . "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . '  <tr><th>' . _MD_MYLINKS_MODCAT . "<br></th></tr>\n" . "  <tr class='odd'>\n" . "    <td>\n";
1263
    $categoryHandler = $helper->getHandler('Category');
1264
    $catObj            = $categoryHandler->get($cid);
1265
1266
    if (isset($catObj) && is_object($catObj)) {
1267
        $criteria = new \CriteriaCompo();
1268
        $criteria->add(new \Criteria('cid', $cid, '!='));
1269
        $catListObjs = $categoryHandler->getAll($criteria);
1270
        $catListTree = new \XoopsObjectTree($catListObjs, 'cid', 'pid');
1271
1272
        $title  = $myts->htmlSpecialChars($catObj->getVar('title'));
1273
        $imgurl = $myts->htmlSpecialChars($catObj->getVar('imgurl'), 'n');
1274
        $pid    = $catObj->getVar('pid');
1275
        echo "      <form action='main.php' method='post'>" . _MD_MYLINKS_TITLEC . "\n" . "        <input type='text' name='title' value='{$title}' size='51' maxlength='50'>\n" . "        <br><br>\n";
1276
        if (0 == $catObj->getVar('pid')) {
1277
            echo '        ' . _MD_MYLINKS_IMGURLMAIN . "<br>\n" . "        <input type='text' name='imgurl' value='{$imgurl}' size='100' maxlength='150'>\n" . "        <br><br>\n";
1278
        }
1279
        echo '        '
1280
             . _MD_MYLINKS_PARENT
1281
             . "&nbsp;\n"
1282
             . '        '
1283
             . $catListTree->makeSelBox('pid', 'title', '- ', $pid, true)
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

1283
             . /** @scrutinizer ignore-deprecated */ $catListTree->makeSelBox('pid', 'title', '- ', $pid, true)

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...
Bug introduced by
It seems like $pid can also be of type array and array; however, parameter $selected of XoopsObjectTree::makeSelBox() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

1283
             . $catListTree->makeSelBox('pid', 'title', '- ', /** @scrutinizer ignore-type */ $pid, true)
Loading history...
1284
             . "\n"
1285
             . "        <br>\n"
1286
             . "        <input type='hidden' name='cid' value='{$cid}'>\n"
1287
             . "        <input type='hidden' name='op' value='modCatS'><br>\n"
1288
             . "        <input type='submit' value='"
1289
             . _MD_MYLINKS_SAVE
1290
             . "'>\n"
1291
             . "        <input type='button' value='"
1292
             . _DELETE
1293
             . "' onclick=\"location='main.php?pid={$pid}&amp;cid={$cid}&amp;op=delCat'\">&nbsp;\n"
1294
             . "        <input type='button' value='"
1295
             . _CANCEL
1296
             . "' onclick=\"javascript:history.go(-1)\">\n"
1297
             . "      </form>\n";
1298
    } else {
1299
        echo '  <tr><td>' . _MD_MYLINKS_CIDERROR . "</td></tr>\n" . "  <tr><td><input type='button' value='" . _BACK . "' onclick=\"javascript:history.go(-1)\"></td></tr>\n";
1300
    }
1301
    echo "    </td>\n" . "  </tr>\n" . "</table>\n";
1302
    require_once __DIR__ . '/admin_footer.php';
1303
}
1304
1305
function modCatS()
1306
{
1307
    global $xoopsDB, $myts, $xoopsModule;
1308
    /** @var \XoopsModules\Mylinks\Helper $helper */
1309
    $helper = \XoopsModules\Mylinks\Helper::getInstance();
1310
1311
    $cid    = Mylinks\Utility::cleanVars($_POST, 'cid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'cid' 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

1311
    $cid    = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'cid', 0, 'int', ['min' => 0]);
Loading history...
1312
    $imgurl = Mylinks\Utility::cleanVars($_POST, 'imgurl', '', 'string');
1313
    $title  = Mylinks\Utility::cleanVars($_POST, 'title', '', 'string');
1314
    //    $title  = $myts->addSlashes($title);
1315
1316
    if (empty($title)) {
1317
        redirect_header('index.php', 3, _MD_MYLINKS_ERRORTITLE);
1318
    }
1319
1320
    //    $imgurl = $myts->addSlashes($imgurl);
1321
    $updateInfo = [
1322
        'pid'    => \Xmf\Request::getInt('pid', 0, 'POST'),
1323
        //                        'title'  =>  $myts->addSlashes($_POST['title']),
1324
        'title'  => $title,
1325
        'imgurl' => $imgurl,
1326
    ];
1327
1328
    $categoryHandler = $helper->getHandler('Category');
1329
    $catObj            = $categoryHandler->get($cid);
1330
1331
    if (isset($catObj) && is_object($catObj)) {
1332
        $catObj->setVars($updateInfo);
1333
        $result = $categoryHandler->insert($catObj);
1334
    } else {
1335
        $result = false;
1336
    }
1337
1338
    if (!$result) {
1339
        Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1339
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_DBNOTUPDATED);
Loading history...
1340
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1341
    }
1342
    redirect_header('index.php', 2, _MD_MYLINKS_DBUPDATED);
1343
}
1344
1345
function delCat()
1346
{
1347
    global $xoopsDB, $myCatTree, $xoopsModule, $xoopsUser;
1348
    /** @var \XoopsModules\Mylinks\Helper $helper */
1349
    $helper = \XoopsModules\Mylinks\Helper::getInstance();
1350
1351
    $cid = Mylinks\Utility::cleanVars($_REQUEST, 'cid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'cid' 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

1351
    $cid = Mylinks\Utility::cleanVars($_REQUEST, /** @scrutinizer ignore-type */ 'cid', 0, 'int', ['min' => 0]);
Loading history...
1352
    $ok  = Mylinks\Utility::cleanVars($_POST, 'ok', 0, 'int', ['min' => 0, 'max' => 1]);
1353
1354
    if (1 == $ok) {
1355
        /**
1356
         * nickname code:
1357
         *
1358
         *  get all subcategories
1359
         *  get all links in these categories/subcategories
1360
         *  get all links in category & subcategories
1361
         *  delete all links in links, text, votedata, broken, & mod db tables that are in any of these categories
1362
         *  delete all comments and notifications for the links that have been deleted
1363
         *  delete category and all subcategories from category db table
1364
         *  delete all notifications for the categories that have been deleted
1365
         */
1366
        $categoryHandler = $helper->getHandler('Category');
1367
1368
        //get all subcategories under the specified category
1369
        $catObjArr = $myCatTree->getAllChild($cid);
1370
        $cidArray  = [];
1371
        foreach ($catObjArr as $catObj) {
1372
            $cidArray[] = $catObj->getVar('cid');
1373
        }
1374
1375
        array_push($cidArray, $cid); //add this category id to the array
1376
        $catIDs   = implode(',', $cidArray);
1377
        $criteria = new \CriteriaCompo();
1378
        $criteria->add(new \Criteria('cid', '(' . (int)$cid . ',' . $catIDs . ')', 'IN'));
1379
1380
        // get list ids in any of these categories
1381
        $sql    = sprintf('SELECT lid FROM `%s` WHERE cid IN %s', $xoopsDB->prefix('mylinks_links'), "({$catIDs})");
1382
        $result = $xoopsDB->query($sql);
1383
        if (!$result) {
1384
            Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1384
            /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1385
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1386
        }
1387
        $lidArray = $xoopsDB->fetchArray($result);
1388
1389
        // delete any links, link notifications and link comments from the database tables
1390
        if ($lidArray) {
1391
            $linkIDs  = '(' . implode(',', $lidArray) . ')';
1392
            $dbTables = ['links', 'text', 'votedata', 'broken', 'mod'];
1393
            foreach ($dbTables as $thisTable) {
1394
                $sql    = sprintf('DELETE FROM `%s` WHERE lid IN %s', $xoopsDB->prefix("mylinks_{$thisTable}"), $linkIDs);
1395
                $result = $xoopsDB->query($sql);
1396
                if (!$result) {
1397
                    Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1397
                    /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1398
                    exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1399
                }
1400
            }
1401
            // remove any notifications and comments for these listings
1402
            foreach ($lidArray as $this_lid) {
1403
                xoops_comment_delete($xoopsModule->getVar('mid'), $this_lid);
1404
                xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $this_lid);
1405
            }
1406
        }
1407
        // delete category and all subcategories from database
1408
        if (!$categoryHandler->deleteAll($criteria)) {
1409
            redirect_header('main.php', 2, _MD_MYLINKS_NORECORDFOUND);
1410
        }
1411
1412
        // delete the notification settings for each (sub)category
1413
        foreach ($cidArray as $key => $id) {
1414
            xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $id);
1415
        }
1416
1417
        redirect_header('index.php', 2, _MD_MYLINKS_CATDELETED);
1418
    } else {
1419
        xoops_cp_header();
1420
        xoops_confirm(['op' => 'delCat', 'cid' => $cid, 'ok' => 1], 'main.php', _MD_MYLINKS_WARNING);
1421
        require_once __DIR__ . '/admin_footer.php';
1422
    }
1423
}
1424
1425
function delNewLink()
1426
{
1427
    global $xoopsDB, $xoopsModule;
1428
    $lid = Mylinks\Utility::cleanVars($_GET, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'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

1428
    $lid = Mylinks\Utility::cleanVars($_GET, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
1429
1430
    $sql    = sprintf('DELETE FROM `%s` WHERE lid = %u', $xoopsDB->prefix('mylinks_links'), $lid);
1431
    $result = $xoopsDB->query($sql);
1432
    if (!$result) {
1433
        redirect_header('main.php', 2, _MD_MYLINKS_NORECORDFOUND);
1434
    }
1435
    $sql    = sprintf('DELETE FROM `%s` WHERE lid = %u', $xoopsDB->prefix('mylinks_text'), $lid);
1436
    $result = $xoopsDB->query($sql);
1437
    if (!$result) {
1438
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1438
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1439
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1440
    }
1441
    // delete comments
1442
    xoops_comment_delete($xoopsModule->getVar('mid'), $lid);
1443
    // delete notifications
1444
    xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $lid);
1445
    redirect_header('index.php', 2, _MD_MYLINKS_LINKDELETED);
1446
}
1447
1448
function addCat()
1449
{
1450
    global $xoopsDB, $myts, $xoopsModule;
1451
    /** @var \XoopsModules\Mylinks\Helper $helper */
1452
    $helper = \XoopsModules\Mylinks\Helper::getInstance();
1453
1454
    $pid    = Mylinks\Utility::cleanVars($_POST, 'pid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'pid' 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

1454
    $pid    = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'pid', 0, 'int', ['min' => 0]);
Loading history...
1455
    $title  = Mylinks\Utility::cleanVars($_POST, 'title', '', 'string');
1456
    $imgurl = Mylinks\Utility::cleanVars($_POST, 'imgurl', '', 'string');
1457
    /*
1458
        $title  = $myts->addSlashes($title);
1459
        $imgurl = $myts->addSlashes($imgurl);
1460
    */
1461
    if (empty($title)) {
1462
        redirect_header('index.php', 2, _MD_MYLINKS_ERRORTITLE);
1463
    }
1464
1465
    $newCatVars = [
1466
        'pid'    => $pid,
1467
        'title'  => $title,
1468
        'imgurl' => $imgurl,
1469
    ];
1470
1471
    $categoryHandler = $helper->getHandler('Category');
1472
    $newCatObj         = $categoryHandler->create();
1473
    $newCatObj->setVars($newCatVars);
1474
    $newCatId = $categoryHandler->insert($newCatObj);
1475
    if ($newCatId) {
1476
        //now update notification handler & trigger new cat added event
1477
        $tags                  = [];
1478
        $tags['CATEGORY_NAME'] = $title;
1479
        $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $newCatId;
1480
        $notificationHandler   = xoops_getHandler('notification');
1481
        $notificationHandler->triggerEvent('global', 0, 'new_category', $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

1481
        $notificationHandler->/** @scrutinizer ignore-call */ 
1482
                              triggerEvent('global', 0, 'new_category', $tags);
Loading history...
1482
        redirect_header('index.php', 2, _MD_MYLINKS_NEWCATADDED);
1483
    } else {
1484
        redirect_header('index.php', 2, _MD_MYLINKS_DBNOTUPDATED);
1485
    }
1486
}
1487
1488
function importCats()
1489
{
1490
    global $xoopsDB, $xoopsModule, $xoopsConfig, $myts;
1491
    /** @var \XoopsModules\Mylinks\Helper $helper */
1492
    $helper = \XoopsModules\Mylinks\Helper::getInstance();
1493
1494
    $ok = Mylinks\Utility::cleanVars($_POST, 'ok', 0, 'int', ['min' => 0, 'max' => 1]);
0 ignored issues
show
Bug introduced by
'ok' 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

1494
    $ok = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'ok', 0, 'int', ['min' => 0, 'max' => 1]);
Loading history...
1495
    if (1 == $ok) {
1496
        if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/sql/mylinks_cat.dat')) {
1497
            $importFile = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/sql/mylinks_cat.dat';
1498
        } else {
1499
            $importFile = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/sql/mylinks_cat.dat';
1500
        }
1501
1502
        if (file_exists($importFile)) {
1503
            /* the following will not work on some shared servers even though it's the most efficient
1504
            $sql = "LOAD DATA INFILE '{$importFile}' INTO TABLE " . $xoopsDB->prefix('mylinks_cat') . " FIELDS TERMINATED BY ',' IGNORE 1 LINES";
1505
            $result = $xoopsDB->query($sql);
1506
            */
1507
1508
            if (false !== ($handle = fopen($importFile, 'r'))) {
1509
                // set 1000 to 0 in the following line if input line is truncated
1510
                while (false !== ($data = fgetcsv($handle, 1000, ','))) {
1511
                    $sql    = sprintf("INSERT INTO `%s` (cid, pid, title, imgurl) VALUES (%u, %u, '%s', '%s')", $xoopsDB->prefix('mylinks_cat'), (int)$data[0], (int)$data[1], $myts->addSlashes($data[2]), $myts->addSlashes($data[3]));
1512
                    $result = $xoopsDB->query($sql);
1513
                    if (!$result) {
1514
                        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1514
                        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1515
                        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1516
                    }
1517
                }
1518
                fclose($handle);
1519
                redirect_header('index.php', 2, _MD_MYLINKS_CATSIMPORTED);
1520
            } else {
1521
                // problem importing categories
1522
                $categoryHandler = $helper->getHandler('Category');
1523
                $result            = $categoryHandler->getAll();
1524
                if (count($result)) {
1525
                    $result = $categoryHandler->deleteAll();  // empty the dB table from partial import
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
1526
                }
1527
                redirect_header('index.php', 2, _MD_MYLINKS_CATSNOTIMPORTED);
1528
            }
1529
        } else {  //exit somewhat gracefully if import file not found
1530
            redirect_header('index.php', 2, sprintf(_MD_MYLINKS_IMPORTFILENOTFOUND, $importFile));
1531
        }
1532
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1533
    }
1534
    xoops_cp_header();
1535
    xoops_confirm(['op' => 'importCats', 'ok' => 1], 'main.php', _MD_MYLINKS_CATWARNING);
1536
    require_once __DIR__ . '/admin_footer.php';
1537
}
1538
1539
function addLink()
1540
{
1541
    global $xoopsDB, $myts, $xoopsUser, $xoopsModule;
1542
1543
    /** @var \XoopsModules\Mylinks\Helper $helper */
1544
    $helper = \XoopsModules\Mylinks\Helper::getInstance();
1545
1546
    $cid         = Mylinks\Utility::cleanVars($_POST, 'cid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'cid' 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

1546
    $cid         = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'cid', 0, 'int', ['min' => 0]);
Loading history...
1547
    $url         = Mylinks\Utility::cleanVars($_POST, 'url', '', 'string');
1548
    $logourl     = Mylinks\Utility::cleanVars($_POST, 'logourl', '', 'string');
1549
    $title       = Mylinks\Utility::cleanVars($_POST, 'title', '', 'string');
1550
    $description = Mylinks\Utility::cleanVars($_POST, 'descarea', '', 'string');
1551
    /*
1552
        $url           = $myts->addSlashes($url);
1553
        $logourl       = $myts->addSlashes($logourl);
1554
        $title         = $myts->addSlashes($title);
1555
        $description   = $myts->addSlashes($description);
1556
    */
1557
    $submitter = $xoopsUser->uid();
1558
    $result    = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE url='{$url}'");
1559
    list($numrows) = $xoopsDB->fetchRow($result);
1560
    $errormsg = [];
1561
    $error    = false;
1562
    if ($numrows > 0) {
1563
        $errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERROREXIST . '</h4>';
1564
        $error      = true;
1565
    }
1566
    if ('' == $title) {  // check if title exists
1567
        $errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERRORTITLE . '</h4>';
1568
        $error      = true;
1569
    }
1570
    if ('' == $url) {  // check if url exists
1571
        $errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERRORURL . '</h4>';
1572
        $error      = true;
1573
    }
1574
    if ('' == $description) { // check if description exists
1575
        $errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERRORDESC . '</h4>';
1576
        $error      = true;
1577
    }
1578
    if ($error) {
1579
        xoops_cp_header();
1580
        $displayMsg = implode('<br>', $errormsg);
1581
        echo "<div class='center;'><fieldset>{$displayMsg}</fieldset></div>\n";
1582
        xoops_cp_footer();
1583
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1584
    }
1585
1586
    $newid  = $xoopsDB->genId($xoopsDB->prefix('mylinks_links') . '_lid_seq');
1587
    $sql    = sprintf("INSERT INTO `%s` (lid, cid, title, url, logourl, submitter, STATUS, DATE, hits, rating, votes, comments) VALUES (%u, %u, '%s', '%s', '%s', %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix('mylinks_links'), $newid, $cid, $title, $url, $logourl, $submitter, 1, time(), 0, 0, 0, 0);
1588
    $result = $xoopsDB->query($sql);
1589
    if (!$result) {
1590
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1590
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1591
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1592
    }
1593
    if (0 == $newid) {
1594
        $newid = $xoopsDB->getInsertId();
1595
    }
1596
    $sql    = sprintf("INSERT INTO `%s` (lid, description) VALUES (%u, '%s')", $xoopsDB->prefix('mylinks_text'), $newid, $description);
1597
    $result = $xoopsDB->query($sql);
1598
    if (!$result) {
1599
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1599
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1600
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1601
    }
1602
    $tags              = [];
1603
    $tags['LINK_NAME'] = $title;
1604
    $tags['LINK_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/singlelink.php?cid={$cid}&amp;lid={$newid}";
1605
1606
    $categoryHandler     = $helper->getHandler('Category');
1607
    $catObj                = $categoryHandler->get($cid);
1608
    $tags['CATEGORY_NAME'] = $catObj->getVar('title');
1609
    unset($catObj, $categoryHandler);
1610
1611
    $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewcat.php?cid={$cid}";
1612
    $notificationHandler  = xoops_getHandler('notification');
1613
    $notificationHandler->triggerEvent('global', 0, 'new_link', $tags);
1614
    $notificationHandler->triggerEvent('category', $cid, 'new_link', $tags);
1615
    redirect_header('main.php?op=linksConfigMenu', 2, _MD_MYLINKS_NEWLINKADDED);
1616
}
1617
1618
function approve()
1619
{
1620
    global $xoopsDB, $myts, $xoopsModule;
1621
    /** @var \XoopsModules\Mylinks\Helper $helper */
1622
    $helper = \XoopsModules\Mylinks\Helper::getInstance();
1623
1624
    $lid         = Mylinks\Utility::cleanVars($_POST, 'lid', 0, 'int', ['min' => 0]);
0 ignored issues
show
Bug introduced by
'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

1624
    $lid         = Mylinks\Utility::cleanVars($_POST, /** @scrutinizer ignore-type */ 'lid', 0, 'int', ['min' => 0]);
Loading history...
1625
    $cid         = Mylinks\Utility::cleanVars($_POST, 'cid', 0, 'int', ['min' => 0]);
1626
    $title       = Mylinks\Utility::cleanVars($_POST, 'title', '', 'string');
1627
    $url         = Mylinks\Utility::cleanVars($_POST, 'url', '', 'string');
1628
    $logourl     = Mylinks\Utility::cleanVars($_POST, 'logourl', '', 'string');
1629
    $description = Mylinks\Utility::cleanVars($_POST, 'description', '', 'string');
1630
    /*
1631
        $url         = $myts->addSlashes($url);
1632
        $logourl     = $myts->addSlashes($logourl);
1633
        $title       = $myts->addSlashes($title);
1634
        $description = $myts->addSlashes($description);
1635
    */
1636
    $query  = 'UPDATE ' . $xoopsDB->prefix('mylinks_links') . " set cid='{$cid}', title='{$title}', url='{$url}', logourl='{$logourl}', status='1', date=" . time() . " WHERE lid='{$lid}'";
1637
    $result = $xoopsDB->query($query);
1638
    if ($result) {
1639
        $query  = 'UPDATE ' . $xoopsDB->prefix('mylinks_text') . " SET description='{$description}' WHERE lid='{$lid}'";
1640
        $result = $xoopsDB->query($query);
1641
        if (!$result) {
1642
            Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1642
            /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1643
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1644
        }
1645
    } else {
1646
        Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsModules\Mylinks\Utility::show_message() has been deprecated. ( Ignorable by Annotation )

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

1646
        /** @scrutinizer ignore-deprecated */ Mylinks\Utility::show_message(_MD_MYLINKS_NORECORDFOUND);
Loading history...
1647
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1648
    }
1649
    $tags              = [];
1650
    $tags['LINK_NAME'] = $title;
1651
    $tags['LINK_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/singlelink.php?cid={$cid}&amp;lid={$lid}";
1652
    $categoryHandler = $helper->getHandler('Category');
1653
    $catObj            = $categoryHandler->get($cid);
1654
    /*
1655
    $sql = "SELECT title FROM " . $xoopsDB->prefix("mylinks_cat") . " WHERE cid=" . $cid;
1656
    $result = $xoopsDB->query($sql);
1657
    $row = $xoopsDB->fetchArray($result);
1658
    $tags['CATEGORY_NAME'] = $row['title'];
1659
    */
1660
    if ($catObj) {
0 ignored issues
show
introduced by
$catObj is of type XoopsObject, thus it always evaluated to true.
Loading history...
1661
        $tags['CATEGORY_NAME'] = $catObj->getVar('title');
1662
        $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewcat.php?cid={$cid}";
1663
        $notificationHandler   = xoops_getHandler('notification');
1664
        $notificationHandler->triggerEvent('global', 0, 'new_link', $tags);
1665
        $notificationHandler->triggerEvent('category', $cid, 'new_link', $tags);
1666
        $notificationHandler->triggerEvent('link', $lid, 'approve', $tags);
1667
        redirect_header('index.php', 2, _MD_MYLINKS_NEWLINKADDED);
1668
    } else {
1669
        redirect_header('index.php', 2, _MD_MYLINKS_DBNOTUPDATED);
1670
    }
1671
}
1672
1673
$op = Mylinks\Utility::cleanVars($_REQUEST, 'op', 'main', 'string');
0 ignored issues
show
Bug introduced by
'op' 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

1673
$op = Mylinks\Utility::cleanVars($_REQUEST, /** @scrutinizer ignore-type */ 'op', 'main', 'string');
Loading history...
1674
1675
switch ($op) {
1676
    case 'delNewLink':
1677
        delNewLink();
1678
        break;
1679
    case 'approve':
1680
        approve();
1681
        break;
1682
    case 'addCat':
1683
        addCat();
1684
        break;
1685
    case 'importCats':
1686
        importCats();
1687
        break;
1688
    case 'addLink':
1689
        addLink();
1690
        break;
1691
    case 'listBrokenLinks':
1692
        listBrokenLinks();
1693
        break;
1694
    case 'delBrokenLinks':
1695
        delBrokenLinks();
1696
        break;
1697
    case 'ignoreBrokenLinks':
1698
        ignoreBrokenLinks();
1699
        break;
1700
    case 'listModReq':
1701
        listModReq();
1702
        break;
1703
    case 'changeModReq':
1704
        changeModReq();
1705
        break;
1706
    case 'ignoreModReq':
1707
        ignoreModReq();
1708
        break;
1709
    case 'delCat':
1710
        delCat();
1711
        break;
1712
    case 'modCat':
1713
        modCat();
1714
        break;
1715
    case 'modCatS':
1716
        modCatS();
1717
        break;
1718
    case 'modLink':
1719
        modLink();
1720
        break;
1721
    case 'modLinkS':
1722
        modLinkS();
1723
        break;
1724
    case 'delLink':
1725
        delLink();
1726
        break;
1727
    case 'delVote':
1728
        delVote();
1729
        break;
1730
    case 'linksConfigMenu':
1731
    default:
1732
        linksConfigMenu();
1733
        break;
1734
    case 'listNewLinks':
1735
        listNewLinks();
1736
        break;
1737
    case 'main':
1738
        break;
1739
}
1740