php天气小偷程序,可自动识别IP地址
tp.php 文件:
/*
tq 天气
qs 趋势
rq 日期
wd 温度
fx 风向
address 地址
qq 805830
*/
include_once('./include/tq/function.inc.php');
$staid = sta_id();
$ip = getIp();
//$address = convertip($ip);
$address = addr();
echo $address." ";
function open($file,$type=''){
if($open=file($file)){
$count=count($open);
for($i=0;$i
$theget.=$open[$i];
}
}else{
die('请求过多,超时,请刷新');
}
return $theget;
}
$_str = open('http://www.weathercn.com/tqyb/detail.jsp?sta_id='.$staid);
//echo $_str;
/**
变量说明:
$str 要进行操作的字符串;
$split 拆分目标字符(串);
$from_no 从第几个开始;
$desc_y_n 顺取(〉0的值)还是倒取(0);
*/
//$_str = "aaa .1..aaa.2..aaa .3..aaa.4..aaa.5..bbb..7.bbb.8..bbb.9..bbb.10..bbb";
$split_a = "中国气象局";
$split_b = "时至";
$str_b = strstr($_str,$split_b);//寻找$split_b第一次出现的位置
$str_a = substr($_str,0,strpos($_str, $split_b));//可以取得字符串的指定长度子字符串
function _getStr_from_to($str,$split,$from_no,$desc_y_n)
{
$arr = explode($split,$str);
$size = sizeof($arr);
$from_no = ($from_no
unset($_tmp_out_str);
if($desc_y_n)
{
//正序
for($i=$from_no;$i
{
$_tmp_out_str .= $split.$arr[$i];
}
}
else
{
$_tmp_from = $size - $from_no;
for($i=0;$i
{
$_tmp_out_str .= $arr[$i].$split;
}
}
return $_tmp_out_str;
}
$srting = _getStr_from_to($str_a,"中国气象局",1,1);
//echo $srting;
preg_match_all('/alt="([^"]*)"/',$srting,$tq);
$tq = $tq[1];
if (is_array($tq))
$tq = implode('转',$tq);
//print_r($tq);
echo $tq." ";
preg_match_all('/([0-9-]*℃)~([0-9-]*℃)/',$srting,$wd);
$wd = $wd[0];
$wd = $wd[0];
print_r($wd);
?>
复制代码function.inc.php 文件
// 获取用户IP地址
function getIp() {
if($_SERVER['HTTP_CLIENT_IP'])
{
return $_SERVER['HTTP_CLIENT_IP'];
} elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
return $_SERVER['REMOTE_ADDR'];
}
}
function getFile($url)
{
if($f=fopen("$url","r"))
{
while(!feof($f))
{
$s.=fgets($f);
}
fclose($f);
return $s;
} else {
return false;
}
}
function putFile($file_name,$file_string)
{
if($f=fopen($file_name,"w"))
{
fwrite($f, $file_string);
}
fclose($f);
}
function cnSubStr($string,$sublen) {
if($sublen>=strlen($string)){
return $string;
}
$s="";
for($i=0;$i
if(ord($string{$i})>127){
$s.=$string{$i}.$string{++$i};
continue;
}else{
$s.=$string{$i};
continue;
}
}
return $s."...";
}
function getPageBar($count = 0)
{
$bad_link_color = "#C0C0C0";
$page["url"] = eregi_replace("&page=[^&]+","",basename($_SERVER[SCRIPT_NAME])."?".$_SERVER[QUERY_STRING]);
$page["result_count"] = (string) $count;
$page["this_page"] = (empty($_GET["page"]))?"1":$_GET["page"];
$page["this_page"] = ($page["result_count"] == 0)?"0":$page["this_page"];
$page["page_size"] = $GLOBALS["option"]["page_size"];
$page["page_count"] = (string) ceil($page["result_count"]/$page["page_size"]);
$page["first_page"] = ($page["this_page"] > 1)?"«":"";
$page["rearward_page"] = ($page["this_page"] »":"";
$page["prev_page"] = ($page["this_page"] > 1)?"‹":"";
$page["next_page"] = ($page["this_page"] ›":"";
$page['start_page'] = ((int)$page["this_page"]-5
$page['end_page'] = ((int)$page["this_page"]+5 > $page['page_count'])?(int)$page["page_count"]:(int)$page["this_page"]+5;
for ($i = $page['start_page'];$i
{
$selected = ($_GET["page"] == $i)?"selected":"";
$page["page_select"] .= "";
$page["page_list"] .= ($i == $page["this_page"])?" $i ":"[$i]";
}
return $page;
}
function getRows($table,$order='')
{
if (!empty($order))
{
$order = explode(',',$order);
$order = 'ORDER BY `'.$order[0].'` '.$order[1];
}
$query = dbQuery("SELECT * FROM `".$GLOBALS['prefix'].$table."` ".$order.";");
while ($row = dbArray($query))
{
$link[$row['id']] = $row;
}
return $link;
}
function autoTime($time)
{
preg_match('/([0-9]*)-([0-9]*)-([0-9]*) ([0-9]*):([0-9]*):([0-9]*)/',$time,$date);
return mktime ($date[4],$date[5],$date[6],$date[2],$date[3],$date[1]);
}
function getTime() {
$t = explode(' ', microtime());
return $t[1] + $t[0];
}
function calendar($time)
{
$start = mktime(0, 0, 0, date('m', $time), 1, date('Y', $time));
$prev_month['year'] = date('Y',$start-86400);
$prev_month['month'] = date('m',$start-86400);
$end = mktime(0, 0, 0, date('m', $time)+1, 1, date('Y', $time));
$next_month['year'] = date('Y',$end);
$next_month['month'] = date('m',$end);
$sWeekday=array('日','一','二','三','四','五','六');
//$sWeekday=array('S','M','T','W','T','F','S');
$title=date('M Y', $time);
$str = '';
$str .=
«
|
{$title}
|
»
|
||||
---|---|---|---|---|---|---|
{$sWeekday[0]}
|
{$sWeekday[1]}
|
{$sWeekday[2]}
|
{$sWeekday[3]}
|
{$sWeekday[4]}
|
{$sWeekday[5]}
|
{$sWeekday[6]}
|
'; | ';
$str.= ($calendar[date('j', $stamp)] > 0)?''.(int)$day.'':(int)$day; $str.= ' | '." ";
return $str;
}
//php利用纯真ip数据库查地址的函数
function convertip($ip) {
if(!preg_match("/^d{1,3}.d{1,3}.d{1,3}.d{1,3}$/", $ip)) {
return '';
}
if($fd = @fopen( "e:hostswkhddbipdatawry.dat", 'rb')) {//fopen()中是纯真ip数据库文件位置,请自行设定!
$ip = explode('.', $ip);
$ipNum = $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3];
$DataBegin = fread($fd, 4);
$DataEnd = fread($fd, 4);
$ipbegin = implode('', unpack('L', $DataBegin));
if($ipbegin
$ipend = implode('', unpack('L', $DataEnd));
if($ipend
$ipAllNum = ($ipend - $ipbegin) / 7 + 1;
$BeginNum = 0;
$EndNum = $ipAllNum;
while($ip1num > $ipNum || $ip2num
$Middle= intval(($EndNum + $BeginNum) / 2);
fseek($fd, $ipbegin + 7 * $Middle);
$ipData1 = fread($fd, 4);
if(strlen($ipData1)
fclose($fd);
return '系统错误';
}
$ip1num = implode('', unpack('L', $ipData1));
if($ip1num
if($ip1num > $ipNum) {
$EndNum = $Middle;
continue;
}
$DataSeek = fread($fd, 3);
if(strlen($DataSeek)
fclose($fd);
return '系统错误';
}
$DataSeek = implode('', unpack('L', $DataSeek.chr(0)));
fseek($fd, $DataSeek);
$ipData2 = fread($fd, 4);
if(strlen($ipData2)
fclose($fd);
return 'System Error';
}
$ip2num = implode('', unpack('L', $ipData2));
if($ip2num
if($ip2num
if($Middle == $BeginNum) {
fclose($fd);
return 'Unknown';
}
$BeginNum = $Middle;
}
}
$ipFlag = fread($fd, 1);
if($ipFlag == chr(1)) {
$ipSeek = fread($fd, 3);
if(strlen($ipSeek)
fclose($fd);
return '系统错误';
}
$ipSeek = implode('', unpack('L', $ipSeek.chr(0)));
fseek($fd, $ipSeek);
$ipFlag = fread($fd, 1);
}
if($ipFlag == chr(2)) {
$AddrSeek = fread($fd, 3);
if(strlen($AddrSeek)
fclose($fd);
return 'System Error';
}
$ipFlag = fread($fd, 1);
if($ipFlag == chr(2)) {
$AddrSeek2 = fread($fd, 3);
if(strlen($AddrSeek2)
fclose($fd);
return 'System Error';
}
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
fseek($fd, $AddrSeek2);
} else {
fseek($fd, -1, SEEK_CUR);
}
while(($char = fread($fd, 1)) != chr(0))
$ipAddr2 .= $char;
$AddrSeek = implode('', unpack('L', $AddrSeek.chr(0)));
fseek($fd, $AddrSeek);
while(($char = fread($fd, 1)) != chr(0))
$ipAddr1 .= $char;
} else {
fseek($fd, -1, SEEK_CUR);
while(($char = fread($fd, 1)) != chr(0))
$ipAddr1 .= $char;
$ipFlag = fread($fd, 1);
if($ipFlag == chr(2)) {
$AddrSeek2 = fread($fd, 3);
if(strlen($AddrSeek2)
fclose($fd);
return 'System Error';
}
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
fseek($fd, $AddrSeek2);
} else {
fseek($fd, -1, SEEK_CUR);
}
while(($char = fread($fd, 1)) != chr(0))
$ipAddr2 .= $char;
}
fclose($fd);
if(preg_match('/http/i', $ipAddr2)) {
$ipAddr2 = '';
}
$ipaddr = "$ipAddr1"; // 完整地址为 "$ipAddr1 $ipAddr2"
$ipaddr = preg_replace('/CZ88.NET/is', '', $ipaddr);
$ipaddr = preg_replace('/^s*/is', '', $ipaddr);
$ipaddr = preg_replace('/s*$/is', '', $ipaddr);
if(preg_match('/http/i', $ipaddr) || $ipaddr == '') {
$ipaddr = 'Unknown';
}
return $ipaddr;
} else {
$datadir = PHPCMS_ROOT.'./ipdata/';
$ip_detail = explode('.', $ip);
if(file_exists($datadir.$ip_detail[0].'.txt')) {
$ip_fdata = @fopen($datadir.$ip_detail[0].'.txt', 'r');
} else {
if(!($ip_fdata = @fopen($datadir.'0.txt', 'r'))) {
return 'Invalid IP data file';
}
}
for ($i = 0; $i
$ip_detail[$i] = sprintf('%03d', $ip_detail[$i]);
}
$ip = join('.', $ip_detail);
do {
$ip_data = fgets($ip_fdata, 200);
$ip_data_detail = explode('|', $ip_data);
if($ip >= $ip_data_detail[0] && $ip
fclose($ip_fdata);
return $ip_data_detail[2].$ip_data_detail[3];
}
} while(!feof($ip_fdata));
fclose($ip_fdata);
return '未知地址';
}
}
// station_id 函数
function sta_id(){
include_once('./include/tq/config.inc.php');
include_once('./include/tq/error.inc.php');
include_once('./include/tq/mysql.inc.php');
include_once('./include/tq/template.inc.php');
unset($onlineip);
if($_SERVER['HTTP_CLIENT_IP']){
$onlineip=$_SERVER['HTTP_CLIENT_IP'];
}elseif($_SERVER['HTTP_X_FORWARDED_FOR']){
$onlineip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$onlineip=$_SERVER['REMOTE_ADDR'];
}
$ips = $onlineip;
$addr = convertip($ips);
$address = $addr;
$address = str_replace(array('省','市','县','工业','北京','区','大学','武汉','西安','安交','海交','新疆','大连','广西'),array(' ',' ',' ',' 工业','北京 ',' ',' ','武汉 ','西安 ','安 交','海 交','新疆 ','大连 ','广西 '),$address);
$addresss = explode(" ",$address);
$address1 = $addresss[0];
$address2 = $addresss[1];
$address3 = $addresss[2];
$address4 = $addresss[3];
$query = dbQuery("select count(*) as num from ".weather_station." where province like '$address1' ");//查询 省字段 数目
$row = dbArray($query);
$number = $row["num"];
if($number>0 && $address2'' && $address1上海 && $address1重庆){
unset($addresss[0]);
}
if($address4==''){
unset($addresss[3]);
}
if($address3==''){
unset($addresss[2]);
}
$query = dbQuery("select count(*) as num from ".weather_station." where station like '$address4' ");//查询 县 字段
$row = dbArray($query);
$number = $row["num"];
if($number==0){
unset($addresss[3]);
}
$query = dbQuery("select count(*) as num from ".weather_station." where station like '$address3' ");//查询 县 字段
$row = dbArray($query);
$number = $row["num"];
if($number==0){
unset($addresss[2]);
}
//数组数据2 查询开始
$queryx = dbQuery("select count(*) as nums from ".weather_station." where station like '$address2' ");//查询 县 字段
$row = dbArray($queryx);
$nums = $row["nums"];
$queryy = dbQuery("select count(*) as numd from ".weather_station." where district like '$address2' ");//查询 市 字段
$row = dbArray($queryy);
$numd = $row["numy"];
if($nums==0 && $numd==0){
unset($addresss[1]); // 如果 数组数据2 不在数据库里则删除数据2
}
//数组数据2 查询结束
$query = dbQuery("select count(*) as num from ".weather_station." where district like '$address2' ");//查询 市 字段
$row = dbArray($query);
$number = $row["num"];
if($number>1 && $address3'' && $nums0 && $address2广州 ){
unset($addresss[1]); // 如果数组数据2在数据库里有 多个 则删除数据2
}
@extract(dbQuery("select count(*) as num_0 from ".weather_station." where district like '$address1' "));//查询 市 字段
@extract(dbQuery("select count(*) as num_1 from ".weather_station." where station like '$address2' "));//查询 县 字段
$number = $num_0;
$numbery = $num_1;
if($number>1 && $numbery>0 && $address2''){
unset($addresss[0]); //如果数组数据1在数据库里有 多个 则删除数据1
}
$addresss = implode("",$addresss);
//字符串处理完毕 下面开始查询 station_id
$query1 = dbQuery("select count(*) as nums_addresss from ".weather_station." where station like '$addresss' ");
$row1 = dbArray($query1);
$nums_addresss = $row1["nums_addresss"];
$query2 = dbQuery("select count(*) as numd_addresss from ".weather_station." where district like '$addresss' ");
$row2 = dbArray($query2);
$numd_addresss = $row2["numd_addresss"];
if($nums_addresss>0){
$result = dbQuery("SELECT station_id FROM ".weather_station." WHERE station like '$addresss' ORDER BY id");
$r = dbArray($result);
$station_id[] = $r[station_id];
$station_id = $station_id[0];
return $station_id; // 查询结果
}
if($nums_addresss==0 && $numd_addresss>0){
$result = dbQuery("SELECT station_id FROM ".weather_station." WHERE district like '$addresss' ORDER BY id");
$r = dbArray($result);
$station_id[] = $r[station_id];
$station_id = $station_id[0];
return $station_id; // 查询结果
//echo $station_id;
}
}
function get_real_ip()
{
$ip=false;
if(!empty($_SERVER["HTTP_CLIENT_IP"]))
{
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip)
{
array_unshift($ips, $ip); $ip = FALSE;
}
for ($i = 0; $i
{
if (!eregi ("^(10|172.16|192.168).", $ips[$i]))
{
$ip = $ips[$i];
break;
}
}
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
function addr(){
include_once('./include/tq/config.inc.php');
include_once('./include/tq/error.inc.php');
include_once('./include/tq/mysql.inc.php');
include_once('./include/tq/template.inc.php');
unset($onlineip);
if($_SERVER['HTTP_CLIENT_IP']){
$onlineip=$_SERVER['HTTP_CLIENT_IP'];
}elseif($_SERVER['HTTP_X_FORWARDED_FOR']){
$onlineip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$onlineip=$_SERVER['REMOTE_ADDR'];
}
$ips = $onlineip;
$addr = convertip($ips);
$address = $addr;
$address = str_replace(array('省','市','县','工业','北京','区','大学','武汉','西安','安交','海交','新疆','大连','广西'),array(' ',' ',' ',' 工业','北京 ',' ',' ','武汉 ','西安 ','安 交','海 交','新疆 ','大连 ','广西 '),$address);
$addresss = explode(" ",$address);
$address1 = $addresss[0];
$address2 = $addresss[1];
$address3 = $addresss[2];
$address4 = $addresss[3];
$query = dbQuery("select count(*) as num from ".weather_station." where province like '$address1' ");//查询 省字段 数目
$row = dbArray($query);
$number = $row["num"];
if($number>0 && $address2'' && $address1上海 && $address1重庆){
unset($addresss[0]);
}
if($address4==''){
unset($addresss[3]);
}
if($address3==''){
unset($addresss[2]);
}
$query = dbQuery("select count(*) as num from ".weather_station." where station like '$address4' ");//查询 县 字段
$row = dbArray($query);
$number = $row["num"];
if($number==0){
unset($addresss[3]);
}
$query = dbQuery("select count(*) as num from ".weather_station." where station like '$address3' ");//查询 县 字段
$row = dbArray($query);
$number = $row["num"];
if($number==0){
unset($addresss[2]);
}
//数组数据2 查询开始
$queryx = dbQuery("select count(*) as nums from ".weather_station." where station like '$address2' ");//查询 县 字段
$row = dbArray($queryx);
$nums = $row["nums"];
$queryy = dbQuery("select count(*) as numd from ".weather_station." where district like '$address2' ");//查询 市 字段
$row = dbArray($queryy);
$numd = $row["numy"];
if($nums==0 && $numd==0){
unset($addresss[1]); // 如果 数组数据2 不在数据库里则删除数据2
}
//数组数据2 查询结束
$query = dbQuery("select count(*) as num from ".weather_station." where district like '$address2' ");//查询 市 字段
$row = dbArray($query);
$number = $row["num"];
if($number>1 && $address3'' && $nums0 && $address2广州 ){
unset($addresss[1]); // 如果数组数据2在数据库里有 多个 则删除数据2
}
@extract(dbQuery("select count(*) as num_0 from ".weather_station." where district like '$address1' "));//查询 市 字段
@extract(dbQuery("select count(*) as num_1 from ".weather_station." where station like '$address2' "));//查询 县 字段
$number = $num_0;
$numbery = $num_1;
if($number>1 && $numbery>0 && $address2''){
unset($addresss[0]); //如果数组数据1在数据库里有 多个 则删除数据1
}
$addresss = implode("",$addresss);
return $addresss; // 结果
}
?>
复制代码config.inc.php
// this file is mysql config
$dbhost = 'localhost';
$dbname = '********';
$dbuser = '********';
$dbpass = '******';
$prefix = '';
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

In iOS 17, Apple introduced several new privacy and security features to its mobile operating system, one of which is the ability to require two-step authentication for private browsing tabs in Safari. Here's how it works and how to turn it off. On an iPhone or iPad running iOS 17 or iPadOS 17, Apple's browser now requires Face ID/Touch ID authentication or a passcode if you have any Private Browsing tab open in Safari and then exit the session or app to access them again. In other words, if someone gets their hands on your iPhone or iPad while it's unlocked, they still won't be able to view your privacy without knowing your passcode
