PHP 微博 发送 查看红包列表

2023-05-16

<?
//aaaaweibohb.php

//发号token
$access_token = "_2A25yCAcuDeRhGeRG7lsU9i7Mwz2IHXVRRbNmrDV8PUJbitAKLU3dkWtNTYgvXJLp7-k6qcElVHTSYziJwT3Egmog";

//领取token
$access_token_GET = 'Cookie: SUB='."_2A25yCAWgDeRhGedJ61AT-SzMzj-IHXVRRbXorDV8PUJbitANLXTmkWtNVmHIxBVIKQELWC4klw2xFEgtqZM8YLkv";
    
require_once "aaaaweiboCode.php";


$money = isset($_REQUEST["money"]) ? $_REQUEST["money"] : "0.03"; //money
$greetings = isset($_REQUEST["greetings"]) ? $_REQUEST["greetings"] : "恭喜发财"; //greetings
$cmd = isset($_REQUEST["cmd"]) ? $_REQUEST["cmd"] : ""; //cmd


if($cmd == "send"){
    create($money,$greetings);//创建订单
    return;
}

$testText = "%E5%BF%AB%E6%9D%A5%E6%8A%A2%EF%BC%8C%E6%89%8B%E5%BF%AB%E6%9C%89%EF%BC%8C%E6%89%8B%E6%85%A2%E6%97%A0%E3%80%82%E6%81%AD%E5%96%9C%E5%8F%91%E8%B4%A2%EF%BC%81";
// echo "$testText=".urldecode($testText);


$Retarr = hbList();//获取红包列表

foreach($Retarr as $value){
    
    $set_id = $value["set_id"];
    $amount = $value["amount"];
    $blessing = $value["blessing"];
    $openRet = $value["openRet"];
    
    echo "ID={$set_id},amount={$amount},blessing={$blessing}<br>";
    
    $yue  = 0;
    $uuid = $blessing;
    $hb_id = $set_id;
    
    if ($amount == "6.66") {
        $yue = 1;
    } else if ($amount == "12.01") {
        $yue = 2;
    }
    if ($yue && $yue > 0  ) {
        $noturl = "http://bcd3a487b3.320.io/Paybc/alipay_id_ini.php?cmd=add&uuid=$uuid&yue=$yue&tradeNo=$hb_id";
        echo file_get_contents($noturl);
    }
    
}



?>
<?php


//aaaaweiboCode.php

$fileName = "weoboHBiog/";//文件名称
is_dir($fileName) OR mkdir($fileName,0777,true);




$url = "https://pay.sc.weibo.com/api/merchant/pay/cashier?sign_type=RSA&sign=bGxMr7zyHyTyi4x80aSU8DaE7g4Yh8KRkg603zuOd07W0gwDk%2Fqo7G3rBX6AWC7GlNUs42tIoDDVwK5SKu2sPvSpH9TF7EnPqSKPGXGhFwOBLLJ7aCZNe2Onz1PIVt4Th4roFPZIC0U5iNBfW15K3VLgTpwRMYRE0JIsFqn1va4%3D&seller_id=5136362277&appkey=743219212&out_pay_id=6000079196652&notify_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwnotify&return_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwreturn%3Fsinainternalbrowser%3Dtopnav&subject=%E5%BE%AE%E5%8D%9A%E7%BA%A2%E5%8C%85&body=&total_amount=100&cfg_follow_uid=5136362277&cfg_share_opt=0&cfg_follow_opt=0";





