// Make sure the process in ES is calling it
// otherwise it is a hack attempt from the outside
if ($hash == $config->matchHash) {
    // Make sure special chars for MySQL are escaped
    $nameOfBanned = addslashes($nameOfBanned);
    $nameOfBanned = str_ireplace(array("\"", "\r\n", "\n", "\r", ";"), "", $nameOfBanned);
    // Remove ; to prevent kick command inyection like name; quit or ; _restart
    $banQueries = new BanQueries();
    $userQueries = new UserQueries();
    $lengthQueries = new LengthQueries();
    $user = $userQueries->getUserInfoBySteamId($banner);
    // i for ignore
    if ($timeScale == "i") {
        $length = $lengthQueries->getBanLength($lengthId);
    } else {
        $length = new Length();
        $length->setLength($lengthId);
        $length->setTimeScale($timeScale);
    }
    $isUserMember = false;
    // If we are not allowing admin bans, then make sure the one being banned is not an admin
    if (!$config->allowAdminBans) {
        $isUserMember = $userQueries->isMember($steamId);
    }
    $username = trim($user->getName());
    $pending = 0;
    // Default pending state is off
    // HARDCODED: 4 = member
    if ($user->getAccessLevel() == 4) {
        $pending = 1;
    }
     }
 }
 $kickedByBan = false;
 // No point checking if they were kicked by name
 if (!$kickedByName) {
     // Determine if this user is IP banned, if so kick them
     if ($banQueries->isIpBanned($ipOfBanned)) {
         kickUser($steamId, $serverId, eregi_replace("gb_time", $LANCHECKUSER_003, $config->banMessage), $messageTOserver);
         $kickedByBan = true;
     }
     // Check to see if the user does exist in the ban list (if active)
     if ($banQueries->doesUserExist($steamId)) {
         $now = time();
         // Get the time now in seconds
         $bannedUser = $banQueries->getBannedUserBySteamId($steamId);
         $length = new Length();
         $length->setLength($bannedUser->getLength());
         $length->setTimeScale($bannedUser->getTimeScale());
         $lengthInSec = $length->getLengthInSeconds();
         $reasonQueries = new ReasonQueries();
         $menssageTOplayer = eregi_replace("gb_reason", $reasonQueries->getReason($bannedUser->getReasonId()), eregi_replace("gb_time", $length->getReadable(), $config->banMessage));
         // Pending bans are banned for X days
         if ($bannedUser->getPending() == 1) {
             // Kick the user if the ban is 24 hours or less
             if ($lengthInSec > 0 && $lengthInSec / 3600 <= 24) {
                 kickUser($steamId, $serverId, $menssageTOplayer, $messageTOserver);
                 $kickedByBan = true;
             } else {
                 // Kick the user for the first 5 days that their ban is in pending mode
                 $addDate = $bannedUser->getAddDate();
                 $daysToKeepBanned = 24 * 3600 * $config->daysBanPending;
示例#3
0
 /**
  * @dataProvider providerForComponentException
  * @expectedException Respect\Validation\Exceptions\ComponentException
  */
 public function test_invalid_constructor_parameters_should_throw_ComponentException_upon_instantiation($string, $min, $max)
 {
     $validator = new Length($min, $max);
     $this->assertFalse($validator->validate($string));
     $this->assertFalse($validator->assert($string));
 }
示例#4
0
 /**
  * @dataProvider providerForComponentException
  * @expectedException Respect\Validation\Exceptions\ComponentException
  */
 public function testInvalidConstructorParametersShouldThrowComponentExceptionUponInstantiation($string, $min, $max)
 {
     $validator = new Length($min, $max);
     $this->assertFalse($validator->__invoke($string));
     $this->assertFalse($validator->assert($string));
 }
 $information2 .= " <th class='colColor2' width='1%' nowrap align='center'>" . $LAN_BANLIST_032 . "</th>";
 $information2 .= " <th class='colColor1' align='center'>" . $LAN_BANLIST_027 . "</th>";
 $information2 .= "</tr>";
 // Ban history of the user
 $banHistory = $banQueries->getBanHistory($bannedUser->getBanId());
 // Loop through banned users and display them
 foreach ($banHistory as $banHistUser) {
     // list($expireDateHist, $expireTimeHist) = split(' ', $banHistUser->getExpireDate());
     list($addDateHist, $addTimeHist) = split(' ', $banHistUser->getAddDate());
     $commentsHist = str_replace(array("\r\n", "\n", "\r"), "<br>", $banHistUser->getComments());
     // Convert newlines into html line breaks
     $commentsHist = str_replace("\"", "&#34;", $commentsHist);
     // Replace quotes with the HTML code
     $commentsHist = str_replace("'", "&#34;", $commentsHist);
     // Replace quotes with the HTML code
     $banLengthHist = new Length();
     $banLengthHist->setLength($banHistUser->getLength());
     $banLengthHist->setTimeScale($banHistUser->getTimeScale());
     /*
     	      if($banHistUser->getLength() == 0) {
     	        $expireDateHist = $LAN_BANLIST_033;
     	        $expireTimeHist = "";
     	      }
     
           	  if($banHistUser->getExpireDate() == 'Expired') {
     	        $expireDateHist = "<i>".$LAN_BANLIST_024."</i>";
     			$expireTimeHist = "";
         	  }
     */
     $information2 .= " <tr>";
     $information2 .= "  <td class='colColor1' nowrap align='center'>" . str_replace('"', "&#34;", $banHistUser->getName());
示例#6
0
 public function testIsTooSmall()
 {
     $v = new Length(array('min' => 2, 'max' => 4));
     $this->assertFalse($v->isValid('1'));
 }
 function getBanLength($id)
 {
     $query = "SELECT length_id, length, time_scale FROM gban_length\r\n              WHERE length_id = '" . $id . "'";
     $this->db->sql_query($query);
     $temp = $this->db->get_row();
     $length = new Length();
     $length->setId($temp['length_id']);
     $length->setLength($temp['length']);
     $length->setTimeScale($temp['time_scale']);
     return $length;
 }
        ?>
</th>
              <th class="colColor2" width="1%" align="center" nowrap><?php 
        echo $LANUPDATEBAN_026;
        ?>
</th>
            </tr>
            <?php 
        // Loop through banned users and display them
        foreach ($banHistory as $banHistUser) {
            $length = "";
            list($expireDate, $expireTime) = split(' ', $banHistUser->getExpireDate());
            list($addDate, $addTime, $year) = split(' ', $banHistUser->getAddDate());
            $comments = str_replace(array("\r\n", "\n", "\r"), "<br/>", $banHistUser->getComments());
            // Convert newlines into html line breaks
            $banLength = new Length();
            $banLength->setLength($banHistUser->getLength());
            $banLength->setTimeScale($banHistUser->getTimeScale());
            if ($banHistUser->getLength() == 0) {
                $expireDate = $LANUPDATEBAN_027;
                $expireTime = "";
            }
            if ($banHistUser->getExpireDate() == 'Expired') {
                $expireDate = "<i>" . $LANUPDATEBAN_028 . "</i>";
                $expireTime = "";
            }
            $length = $banLength->getReadable();
            ?>
            <tr>
              <td class="colColor1" nowrap align="center"><?php 
            echo $banHistUser->getName();
示例#9
0
 /**
  * @dataProvider providerForInvalidLengthNonInclusive
  */
 public function testLengthOutsideBoundsForNonInclusiveCasesReturnFalse($string, $min, $max)
 {
     $validator = new Length($min, $max, false);
     $this->assertfalse($validator->validate($string));
 }
示例#10
0
文件: LengthTest.php 项目: seytar/psx
 public function testFilterStringLength()
 {
     $filter = new Length(3, 8);
     $this->assertEquals(false, $filter->apply('fo'));
     $this->assertEquals(true, $filter->apply('foo'));
     $this->assertEquals(true, $filter->apply('foobarte'));
     $this->assertEquals(false, $filter->apply('foobartes'));
     // test error message
     $this->assertErrorMessage($filter->getErrorMessage());
     $filter = new Length(8);
     $this->assertEquals(true, $filter->apply('fo'));
     $this->assertEquals(true, $filter->apply('foo'));
     $this->assertEquals(true, $filter->apply('foobarte'));
     $this->assertEquals(false, $filter->apply('foobartes'));
     // test error message
     $this->assertErrorMessage($filter->getErrorMessage());
 }