【微信】禁止微信浏览器后退

Continue Read..
公司做了投票的页面  然后被刷票了  找了一天的BUG  终于被JS兄无意间发现了()   真心大BUG
正常程序是点击后刷新页面 换人投票的 
结果微信可以后退  然后继续出来这个人   就可以无限投票了  
下面就是防止微信浏览器后退的
<script>
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    WeixinJSBridge.call('hideToolbar');
    WeixinJSBridge.call('hideOptionMenu');
});
</script>
<SCRIPT language="JavaScript">
javascript:window.history.forward(1);
</SCRIPT>


php端
header("Cache-control:no-cache,no-store,must-revalidate");
header("Pragma:no-cache");
header("Expires:0");

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

【微信】弹出验证,获取微信用户信息

Continue Read..
function getWxUrl($url, $param = null) {
    if($param != null) {
        $query = http_build_query($param);
        $url = $url . '?' . $query;
    }   
    $ch = curl_init();
    if(stripos($url, "https://") !== false){
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    }   
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
    $content = curl_exec($ch);
    $status = curl_getinfo($ch);
    curl_close($ch);
    if(intval($status["http_code"]) == 200) {
       return $content;
    }else{
        echo $status["http_code"];
        return false;
    }   
}



function getWxAll(){
    if(!strpos($_SERVER['HTTP_USER_AGENT'],"MicroMessenger")){echo '请在微信中打开1'; exit();}
    $AppID = C("Wx_appid"); $AppSecret = C("Wx_token");
    $url = urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    $openid_cookiename = substr(md5($_SERVER['HTTP_USER_AGENT'].get_client_ip()),8,8);
    $openid = cookie($openid_cookiename);
    //$openid = "";     //这里是测试的时候用的 测试的时候打开
    if(empty($openid)){
        $codeid = $_GET['code'];
        if(empty($codeid)){
        //echo "a";
            Redirect('https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$AppID.'&redirect_uri='.$url.'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect');
            exit();
        }else{
        //echo "b";
            $response = getWxCode($codeid);
            if($response == false) {
                return false;
            }
            $user = $response;
           // dump($user);die;
            if (isset($user->error) || $user->openid == "") {
              echo '请在微信中打开2'; exit();
            }
            $openid = $user->openid;
            if(empty($openid)){echo '请在微信中打开3';exit();}
            cookie($openid_cookiename,$openid,30*24*60*60);
        }
    }
}

    //通过第三方获取CODE用户基本信息(未关注也可以获取)
function getWxCode($code){   
$AppID = C("Wx_appid"); $AppSecret = C("Wx_token");
    $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$AppID."&secret=".$AppSecret."&code=".$code."&grant_type=authorization_code";
    $res = getWxUrl($url);
    $data = json_decode($res, true);
    $scope = $data['scope'];
    //当为弹出授权时
    if ($scope == 'snsapi_userinfo'){
   $access_token = $data['access_token'];
   $openid = $data['openid'];
   $url = "https://api.weixin.qq.com/sns/userinfo?access_token=".$access_token."&openid=".$openid;
        $res = getWxUrl($url);
    }
    return json_decode($res, true);
}

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

【微信】限制只允许在微信中打开, 并且能够隐藏获取OPENID。

Continue Read..
  if(!strpos($_SERVER['HTTP_USER_AGENT'],"MicroMessenger")){echo '请在微信中打开'; exit();}
$AppID = 'wx9872b52811ccdbb1'; $AppSecret = '5e5c983fabadc130e2ea5120f7d09a90';
$url = urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$openid_cookiename = substr(md5($_SERVER['HTTP_USER_AGENT'].getClientIp()),8,8);
$openid = cookie($openid_cookiename);
if(empty($openid)){
$codeid = $_GET['code'];
if(empty($codeid)){
Redirect('https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$AppID.'&redirect_uri='.$url.'&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect');
exit();
}else{
$response = $this->get('https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$AppID.'&secret='.$AppSecret.'&code='.$codeid.'&grant_type=authorization_code');
if($response == false) {
return false;
}
$user = json_decode($response);
if (isset($user->error) || $user->openid == "") {
echo '请在微信中打开'; exit();
}
$openid = $user->openid;
if(empty($openid)){echo '请在微信中打开';exit();}
cookie($openid_cookiename,$openid,30*24*60*60);
}
}



public function get($url, $param = null) {
if($param != null) {
$query = http_build_query($param);
$url = $url . '?' . $query;
}   
$ch = curl_init();
if(stripos($url, "https://") !== false){
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}   
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
$content = curl_exec($ch);
$status = curl_getinfo($ch);
curl_close($ch);
if(intval($status["http_code"]) == 200) {
return $content;
}else{
echo $status["http_code"];
return false;
}   
}
限制只允许在微信中打开, 并且能够隐藏获取OPENID。

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

实时日期天数倒计时

Continue Read..
<input type="text" value="" id="input" size="1000"/>

<script type="text/javascript">

function counter() {

var date = new Date();

var year = date.getFullYear();

var date2 = new Date(year, 12, 31, 23, 59, 59);

var time = (date2 - date)/1000;

var day =Math.floor(time/(24*60*60))

var hour = Math.floor(time%(24*60*60)/(60*60))

var minute = Math.floor(time%(24*60*60)%(60*60)/60);

var second = Math.floor(time%(24*60*60)%(60*60)%60);

var str = year + "年还剩"+day+"天"+hour+"时"+minute+"分"+second+"秒";

document.getElementById("input").value = str;

}

window.setInterval("counter()", 1000);

</script>

【TP】获取中文首字母

Continue Read..
/*
 * 获取中文首字母
 */
//获取字段第一个字首字母
function getfirstchar($s0){   
    $fchar = ord($s0{0});
    if($fchar >= ord("A") and $fchar <= ord("z") )return strtoupper($s0{0});
    $s1 = iconv("UTF-8","gb2312", $s0);
    $s2 = iconv("gb2312","UTF-8", $s1);
    if($s2 == $s0){$s = $s1;}else{$s = $s0;}
    $asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
    if($asc >= -20319 and $asc <= -20284) return "A";
    if($asc >= -20283 and $asc <= -19776) return "B";
    if($asc >= -19775 and $asc <= -19219) return "C";
    if($asc >= -19218 and $asc <= -18711) return "D";
    if($asc >= -18710 and $asc <= -18527) return "E";
    if($asc >= -18526 and $asc <= -18240) return "F";
    if($asc >= -18239 and $asc <= -17923) return "G";
    if($asc >= -17922 and $asc <= -17418) return "H";
    if($asc >= -17417 and $asc <= -16475) return "J";
    if($asc >= -16474 and $asc <= -16213) return "K";
    if($asc >= -16212 and $asc <= -15641) return "L";
    if($asc >= -15640 and $asc <= -15166) return "M";
    if($asc >= -15165 and $asc <= -14923) return "N";
    if($asc >= -14922 and $asc <= -14915) return "O";
    if($asc >= -14914 and $asc <= -14631) return "P";
    if($asc >= -14630 and $asc <= -14150) return "Q";
    if($asc >= -14149 and $asc <= -14091) return "R";
    if($asc >= -14090 and $asc <= -13319) return "S";
    if($asc >= -13318 and $asc <= -12839) return "T";
    if($asc >= -12838 and $asc <= -12557) return "W";
    if($asc >= -12556 and $asc <= -11848) return "X";
    if($asc >= -11847 and $asc <= -11056) return "Y";
    if($asc >= -11055 and $asc <= -10247) return "Z";
    return null;
}


/*
 * 读取人员列表  按拼音排序
 */
function getUserName($key = "userArr"){
    
    $data = S($key); //获取缓存数据
    if(!$data){
        if(empty($_SESSION['AdminId'])){
            $AdminId = 0;
        }else{
            $AdminId = $_SESSION['AdminId'];
        }
        $dao = D('user');
        $where['islock'] = 0;
        $where['gsid'] = session("gsid");
        $blockValue = $dao->field('AdminId,cname,tel')->where($where)->order("AdminId asc")->select();
        
        
        $i = 1 ;
        foreach($blockValue as $key => $v){
            $py = getfirstchar($v['cname']);
            $data[$i]['pinyin'] = $py;
            $data[$i]['N_cname'] = $py . '-' . $v['cname'];
            $data[$i]['AdminId'] = $v['AdminId'];
            $data[$i]['cname'] = $v['cname'];
            $data[$i]['tel'] = $v['tel'];
            $i++;
        }
        $data = array_sort($data,'pinyin');
        S($key,$data,C('cachetime')); //保存缓存数据
    }
    return $data ;
}

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

【JS】怎么让傻逼360实现收藏功能

Continue Read..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript"> 
// 设置为主页 
function SetHome(obj,vrl){ 
try{ 
obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl); 
catch(e){ 
if(window.netscape) { 
try { 
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
catch (e) { 
alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); 
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
prefs.setCharPref('browser.startup.homepage',vrl); 
}else{ 
alert("您的浏览器不支持,请按照下面步骤操作:1.打开浏览器设置。2.点击设置网页。3.输入:"+vrl+"点击确定。"); 
// 加入收藏 兼容360和IE6 
function shoucang(sTitle,sURL) 
try 

window.external.addFavorite(sURL, sTitle); 
window.external.addFavorite('http://www.xtszyy.com');
catch (e) 

try 

window.sidebar.addPanel(sTitle, sURL, ""); 
catch (e) 
alert("加入收藏失败,请使用Ctrl+D进行添加"); 
</script>
</head>

<body>
<li class="fore1"><a href="javascript:void(0)" onclick="SetHome(this,window.location)">设为首页</a></li> 
<li class="ge">|</li> 
<li class="fore2"><a href="javascript:void(0)" onclick="shoucang(document.title,window.location)">加入收藏</a></li> 
<li class="ge">|</li> 
</body>
</html>

【PHP】访问url接口 获取返回值

Continue Read..

今天公司要做短信接口   然后是个url的

而且是get参数 中文必须是gbk的

 

$content = '您正在进行手机验证服务,验证码:'.$yzm.'请勿泄漏此信息'.'【'.$qm.'】';

$content = urlencode(iconv('UTF-8', 'GB2312', $content));

 

 

$ch = curl_init();

// 2. 设置选项,包括URL

curl_setopt($ch, CURLOPT_URL, "http://admin.sms9.net/houtai/sms.php?cpid=9454&password=".$password."&channelid=13063&tele=".$phone."&msg=".$content."&timestamp=".$timestamp);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HEADER, 0);

// 3. 执行并获取HTML文档内容

$output = curl_exec($ch);

// 4. 释放curl句柄

curl_close($ch);

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权