Code Duplication    Length = 108-109 lines in 2 locations

class/db.php 1 location

@@ 178-286 (lines=109) @@
175
     * handlePosts function
176
     * @return void
177
     */
178
    public function handlePosts()
179
    {
180
		
181
        global $xoopsUser, $xoopsDB;
182
        $myts = MyTextSanitizer::getInstance();
183
        $uid  = $xoopsUser->getVar('uid');
184
        $user = new XoopsUser($uid);
185
        $img  = new SmallWorldImages;
186
        if ('' == $this->getVar($uid, 'userimage')) {
187
            $avatar = $user->user_avatar();
188
        } else {
189
            $avatar = $this->getVar($uid, 'userimage');
190
        }
191
192
        if ('2' != $_POST['relationship']) {
193
            $partner = Smallworld_sanitize($_POST['partner']);
194
        } else {
195
            $partner = '';
196
        }
197
198
        $regdate                = time();
199
        $username               = $user->uname();
200
        $realname               = Smallworld_sanitize($_POST['realname']);
201
        $gender                 = isset($_POST['gender']) ? $_POST['gender'] : '';
202
        $intingender            = isset($_POST['intingender']) ? Smallworld_sanitize(serialize($_POST['intingender'])) : Smallworld_sanitize(serialize([0 => '3']));
203
        $relationship           = Smallworld_sanitize($_POST['relationship']);
204
        $searchrelat            = isset($_POST['searchrelat']) ? Smallworld_sanitize(serialize($_POST['searchrelat'])) : Smallworld_sanitize(serialize([0 => '0']));
205
        $birthday               = Smallworld_sanitize(Smallworld_euroToUsDate($_POST['birthday']));
206
        $birthplace             = Smallworld_sanitize($_POST['birthplace']);
207
        $birthplace_lat         = Smallworld_sanitize($_POST['birthplace_lat']);
208
        $birthplace_lng         = Smallworld_sanitize($_POST['birthplace_lng']);
209
        $birthplace_country     = Smallworld_sanitize($_POST['birthplace_country']);
210
        $birthplace_country_img = isset($_POST['birthplace_country_img']) ? Smallworld_sanitize($_POST['birthplace_country_img']) : '';
211
        $politic                = Smallworld_sanitize($_POST['politic']);
212
        $religion               = Smallworld_sanitize($_POST['religion']);
213
        $emailtype              = Smallworld_sanitize(serialize($_POST['emailtype']));
214
        $screenname_type        = Smallworld_sanitize(serialize($_POST['screenname_type']));
215
        $screenname             = Smallworld_sanitize(serialize($_POST['screenname']));
216
        $mobile                 = Smallworld_sanitize($_POST['mobile']);
217
        $phone                  = Smallworld_sanitize($_POST['phone']);
218
        $adress                 = Smallworld_sanitize($_POST['adress']);
219
        $present_city           = Smallworld_sanitize($_POST['present_city']);
220
        $present_lat            = Smallworld_sanitize($_POST['present_lat']);
221
        $present_lng            = Smallworld_sanitize($_POST['present_lng']);
222
        $present_country        = Smallworld_sanitize($_POST['present_country']);
223
        $present_country_img    = isset($_POST['present_country_img']) ? Smallworld_sanitize($_POST['present_country_img']) : '';
224
        $website                = Smallworld_sanitize($_POST['website']);
225
        $interests              = Smallworld_sanitize($_POST['interests']);
226
        $music                  = Smallworld_sanitize($_POST['music']);
227
        $tvshow                 = Smallworld_sanitize($_POST['tvshow']);
228
        $movie                  = Smallworld_sanitize($_POST['movie']);
229
        $books                  = Smallworld_sanitize($_POST['books']);
230
        $aboutme                = Smallworld_sanitize($_POST['aboutme']);
231
        $school_type            = Smallworld_sanitize(serialize($_POST['school_type']));
232
        $school                 = Smallworld_sanitize(serialize($_POST['school']));
233
        $schoolstart            = Smallworld_sanitize(serialize($_POST['schoolstart']));
234
        $schoolstop             = Smallworld_sanitize(serialize($_POST['schoolstop']));
235
        $jobemployer            = Smallworld_sanitize(serialize($_POST['employer']));
236
        $jobposition            = Smallworld_sanitize(serialize($_POST['position']));
237
        $jobstart               = Smallworld_sanitize(serialize(Smallworld_YearOfArray($_POST['jobstart'])));
238
        $jobstop                = Smallworld_sanitize(serialize(Smallworld_YearOfArray($_POST['jobstop'])));
239
        $jobdescription         = Smallworld_sanitize(serialize($_POST['description']));
240
241
        $sql = '';
242
243
        if ('edit' === $_POST['function']) {
244
            // Update all values in user_table
245
            $sql    = 'UPDATE ' . $xoopsDB->prefix('smallworld_user') . ' SET ';
246
            $sql    .= "realname = '" . $realname . "', username= '" . $username . "', userimage = '" . $avatar . "', gender = '" . $gender . "',";
247
            $sql    .= "intingender = '" . $intingender . "',relationship = '" . $relationship . "', partner = '" . $partner . "', searchrelat = '" . $searchrelat . "',";
248
            $sql    .= "birthday = '" . $birthday . "',birthplace = '" . $birthplace . "',birthplace_lat = '" . (float)$birthplace_lat . "',";
249
            $sql    .= "birthplace_lng = '" . (float)$birthplace_lng . "',birthplace_country = '" . $birthplace_country . "',politic = '" . $politic . "',";
250
            $sql    .= "religion = '" . $religion . "',emailtype = '" . $emailtype . "',screenname_type = '" . $screenname_type . "',";
251
            $sql    .= "screenname = '" . $screenname . "',mobile = '" . (float)$mobile . "',phone = '" . (float)$phone . "',adress = '" . $adress . "',";
252
            $sql    .= "present_city = '" . $present_city . "',present_lat = '" . (float)$present_lat . "',present_lng = '" . (float)$present_lng . "',";
253
            $sql    .= "present_country = '" . $present_country . "',website = '" . $website . "',interests = '" . $interests . "',";
254
            $sql    .= "music = '" . $music . "',tvshow = '" . $tvshow . "',movie = '" . $movie . "',";
255
            $sql    .= "books = '" . $books . "',aboutme = '" . $aboutme . "',school_type = '" . $school_type . "',";
256
            $sql    .= "school = '" . $school . "', schoolstart = '" . $schoolstart . "',schoolstop = '" . $schoolstop . "',";
257
            $sql    .= "employer = '" . $jobemployer . "', position = '" . $jobposition . "',jobstart = '" . $jobstart . "',";
258
            $sql    .= "jobstop = '" . $jobstop . "', description = '" . $jobdescription . "' ";
259
            $sql    .= "WHERE userid ='" . (int)$uid . "'";
260
            $result = $xoopsDB->queryF($sql);
261
            if (false === $result) {
262
                die('SQL error:' . $sql . '');
263
            }
264
265
            $this->EditAdmins($uid, $realname, $avatar);
266
            $img->createAlbum($uid);
267
        }
268
		
269
        if ('save' === $_POST['function']) {
270
            $sql    = 'INSERT INTO '
271
                      . $xoopsDB->prefix('smallworld_user')
272
                      . ' (userid, regdate, username, userimage, realname, gender, intingender, relationship, partner, searchrelat, birthday, birthplace, birthplace_lat, birthplace_lng, birthplace_country, politic, religion, emailtype, screenname_type, screenname, mobile, phone, adress, present_city, present_lat, present_lng, present_country, website, interests, music, tvshow, movie, books, aboutme, school_type, school, schoolstart, schoolstop, employer, position, jobstart, jobstop, description, friends, followers, admin_flag) ';
273
            $sql    .= "VALUES ('" . (int)$uid . "', '" . $regdate . "', '" . $username . "', '" . $avatar . "', '" . $realname . "', '" . $gender . "', '" . $intingender . "', '" . $relationship . "', '" . $partner . "', '" . $searchrelat . "','";
274
            $sql    .= $birthday . "', '" . $birthplace . "', '" . (float)$birthplace_lat . "', '" . (float)$birthplace_lng . "', '" . $birthplace_country . "', '" . $politic . "', '" . $religion . "','";
275
            $sql    .= $emailtype . "', '" . $screenname_type . "', '" . $screenname . "', '" . (float)$mobile . "', '" . (float)$phone . "', '" . $adress . "', '" . $present_city . "', '" . (float)$present_lat . "','";
276
            $sql    .= (float)$present_lng . "', '" . $present_country . "', '" . $website . "', '" . $interests . "', '" . $music . "', '" . $tvshow . "', '" . $movie . "', '" . $books . "', '" . $aboutme . "', '";
277
            $sql    .= $school_type . "', '" . $school . "', '" . $schoolstart . "', '" . $schoolstop . "', '" . $jobemployer . "', '" . $jobposition . "', '" . $jobstart . "', '" . $jobstop . "', '" . $jobdescription . "', ";
278
            $sql    .= "'0', '0', '0')";
279
            $result = $xoopsDB->queryF($sql);
280
            if (false === $result) {
281
                die('SQL error:' . $sql . '');
282
            }
283
            $this->SetAdmins($uid, $username, $realname, $avatar);
284
            $img->createAlbum($uid);
285
        }
286
    }
