Code Duplication    Length = 28-28 lines in 3 locations

class/wall.php 1 location

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

class/WallUpdates.php 1 location

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

include/functions.php 1 location

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