Code Duplication    Length = 32-32 lines in 2 locations

class/wall.php 1 location

@@ 170-201 (lines=32) @@
167
     * @param int    $priv
168
     * @return array|bool
169
     */
170
    public function Insert_Update($uid, $update, $priv)
171
    {
172
        global $xoopsUser, $xoopsDB;
173
        $update = Smallworld_sanitize(htmlentities($update, ENT_QUOTES, 'UTF-8'));
174
        $time   = time();
175
        if (!isset($priv)) {
176
            $priv = 0;
177
        }
178
        $query  = 'SELECT msg_id,message FROM ' . $xoopsDB->prefix('smallworld_messages') . " WHERE uid_fk='" . $uid . "' ORDER BY msg_id DESC LIMIT 1";
179
        $result = $xoopsDB->queryF($query);
180
        $row = $xoopsDB->fetchArray($result);
181
        if ($update != $row['message']) {
182
            $query    = 'INSERT INTO ' . $xoopsDB->prefix('smallworld_messages') . " (message, uid_fk, priv, created) VALUES ('" . $update . "', '" . $uid . "', '" . $priv . "', '" . $time . "')";
183
            $result   = $xoopsDB->queryF($query);
184
            $newquery = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $uid . "' ORDER BY M.msg_id DESC LIMIT 1 ";
185
            $result2  = $xoopsDB->queryF($newquery);
186
            while ($row = $xoopsDB->fetchArray($result2)) {
187
                $data[] = $row;
188
            }
189
            $count = $xoopsDB->getRowsNum($result2);
190
            if ($count < 1) {
191
                return false;
192
            } else {
193
                while ($row = $xoopsDB->fetchArray($result2)) {
194
                    $data[] = $row;
195
                }
196
                if (!empty($data)) {
197
                    return $data;
198
                }
199
            }
200
        }
201
    }
202
203
    /**
204
     * @Insert comment

class/WallUpdates.php 1 location

@@ 175-206 (lines=32) @@
172
     * @param int    $priv
173
     * @return array|bool
174
     */
175
    public function Insert_Update($uid, $update, $priv)
176
    {
177
        global $xoopsUser, $xoopsDB;
178
        $update = Smallworld_sanitize(htmlentities($update, ENT_QUOTES, 'UTF-8'));
179
        $time   = time();
180
        if (!isset($priv)) {
181
            $priv = 0;
182
        }
183
        $query  = 'SELECT msg_id,message FROM ' . $xoopsDB->prefix('smallworld_messages') . " WHERE uid_fk='" . $uid . "' ORDER BY msg_id DESC LIMIT 1";
184
        $result = $xoopsDB->queryF($query);
185
        $row = $xoopsDB->fetchArray($result);
186
        if ($update != $row['message']) {
187
            $query    = 'INSERT INTO ' . $xoopsDB->prefix('smallworld_messages') . " (message, uid_fk, priv, created) VALUES ('" . $update . "', '" . $uid . "', '" . $priv . "', '" . $time . "')";
188
            $result   = $xoopsDB->queryF($query);
189
            $newquery = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $uid . "' ORDER BY M.msg_id DESC LIMIT 1 ";
190
            $result2  = $xoopsDB->queryF($newquery);
191
            while ($row = $xoopsDB->fetchArray($result2)) {
192
                $data[] = $row;
193
            }
194
            $count = $xoopsDB->getRowsNum($result2);
195
            if ($count < 1) {
196
                return false;
197
            } else {
198
                while ($row = $xoopsDB->fetchArray($result2)) {
199
                    $data[] = $row;
200
                }
201
                if (!empty($data)) {
202
                    return $data;
203
                }
204
            }
205
        }
206
    }
207
208
    /**
209
     * @Insert comment