Code Duplication    Length = 14-16 lines in 4 locations

class/Admin.php 4 locations

@@ 147-162 (lines=16) @@
144
        $result  = $xoopsDB->queryF($sql);
145
        $counter = $xoopsDB->getRowsNum($result);
146
147
        if ($counter < 1) {
148
            $msg = [];
149
        } else {
150
            $msg = [];
151
            $i   = 1;
152
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
153
                $msg['counter'][$i] = $i;
154
                $msg['img'][$i]     = "<img style='margin:0px 5px;' src = '../assets/images/" . $i . ".png'>";
155
                if ($msg['counter'][$i] > 3) {
156
                    $msg['img'][$i] = '';
157
                }
158
                $msg['cnt'][$i]  = $row['cnt'];
159
                $msg['from'][$i] = $xoopsUser->getUnameFromId($row['uid_fk']);
160
                ++$i;
161
            }
162
        }
163
164
        return $msg;
165
    }
@@ 189-203 (lines=15) @@
186
        $result   = $xoopsDB->queryF($sql);
187
        $msgtoday = [];
188
189
        if (0 != $xoopsDB->getRowsNum($result)) {
190
            $i = 1;
191
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
192
                $msgtoday['counter'][$i] = $i;
193
                $msgtoday['img'][$i]     = "<img style='margin:0px 5px;' src = '../assets/images/" . $i . ".png'>";
194
                if ($msgtoday['counter'][$i] > 3) {
195
                    $msgtoday['img'][$i] = '';
196
                }
197
                $msgtoday['cnt'][$i]  = $row['cnt'];
198
                $msgtoday['from'][$i] = $xoopsUser->getUnameFromId($row['uid_fk']);
199
                ++$i;
200
            }
201
        } else {
202
            $msgtoday = [];
203
        }
204
205
        return $msgtoday;
206
    }
@@ 225-238 (lines=14) @@
222
            $result = $xoopsDB->queryF($sql);
223
            $count  = $xoopsDB->getRowsNum($result);
224
            $i      = 1;
225
            if ($count >= $i) {
226
                while (false !== ($row = $xoopsDB->fetchArray($result))) {
227
                    $array['counter'][$i] = $i;
228
                    $array['img'][$i]     = "<img height='10px' width='10px' " . "style='margin:0px 5px;' src = '../assets/images/like.png'>";
229
                    if ($array['counter'][$i] > 3) {
230
                        $array['img'][$i] = '';
231
                    }
232
                    $array['cnt'][$i]  = $row['cnt'];
233
                    $array['user'][$i] = $xoopsUser->getUnameFromId($row['owner']);
234
                    ++$i;
235
                }
236
            } else {
237
                $array = [];
238
            }
239
        } else {
240
            $sql    = 'SELECT owner, count(*) AS cnt FROM ' . $xoopsDB->prefix('smallworld_vote') . " WHERE down='1' GROUP BY owner ORDER BY cnt DESC LIMIT 20";
241
            $result = $xoopsDB->queryF($sql);
@@ 244-257 (lines=14) @@
241
            $result = $xoopsDB->queryF($sql);
242
            $count  = $xoopsDB->getRowsNum($result);
243
            $i      = 1;
244
            if (0 != $count) {
245
                while (false !== ($row = $xoopsDB->fetchArray($result))) {
246
                    $array['counter'][$i] = $i;
247
                    $array['img'][$i]     = "<img height='10px' width='10px' " . "style='margin:0px 5px;' src = '../assets/images/dislike.png'>";
248
                    if ($array['counter'][$i] > 3) {
249
                        $array['img'][$i] = '';
250
                    }
251
                    $array['cnt'][$i]  = $row['cnt'];
252
                    $array['user'][$i] = $xoopsUser->getUnameFromId($row['owner']);
253
                    ++$i;
254
                }
255
            } else {
256
                $array = [];
257
            }
258
        }
259
260
        return $array;