×

欢迎光临,有什么想法就留言告诉我吧!

你的精彩评论可能会出现在这里哦! 留言抢沙发

php

JS CryptoJS.AES.decrypt 对应 php 解密方法

chen chen 发表于2021-08-25 浏览876 评论0

JS 

function decrypt(word){
    if (isEmpty(word)) {
        return word;
    }
    try{
    	console.log(CryptoJS.mode.ECB);
        var key = CryptoJS.enc.Utf8.parse("rkmiplusfighting");
        var decrypt = CryptoJS.AES.decrypt(word, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
        return CryptoJS.enc.Utf8.stringify(decrypt).toString();
    } catch (e) {
        console.log(e.name + ": " + e.message);
    }
    return '';
}

php

php解析获取图片经纬度定位信息,拍摄时间,宽高(使用高德地图接口)

chen chen 发表于2021-08-24 浏览861 评论0
if(function_exists('date_default_timezone_set')){date_default_timezone_set('Hongkong');}

class ImgHelper{
    public  function get_img_info($img_url,$gaode_key){
        $exif = exif_read_data($img_url, 0, true);
        if ($exif === false) {
            return false;
        } else {
            $latitude = $exif['GPS']['GPSLatitude'];   //纬度
            $longitude = $exif['GPS']['GPSLongitude']; //经度
            $GPSLatitudeRef = $exif['GPS']['GPSLatitudeRef']; //南半球 S 北半球 N
            $GPSLongitudeRef = $exif['GPS']['GPSLongitudeRef']; //东半球 S 西半球 N
            //计算经纬度信息
            $latitude = self::get_gps($latitude, $GPSLatitudeRef);
            $longitude = self::get_gps($longitude, $GPSLongitudeRef);

            /**使用高德地图提供逆向地理编码接口获取定位信息;
             * 需在高德申请key
             * 高德接口地址:http://lbs.amap.com/api/webservice/guide/api/georegeo
             */

            $url = "http://restapi.amap.com/v3/geocode/regeo?key=$gaode_key&location=$longitude,$latitude&poitype=&radius=10000&extensions=all&batch=false&roadlevel=0";
            $res = file_get_contents($url);
            $res = json_decode($res, true);

            if ($res['status'] == 1) {
                $address = $res['regeocode']['formatted_address'];
                $province = $res['regeocode']['addressComponent']['province'];
                $district = $res['regeocode']['addressComponent']['district'];
                $township = $res['regeocode']['addressComponent']['township'];
                $city = $res['regeocode']['addressComponent']['city'];
                $senic_spot = $res['regeocode']['aois'][0]['name'];
            }

            //图片拍摄时间
            $time = date("Y-m-d H:i:s", $exif['FILE']['FileDateTime']);

            //图片宽高
            $imgsize = getimagesize($img_url);
            $width = $imgsize[0];
            $height = $imgsize[1];
            $data = array(
                'img_time' => $time,//图片拍摄时间
                'latitude' => $latitude,//纬度
                'longitude' => $longitude,//经度
                'address' => $address,//详细地址
                'province' => $province,//省份
                'city' => $city,//城市
                'district' => $district,//区
                'township' => $township,//街道
                'senic_spot'=>$senic_spot,//景点名称
                'height'=>$height,
                'width'=>$width
            );

            return $data;
        }
    }


    //计算经纬度
    public function get_gps($exifCoord,$banqiu)
    {
        $degrees= count($exifCoord) > 0 ? self::gps2Num($exifCoord[0]) : 0;
        $minutes= count($exifCoord) > 1 ? self::gps2Num($exifCoord[1]) : 0;
        $seconds= count($exifCoord) > 2 ? self::gps2Num($exifCoord[2]) : 0;
        $minutes+= 60 * ($degrees- floor($degrees));
        $degrees= floor($degrees);
        $seconds+= 60 * ($minutes- floor($minutes));
        $minutes= floor($minutes);
        if($seconds>= 60)
        {
            $minutes+= floor($seconds/60.0);
            $seconds-= 60*floor($seconds/60.0);
        }
        if($minutes>= 60)
        {
            $degrees+= floor($minutes/60.0);
            $minutes-= 60*floor($minutes/60.0);
        }
        $lng_lat = $degrees + $minutes/60 + $seconds/60/60;
        if(strtoupper($banqiu) == 'W' || strtoupper($banqiu) == 'S'){
            //如果是南半球 或者 西半球 乘以-1
            $lng_lat = $lng_lat * -1;
        }
        return $lng_lat;
        //return array('degrees'=> $degrees, 'minutes'=> $minutes, 'seconds'=> $seconds);
    }

    /*
    取得EXIF的內容
    分数 转 小数
    */
    public  function gps2Num($coordPart)
    {
        $parts= explode('/', $coordPart);
        if(count($parts) <= 0)
            return 0;
        if(count($parts) == 1)
            return $parts[0];
        return floatval($parts[0]) / floatval($parts[1]);
    }
}
echo '<pre>';
print_r(ImgHelper::get_img_info('111133333.jpg','111111222223333'));
echo '</pre>';

php

php 通过CSS文件抓取图片

chen chen 发表于2021-08-20 浏览851 评论0

看到一个喜欢的网站,想抓点图片素材,一个一个复制盛世费劲,分析CSS发现图片元素都写在CSS里面。就不要怪我了。
帖代码

把css内容复制到到 $str中  或者 file_get_contents  CSS的路径 也可以
$str='@charset "utf-8";
body {
    width: 100%;
    height: 100%;
    background: url(../images/bg.jpg) no-repeat;
    .......
';