Code Duplication    Length = 10-14 lines in 5 locations

include/functions.php 5 locations

@@ 1028-1041 (lines=14) @@
1025
 * @param int $userid
1026
 * @returns string
1027
 */
1028
function smallworld_getRndImg($userid)
1029
{
1030
    global $xoopsDB;
1031
    $sql    = 'SELECT imgname FROM ' . $xoopsDB->prefix('smallworld_images') . ' WHERE userid = ' . $userid . ' AND time BETWEEN UNIX_TIMESTAMP( ) - 3000 AND UNIX_TIMESTAMP() ORDER BY rand() LIMIT 1';
1032
    $result = $xoopsDB->queryF($sql);
1033
    while ($r = $xoopsDB->fetchArray($result)) {
1034
        $img = $r['imgname'];
1035
    }
1036
    if (!empty($img)) {
1037
        return $img;
1038
    } else {
1039
        return false;
1040
    }
1041
}
1042
1043
/**
1044
 * @Get url of smallworld
@@ 509-518 (lines=10) @@
506
 * @param $msg_id_fk
507
 * @return mixed
508
 */
509
function Smallworld_getOwnerFromComment($msg_id_fk)
510
{
511
    global $xoopsDB;
512
    $sql    = 'SELECT uid_fk FROM ' . $xoopsDB->prefix('smallworld_messages') . " WHERE msg_id = '" . $msg_id_fk . "'";
513
    $result = $xoopsDB->queryF($sql);
514
    while ($r = $xoopsDB->fetchArray($result)) {
515
        $owner = $r['uid_fk'];
516
    }
517
    return $owner;
518
}
519
520
// Get username from userID
521
/**
@@ 525-534 (lines=10) @@
522
 * @param $userID
523
 * @return mixed
524
 */
525
function Smallworld_getName($userID)
526
{
527
    global $xoopsUser, $xoopsDB;
528
    $sql    = 'SELECT username FROM ' . $xoopsDB->prefix('smallworld_user') . " WHERE userid = '" . (int)$userID . "'";
529
    $result = $xoopsDB->queryF($sql);
530
    while ($row = $xoopsDB->fetchArray($result)) {
531
        $name = $row['username'];
532
    }
533
    return $name;
534
}
535
536
// Check if user has been taken down for inspection by admin
537
// Userid = user id of user to check
@@ 873-882 (lines=10) @@
870
 * @param $id
871
 * @return mixed
872
 */
873
function smallworldCheckPriv($id)
874
{
875
    global $xoopsDB;
876
    $public = 'SELECT priv FROM ' . $xoopsDB->prefix('smallworld_messages') . ' WHERE msg_id = ' . $id . '';
877
    $result = $xoopsDB->queryF($public);
878
    while ($row = $xoopsDB->fetchArray($result)) {
879
        $priv = $row['priv'];
880
    }
881
    return $priv;
882
}
883
884
// Function to calculate remaining seconds until user's birthday
885
// Input $d : date('Y-m-d') format
@@ 1426-1435 (lines=10) @@
1423
 * @param $name
1424
 * @return array @users
1425
 */
1426
function smallworld_getUidFromName($name)
1427
{
1428
    global $xoopsDB;
1429
    $sql    = 'SELECT userid FROM ' . $xoopsDB->prefix('smallworld_user') . " WHERE username = '" . $name . "'";
1430
    $result = $xoopsDB->queryF($sql);
1431
    while ($r = $xoopsDB->fetchArray($result)) {
1432
        $id = $r['userid'];
1433
    }
1434
    return $id;
1435
}
1436
1437
/**
1438
 * Extract users from @tags