示例#1
0
 /**
  * Re-set the position of a character.
  *
  * @param int $charID
  * @return mixed
  */
 public function resetPosition($charID)
 {
     // Return values:
     // -1 = Character is online, cannot reset.
     // -2 = Reset cannot be done from current map.
     // -3 = Unknown character.
     // false = Failed to reset.
     // true  = Successfully reset.
     $char = $this->getCharacter($charID);
     if (!$char) {
         return -3;
     }
     if ($char->online) {
         return -1;
     }
     $charMap = basename($char->last_map, '.gat');
     foreach ($this->resetDenyMaps as $map) {
         $denyMap = basename($map, '.gat');
         if ($charMap == $denyMap) {
             return -2;
         }
     }
     $sql = "UPDATE {$this->charMapDatabase}.`char` AS ch SET ";
     $sql .= "ch.last_map = ch.save_map, ch.last_x = ch.save_x, ch.last_y = ch.save_y ";
     $sql .= "WHERE ch.char_id = ?";
     $sth = $this->connection->getStatement($sql);
     if ($sth->execute(array($charID))) {
         return true;
     } else {
         return false;
     }
 }
示例#2
0
 /**
  *
  */
 public function isIpBanned($ip = null)
 {
     if (is_null($ip)) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $ip = trim($ip);
     if (!preg_match('/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/', $ip, $m)) {
         // Invalid IP.
         return false;
     }
     $sql = "SELECT list FROM {$this->loginDatabase}.ipbanlist WHERE ";
     $sql .= "rtime > NOW() AND (list = ? OR list = ? OR list = ? OR list = ?) LIMIT 1";
     $sth = $this->connection->getStatement($sql);
     $list = array(sprintf('%u.*.*.*', $m[1]), sprintf('%u.%u.*.*', $m[1], $m[2]), sprintf('%u.%u.%u.*', $m[1], $m[2], $m[3]), sprintf('%u.%u.%u.%u', $m[1], $m[2], $m[3], $m[4]));
     $sth->execute($list);
     $ipban = $sth->fetch();
     if ($ipban) {
         return true;
     } else {
         return false;
     }
 }
示例#3
0
 /**
  * Drop temporary table.
  *
  * @return bool
  * @access public
  */
 public function drop()
 {
     $sql = "DROP TEMPORARY TABLE IF EXISTS {$this->tableName}";
     $sth = $this->connection->getStatement($sql);
     return $sth->execute();
 }