mysql插入先判断是否存在 若没有则插入 若有则更新

INSERT INTO history(staid, stype, sdate, svalue) VALUES( '53357', 1, '2022-06-20 10:00:00', 0.1)
ON DUPLICATE KEY
UPDATE svalue = 0.3

来源:天气API tianqiapi.com


程序猿 发布于 2022-6-17 01:31

PHP通过CURL伪装IP来源

请求这个url打开输出自己的ip, 用PHP提交后, IP为 101.32.22.109
↓↓↓
$url = 'https://quan.xianguomall.com/gaode2.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('CLIENT-IP: 101.32.22.109','X-FORWARDED-FOR: 101.32.22.109'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// 模拟来源
curl_setopt($ch, CURLOPT_REFERER, '');
$response = curl_exec($ch);
if($error=curl_error($ch)){
die($error);
}
curl_close($ch);
echo $response;


程序猿 发布于 2022-6-16 05:46

nginx伪静态demo

location /china {
rewrite ^/china.xml$ /index.php?c=xmlapi;
}
location /t/xml_city {
rewrite ^/t/xml_city/([a-zA-Z]+).xml$ /index.php?c=xmlapi&a=city&alias=$1;
}

location /news {
rewrite ^/news/(\d+)/(\d+)(|\/)$ /news/index.php?catid=$1&page=$2;
}
location /newsinfo {
rewrite ^/newsinfo/(\d+).html$ /news/info.php?id=$1;
}


程序猿 发布于 2022-5-17 06:29

微信小程序优惠券领券核销源码 领券核销平台

领券演示小程序 , 如需购买源码请联系微信: hype522147

微信公众号+小程序领券核销源码


操作流程非常简单

用户端: 扫码进入店铺小程序 > 点击领券 > 支付 > 出示二维码核销
管理端: 打开微信扫一扫扫描用户出示的二维码 > 核销成功
后台端: 创建优惠券、套餐券、订单查看、店员管理(扫码绑定)、结算提现、数据报表等等
BOSS端: 店铺审核、券管理、订单管理、结算管理、用户管理、流量统计等等

界面截图

小程序截图 小程序截图 小程序截图
...

程序猿 发布于 2022-4-10 12:41

微信小程序返回上一页 没有上一页的情况下返回首页

微信小程序返回上一页 没有上一页的情况下返回首页

goback: function (e) {
        let pages = getCurrentPages();
        if (pages.length > 1) {
          wx.navigateBack({//返回
            delta: 1
          });
        }
        if (pages.length == 1) {
          wx.reLaunch({
            url: '/pages/index/index',
          })
        }
      },

程序猿 发布于 2022-3-25 06:55

PHP 计算两个坐标之间距离