287
288
    /**
289
     * SetAdmins function

class/SmallWorldDB.php 1 location

@@ 182-289 (lines=108) @@
179
     * handlePosts function
180
     * @return void
181
     */
182
    public function handlePosts()
183
    {
184
        global $xoopsUser, $xoopsDB;
185
        $myts = \MyTextSanitizer::getInstance();
186
        $uid  = $xoopsUser->getVar('uid');
187
        $user = new \XoopsUser($uid);
188
        $img  = new SmallWorldImages;
189
        if ('' == $this->getVar($uid, 'userimage')) {
190
            $avatar = $user->user_avatar();
191
        } else {
192
            $avatar = $this->getVar($uid, 'userimage');
193
        }
194
195
        if ('2' != $_POST['relationship']) {
196
            $partner = Smallworld_sanitize($_POST['partner']);
197
        } else {
198
            $partner = '';
199
        }
200
201
        $regdate                = time();
202
        $username               = $user->uname();
203
        $realname               = Smallworld_sanitize($_POST['realname']);
204
        $gender                 = isset($_POST['gender']) ? $_POST['gender'] : '';
205
        $intingender            = isset($_POST['intingender']) ? Smallworld_sanitize(serialize($_POST['intingender'])) : Smallworld_sanitize(serialize([0 => '3']));
206
        $relationship           = Smallworld_sanitize($_POST['relationship']);
207
        $searchrelat            = isset($_POST['searchrelat']) ? Smallworld_sanitize(serialize($_POST['searchrelat'])) : Smallworld_sanitize(serialize([0 => '0']));
208
        $birthday               = Smallworld_sanitize(Smallworld_euroToUsDate($_POST['birthday']));
209
        $birthplace             = Smallworld_sanitize($_POST['birthplace']);
210
        $birthplace_lat         = Smallworld_sanitize($_POST['birthplace_lat']);
211
        $birthplace_lng         = Smallworld_sanitize($_POST['birthplace_lng']);
212
        $birthplace_country     = Smallworld_sanitize($_POST['birthplace_country']);
213
        $birthplace_country_img = isset($_POST['birthplace_country_img']) ? Smallworld_sanitize($_POST['birthplace_country_img']) : '';
214
        $politic                = Smallworld_sanitize($_POST['politic']);
215
        $religion               = Smallworld_sanitize($_POST['religion']);
216
        $emailtype              = Smallworld_sanitize(serialize($_POST['emailtype']));
217
        $screenname_type        = Smallworld_sanitize(serialize($_POST['screenname_type']));
218
        $screenname             = Smallworld_sanitize(serialize($_POST['screenname']));
219
        $mobile                 = Smallworld_sanitize($_POST['mobile']);
220
        $phone                  = Smallworld_sanitize($_POST['phone']);
221
        $adress                 = Smallworld_sanitize($_POST['adress']);
222
        $present_city           = Smallworld_sanitize($_POST['present_city']);
223
        $present_lat            = Smallworld_sanitize($_POST['present_lat']);
224
        $present_lng            = Smallworld_sanitize($_POST['present_lng']);
225
        $present_country        = Smallworld_sanitize($_POST['present_country']);
226
        $present_country_img    = isset($_POST['present_country_img']) ? Smallworld_sanitize($_POST['present_country_img']) : '';
227
        $website                = Smallworld_sanitize($_POST['website']);
228
        $interests              = Smallworld_sanitize($_POST['interests']);
229
        $music                  = Smallworld_sanitize($_POST['music']);
230
        $tvshow                 = Smallworld_sanitize($_POST['tvshow']);
231
        $movie                  = Smallworld_sanitize($_POST['movie']);
232
        $books                  = Smallworld_sanitize($_POST['books']);
233
        $aboutme                = Smallworld_sanitize($_POST['aboutme']);
234
        $school_type            = Smallworld_sanitize(serialize($_POST['school_type']));
235
        $school                 = Smallworld_sanitize(serialize($_POST['school']));
236
        $schoolstart            = Smallworld_sanitize(serialize($_POST['schoolstart']));
237
        $schoolstop             = Smallworld_sanitize(serialize($_POST['schoolstop']));
238
        $jobemployer            = Smallworld_sanitize(serialize($_POST['employer']));
239
        $jobposition            = Smallworld_sanitize(serialize($_POST['position']));
240
        $jobstart               = Smallworld_sanitize(serialize(Smallworld_YearOfArray($_POST['jobstart'])));
241
        $jobstop                = Smallworld_sanitize(serialize(Smallworld_YearOfArray($_POST['jobstop'])));
242
        $jobdescription         = Smallworld_sanitize(serialize($_POST['description']));
243
244
        $sql = '';
245
246
        if ('edit' === $_POST['function']) {
247
            // Update all values in user_table
248
            $sql    = 'UPDATE ' . $xoopsDB->prefix('smallworld_user') . ' SET ';
249
            $sql    .= "realname = '" . $realname . "', username= '" . $username . "', userimage = '" . $avatar . "', gender = '" . $gender . "',";
250
            $sql    .= "intingender = '" . $intingender . "',relationship = '" . $relationship . "', partner = '" . $partner . "', searchrelat = '" . $searchrelat . "',";
251
            $sql    .= "birthday = '" . $birthday . "',birthplace = '" . $birthplace . "',birthplace_lat = '" . (float)$birthplace_lat . "',";
252
            $sql    .= "birthplace_lng = '" . (float)$birthplace_lng . "',birthplace_country = '" . $birthplace_country . "',politic = '" . $politic . "',";
253
            $sql    .= "religion = '" . $religion . "',emailtype = '" . $emailtype . "',screenname_type = '" . $screenname_type . "',";
254
            $sql    .= "screenname = '" . $screenname . "',mobile = '" . (float)$mobile . "',phone = '" . (float)$phone . "',adress = '" . $adress . "',";
255
            $sql    .= "present_city = '" . $present_city . "',present_lat = '" . (float)$present_lat . "',present_lng = '" . (float)$present_lng . "',";
256
            $sql    .= "present_country = '" . $present_country . "',website = '" . $website . "',interests = '" . $interests . "',";
257
            $sql    .= "music = '" . $music . "',tvshow = '" . $tvshow . "',movie = '" . $movie . "',";
258
            $sql    .= "books = '" . $books . "',aboutme = '" . $aboutme . "',school_type = '" . $school_type . "',";
259
            $sql    .= "school = '" . $school . "', schoolstart = '" . $schoolstart . "',schoolstop = '" . $schoolstop . "',";
260
            $sql    .= "employer = '" . $jobemployer . "', position = '" . $jobposition . "',jobstart = '" . $jobstart . "',";
261
            $sql    .= "jobstop = '" . $jobstop . "', description = '" . $jobdescription . "' ";
262
            $sql    .= "WHERE userid ='" . (int)$uid . "'";
263
            $result = $xoopsDB->queryF($sql);
264
            if (false === $result) {
265
                die('SQL error:' . $sql . '');
266
            }
267
268
            $this->EditAdmins($uid, $realname, $avatar);
269
            $img->createAlbum($uid);
270
        }
271
272
        if ('save' === $_POST['function']) {
273
            $sql    = 'INSERT INTO '
274
                      . $xoopsDB->prefix('smallworld_user')
275
                      . ' (userid, regdate, username, userimage, realname, gender, intingender, relationship, partner, searchrelat, birthday, birthplace, birthplace_lat, birthplace_lng, birthplace_country, politic, religion, emailtype, screenname_type, screenname, mobile, phone, adress, present_city, present_lat, present_lng, present_country, website, interests, music, tvshow, movie, books, aboutme, school_type, school, schoolstart, schoolstop, employer, position, jobstart, jobstop, description, friends, followers, admin_flag) ';
276
            $sql    .= "VALUES ('" . (int)$uid . "', '" . $regdate . "', '" . $username . "', '" . $avatar . "', '" . $realname . "', '" . $gender . "', '" . $intingender . "', '" . $relationship . "', '" . $partner . "', '" . $searchrelat . "','";
277
            $sql    .= $birthday . "', '" . $birthplace . "', '" . (float)$birthplace_lat . "', '" . (float)$birthplace_lng . "', '" . $birthplace_country . "', '" . $politic . "', '" . $religion . "','";
278
            $sql    .= $emailtype . "', '" . $screenname_type . "', '" . $screenname . "', '" . (float)$mobile . "', '" . (float)$phone . "', '" . $adress . "', '" . $present_city . "', '" . (float)$present_lat . "','";
279
            $sql    .= (float)$present_lng . "', '" . $present_country . "', '" . $website . "', '" . $interests . "', '" . $music . "', '" . $tvshow . "', '" . $movie . "', '" . $books . "', '" . $aboutme . "', '";
280
            $sql    .= $school_type . "', '" . $school . "', '" . $schoolstart . "', '" . $schoolstop . "', '" . $jobemployer . "', '" . $jobposition . "', '" . $jobstart . "', '" . $jobstop . "', '" . $jobdescription . "', ";
281
            $sql    .= "'0', '0', '0')";
282
            $result = $xoopsDB->queryF($sql);
283
            if (false === $result) {
284
                die('SQL error:' . $sql . '');
285
            }
286
            $this->SetAdmins($uid, $username, $realname, $avatar);
287
            $img->createAlbum($uid);
288
        }
289
    }
290
291
    /**
292
     * SetAdmins function