//创建订单
function create($money="",$blessing=""){
    $blessing = urlencode($blessing);
    $url = "https://mall.e.weibo.com/aj/redenvelope/create";
    //bag_type=0 手气,bag_type=1 普通
    $dat = "bag_type=0&puicode=&msgtype=0&msgid=0&aid=01A3S-OjKNGoF8x3WPxkaX1jRhIwz1h_0ba6J8Lb8u1e78lzM.&amount=1.00&count=1&blessing=%E5%BF%AB%E6%9D%A5%E6%8A%A2%EF%BC%8C%E6%89%8B%E5%BF%AB%E6%9C%89%EF%BC%8C%E6%89%8B%E6%85%A2%E6%97%A0%E3%80%82%E6%81%AD%E5%96%9C%E5%8F%91%E8%B4%A2%EF%BC%81&_t=0";
    
    $dat = "bag_type=0&puicode=&msgtype=0&msgid=0&aid=01A3S-OjKNGoF8x3WPxkaX1jRhIwz1h_0ba6J8Lb8u1e78lzM.&amount=$money&count=1&blessing=%E5%BF%AB%E6%9D%A5%E6%8A%A2%EF%BC%8C%E6%89%8B%E5%BF%AB%E6%9C%89%EF%BC%8C%E6%89%8B%E6%85%A2%E6%97%A0%E3%80%82%E6%81%AD%E5%96%9C%E5%8F%91%E8%B4%A2%EF%BC%81&_t=0";
    
    $dat = "bag_type=1&puicode=&msgtype=2&msgid=4526394552698990&aid=01A3S-OjKNGoF8x3WPxkaX1jRhIwz1h_0ba6J8Lb8u1e78lzM.&singalAmount=$money&count=1&blessing=$blessing&amount=$money&_t=0";
    
    
    $reText = HttppostTx($url,$dat);
    // echo $reText;
    
    $j = json_decode($reText);
    
    $retcode = $j->code;
    $retmsg = $j->msg;
    $retUrl = $j->data->url;
    if($retcode == 100000){
        getWBpay($retUrl);
    }else{
        echo "001".$retmsg;
        
    }
    //{"code":"100000","msg":"\u64cd\u4f5c\u6210\u529f"
    
    
    // echo $retUrl;
    //https://pay.sc.weibo.com/api/merchant/pay/cashier?sign_type=RSA&sign=bGxMr7zyHyTyi4x80aSU8DaE7g4Yh8KRkg603zuOd07W0gwDk%2Fqo7G3rBX6AWC7GlNUs42tIoDDVwK5SKu2sPvSpH9TF7EnPqSKPGXGhFwOBLLJ7aCZNe2Onz1PIVt4Th4roFPZIC0U5iNBfW15K3VLgTpwRMYRE0JIsFqn1va4%3D&seller_id=5136362277&appkey=743219212&out_pay_id=6000079196652&notify_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwnotify&return_url=https%3A%2F%2Fhb.e.weibo.com%2Fv2%2Fbonus%2Fpay%2Fwreturn%3Fsinainternalbrowser%3Dtopnav&subject=%E5%BE%AE%E5%8D%9A%E7%BA%A2%E5%8C%85&body=&total_amount=100&cfg_follow_uid=5136362277&cfg_share_opt=0&cfg_follow_opt=0
    
}
//打开订单-获取-pay_params
function getWBpay($url){
    
    
    $reText = HttppostTx($url,$dat);
    //{"code":0,"msg":"","data":"sinaweibo://wbpay?entry=cashier&pay_params=xxx
    // echo $reText;
    
    $j = json_decode($reText);
    
    $retcode = $j->code;
    $retmsg = $j->msg;
    $data = $j->data;
    if($retcode."" == "0"){
        $data = str_replace("sinaweibo://wbpay?entry=cashier&pay_params=","",$data);
        buildparams($data);
    }else{
        echo "002".$retmsg;
    }

    //sinaweibo://wbpay?entry=cashier&pay_params=
    
    // echo $data;
    //{"code":0,"msg":"","data":"sinaweibo:\/\/wbpay?entry=cashier&pay_params=sign_type%3Dmd5%26sign%3D5903946d44dfaafae60a2616e92ef062%26seller_id%3D5136362277%26out_pay_id%3D6000079196652%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0"}
    
    //sign_type%3Dmd5%26sign%3D5903946d44dfaafae60a2616e92ef062%26seller_id%3D5136362277%26out_pay_id%3D6000079196652%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0
    
    // sign_type%3Dmd5%26sign%3D5903946d44dfaafae60a2616e92ef062%26seller_id%3D5136362277%26out_pay_id%3D6000079196652%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0
    
}
//获取连接
function buildparams($pay_params=""){
    global $access_token;
    
    
    prepare($pay_params);
    
    
    $url = "https://pay.sc.weibo.com/api/client/opensdk/pay/buildparams";
    $dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&channel=ali_cashier&coupon_amount=0&request_str=sign_type%3Dmd5%26sign%3D6e7e7e87c0758057dbb5adc1be8ca6b4%26seller_id%3D5136362277%26out_pay_id%3D6000079194943%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
    
    $dat = "uid=2859560081&gsid=$access_token&channel=ali_cashier&coupon_amount=0&request_str=$pay_params&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
    
    // $dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&channel=ali_cashier&coupon_amount=0&request_str=$pay_params&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
    
    // $dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&channel=ali_cashier&coupon_amount=0&request_str=sign_type%3Dmd5%26sign%3D4adfa9df216c9efc7e996ab5a707eb0a%26seller_id%3D5136362277%26out_pay_id%3D6000079197382%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
    
    // echo $dat;
    $reText = HttppostTx($url,$dat);
    //{code: "100000", msg: "操作成功", data: {
    
    $j = json_decode($reText);
    
    $retcode = $j->code;
    $retmsg = $j->msg;
    $retsdk_data = $j->data->sdk_data;
    if($retcode == 100000){
        echo $retsdk_data;
    }else{
        echo "004".$retmsg;
    }
    
    // echo $reText;
}
//准备支付
function prepare($pay_params=""){
    global $access_token;
    $url = "https://pay.sc.weibo.com/api/client/opensdk/pay/prepare";
    $dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&request_str=sign_type%3Dmd5%26sign%3D4adfa9df216c9efc7e996ab5a707eb0a%26seller_id%3D5136362277%26out_pay_id%3D6000079197382%26appkey%3D743219212%26notify_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwnotify%26return_url%3Dhttps%25253A%25252F%25252Fhb.e.weibo.com%25252Fv2%25252Fbonus%25252Fpay%25252Fwreturn%25253Fsinainternalbrowser%25253Dtopnav%26subject%3D%2525E5%2525BE%2525AE%2525E5%25258D%25259A%2525E7%2525BA%2525A2%2525E5%25258C%252585%26body%3D%26total_amount%3D100%26cfg_follow_uid%3D5136362277%26cfg_share_opt%3D0%26cfg_follow_opt%3D0&is4g=0&apple_pay_allowed=0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
    
    $dat = "uid=2859560081&gsid=_2A25yCAcvDeRxGeRG7lsU9i7Mwz2IHXVunB3nrDV6PUJbkdAKLUSmkWpNTYgvXJY99Xx91EhRxIu0XL2Us5LBH0sS&request_str=$pay_params&is4g=0&apple_pay_allowed=0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
    $dat = "uid=2859560081&gsid=$access_token&request_str=$pay_params&is4g=0&apple_pay_allowed=0&from=10A2093010&v_p=81&wm=3333_2001&lang=zh_CN";
    HttppostTx($url,$dat);
    //{"code":"100000","msg":"\u64cd\u4f5c\u6210\u529f","data":{"is_bind_alipay":1,"permit_sign":0,"total_amount":100,"balance":0,"balance_allowed":0,"method":[{"type":"ali_password","left_text":"","right_text":"","selected":0},{"type":"ali_cashier","left_text":"","right_text":"","selected":1}],"apple_card_type":2,"coupon_total_amount":0,"coupon_amount":0,"fold_count":0,"fold_text":""}}
}
//红包列表
function hbList(){
    $url = "https://mall.e.weibo.com/h5/aj/redenvelope/redstaticlist";
    $dat = "_t=0";
    $reText = HttppostTx($url,$dat);
    //{"code":"100000","msg":"操作成功","data":
    $j = json_decode($reText);
    $Retarr;
    
    $retcode = $j->code;
    $retmsg = $j->msg;
    $ret_html = $j->data->html;
    if($retcode == 100000){
        // echo $ret_html;
        
        //==========自己ID截取=========
        //<a href="https://hongbao.weibo.cn/h5/hongbaolist?ouid=28xxxx081" sud
        $ouid = substrText($ret_html,"https://hongbao.weibo.cn/h5/hongbaolist?ouid=",'" suda-uatrack');
        echo "ID:" . $ouid . "<br>";
        
        //=========红包ID截取==========
        // <a href="https://mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=600xxx4&uicode=">
        //hander
        //<!-- 发出的红包 -->
        //xxxxxxxxxxxxxx
        //<!-- 发出的红包 -->
        //end
        $arrSendHB = explode("<!-- 发出的红包 -->",$ret_html);
        if(count($arrSendHB) == 3){
            $SendHBText = $arrSendHB[1];
        }
        //============金 额============
        //    <p class="amount">1.00元</p>
        
        $arrAmount = explode('p class="amount"',$SendHBText);
        // echo count($arrAmount). "<br>";
        
        $arrSet_id = explode("mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=",$SendHBText);
        $counSet_id = count($arrSet_id);
        // echo $counSet_id;
        
        for($i=1;$i<$counSet_id;++$i){
            $value = "" . $arrSet_id[$i];
            $set_id = substr($value,0,13);
            
            $amount = substrText($arrAmount[$i] ,">" ,"元<");//>1.00元</p>.....
            $fee = intval($amount*100);
            // echo $amount;
            // sendnotify($ouid, $set_id, $fee);
            $openRet = draw($set_id);
            $blessing = getHBinfo($set_id);
            echo "ID=$set_id,金额=$amount,备注=$blessing,格式金额=$fee,打开=$openRet<br>";
            
            $arrtp['set_id']=$set_id;
            $arrtp['amount']=$amount;
            $arrtp['blessing']=$blessing;
            $arrtp['openRet']=$openRet;
            
            $Retarr[] = $arrtp;
        }
        
    }else{
        echo "hbList".$retmsg;
    }
    
    return $Retarr;
    
}
//获取红包备注信息
function getHBinfo($set_id=""){
    global $fileName;
    $hb_order_flie = $fileName . $set_id . "备注";
    
    if(!$set_id || $set_id == ""){
       return "ID nli"; 
    }
    if(file_exists($hb_order_flie)){
        return file_get_contents($hb_order_flie);
    }
    
    $url = "https://mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=6000079387892&uicode=";
    $url = "https://mall.e.weibo.com/h5/redenvelope/recvdetailowner?set_id=$set_id&uicode=";
    $reText =  HttppostTx($url);
    
    // <!-- 主人态红包详情 -->
    if(strpos($reText,"主人态红包详情") > 0){
        //  <p class="blessing">恭喜发财666</p>
        $blessing = substrText($reText,'<p class="blessing">','</p>');
        xdd_file($hb_order_flie, $blessing);
        return $blessing;
    }
    // echo $reText;
}
//打开红包
function draw($set_id=""){
    
    global $access_token_GET;
    
    $tptoken = $access_token_GET;
    //领取红包号Cookie
    // $tptoken = 'Cookie: SUB='."_2A25yCAWgDeRhGedJ61AT-SzMzj-IHXVRRbXorDV8PUJbitANLXTmkWtNVmHIxBVIKQELWC4klw2xFEgtqZM8YLkv";
    
    global $fileName;
    $hb_order_flie = $fileName . $set_id . "open";
    
    if(!$set_id || $set_id == ""){
       return "ID nli"; 
    }
    if(file_exists($hb_order_flie)){
        return "ok";
    }
    
    
    sendmsg($set_id); //发送消息到聊天-否则没有权限
    
    
    $url = "https://mall.e.weibo.com/h5/redenvelope/draw?set_id=6000079360793&sinainternalbrowser=topnav&portrait_only=1&from=10A2093010&weiboauthoruid=";
    $url = "https://mall.e.weibo.com/h5/redenvelope/draw?set_id=$set_id&sinainternalbrowser=topnav&portrait_only=1&from=10A2093010&weiboauthoruid=";
    $reText =  HttppostTx($url,"",$tptoken);
    
    
    // <!--红包开包页面-->
    // <!--来晚了-->
    if(strpos($reText,"红包开包页面") > 0){
        xdd_file($hb_order_flie,"ok");
        return "open ok";
    }else if(strpos($reText,"--来晚了--") > 0){
        $error_word =  substrText($reText,'<p class="error_word">','</p>');
        return "<br>ID=$set_id,".$error_word."<br>";
    }else if(!$reText || $reText == ""){
        // xdd_file($hb_order_flie,"ret nil");
        return "ret nil";
    }
    else{
        return $reText;
    }
}

