Code Duplication    Length = 28-28 lines in 2 locations

class/WallUpdates.php 1 location

@@ 140-167 (lines=28) @@
137
     * @param int $uid
138
     * @return string
139
     */
140
    public function Gravatar($uid)
141
    {
142
        global $xoopsUser, $xoopsDB;
143
        $image  = '';
144
        $sql    = 'SELECT userimage FROM ' . $xoopsDB->prefix('smallworld_user') . " WHERE userid = '" . $uid . "'";
145
        $result = $xoopsDB->queryF($sql);
146
        while ($r = $xoopsDB->fetchArray($result)) {
147
            $image = $r['userimage'];
148
        }
149
150
        $image = ('' == $image || 'blank.gif' === $image) ? smallworld_getAvatarLink($uid, $image) : $image;
151
152
        $type = [
153
            1 => 'jpg',
154
            2 => 'jpeg',
155
            3 => 'png',
156
            4 => 'gif',
157
        ];
158
159
        $ext = explode('.', $image);
160
161
        if (@!in_array(strtolower($ext[1]), $type) || '' == $image) {
162
            $avatar = '';
163
        } else {
164
            $avatar = $image;
165
        }
166
        return $avatar;
167
    }
168
169
    /**
170
     * @Insert update

include/functions.php 1 location

@@ 657-684 (lines=28) @@
654
 * @param $uid
655
 * @return string
656
 */
657
function Smallworld_Gravatar($uid)
658
{
659
    global $xoopsUser, $xoopsDB;
660
    $image  = '';
661
    $sql    = 'SELECT userimage FROM ' . $xoopsDB->prefix('smallworld_user') . " WHERE userid = '" . $uid . "'";
662
    $result = $xoopsDB->queryF($sql);
663
    while ($r = $xoopsDB->fetchArray($result)) {
664
        $image = $r['userimage'];
665
    }
666
667
    $image = ('' == $image || 'blank.gif' === $image) ? smallworld_getAvatarLink($uid, $image) : $image;
668
669
    $type = [
670
        1 => 'jpg',
671
        2 => 'jpeg',
672
        3 => 'png',
673
        4 => 'gif',
674
    ];
675
676
    $ext = explode('.', $image);
677
678
    if (@!in_array(strtolower($ext[1]), $type) || '' == $image) {
679
        $avatar = '';
680
    } else {
681
        $avatar = $image;
682
    }
683
    return $avatar;
684
}
685
686
// find user with most posted messages
687
/**