Infractions::bam_getInfraction PHP Method

bam_getInfraction() public method

Params: $type (string), either ban, kick or mute; $id (int), ID of infraction
public bam_getInfraction ( $type, $id )
    public function bam_getInfraction($type, $id)
    {
        $ids = explode(';', $id);
        $name = $ids[0];
        if ($ids[1]) {
            $time = date('Y-m-d H:i:s', $ids[1]);
        } else {
            $time = null;
        }
        if ($type === "ban" || $type === "temp_ban") {
            $results = $this->_db->get('history', array("time", "=", $time))->results();
            foreach ($results as $result) {
                if ($result->name == $name) {
                    return $result;
                }
            }
        } else {
            if ($type === "mute") {
                if ($time) {
                    $results = $this->_db->get('mutes', array("time", "=", $time))->results();
                    foreach ($results as $result) {
                        if ($result->name == $name) {
                            return $result;
                        }
                    }
                } else {
                    $results = $this->_db->get('mutes', array('name', '=', htmlspecialchars($name)))->results();
                    foreach ($results as $result) {
                        if ($result->time == null) {
                            return $result;
                        }
                    }
                }
            }
        }
        return false;
    }

Usage Example

Example #1
0
                 } catch (Exception $e) {
                     die($e->getMessage());
                 }
             }
             $staff = $queries->getWhere('uuid_cache', array('uuid', '=', $staff_uuid));
             $staff = htmlspecialchars($staff[0]->mcname);
         } else {
             $staff = $queries->getWhere('users', array('uuid', '=', $staff_uuid));
             $staff = htmlspecialchars($staff[0]->mcname);
         }
     } else {
         $staff = 'Console';
     }
     break;
 case 'bam':
     $infraction = $infractions->bam_getInfraction($_GET["type"], $_GET["id"]);
     // Get username
     $username = htmlspecialchars($infraction->name);
     // Reason
     if ($infraction->cause) {
         $reason = htmlspecialchars($infraction->cause);
     } else {
         $reason = $infractions_language['no_reason'];
     }
     // Expires/expired?
     switch ($_GET['type']) {
         case 'ban':
         case 'temp_ban':
             // Get date of infraction
             $created = '<span rel="tooltip" data-placement="top" title="' . date('jS M Y, H:i', strtotime($infraction->time)) . '">' . $timeago->inWords(date('d M Y, H:i', strtotime($infraction->time)), $time_language) . '</span>';
             break;