//发送消息到...
function sendmsg($set_id=""){
    $url = "https://mall.e.weibo.com/aj/redenvelope/sendmsg";
    $dat = "msgid=4526394552698990&msgtype=2&set_id=6000079200997&client_version=10.2.0&_t=0";
    $dat = "msgid=4526394552698990&msgtype=2&set_id=$set_id&client_version=10.2.0&_t=0";
    $reText =  HttppostTx($url,$dat);
}
//发送通知--没用
// function sendnotify($uid="",$set_id="",$fee){
//     $url = "https://mall.e.weibo.com/aj/redenvelope/sendnotify";
//     // $dat = "uid=2859560081&set_id=6000079198644&bonus=73&_t=0";
//     // $dat = "uid=$uid&set_id=$set_id&bonus=73&_t=0";
//     $dat = "uid=$uid&set_id=$set_id&bonus=$fee&_t=0";
//     $reText =  HttppostTx($url,$dat);
//     //{"code":"100000","msg":"操作成功"}
    
//     $j = json_decode($reText);
    
//     $retcode = $j->code;
//     $retmsg = $j->msg;
//     // $retsdk_data = $j->data->sdk_data;
//     if($retcode == 100000){
//         echo $retmsg;
//     }else{
//         echo "sendnotify".$retmsg;
//     }
// }
function HttppostTx($url='', $post_data = '', $ContentType="a:a",$timeout = 5)
{
    global $access_token;
    // curl
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不验证证书

    if ($post_data != '') {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        curl_setopt($ch, CURLOPT_POST, 1);
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Requested-With: XMLHttpRequest',
'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Weibo (iPhone11,6__weibo__10.2.0__iphone__os12.3.1)',
// 'Cookie:  SUB=',
'Cookie: SUB='.$access_token,
$ContentType,
    ));
    $file_contents = curl_exec($ch);
    curl_close($ch);
    return $file_contents;
}
function substrText($str="", $zText="", $yText=""){
// $result = strstr($tempText,'ticket=',1);//取前面

    $result = $zText?strpos($str, $zText, 0):0;//位置
    $resuly = $yText?strpos($str, $yText, $result):0;//文本,寻找文本,何处开始
    
    
    $s1=$result+strlen($zText);
    $s2=$resuly-$s1;
    if(!$yText ){
        $reText =  substr($str, $s1 );
    }else{
        $reText =  substr($str, $s1 , $s2);
    }
    return $reText;
}
function xdd_file($filename,$text=""){
    try {
        if(!$text || $text == ""){
            if(file_exists($filename)){
                return file_get_contents($filename);
            }
            return "";
        }else{
            return file_put_contents($filename, $text);
        }
    } catch (Exception $e) {
       // return $e;
    }
}


?>

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PHP 微博 发送 查看红包列表 的相关文章

  • 带数据透视表的 Laravel 查询生成器

    我有两个带有数据透视表的表 Table tours id name country id featured Table countries id name 数据透视表country tour id country id tour id 我想
  • 将具有子目录的域转发到具有子目录的其他域

    我有一个热爱域名的客户 更喜欢转发域名 其中许多域没有与其关联的网站 它们仅用于营销和转发 我知道如何轻松地将一个域转发到另一个域 但我好奇的是如何将这些域的特定 url 转发到其他特定 url 例如 www site1 com 目录 gt
  • 不带 GROUP BY 的聚合查询

    这个查询似乎在我的旧机器上完美运行 但是 在我的 MySQL 5 7 14 和 PHP 5 6 25 的新机器上 它会抛出错误 致命错误 未捕获异常 PDOException 并带有消息 SQLSTATE 42000 语法错误或访问冲突 1
  • 用于验证 ip 列表中的 ip 范围的正则表达式

    我有正则表达式用于验证 50 个 ips 逗号分隔的列表 25 0 5 2 0 4 0 9 01 0 9 0 9 3 25 0 5 2 0 4 0 9 01 0 9 0 9 1 50 列表示例 10 10 10 1 127 0 0 1 现在
  • 正则表达式将从文本文件中提取句子

    我需要一个正则表达式来从文本文件中提取句子 示例文本 以 2004 年底发生的亚洲海啸灾难为例 对 Google 新闻 http news google com 的查询在一个月内 1 月 17 日 返回了超过 80 000 篇有关该事件的在
  • 在 woocommerce 管理订单页面中单击自定义按钮运行函数

    基于 在 woocommerce 中的管理订单列表顶部添加一个按钮 https stackoverflow com questions 49437781 add a button on top of admin orders list in
  • 在 PHP 中重新定义常量

    是否可以在 php 中重新定义由define功能 我有一个包含多个常量的类 其中包含用户数据 我正在尝试为多个用户使用该类 define ALLEGRO ID id define ALLEGRO LOGIN login define ALL
  • 如何使用 PHP 从图像文件中读取 Lightroom 关键字?

    我有一个照片社区 www jungledragon com http www jungledragon com 允许用户上传照片 我的平台是 PHP CodeIgniter 作为上传过程的一部分 我已经使用 PHP 读取 EXIF 信息ex
  • 如何判断是否ob_start();已经被调用了

    我使用输出缓冲进行 gzip 压缩并访问之前在 PHP 脚本中发布的内容 if ob start ob gzhandler ob start 现在 如果该脚本包含在另一个已使用 ob start 的脚本中 我会收到警告 警告 ob star
  • PHP比较两个字符串的随机位置

    PHP比较两个字符串 示例我得到了一串数字 1 2 2 1 and another is 2 1 2 1 结果是 true 因为它只是 1 2 2 1 和 2 2 1 1 的位置洗牌 但如果该值为 1 2 2 2 and another i
  • PHP—array_merge_recursive() - 相同键没有数组

    php a php gt data1 tag gt div classes gt 1 2 3 php gt data2 tag gt section classes gt 2 3 4 5 6 php gt result array merg
  • 多维数组内的移动

    我有一个用表格显示的数组 如何使用用户输入进行移动 目前 0 被分配给每个数组 但我计划为该数组分配其他值 我的问题是 如何使用用户输入在数组内向上 向下 向右 向左移动和对角移动 Array 0 gt Array 0 gt 0 1 gt
  • 支持通过 OAuth 进行 Facebook/Twitter 身份验证的 CAS 服务器

    我正在寻找一个支持 Facebook Twitter 通过 OAuth 进行单点登录身份验证的 CAS 服务器 我检查过 JASIG CAS 服务器 但它看起来不支持它们 我的 java web 应用程序基于 Spring Security
  • 使用 OpenSSL 在 PHP 中进行 AES 加密/在 Node.js 中进行解密

    我正在使用 PHP 和 Nodejs 使用 OpenSSL 进行对称加密 PHP 使用 OpenSSL 库 Node js 解密基于实现的加密 问题是 Node js 中的解密文本只是部分正确 PHP 加密函数 function encry
  • 如何将 WordPress 类别选择限制为只有一个?

    我有一个自定义帖子类型和一个自定义分类设置 非常标准的东西 但是 我想知道如何限制我的客户在每个帖子中选择多个分类类别 我不介意他们能够创建和删除分类类型 但我不希望他们选择多个分类类型 因为这些是复选框 所以它们可以 也许单选按钮可以工作
  • 获取特定月份/年份的第一天

    有没有比以下更好的方法返回特定月份 年份的第一天的日期 month date m year date Y from date Y m d mktime 0 0 0 month 1 year 这在计算上并不完全优雅 但我喜欢它 因为它非常可读
  • PhpPresentation imagecreatefromstring():数据不是可识别的格式 - PHP7.2

    我正在尝试使用 PhpPresentation 来阅读sample pptx使用文档中为读者提供的简单说明进行文件处理 我得到 imagecreatefromstring Data is not in a recognized format
  • 添加 current_page_item 类

    我正在研究 WordPress 设计 我想创建一个自定义菜单 items wp get nav menu items Menu array order gt ASC orderby gt menu order post type gt na
  • 纠正装饰器模式的一个大缺点

    不久前 我在重构一些游戏战斗代码时决定尝试装饰器模式 战斗者可以拥有各种被动能力 也可能是不同类型的生物 我认为装饰器可以让我在运行时以各种组合添加行为 因此我不需要数百个子类 我几乎已经完成了 15 个左右的被动能力装饰器 在测试中我发现
  • 如何使用 PHP 正确添加跨站请求伪造 (CSRF) 令牌

    我正在尝试为我网站上的表单添加一些安全性 其中一个表单使用 AJAX 另一个表单是简单的 联系我们 表单 我正在尝试添加 CSRF 令牌 我遇到的问题是令牌有时只显示在 HTML 值 中 其余时间 该值为空 这是我在 AJAX 表单上使用的

随机推荐