コード例 #1
0
ファイル: UserOnline.class.php プロジェクト: nick-strohm/WCF
 /**
  * Returns the ip address.
  * 
  * @return	string
  */
 public function getFormattedIPAddress()
 {
     if ($address = UserUtil::convertIPv6To4($this->ipAddress)) {
         return $address;
     }
     return $this->ipAddress;
 }
コード例 #2
0
 /**
  * @see	wcf\system\option\IOptionType::validate()
  */
 public function validate(Option $option, $newValue)
 {
     if (!empty($newValue)) {
         $ips = explode("\n", $newValue);
         foreach ($ips as $ip) {
             $ip = trim($ip);
             $ip = UserUtil::convertIPv6To4($ip);
             if (empty($ip)) {
                 throw new UserInputException($option->optionName, 'validationFailed');
             }
         }
     }
 }
コード例 #3
0
 /**
  * Returns the ip address and attempts to convert into IPv4.
  * 
  * @return	string
  */
 public function getIpAddress()
 {
     return UserUtil::convertIPv6To4($this->ipAddress);
 }
コード例 #4
0
ファイル: WCF.class.php プロジェクト: nick-strohm/WCF
 /**
  * Executes the blacklist.
  */
 protected function initBlacklist()
 {
     $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
     if (defined('BLACKLIST_IP_ADDRESSES') && BLACKLIST_IP_ADDRESSES != '') {
         if (!StringUtil::executeWordFilter(UserUtil::convertIPv6To4(self::getSession()->ipAddress), BLACKLIST_IP_ADDRESSES)) {
             if ($isAjax) {
                 throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
             } else {
                 throw new PermissionDeniedException();
             }
         } else {
             if (!StringUtil::executeWordFilter(self::getSession()->ipAddress, BLACKLIST_IP_ADDRESSES)) {
                 if ($isAjax) {
                     throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
                 } else {
                     throw new PermissionDeniedException();
                 }
             }
         }
     }
     if (defined('BLACKLIST_USER_AGENTS') && BLACKLIST_USER_AGENTS != '') {
         if (!StringUtil::executeWordFilter(self::getSession()->userAgent, BLACKLIST_USER_AGENTS)) {
             if ($isAjax) {
                 throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
             } else {
                 throw new PermissionDeniedException();
             }
         }
     }
     if (defined('BLACKLIST_HOSTNAMES') && BLACKLIST_HOSTNAMES != '') {
         if (!StringUtil::executeWordFilter(@gethostbyaddr(self::getSession()->ipAddress), BLACKLIST_HOSTNAMES)) {
             if ($isAjax) {
                 throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
             } else {
                 throw new PermissionDeniedException();
             }
         }
     }
     // handle banned users
     if (self::getUser()->userID && self::getUser()->banned) {
         if ($isAjax) {
             throw new AJAXException(self::getLanguage()->getDynamicVariable('wcf.user.error.isBanned'), AJAXException::INSUFFICIENT_PERMISSIONS);
         } else {
             throw new NamedUserException(self::getLanguage()->getDynamicVariable('wcf.user.error.isBanned'));
         }
     }
 }
コード例 #5
0
 public function getIpLog()
 {
     // get ip addresses of the author
     $authorIpAddresses = News::getIpAddressByAuthor($this->news->userID, $this->news->username, $this->news->ipAddress);
     // resolve hostnames
     $newIpAddresses = array();
     foreach ($authorIpAddresses as $ipAddress) {
         $ipAddress = UserUtil::convertIPv6To4($ipAddress);
         $newIpAddresses[] = array('hostname' => @gethostbyaddr($ipAddress), 'ipAddress' => $ipAddress);
     }
     $authorIpAddresses = $newIpAddresses;
     // get other users of this ip address
     $otherUsers = array();
     if ($this->news->ipAddress) {
         $otherUsers = News::getAuthorByIpAddress($this->news->ipAddress, $this->news->userID, $this->news->username);
     }
     $ipAddress = UserUtil::convertIPv6To4($this->news->ipAddress);
     if ($this->news->userID) {
         $sql = "SELECT\tregistrationIpAddress\n\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\tWHERE\tuserID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->news->userID));
         $row = $statement->fetchArray();
         if ($row !== false && $row['registrationIpAddress']) {
             $registrationIpAddress = UserUtil::convertIPv6To4($row['registrationIpAddress']);
             WCF::getTPL()->assign(array('registrationIpAddress' => array('hostname' => @gethostbyaddr($registrationIpAddress), 'ipAddress' => $registrationIpAddress)));
         }
     }
     WCF::getTPL()->assign(array('authorIpAddresses' => $authorIpAddresses, 'ipAddress' => array('hostname' => @gethostbyaddr($ipAddress), 'ipAddress' => $ipAddress), 'otherUsers' => $otherUsers, 'news' => $this->news));
     return array('newsID' => $this->news->newsID, 'template' => WCF::getTPL()->fetch('newsIpAddress', 'cms'));
 }