Code Duplication    Length = 14-16 lines in 4 locations

class/Admin.php 4 locations

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