/**

  • 计算两个坐标(经度,纬度)之间距离
    /
    public static function distance($lat1, $lng1, $lat2, $lng2, $miles = true)
    {
    $pi80 = M_PI / 180;
    $lat1
    = $pi80;
    $lng1 = $pi80;
    $lat2
    = $pi80;
    $lng2 = $pi80;
    $r = 6372.797; // mean radius of Earth in km
    $dlat = $lat2 - $lat1;
    $dlng = $lng2 - $lng1;
    $a = sin($dlat/2)
    sin($dlat/2)+cos($lat1)cos($lat2)sin($dlng/2)sin($dlng/2);
    $c = 2
    atan2(sqrt($a), sqrt(1 - $a));
    $km = $r $c;
    return ($miles ? ($km
    0.621371192) : $km);
    }

程序猿 发布于 2022-2-11 08:40

2022年北京东奥会奖牌榜API接口

官网文档地址
https://yikeapi.com/index/olympic

请求方式
GET

接口地址:
http://apia.yikeapi.com/olympic/

请求示例 (appid和appsecret进入官网注册账号)
http://apia.yikeapi.com/olympic/?appid=&appsecret=

请求参数说明:
appid 用户appid
appsecret 用户appsecret
callback jsonp参数 如: jQuery.Callbacks
vue 跨域参数 如果您使用的是react、vue、angular请填写值: 1

返回JSON示例

   {
        "errcode":0,
        "errmsg":"success",
        "update_time":"2022-01-01 11:26:46",
        "list":[
            {
                "country":"中国", #国家名称
                "flag":"https://search-operate.cdn.bcebos.com/7dce3e5758a82e720ec1c7123d246616.png", #国旗图片CDN
                "jin":1, #金牌
                "yin":0, #银牌
                "tong":0, #铜牌
                "total":1 #总数
            },
            {
                "country":"美国",
                "flag":"https://search-operate.cdn.bcebos.com/8c00d69be531ba4b21d5100d2a13fb8b.png",
                "jin":0,
                "yin":1,
                "tong":0,
                "total":1
            },
            {
                "country":"澳大利亚",
                "flag":"https://search-operate.cdn.bcebos.com/be6980d6afd68c698d92dd85b00ac35e.png",
                "jin":0,
                "yin":0,
                "tong":1,
                "total":1
            }
        ]
    }

程序猿 发布于 2022-2-3 02:12

12306列车查询API接口对接 高铁动车查询接口文档

该接口提供全国火车票车次查询, 站到站查询接口。
比如您查询"济南"到"北京", 接口会返回所有济南到北京的列车, 慢车、动车、高铁都会有, 但是不会出现票价, 适合做出行规划。

请求方式:GET

接口地址:
http://apia.yikeapi.com/train/

请求示例
http://apia.yikeapi.com/train/?start_station=烟台&stop_station=青岛&appid=43656176&appsecret=I42og6Lm

请求参数说明:

参数名 必选 类型 说明 备注(示例)
appid string 用户appid 注册开发者账号
appsecret string 用户appsecret
start_station string 出发站 示例: 烟台
stop_station string 终点站 示例: 青岛

响应JSON

{
    "errcode":0,
    "errmsg":"success",
    "api":"yikeapi.com",
    "usetime":0.10343503952026367,
    "list":[
        {
            "train_id":"16019",//列车编号,根据此编号查询列车详情
            "station_train_code":"C6520",//列车名称
            "train_from_station":"烟台",//列车始发站
            "train_to_station":"青岛",//列车终点站
            "from_station":"烟台",//出发站
            "to_station":"青岛",//到达站
            "start_time_unix":1642544460,
            "start_time":"06:21",//出发时间
            "stop_time":"08:12",//到达时间
            "day_diff":0//是否跨日, 0:否 1是
        },
        {
            "train_id":"9861",
            "station_train_code":"D2926",
            "train_from_station":"荣成",
            "train_to_station":"上海虹桥",
            "from_station":"烟台南",
            "to_station":"青岛西",
            "start_time_unix":1642546560,
            "start_time":"06:56",
            "stop_time":"08:53",
            "day_diff":0
        },
        {
            "train_id":"8173",
            "station_train_code":"D2138",
            "train_from_station":"烟台",
            "train_to_station":"上海虹桥",
            "from_station":"烟台",
            "to_station":"青岛西",
            "start_time_unix":1642548840,
            "start_time":"07:34",
            "stop_time":"09:41",
            "day_diff":0
        },
        {
            "train_id":"21837",
            "station_train_code":"C6552",
            "train_from_station":"荣成",
            "train_to_station":"青岛北",
            "from_station":"烟台南",
            "to_station":"青岛北",
            "start_time_unix":1642549080,
            "start_time":"07:38",
            "stop_time":"08:40",
            "day_diff":0
        },
        {
            "train_id":"3346",
            "station_train_code":"G5588",
            "train_from_station":"威海",
            "train_to_station":"曲阜东",
            "from_station":"烟台南",
            "to_station":"青岛北",
            "start_time_unix":1642551960,
            "start_time":"08:26",
            "stop_time":"09:44",
            "day_diff":0
        },
        {
            "train_id":"4535",
            "station_train_code":"G1850",
            "train_from_station":"烟台",
            "train_to_station":"长沙南",
            "from_station":"烟台",
            "to_station":"青岛西",
            "start_time_unix":1642556640,
            "start_time":"09:44",
            "stop_time":"11:35",
            "day_diff":0
        },
        {
            "train_id":"4880",
            "station_train_code":"G2684",
            "train_from_station":"威海",
            "train_to_station":"兰州西",
            "from_station":"烟台南",
            "to_station":"青岛西",
            "start_time_unix":1642558560,
            "start_time":"10:16",
            "stop_time":"11:57",
            "day_diff":0
        },
        {
            "train_id":"20773",
            "station_train_code":"C6546",
            "train_from_station":"烟台",
            "train_to_station":"青岛北",
            "from_station":"烟台",
            "to_station":"青岛北",
            "start_time_unix":1642558560,
            "start_time":"10:16",
            "stop_time":"11:23",
            "day_diff":0
        },
        {
            "train_id":"8746",
            "station_train_code":"D6050",
            "train_from_station":"烟台",
            "train_to_station":"青岛北",
            "from_station":"烟台",
            "to_station":"青岛北",
            "start_time_unix":1642559520,
            "start_time":"10:32",
            "stop_time":"11:40",
            "day_diff":0
        },
        {
            "train_id":"21440",
            "station_train_code":"C6508",
            "train_from_station":"荣成",
            "train_to_station":"青岛",
            "from_station":"烟台南",
            "to_station":"青岛",
            "start_time_unix":1642571760,
            "start_time":"13:56",
            "stop_time":"15:40",
            "day_diff":0
        },
        {
            "train_id":"20506",
            "station_train_code":"C6544",
            "train_from_station":"威海",
            "train_to_station":"青岛",
            "from_station":"烟台南",
            "to_station":"青岛",
            "start_time_unix":1642573680,
            "start_time":"14:28",
            "stop_time":"15:50",
            "day_diff":0
        },
        {
            "train_id":"8744",
            "station_train_code":"D6046",
            "train_from_station":"烟台",
            "train_to_station":"青岛",
            "from_station":"烟台",
            "to_station":"青岛",
            "start_time_unix":1642573980,
            "start_time":"14:33",
            "stop_time":"16:29",
            "day_diff":0
        },
        {
            "train_id":"3344",
            "station_train_code":"G5584",
            "train_from_station":"威海",
            "train_to_station":"曲阜东",
            "from_station":"烟台南",
            "to_station":"青岛西",
            "start_time_unix":1642575600,
            "start_time":"15:00",
            "stop_time":"16:39",
            "day_diff":0
        },
        {
            "train_id":"9863",
            "station_train_code":"D2930",
            "train_from_station":"威海",
            "train_to_station":"上海虹桥",
            "from_station":"烟台南",
            "to_station":"青岛西",
            "start_time_unix":1642577340,
            "start_time":"15:29",
            "stop_time":"17:06",
            "day_diff":0
        },
        {
            "train_id":"3348",
            "station_train_code":"G5592",
            "train_from_station":"烟台",
            "train_to_station":"菏泽东",
            "from_station":"烟台",
            "to_station":"青岛西",
            "start_time_unix":1642577760,
            "start_time":"15:36",
            "stop_time":"17:18",
            "day_diff":0
        },
        {
            "train_id":"21438",
            "station_train_code":"C6504",
            "train_from_station":"荣成",
            "train_to_station":"青岛",
            "from_station":"烟台南",
            "to_station":"青岛",
            "start_time_unix":1642585080,
            "start_time":"17:38",
            "stop_time":"19:17",
            "day_diff":0
        },
        {
            "train_id":"23007",
            "station_train_code":"C6582",
            "train_from_station":"威海",
            "train_to_station":"青岛北",
            "from_station":"烟台南",
            "to_station":"青岛北",
            "start_time_unix":1642586160,
            "start_time":"17:56",
            "stop_time":"18:58",
            "day_diff":0
        },
        {
            "train_id":"23009",
            "station_train_code":"C6588",
            "train_from_station":"威海",
            "train_to_station":"青岛",
            "from_station":"烟台南",
            "to_station":"青岛",
            "start_time_unix":1642586940,
            "start_time":"18:09",
            "stop_time":"20:01",
            "day_diff":0
        },
        {
            "train_id":"8768",
            "station_train_code":"D6092",
            "train_from_station":"烟台",
            "train_to_station":"青岛北",
            "from_station":"烟台",
            "to_station":"青岛北",
            "start_time_unix":1642589280,
            "start_time":"18:48",
            "stop_time":"20:00",
            "day_diff":0
        },
        {
            "train_id":"22804",
            "station_train_code":"C6578",
            "train_from_station":"烟台",
            "train_to_station":"青岛北",
            "from_station":"烟台",
            "to_station":"青岛北",
            "start_time_unix":1642592040,
            "start_time":"19:34",
            "stop_time":"20:54",
            "day_diff":0
        },
        {
            "train_id":"23945",
            "station_train_code":"C662",
            "train_from_station":"龙口市",
            "train_to_station":"青岛",
            "from_station":"烟台",
            "to_station":"青岛",
            "start_time_unix":1642593240,
            "start_time":"19:54",
            "stop_time":"22:11",
            "day_diff":0
        }
    ]
}

程序猿 发布于 2022-1-21 09:14

nohup 不输出log

执行守护程序,并且不输出log
nohup sh ./timer_hours.sh > /dev/null 2>&1 &


程序猿 发布于 2022-1-18 09:20

linux 定期删除文件夹下一周前的文件 + 定时任务

find ./ -mtime +5 -name "*.php" -exec rm -rf {} \;

find:linux的查找命令,用户查找指定条件的文件;
/data/wwwroot/log/:想要进行清理的任意目录;
-mtime:标准语句写法;
+30:查找30天前的文件,这里用数字代表天数;
".log":希望查找的数据类型,""表示查找所有文件
-exec:固定写法;
rm -rf:强制删除文件,包括目录;
{} \; :固定写法,一对大括号+空格++;


程序猿 发布于 2021-12-24 05:59
    1 2

搜索