403Webshell
Server IP : 116.153.78.57  /  Your IP : 43.174.71.198
Web Server : nginx/1.28.0
System : Linux 1763701629066 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64
User : www ( 1001)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/inc/classes/ip/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/inc/classes/ip/IpLocation.php
<?php


namespace itbdw\Ip;

use itbdw\Ip\IpParser\QQwry;
use itbdw\Ip\IpParser\IpV6wry;
use itbdw\Ip\IpParser\Ip2Region;

use itbdw\Ip\StringParser;
/**
 * Class IpLocation
 * @package itbdw\Ip
 */
class IpLocation {
    /**
     * @var
     */
    private static $isQQwry;
    /**
     * @var
     */
    private static $ipV4Path;
    /**
     * @var
     */
    private static $ipV6Path;

    /**
     * 获取位置而不进行分析
     * @param $ip
     * @param string $ipV4Path
     * @param string $ipV6Path
     * @return array
     */
    public static function getLocationWithoutParse($ip, $ipV4Path='', $ipV6Path='') {

        //if  ipV4Path 记录位置
        if (strlen($ipV4Path)) {
            self::setIpV4Path($ipV4Path);
        }

        //if  ipV6Path 记录位置
        if (strlen($ipV6Path)) {
            self::setIpV6Path($ipV6Path);
        }

        if (self::isIpV4($ip)) {
            if (self::$isQQwry) {
                $ins = new QQwry();
            }else{
                $ins = new Ip2Region();
            }
            $ins->setDBPath(self::getIpV4Path());
            $location = $ins->getIp($ip);
        } else if (self::isIpV6($ip)) {
            $ins = new IpV6wry();
            $ins->setDBPath(self::getIpV6Path());
            $location = $ins->getIp($ip);

        } else {
            $location = [
                'error' => 'IP Invalid'
            ];
        }

        return $location;
    }

    /**
     * 获取位置并且进行分析
     * @param $ip
     * @param string $ipV4Path
     * @param string $ipV6Path
     * @return array|mixed
     */
    public static function getLocation($ip,$isQQwry, $ipV4Path='', $ipV6Path='') {
        self::$isQQwry = $isQQwry;
        $location = self::getLocationWithoutParse($ip, $ipV4Path, $ipV6Path);
        if (isset($location['error'])) {
            return $location;
        }
        if($location['show']){
            return $location['data'];
        }
        return StringParser::parse($location['data']);
    }

    /**
     * 设置 IPV4 数据库地址
     * @param $path
     */
    public static function setIpV4Path($path)
    {
        self::$ipV4Path = $path;
    }

    /**
     * 设置 IPV6 数据库地址
     * @param $path
     */
    public static function setIpV6Path($path)
    {
        self::$ipV6Path = $path;
    }

    /**
     * IPV4 数据库地址
     * @return string
     */
    private static function getIpV4Path() {
        $_ipPath = self::src('/ip2region.xdb');
        if (self::$isQQwry)
            $_ipPath = self::src('/qqwry.dat');
        return self::$ipV4Path ?: $_ipPath;
    }

    /**
     * IPV6 数据库地址
     * @return string
     */
    private static function getIpV6Path() {
        return self::$ipV6Path ? : self::src('/ipv6wry.db');
    }

    /**
     * 判断 ipv4
     * @param $ip
     * @return bool
     */
    private static function isIpV4($ip) {
        return false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
    }

    /**
     * 判断 ipv6
     * @param $ip
     * @return bool
     */
    private static function isIpV6($ip) {
        return false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
    }

    /**
     * @param $filename
     * @return string
     */
    public static function src($filename) {
        return self::root($filename);
    }

    /**
     * @param $filename
     * @return string
     */
    public static function root($filename) {
        return IP_DATABASE_ROOT_DIR . $filename;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit