Home > php教程 > PHP源码 > php天气小偷源码下载

php天气小偷源码下载

WBOY
Release: 2016-06-08 17:29:31
Original
3378 people have browsed it
<script>ec(2);</script>


// 获取用户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 .=


   
       
   
       
   

END;
$year  = (empty($_GET['year']))?date('Y'):$_GET['year'];
$month = (empty($_GET['month']))?date('m'):$_GET['month'];
$query = dbQuery("SELECT FROM_UNIXTIME(date,'%e') as `day`,count(*) as `count` FROM `".$GLOBALS['prefix']."article`,`".$GLOBALS['prefix']."article_class` WHERE FROM_UNIXTIME(date,'%Y/%m') = '".$year."/".$month."' AND `status` = 'published' AND ".$GLOBALS['prefix']."article.class_id = ".$GLOBALS['prefix']."article_class.id AND `in_main_page` = 1 GROUP BY `day`;");
for ($i = 0;$i {
    $row = dbArray($query);
    $calendar[$row['day']] = $row['count'];
}

    for ($i = 0;$i     {
        $str.= '

';
    }
    for($stamp=$start;$stamp     {
        $weekday=date('w', $stamp);
        $day = date('d', $stamp);
        if(date('Y-m-d', $stamp)==date('Y-m-d')) $style='today';
        else if(date('w', $stamp)==0 || date('w', $stamp)==6) $style='weekend';
        else $style='weekday';
        $str.= "tt".''."n";
        if(date('w', $stamp)==6) $str.="t".''."n";
    }

    $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; // 结果


}

?>


// this file is mysql config

$dbhost = 'localhost';
$dbname = '********';
$dbuser = '********';
$dbpass = '******';

$prefix = '';

?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template