Infractions::lb_getInfraction PHP Method

lb_getInfraction() public method

Params: $type (string), either ban, kick or mute; $id (int), ID of infraction
public lb_getInfraction ( $type, $id )
    public function lb_getInfraction($type, $id)
    {
        if ($type === "ban" || $type === "temp_ban") {
            $results = $this->_db->get($this->_prefix . 'bans', array("id", "=", $id))->results();
            $username = $this->_db->get($this->_prefix . 'history', array('uuid', '=', htmlspecialchars($results[0]->uuid)))->results();
            if (count($username) > 1) {
                // get most recent name
                usort($username, function ($a, $b) {
                    return strtotime($b->date) - strtotime($a->date);
                });
            }
            if (count($username)) {
                $username = htmlspecialchars($username[0]->name);
            } else {
                $username = 'Unknown';
            }
            return array($results[0], $username);
        } else {
            if ($type === "mute") {
                $results = $this->_db->get($this->_prefix . 'mutes', array("id", "=", $id))->results();
                $username = $this->_db->get($this->_prefix . 'history', array('uuid', '=', htmlspecialchars($results[0]->uuid)))->results();
                if (count($username) > 1) {
                    // get most recent name
                    usort($username, function ($a, $b) {
                        return strtotime($b->date) - strtotime($a->date);
                    });
                }
                if (count($username)) {
                    $username = htmlspecialchars($username[0]->name);
                } else {
                    $username = 'Unknown';
                }
                return array($results[0], $username);
            } else {
                if ($type === "warning") {
                    $results = $this->_db->get($this->_prefix . 'warnings', array("id", "=", $id))->results();
                    $username = $this->_db->get($this->_prefix . 'history', array('uuid', '=', htmlspecialchars($results[0]->uuid)))->results();
                    if (count($username) > 1) {
                        // get most recent name
                        usort($username, function ($a, $b) {
                            return strtotime($b->date) - strtotime($a->date);
                        });
                    }
                    if (count($username)) {
                        $username = htmlspecialchars($username[0]->name);
                    } else {
                        $username = 'Unknown';
                    }
                    return array($results[0], $username);
                } else {
                    if ($type === "kick") {
                        $results = $this->_db->get($this->_prefix . 'kicks', array("id", "=", $id))->results();
                        $username = $this->_db->get($this->_prefix . 'history', array('uuid', '=', htmlspecialchars($results[0]->uuid)))->results();
                        if (count($username) > 1) {
                            // get most recent name
                            usort($username, function ($a, $b) {
                                return strtotime($b->date) - strtotime($a->date);
                            });
                        }
                        if (count($username)) {
                            $username = htmlspecialchars($username[0]->name);
                        } else {
                            $username = 'Unknown';
                        }
                        return array($results[0], $username);
                    }
                }
            }
        }
        return false;
    }

Usage Example

Example #1
0
                         // Unbanned
                         $expires = '<span class="label label-success" rel="tooltip" data-placement="top" title="' . date('jS M Y, H:i', $infraction[0]->ban_unbandate) . '">' . str_replace('{x}', htmlspecialchars($infraction[0]->ban_unbanstaff), $infractions_language['revoked_by']) . '</span>';
                     }
                 }
             }
             break;
     }
     // Staff
     if (!isset($_GET['past'])) {
         $staff = htmlspecialchars($infractions->bm_getUsernameFromID($infraction[0]->actor_id));
     } else {
         $staff = htmlspecialchars($infractions->bm_getUsernameFromID($infraction[0]->pastActor_id));
     }
     break;
 case 'lb':
     $infraction = $infractions->lb_getInfraction($_GET["type"], $_GET["id"]);
     $username = htmlspecialchars($infraction[1]);
     $infraction = $infraction[0];
     switch ($_GET['type']) {
         case 'ban':
             if ($infraction->active == null) {
                 $expires = '<span class="label label-danger">' . $infractions_language['permanent'] . '</span>';
             } else {
                 if ($infraction->active == 0x1) {
                     // active
                     $expires = '<span class="label label-danger">' . $infractions_language['permanent'] . '</span>';
                 } else {
                     // revoked
                     $expires = '<span class="label label-success">' . $infractions_language['revoked'] . '</span>';
                 }
             }