Welcom to 评论 - lizhenqiu blog!
#818
#819
show_cover_pic=1
#820
/*清除浮动*/ * html .q {height:1%;} *+html .q {height:1%;} .q:after {content:""; display:block; height:0; clear:both; overflow:hidden;} .clear {clear:both; height:0px; overflow:hidden;} .hidden {display:none;}
#821
function hi(){ var a = 1; return function(){ console.log(a++); }; }; var aaa = hi(); var bbb = hi; aaa(); aaa(); bbb();
aaa 是将 hi() 的运行结果赋值给它,即 return 返回的匿名函数,此时有一个闭包,则每次调用 aaa 时都访问的同一个 a,aaa() 第一次运行结果为 1,第二次为2 而 bbb 将是将 hi 这个函数名赋值给它,则调用 bbb() 后返回一个函数表达式,即function(){console.log(a++)};
bbb就是hi本身,换句话说就是外层的function。bbb()的结果应该跟hi()的结果一样。 aaa是hi()调用之后返回的那个东西,也就是说它是里层的function,a是它闭包里面的一个对象。aaa()的调用结果是console.log(a++)。
hi()是将hi函数运行之后返回 function(){console.log(a++)},这种返回值是函数的方法叫做函数式编程,楼主可以查找下相关的资料看看。 aaa 的值是 function(){console.log(a++)},而aaa再次运行的话就会打印出来a的值,这个地方可以看下上面那个hi函数,其中包含一个闭包,也就是说hi函数返回的function(){console.log(a++)}这个函数会一直保持着对引用,也就是说每调用一次 aaa ,那么打印的值都会加上1,关于具体的闭包,楼主还是可以自己查查资料 bbb 的值就是hi函数,这是一个普通的赋值操作
#822
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>sticky footer</title> <style type="text/css"> *{padding: 0;margin: 0;font-size: 48px} /* 第一步设置盒子为满屏大小 */ .box{ position: fixed; width: 100%; height: 100%; top: 0; left: 0; overflow: auto; background: green; } /* 第二步子盒子设置最小高度且清除浮动 给一个padding-bottom 等于footer 避免内容被footer遮盖*/ .box .main{ width: 100%; min-height: 100%; padding-bottom: 100px; } .box .main .content{ background: orange; /*padding-bottom: 100px;*/ } /* 第三步footer的高度和margin-top要相等 */ .box .footer{ position: relative; width: 100%; height: 100px; background: #f3f3f3; margin: -100px auto 0 auto; clear: both; text-align: center; line-height: 100px; } .clearfix{ display: inline-block; } .clearfix::after{ content: "."; display: block; height: 0; line-height: 0; visibility: hidden; clear: both; } </style> </head> <body> <div class="box"> <div class="main clearfix"> <div class="content"> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> </div> </div> <div class="footer">这是footer区域</div> </div> </body> </html>
<html> <head> <style> body { display: flex; flex-flow: column; min-height: 100vh; } main{flex:1} header,footer{height:80px;} </style> </head> <body> <header> <h1>Site name</h1> </header> <main> <p>Bacon Ipsum dolor sit amet... <!-- Filler text from baconipsum.com --> </p> </main> <footer> <p> © 2015 No rights reserved.</p> <p>Made with ♥ by an anonymous pastafarian.</p> </footer> </body> </html>
#823
1、对 this 的关联。函数内置 this 的值,取决于箭头函数在哪儿定义,而非箭头函数执行的上下文环境。 2 、new 不可用。箭头函数不能使用 new 关键字来实例化对象,不然会报错。 3、this 不可变。函数内置 this 不可变,在函数体内整个执行环境中为常量。 4、没有arguments对象。更不能通过arguments对象访问传入参数。只能使用显式命名或其他ES6新特性来完成。
var sum = () => 1 + 2; // 等同于: var sum = function() { return 1 + 2; };
var reflect = value => value; // 等同于: var reflect = function(value) { return value; }; x => x * x //等同于: function (x) { return x * x; }
var sum = (num1, num2) => num1 + num2; // 等同于: var sum = function(num1, num2) { return num1 + num2; };
var sum = (num1, num2) => { return num1 + num2; } //等同于: var sum = function(num1, num2) { return num1 + num2; };
var getTempItem = id = > ({ id: id, name: "Temp" }); // 等同于: var getTempItem = function(id) { return { id: id, name: "Temp" }; };
var obj = { birth: 1990, getAge: function () { var b = this.birth; // 1990 var fn = () => new Date().getFullYear() - this.birth; // this指向obj对象 return fn(); } }; obj.getAge(); // 25
var that = this;
var obj = { birth: 1990, getAge: function (year) { var b = this.birth; // 1990 var fn = (y) => y - this.birth; // this.birth仍是1990 return fn.call({birth:2000}, year); } }; obj.getAge(2015); // 25
#824
<?php namespace Addons\Qunsend\Controller; use Home\Controller\AddonsController; class QunsendController extends AddonsController{ function sf(){ $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); } function nconfig(){ return getAddonConfig ( 'WeiSite' ); } //预览 function qunfasyl(){ $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $nconfig=$this->nconfig(); //echo $nconfig['bbyueyuesjttsyywxh'];exit; $access_token=get_access_token (); $s=M('qunsend')->where('id='.$id)->find(); $media_id=$s['media_id']; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"'.$nconfig['bbyueyuesjttsyywxh'].'","mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); //dump($res['0']); if($res['0']!=0){ echo $res['errmsg']; exit; } $sav['qf']='已预览'; M('qunsend')->where('id='.$id)->save($sav); $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); //if($res['0']==0) echo '预览已经发送'; exit; } //推送 function qunfas(){ //exit; $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $access_token=get_access_token (); $s=M('qunsend')->where('id='.$id)->find(); $media_id=$s['media_id']; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=' . $access_token; $paramStr .= '{"filter":{"is_to_all":true},"mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews","send_ignore_reprint":0}'; $res = post_data ( $url, $paramStr ); if($res['0']!=0){ echo $res['errmsg']; exit; } $sav['qf']='已经群发'; M('qunsend')->where('id='.$id)->save($sav); $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); //dump($res); exit; } //多个推送 function morepostgetss($s,$access_token,$contenttop,$contentbottom,$id){ foreach($s as $k=>$a){ //封面上传 if(!$a['cover']){ $path='/logo2.jpg';} else{ $path = get_cover ( $a['cover'] ); $path = $path['path']; $res=$this->wximgup($path,$access_token); $coverurl=$res['media_id']; } //内容图片 $content=$a['content']; $content=str_ireplace("data-src=","src=",$content); preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match); foreach($match['1'] as $k=>&$v){ $res=$this->wximgup($v,$access_token,1); $content=str_ireplace($v,$res['url'],$content); } $nconfig=$this->nconfig(); $jsonArr['articles'][]=array( // 我就是少了这层array 才会报empty news data 错误 "title"=> $a['ntitle'],//标题 "thumb_media_id"=> $coverurl, "author"=>$nconfig['bbyueyuesjttsyywxh'],//发布者 "digest"=> $a['intro'],//简介 "show_cover_pic"=> 1,//是否显示封面? "content"=> $contenttop.$content.$contentbottom, "content_source_url"=> 'http://bcwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/index.html'//'http://ihosuwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/lastprice/sp/sp/id/'.$id.'.html', ); } $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; //dump($jsonArr['articles']);exit; $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=post_data ( $articlesurl, $json3, true ); $media_id=$res['media_id']; //dump($res);exit; $acs['sid']=$s['0']['id']; $acs['title']=$s['0']['ntitle']; $acs['ctime']=time(); $acs['media_id']=$media_id; $acs['content']=$s['0']['content']; $acs['coverurl']=$jsonArr['articles']['0']['thumb_media_id']; $cs=M('qunsend')->add($acs); echo $cs; exit; /* 预览 $nconfig=$this->nconfig(); $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"'.$nconfig['bbyueyuesjttsyywxh'].'","mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); dump($res);exit;*/ } function ass(){ //获取推送文章 qunsend $id=I('get.id'); if(!$id){ echo 'no id'; exit; } $access_token=get_access_token (); $contenttop='<p><img src="http://mmbiz.qpic.cn/mmbiz_gif/qbke2mSU58VnW25BcMnoDRqJUNULibduT7b7bBLnWcvxgWCgzpg17QRKcz8icj7vrCoHG9a6gfiabuZuOl5oeluBw/0"></p>'; $contentbottom='<p><img src="http://mmbiz.qpic.cn/mmbiz_gif/qbke2mSU58VnW25BcMnoDRqJUNULibduT6EiaeRoqKTA8ObByU69qNMnBibqYkjeWtThD1dUm8vAwoGuHlm6JsiaOA/0"></p>'; /*$p='\618-150429120J5.gif'; $res=$this->wximgup($p,$access_token,1); dump($res); exit;*/ //是否多个群发 $inid=explode(',',$id); if($inid['1']){ //多个群发 $wc['id']=array('in','0,'.$id); $s=M('custom_reply_news')->where($wc)->select(); $this->morepostgetss($s,$access_token,$contenttop,$contentbottom,$inid['0']); return false; }else{ $s=M('custom_reply_news')->where('id='.$id)->find(); } $s['title']=$s['ntitle']; //dump($s);exit; $content=$s['content']; preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match); /*dump($match); exit;*/ //重新上传文中的图片链接 //$nimgurl=explode('<img src="',$s['content']); foreach($match['1'] as $k=>&$v){ $res=$this->wximgup($v,$access_token,1); $content=str_ireplace($v,$res['url'],$content); } /*dump($content); exit;*/ //$content=$s['content']; //$content=21321321;//str_ireplace('/Uploads/Editor/gh_c7d5c953c490/','http://ihosuwx.test2.resonance.net.cn/Uploads/Editor/gh_c7d5c953c490/',$content); //检查是否存在预推送文章 /*$cs=M('qunsend')->where('sid='.$id)->find(); if(empty($cs)){ }else{ exit; } //防止文章修改推送 改为使用最新 所以每次添加 */ if(!$s['cover']) $path='/logo.png'; else{ $path = get_cover ( $s['cover'] ); $path = $path['path']; } $nconfig=$this->nconfig(); //900*500比例尺寸 2017.10.10 if($nconfig['wxfmzdddd']){ $this->getnewjjfm($path); $path='/12345678980.jpg'; } //end //修复空封面bug $res=$this->wximgup($path,$access_token); //dump($res); //exit; $coverurl=$res['media_id']; //$content=$nimgurl;//$s['content']; //echo $content;exit; $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; $jsonArr = array( "articles"=> array( array( // 我就是少了这层array 才会报empty news data 错误 "title"=> $s['title'], "thumb_media_id"=> $coverurl, "author"=> $nconfig['bbyueyuesjttsyywxh'], "digest"=> $s['intro'], "show_cover_pic"=> 0, "content"=> $contenttop.$content.$contentbottom, "content_source_url"=> 'http://bcwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/index.html',//'http://ihosuwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/lastprice/sp/sp/id/'.$id.'.html', ) ) ); $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=post_data ( $articlesurl, $json3, true ); $media_id=$res['media_id']; /*$url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"iswtf_","mpnews":{"media_id":"'.$res['media_id'].'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr );*/ //dump($res);exit; $acs['sid']=$id; $acs['title']=$s['title']; $acs['ctime']=time(); $acs['media_id']=$media_id; $acs['content']=$content; $acs['coverurl']=$coverurl; $cs=M('qunsend')->add($acs); echo $cs; //dump($acs); exit; //echo 'fasd'; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; //$paramStr .= '{"filter":{"is_to_all":true},'; //$paramStr .= '"text":{"content":"' . '3432423423' . '"},"msgtype":"text"}'; $res=$this->get_image_media_id(740,$access_token); $paramStr .= '{"towxname":"iswtf_","mpnews":{"media_id":"'.$res['media_id'].'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); dump($res); //$neww=$this->get_image_media_id(625); //dump($neww); //$this->display(); } //上传图片到微信 function wximgup($path,$access_token,$u){ $url='https://api.weixin.qq.com/cgi-bin/media/uploadimg'; if(!$u) $url='https://api.weixin.qq.com/cgi-bin/media/upload'; $param ['media'] = '@' . realpath(SITE_PATH . $path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token; $param ['type'] = 'image'; //$param ['media'] = curl_file_create($path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token); $param ['access_token'] = $access_token; return $res = post_data ( $url, $param, true ); } // 新增临时图片素材 function get_image_media_id($cover_id,$access_token) { $cover = get_cover ( $cover_id ); $path = $cover ['path']; /*echo get_access_token ();exit; $key = 'access_token_' . get_token (); echo S ( $key );exit;*/ /*$key = 'access_token_' . get_token (); S ( $key, 0, 7200 );*/ //echo realpath(SITE_PATH . $path);exit; //$access_token=get_access_token (); //$url='https://api.weixin.qq.com/cgi-bin/media/uploadimg'; $url='https://api.weixin.qq.com/cgi-bin/media/upload'; $param ['media'] = '@' . realpath(SITE_PATH . $path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token; $param ['type'] = 'image'; //$param ['media'] = curl_file_create($path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token); $param ['access_token'] = $access_token; return $res = post_data ( $url, $param, true ); //start $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; //$articlesparam ['access_token'] = $access_token; /*$articlesparam ['articles'][0]['thumb_media_id'] = $res['media_id']; $articlesparam ['articles'][0]['author'] = '3432423'; $articlesparam ['articles'][0]['title'] = 'Happy Day'; $articlesparam ['articles'][0]['content_source_url'] = 'www.qq.com'; $articlesparam ['articles'][0]['content'] = 'content'; $articlesparam ['articles'][0]['digest'] = 'digest'; $articlesparam ['articles'][0]['show_cover_pic'] = 1;*/ $jsonArr = array( "articles"=> array( array( // 我就是少了这层array 才会报empty news data 错误 "title"=> 'dingdingdemo', "thumb_media_id"=> $res['media_id'], "author"=> 'martin', "digest"=> 'digest', "show_cover_pic"=> 0, "content"=> $content, "content_source_url"=> 'https://www.baidu.com/', ) ) ); $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); return post_data ( $articlesurl, $json3, true ); //end return $res['media_id']; echo $path;exit; $driver = C ( 'PICTURE_UPLOAD_DRIVER' ); if ($driver != 'Local' && ! file_exists ( SITE_PATH . $cover ['path'] )) { // 先把图片下载到本地 $pathinfo = pathinfo ( SITE_PATH . $cover ['path'] ); mkdirs ( $pathinfo ['dirname'] ); $content = wp_file_get_contents ( $cover ['url'] ); $res = file_put_contents ( SITE_PATH . $cover ['path'], $content ); if (! $res) { return 0; } } $path = $cover ['path']; if (! $path) { return 0; } $param ['type'] = 'image'; $param ['media'] = '@' . realpath ( SITE_PATH . $path ); $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . get_access_token (); $res = post_data ( $url, $param, true ); if (isset ( $res ['errcode'] ) && $res ['errcode'] != 0) { return $res; } return $res ['media_id']; } function getnewjjfm($src){ //原始图像 $dst = "./a.png"; //实测900*500比例尺寸图片已不会出现裁剪图片边缘的问题,只需要发送多图文消息时注意标题文字是否会挡住图片内容即可。 $minx=900; $miny=500; //得到原始图片信息 $dst_im = imagecreatefrompng($dst); $dst_info = getimagesize($dst); //水印图像 $src = ".".$src; $src_im = imagecreatefromjpeg($src); $src_info = getimagesize($src); $nx=$src_info[0]; $ny=$src_info[1]; if($nx>$minx || $ny>$miny){ //获取大图信息 $maxx=$src_info[0];//宽 $maxy=$src_info[1];//长 $maxt=$src_info[2];//格式 $maxm=$src_info['mime'];//mime类型 //缩放判断 if(($minx/$maxx)>($miny/$maxy)){ $scale=$miny/$maxy; }else{ $scale=$minx/$maxx; } //对所求值进行取整 $minx=floor($maxx*$scale); $miny=floor($maxy*$scale); //添加小图 $minim=imagecreatetruecolor($minx,$miny); //缩放函数 imagecopyresampled($minim,$src_im,0,0,0,0,$minx,$miny,$maxx,$maxy); //imagejpeg($minim); $src_im=$minim; $nx=$minx; $ny=$miny; } //水印透明度 $alpha = 100; $nwx=($dst_info[0]-$nx)/2; $nwy=($dst_info[1]-$ny)/2; //imagealphablending($dst_im , false);//关闭混合模式,以便透明颜色能覆盖原画板 //imagefill($image , 0 , 0 , $bg);//填充 imagesavealpha($dst_im , true);//设置保存PNG时保留透明通道信息 //合并水印图片 imagecopymerge($dst_im,$src_im,$nwx,$nwy,0,0,$nx,$ny,$alpha); //输出合并后水印图片 imagepng($dst_im,'./12345678980.jpg'); imagedestroy($dst_im); imagedestroy($src_im); } }
<extend name="Base/common" /> <block name="body"> <div class="span9 page_message"> <section id="contents"> <include file="Addons/_nav" /> <if condition="$add_button || $del_button || $search_button || !empty($top_more_button)"> <div class="table-bar"> <div class="fl"> <empty name="model.extend"> <div class="tools"> <if condition="$add_button"><php> $add_url || $add_url = U('add?model='.$model['id'], $get_param);</php><a class="btn" href="{$add_url}">新 增</a></if> <if condition="$del_button"><php> $del_url || $del_url = U('del?model='.$model['id'], $get_param);</php><button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">删 除</button></if> <php>$url=addons_url ( 'WeiSite://Cms/lists' ); $geturl= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; </php> <if condition="$url eq $geturl"><button class="btn ajax-post confirm create" target-form="ids">生成群发</button> </if> <volist name="top_more_button" id="vo"> <if condition="$vo[is_buttion]"> <button class="btn {$vo.class}" target-form="ids" url="{$vo.url}">{$vo.title}</button> <else /> <a class="btn" href="{$vo.url}">{$vo.title}</a> </if> </volist> </div> </empty> </div> <!-- 高级搜索 --> <if condition="$search_button"> <div class="search-form fr cf"> <div class="sleft"> <php> $get_param[model]=$model['name']; $search_url || $search_url = addons_url($_REQUEST ['_addons'].'://'.$_REQUEST ['_controller'].'/lists', $get_param);</php> <php>empty($search_key) && $search_key=$model['search_key'];empty($search_key) && $search_key='title';</php> <input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}" placeholder="{$placeholder}"> <a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a> </div> </div> </if> </div> </if> <!-- 数据列表 --> <div class="data-table"> <div class="table-striped"> <table cellspacing="1"> <!-- 表头 --> <thead> <tr> <if condition="$check_all"><th class="row-selected row-selected"> <input type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label></th></if> <volist name="list_grids" id="field"> <th <notempty name="field.width">width="{$field.width}%"</notempty> >{$field.title}</th> </volist> </tr> </thead> <!-- 列表 --> <tbody> <volist name="list_data" id="data"> <tr> <if condition="$check_all"><td><input class="ids regular-checkbox" type="checkbox" value="{$data['id']}" name="ids[]" id="check_{$data['id']}"><label for="check_{$data['id']}"></label></td></if> <volist name="list_grids" id="grid"> <td>{:get_list_field($data,$grid,$model)}</td> </volist> </tr> </volist> </tbody> </table> </div> </div> <div class="page"> {$_page|default=''} </div> </section> </div> </block> <block name="script"> <script type="text/javascript"> $(function(){ //搜索功能 $("#search").click(function(){ var url = $(this).attr('url'); var query = $('.search-form').find('input').serialize(); query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,''); query = query.replace(/^&/g,''); if( url.indexOf('?')>0 ){ url += '&' + query; }else{ url += '?' + query; } window.location.href = url; }); //回车自动提交 $('.search-form').find('input').keyup(function(event){ if(event.keyCode===13){ $("#search").click(); } }); }) </script> <script> $(function(){ $(".create").click(function(){ var checkid = new Array(); $("input[type=checkbox]:checked").each(function(){ // checkid= $(this).val(); if(!(isNaN($(this).val()))) checkid.push($(this).val()); //return checkid; }); //alert(checkid); //var checkid= '1'; $.ajax( { url: '/index.php?s=/addon/Qunsend/Qunsend/allcreate/id/'+checkid+'.html', //这里是静态页的地址 type: "GET", //静态页用get方法,否则服务器会抛出405错误 beforeSend: function(){ }, success: function(data){ return false; alert(data); if(data && data!=0) location.href = '/index.php?s=/addon/Qunsend/Qunsend/lists.html'; else{ alert('生成失败,请重试!'); location.href = '/index.php?s=/addon/WeiSite/Cms/lists.html'; } } }); }); }); </script> </block>
"author"=>$nconfig['bbyueyuesjttsyywxh'],//发布者 "digest"=> $a['intro'],//简介 "show_cover_pic"=> 1,//是否显示封面?
#825
#826
#827
#828
<?php /** * * 插件机制的实现核心类 */ class PluginManager { /** * 监听已注册的插件 * * @access private * @var array */ private $_listeners = array(); /** * 构造函数 * * @access public * @return void */ public function __construct() { #这里$plugin数组包含我们获取已经由用户激活的插件信息 #为演示方便,我们假定$plugin中至少包含 #$plugin = array( # 'name' => '插件名称', # 'directory'=>'插件安装目录' #); $plugins = get_active_plugins();#这个函数请自行实现 if($plugins) { foreach($plugins as $plugin) {//假定每个插件文件夹中包含一个actions.php文件,它是插件的具体实现 if (@file_exists(STPATH .'plugins/'.$plugin['directory'].'/actions.php')) { include_once(STPATH .'plugins/'.$plugin['directory'].'/actions.php'); $class = $plugin['name'].'_actions'; if (class_exists($class)) { //初始化所有插件 new $class($this); } } } } #此处做些日志记录方面的东西 } /** * 注册需要监听的插件方法(钩子) * * @param string $hook * @param object $reference * @param string $method */ function register($hook, &$reference, $method) { //获取插件要实现的方法 $key = get_class($reference).'->'.$method; //将插件的引用连同方法push进监听数组中 $this->_listeners[$hook][$key] = array(&$reference, $method); #此处做些日志记录方面的东西 } /** * 触发一个钩子 * * @param string $hook 钩子的名称 * @param mixed $data 钩子的入参 * @return mixed */ function trigger($hook, $data='') { $result = ''; //查看要实现的钩子,是否在监听数组之中 if (isset($this->_listeners[$hook]) && is_array($this->_listeners[$hook]) && count($this->_listeners[$hook]) > 0) { // 循环调用开始 foreach ($this->_listeners[$hook] as $listener) { // 取出插件对象的引用和方法 $class =& $listener[0]; $method = $listener[1]; if(method_exists($class,$method)) { // 动态调用插件的方法 $result .= $class->$method($data); } } } #此处做些日志记录方面的东西 return $result; } }
<?php /** * 这是一个Hello World简单插件的实现 */ /** *需要注意的几个默认规则: * 1. 本插件类的文件名必须是action * 2. 插件类的名称必须是{插件名_actions} */ class DEMO_actions { //解析函数的参数是pluginManager的引用 function __construct(&$pluginManager) { //注册这个插件 //第一个参数是钩子的名称 //第二个参数是pluginManager的引用 //第三个是插件所执行的方法 $pluginManager->register('demo', $this, 'say_hello'); } function say_hello() { echo 'Hello World'; } }
$pluginManager->trigger('demo','');
#829
/*webkit内核*/ .scroll_content::-webkit-scrollbar { width:0px; height:0px; } .scroll_content::-webkit-scrollbar-button { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-track { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-track-piece { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-thumb{ background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-corner { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-resizer { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar { width:10px; height:10px; } /*o内核*/ .scroll_content .-o-scrollbar{ -moz-appearance: none !important; background: rgba(0,255,0,0) !important; } .scroll_content::-o-scrollbar-button { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-track { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-track-piece { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-thumb{ background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-corner { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-resizer { background-color:rgba(0,0,0,0); } /*IE10,IE11,IE12*/ .scroll_content{ -ms-scroll-chaining: chained; -ms-overflow-style: none; -ms-content-zooming: zoom; -ms-scroll-rails: none; -ms-content-zoom-limit-min: 100%; -ms-content-zoom-limit-max: 500%; -ms-scroll-snap-type: proximity; -ms-scroll-snap-points-x: snapList(100%, 200%, 300%, 400%, 500%); -ms-overflow-style: none; overflow: auto; } <script src="lib/jquery.min.js"></script> <script src="lib/jquery.nicescroll.min.js"></script> $(function(){ //FF下用JS实现自定义滚动条 $(".scroll_content").niceScroll({cursorborder:"",cursorcolor:"rgba(0,0,0,0)",boxzoom:true}); })
#830
<!--[if lt IE 9]> <script src="dist/html5shiv.js"></script> <![endif]-->
<!--[if lte IE 8]><script src="js/libs/selectivizr.js"></script><![endif]-->
<!DOCTYPE html> <!--[if lt IE 7 ]> <html class="ie6 lazy " lang="en"> <![endif]--> <!--[if IE 7 ]> <html class="ie7 lazy " lang="en"> <![endif]--> <!--[if IE 8 ]> <html class="ie8 lazy " lang="en"> <![endif]--> <!--[if IE 9 ]> <html class="ie9 lazy " lang="en"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
#831
1,reload 方法,该方法强迫浏览器刷新当前页面。 语法:location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前页。true, 则以 GET 方式,从服务端取最新的页面, 相当于客户端点击 F5("刷新") 2,replace 方法,该方法通过指定URL替换当前缓存在历史里(客户端)的项目,因此当使用replace方法之后,你不能通过“前进”和“后退”来访问已经被替换的URL。 语法: location.replace(URL) 通常使用: location.reload() 或者是 history.go(0) 来做。 此方法类似客户端点F5刷新页面,所以页面method="post"时,会出现"网页过期"的提示。 因为Session的安全保护机制。 当调用 location.reload() 方法时, aspx页面此时在服务端内存里已经存在, 因此必定是 IsPostback 的。 如果有这种应用: 需要重新加载该页面,也就是说期望页面能够在服务端重新被创建,期望是 Not IsPostback 的。 这里,location.replace() 就可以完成此任务。被replace的页面每次都在服务端重新生成。 代码: location.replace(location.href); 返回并刷新页面: location.replace(document.referrer); document.referrer //前一个页面的URL 不要用 history.go(-1),或 history.back();来返回并刷新页面,这两种方法不会刷新页面。
<a href="javascript:history.go(-1);">后退</a> <a href="javascript:history.go(1);">前进</a>
#832
#833
$content=$s['content']; $content=str_ireplace("data-src=","src=",$content); preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match);
#834
#835
#836
\Application\Common\Common\function.php
// 判断公众号的类型:是订阅号还是服务号 function get_token_type($token = '') { empty ( $token ) && $token = get_token ();//修复订阅号 服务号判断权限bug $info = get_token_appinfo ( $token ); return intval ( $info ['type'] ); }
function OAuthWeixin($callback) { $isWeixinBrowser = isWeixinBrowser (); $info = get_token_appinfo (); if (! $isWeixinBrowser || empty ( $info ['appid'] )) { redirect ( $callback . '&openid=-1' ); } $param ['appid'] = $info ['appid']; //dump($_GET ['state']);exit; //$_GET ['getOpenId']=1; if (! isset ( $_GET ['getOpenId'] ) && $info['type']==1) { //修复订阅号 服务号判断权限bug $param ['redirect_uri'] = $callback . '&getOpenId=1'; $param ['response_type'] = 'code'; $param ['scope'] = 'snsapi_base'; $param ['state'] = 123; $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query ( $param ) . '#wechat_redirect'; redirect ( $url ); } elseif ($_GET ['state']) { $param ['secret'] = $info ['secret']; $param ['code'] = I ( 'code' ); $param ['grant_type'] = 'authorization_code'; $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?' . http_build_query ( $param ); $content = file_get_contents ( $url ); $content = json_decode ( $content, true ); redirect ( $callback . '&openid=' . $content ['openid'] ); } }
确定要清除编辑框内容吗?
该删除操作将不可恢复。
删除 取消
激活Windows
转到"设置"以激活Windows。
#818
#819
show_cover_pic=1
的时候,显示封面是在文章最开头那里显示,一般改0
#820
/*清除浮动*/ * html .q {height:1%;} *+html .q {height:1%;} .q:after {content:""; display:block; height:0; clear:both; overflow:hidden;} .clear {clear:both; height:0px; overflow:hidden;} .hidden {display:none;}
#821
function hi(){ var a = 1; return function(){ console.log(a++); }; }; var aaa = hi(); var bbb = hi; aaa(); aaa(); bbb();
这段代码中 aaa与bbb的区别是什么?
aaa 是将 hi() 的运行结果赋值给它,即 return 返回的匿名函数,此时有一个闭包,则每次调用 aaa 时都访问的同一个 a,aaa() 第一次运行结果为 1,第二次为2 而 bbb 将是将 hi 这个函数名赋值给它,则调用 bbb() 后返回一个函数表达式,即function(){console.log(a++)};
bbb就是hi本身,换句话说就是外层的function。bbb()的结果应该跟hi()的结果一样。 aaa是hi()调用之后返回的那个东西,也就是说它是里层的function,a是它闭包里面的一个对象。aaa()的调用结果是console.log(a++)。
hi()是将hi函数运行之后返回 function(){console.log(a++)},这种返回值是函数的方法叫做函数式编程,楼主可以查找下相关的资料看看。 aaa 的值是 function(){console.log(a++)},而aaa再次运行的话就会打印出来a的值,这个地方可以看下上面那个hi函数,其中包含一个闭包,也就是说hi函数返回的function(){console.log(a++)}这个函数会一直保持着对引用,也就是说每调用一次 aaa ,那么打印的值都会加上1,关于具体的闭包,楼主还是可以自己查查资料 bbb 的值就是hi函数,这是一个普通的赋值操作
#822
在网页设计中,Sticky footers设计是最古老和最常见的效果之一,大多数人都曾经经历过。它可以概括如下:如果页面内容不够长的时候,页脚块粘贴在视窗底部;如果内容足够长时,页脚块会被内容向下推送。
方法一 :fixed
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>sticky footer</title> <style type="text/css"> *{padding: 0;margin: 0;font-size: 48px} /* 第一步设置盒子为满屏大小 */ .box{ position: fixed; width: 100%; height: 100%; top: 0; left: 0; overflow: auto; background: green; } /* 第二步子盒子设置最小高度且清除浮动 给一个padding-bottom 等于footer 避免内容被footer遮盖*/ .box .main{ width: 100%; min-height: 100%; padding-bottom: 100px; } .box .main .content{ background: orange; /*padding-bottom: 100px;*/ } /* 第三步footer的高度和margin-top要相等 */ .box .footer{ position: relative; width: 100%; height: 100px; background: #f3f3f3; margin: -100px auto 0 auto; clear: both; text-align: center; line-height: 100px; } .clearfix{ display: inline-block; } .clearfix::after{ content: "."; display: block; height: 0; line-height: 0; visibility: hidden; clear: both; } </style> </head> <body> <div class="box"> <div class="main clearfix"> <div class="content"> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> </div> </div> <div class="footer">这是footer区域</div> </div> </body> </html>
方法二,flexbox
<html> <head> <style> body { display: flex; flex-flow: column; min-height: 100vh; } main{flex:1} header,footer{height:80px;} </style> </head> <body> <header> <h1>Site name</h1> </header> <main> <p>Bacon Ipsum dolor sit amet... <!-- Filler text from baconipsum.com --> </p> </main> <footer> <p> © 2015 No rights reserved.</p> <p>Made with ♥ by an anonymous pastafarian.</p> </footer> </body> </html>
我们需要在页头和页脚设置高度,但其内容的高度自动伸缩的来适配剩余空间。我们可以在<main>上设置flex值大于0(常用的是1)
flex属性是flex-grow、flex-shrink和flex-basis三个属性缩写。任何元素设置了flex大于0,元素就会灵活的控制自己的尺寸,来适配容器的剩余空间。例如,如果<main>设置了flex:2,<footer>设置了flex:1,那么页脚的高度是主内容高度的二分之一,同样的,如果值设置的是4和2而不是2和1,他们效果是一样的,因为他们的倍数比例值一样。
#823
ES6标准新增了一种新的函数:Arrow Function(箭头函数)。
箭头函数与传统的JavaScript函数主要区别在于以下几点:
1、对 this 的关联。函数内置 this 的值,取决于箭头函数在哪儿定义,而非箭头函数执行的上下文环境。 2 、new 不可用。箭头函数不能使用 new 关键字来实例化对象,不然会报错。 3、this 不可变。函数内置 this 不可变,在函数体内整个执行环境中为常量。 4、没有arguments对象。更不能通过arguments对象访问传入参数。只能使用显式命名或其他ES6新特性来完成。
这些差异的存在是有理可循的。首先,对this的绑定是JavaScript错误的常见来源之一。容易丢失函数内置数值,或得出意外结果。其次,将箭头函数限制为使用固定this引用,有利于JavaScript引擎优化处理。
语法:
箭头函数的语法很简单,定义自变量,然后是箭头和函数主体。
1、不引入参数:
var sum = () => 1 + 2; // 等同于: var sum = function() { return 1 + 2; };
2、引入单个参数:
var reflect = value => value; // 等同于: var reflect = function(value) { return value; }; x => x * x //等同于: function (x) { return x * x; }
传一个参数就直接写就好了,不用加小括号。
句,所以也不用加大括号。
函数构造完毕赋给reflect加以引用。
3、引入多个参数,则应加上小括号
var sum = (num1, num2) => num1 + num2; // 等同于: var sum = function(num1, num2) { return num1 + num2; };
4、若你想使用标准的函数体,或者函数体内可能有更多的语句要执行,则要用大括号将函数体括起来,并明确定义返回值。
var sum = (num1, num2) => { return num1 + num2; } //等同于: var sum = function(num1, num2) { return num1 + num2; };
大括号内的部分基本等同于传统函数
5、箭头函数若要返回自定义对象的话,就必须用小括号把该对象括起来先
var getTempItem = id = > ({ id: id, name: "Temp" }); // 等同于: var getTempItem = function(id) { return { id: id, name: "Temp" }; };
用小括号包含大括号则是对象的定义,而非函数主体
箭头函数完全修复了this的指向,this总是指向词法作用域,也就是外层调用者obj:
var obj = { birth: 1990, getAge: function () { var b = this.birth; // 1990 var fn = () => new Date().getFullYear() - this.birth; // this指向obj对象 return fn(); } }; obj.getAge(); // 25
如果使用箭头函数,以前的那种hack写法:
var that = this;
就不再需要了。
由于this在箭头函数中已经按照词法作用域绑定了,所以,用call()或者apply()调用箭头函数时,无法对this进行绑定,即传入的第一个参数被忽略:
var obj = { birth: 1990, getAge: function (year) { var b = this.birth; // 1990 var fn = (y) => y - this.birth; // this.birth仍是1990 return fn.call({birth:2000}, year); } }; obj.getAge(2015); // 25
#824
图文消息,一个图文消息支持1到8条图文
QunsendController.class.php
<?php namespace Addons\Qunsend\Controller; use Home\Controller\AddonsController; class QunsendController extends AddonsController{ function sf(){ $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); } function nconfig(){ return getAddonConfig ( 'WeiSite' ); } //预览 function qunfasyl(){ $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $nconfig=$this->nconfig(); //echo $nconfig['bbyueyuesjttsyywxh'];exit; $access_token=get_access_token (); $s=M('qunsend')->where('id='.$id)->find(); $media_id=$s['media_id']; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"'.$nconfig['bbyueyuesjttsyywxh'].'","mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); //dump($res['0']); if($res['0']!=0){ echo $res['errmsg']; exit; } $sav['qf']='已预览'; M('qunsend')->where('id='.$id)->save($sav); $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); //if($res['0']==0) echo '预览已经发送'; exit; } //推送 function qunfas(){ //exit; $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $access_token=get_access_token (); $s=M('qunsend')->where('id='.$id)->find(); $media_id=$s['media_id']; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=' . $access_token; $paramStr .= '{"filter":{"is_to_all":true},"mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews","send_ignore_reprint":0}'; $res = post_data ( $url, $paramStr ); if($res['0']!=0){ echo $res['errmsg']; exit; } $sav['qf']='已经群发'; M('qunsend')->where('id='.$id)->save($sav); $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); //dump($res); exit; } //多个推送 function morepostgetss($s,$access_token,$contenttop,$contentbottom,$id){ foreach($s as $k=>$a){ //封面上传 if(!$a['cover']){ $path='/logo2.jpg';} else{ $path = get_cover ( $a['cover'] ); $path = $path['path']; $res=$this->wximgup($path,$access_token); $coverurl=$res['media_id']; } //内容图片 $content=$a['content']; $content=str_ireplace("data-src=","src=",$content); preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match); foreach($match['1'] as $k=>&$v){ $res=$this->wximgup($v,$access_token,1); $content=str_ireplace($v,$res['url'],$content); } $nconfig=$this->nconfig(); $jsonArr['articles'][]=array( // 我就是少了这层array 才会报empty news data 错误 "title"=> $a['ntitle'],//标题 "thumb_media_id"=> $coverurl, "author"=>$nconfig['bbyueyuesjttsyywxh'],//发布者 "digest"=> $a['intro'],//简介 "show_cover_pic"=> 1,//是否显示封面? "content"=> $contenttop.$content.$contentbottom, "content_source_url"=> 'http://bcwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/index.html'//'http://ihosuwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/lastprice/sp/sp/id/'.$id.'.html', ); } $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; //dump($jsonArr['articles']);exit; $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=post_data ( $articlesurl, $json3, true ); $media_id=$res['media_id']; //dump($res);exit; $acs['sid']=$s['0']['id']; $acs['title']=$s['0']['ntitle']; $acs['ctime']=time(); $acs['media_id']=$media_id; $acs['content']=$s['0']['content']; $acs['coverurl']=$jsonArr['articles']['0']['thumb_media_id']; $cs=M('qunsend')->add($acs); echo $cs; exit; /* 预览 $nconfig=$this->nconfig(); $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"'.$nconfig['bbyueyuesjttsyywxh'].'","mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); dump($res);exit;*/ } function ass(){ //获取推送文章 qunsend $id=I('get.id'); if(!$id){ echo 'no id'; exit; } $access_token=get_access_token (); $contenttop='<p><img src="http://mmbiz.qpic.cn/mmbiz_gif/qbke2mSU58VnW25BcMnoDRqJUNULibduT7b7bBLnWcvxgWCgzpg17QRKcz8icj7vrCoHG9a6gfiabuZuOl5oeluBw/0"></p>'; $contentbottom='<p><img src="http://mmbiz.qpic.cn/mmbiz_gif/qbke2mSU58VnW25BcMnoDRqJUNULibduT6EiaeRoqKTA8ObByU69qNMnBibqYkjeWtThD1dUm8vAwoGuHlm6JsiaOA/0"></p>'; /*$p='\618-150429120J5.gif'; $res=$this->wximgup($p,$access_token,1); dump($res); exit;*/ //是否多个群发 $inid=explode(',',$id); if($inid['1']){ //多个群发 $wc['id']=array('in','0,'.$id); $s=M('custom_reply_news')->where($wc)->select(); $this->morepostgetss($s,$access_token,$contenttop,$contentbottom,$inid['0']); return false; }else{ $s=M('custom_reply_news')->where('id='.$id)->find(); } $s['title']=$s['ntitle']; //dump($s);exit; $content=$s['content']; preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match); /*dump($match); exit;*/ //重新上传文中的图片链接 //$nimgurl=explode('<img src="',$s['content']); foreach($match['1'] as $k=>&$v){ $res=$this->wximgup($v,$access_token,1); $content=str_ireplace($v,$res['url'],$content); } /*dump($content); exit;*/ //$content=$s['content']; //$content=21321321;//str_ireplace('/Uploads/Editor/gh_c7d5c953c490/','http://ihosuwx.test2.resonance.net.cn/Uploads/Editor/gh_c7d5c953c490/',$content); //检查是否存在预推送文章 /*$cs=M('qunsend')->where('sid='.$id)->find(); if(empty($cs)){ }else{ exit; } //防止文章修改推送 改为使用最新 所以每次添加 */ if(!$s['cover']) $path='/logo.png'; else{ $path = get_cover ( $s['cover'] ); $path = $path['path']; } $nconfig=$this->nconfig(); //900*500比例尺寸 2017.10.10 if($nconfig['wxfmzdddd']){ $this->getnewjjfm($path); $path='/12345678980.jpg'; } //end //修复空封面bug $res=$this->wximgup($path,$access_token); //dump($res); //exit; $coverurl=$res['media_id']; //$content=$nimgurl;//$s['content']; //echo $content;exit; $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; $jsonArr = array( "articles"=> array( array( // 我就是少了这层array 才会报empty news data 错误 "title"=> $s['title'], "thumb_media_id"=> $coverurl, "author"=> $nconfig['bbyueyuesjttsyywxh'], "digest"=> $s['intro'], "show_cover_pic"=> 0, "content"=> $contenttop.$content.$contentbottom, "content_source_url"=> 'http://bcwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/index.html',//'http://ihosuwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/lastprice/sp/sp/id/'.$id.'.html', ) ) ); $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=post_data ( $articlesurl, $json3, true ); $media_id=$res['media_id']; /*$url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"iswtf_","mpnews":{"media_id":"'.$res['media_id'].'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr );*/ //dump($res);exit; $acs['sid']=$id; $acs['title']=$s['title']; $acs['ctime']=time(); $acs['media_id']=$media_id; $acs['content']=$content; $acs['coverurl']=$coverurl; $cs=M('qunsend')->add($acs); echo $cs; //dump($acs); exit; //echo 'fasd'; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; //$paramStr .= '{"filter":{"is_to_all":true},'; //$paramStr .= '"text":{"content":"' . '3432423423' . '"},"msgtype":"text"}'; $res=$this->get_image_media_id(740,$access_token); $paramStr .= '{"towxname":"iswtf_","mpnews":{"media_id":"'.$res['media_id'].'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); dump($res); //$neww=$this->get_image_media_id(625); //dump($neww); //$this->display(); } //上传图片到微信 function wximgup($path,$access_token,$u){ $url='https://api.weixin.qq.com/cgi-bin/media/uploadimg'; if(!$u) $url='https://api.weixin.qq.com/cgi-bin/media/upload'; $param ['media'] = '@' . realpath(SITE_PATH . $path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token; $param ['type'] = 'image'; //$param ['media'] = curl_file_create($path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token); $param ['access_token'] = $access_token; return $res = post_data ( $url, $param, true ); } // 新增临时图片素材 function get_image_media_id($cover_id,$access_token) { $cover = get_cover ( $cover_id ); $path = $cover ['path']; /*echo get_access_token ();exit; $key = 'access_token_' . get_token (); echo S ( $key );exit;*/ /*$key = 'access_token_' . get_token (); S ( $key, 0, 7200 );*/ //echo realpath(SITE_PATH . $path);exit; //$access_token=get_access_token (); //$url='https://api.weixin.qq.com/cgi-bin/media/uploadimg'; $url='https://api.weixin.qq.com/cgi-bin/media/upload'; $param ['media'] = '@' . realpath(SITE_PATH . $path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token; $param ['type'] = 'image'; //$param ['media'] = curl_file_create($path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token); $param ['access_token'] = $access_token; return $res = post_data ( $url, $param, true ); //start $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; //$articlesparam ['access_token'] = $access_token; /*$articlesparam ['articles'][0]['thumb_media_id'] = $res['media_id']; $articlesparam ['articles'][0]['author'] = '3432423'; $articlesparam ['articles'][0]['title'] = 'Happy Day'; $articlesparam ['articles'][0]['content_source_url'] = 'www.qq.com'; $articlesparam ['articles'][0]['content'] = 'content'; $articlesparam ['articles'][0]['digest'] = 'digest'; $articlesparam ['articles'][0]['show_cover_pic'] = 1;*/ $jsonArr = array( "articles"=> array( array( // 我就是少了这层array 才会报empty news data 错误 "title"=> 'dingdingdemo', "thumb_media_id"=> $res['media_id'], "author"=> 'martin', "digest"=> 'digest', "show_cover_pic"=> 0, "content"=> $content, "content_source_url"=> 'https://www.baidu.com/', ) ) ); $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); return post_data ( $articlesurl, $json3, true ); //end return $res['media_id']; echo $path;exit; $driver = C ( 'PICTURE_UPLOAD_DRIVER' ); if ($driver != 'Local' && ! file_exists ( SITE_PATH . $cover ['path'] )) { // 先把图片下载到本地 $pathinfo = pathinfo ( SITE_PATH . $cover ['path'] ); mkdirs ( $pathinfo ['dirname'] ); $content = wp_file_get_contents ( $cover ['url'] ); $res = file_put_contents ( SITE_PATH . $cover ['path'], $content ); if (! $res) { return 0; } } $path = $cover ['path']; if (! $path) { return 0; } $param ['type'] = 'image'; $param ['media'] = '@' . realpath ( SITE_PATH . $path ); $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . get_access_token (); $res = post_data ( $url, $param, true ); if (isset ( $res ['errcode'] ) && $res ['errcode'] != 0) { return $res; } return $res ['media_id']; } function getnewjjfm($src){ //原始图像 $dst = "./a.png"; //实测900*500比例尺寸图片已不会出现裁剪图片边缘的问题,只需要发送多图文消息时注意标题文字是否会挡住图片内容即可。 $minx=900; $miny=500; //得到原始图片信息 $dst_im = imagecreatefrompng($dst); $dst_info = getimagesize($dst); //水印图像 $src = ".".$src; $src_im = imagecreatefromjpeg($src); $src_info = getimagesize($src); $nx=$src_info[0]; $ny=$src_info[1]; if($nx>$minx || $ny>$miny){ //获取大图信息 $maxx=$src_info[0];//宽 $maxy=$src_info[1];//长 $maxt=$src_info[2];//格式 $maxm=$src_info['mime'];//mime类型 //缩放判断 if(($minx/$maxx)>($miny/$maxy)){ $scale=$miny/$maxy; }else{ $scale=$minx/$maxx; } //对所求值进行取整 $minx=floor($maxx*$scale); $miny=floor($maxy*$scale); //添加小图 $minim=imagecreatetruecolor($minx,$miny); //缩放函数 imagecopyresampled($minim,$src_im,0,0,0,0,$minx,$miny,$maxx,$maxy); //imagejpeg($minim); $src_im=$minim; $nx=$minx; $ny=$miny; } //水印透明度 $alpha = 100; $nwx=($dst_info[0]-$nx)/2; $nwy=($dst_info[1]-$ny)/2; //imagealphablending($dst_im , false);//关闭混合模式,以便透明颜色能覆盖原画板 //imagefill($image , 0 , 0 , $bg);//填充 imagesavealpha($dst_im , true);//设置保存PNG时保留透明通道信息 //合并水印图片 imagecopymerge($dst_im,$src_im,$nwx,$nwy,0,0,$nx,$ny,$alpha); //输出合并后水印图片 imagepng($dst_im,'./12345678980.jpg'); imagedestroy($dst_im); imagedestroy($src_im); } }
/Application/Home/View/default/Addons/
lists.html
<extend name="Base/common" /> <block name="body"> <div class="span9 page_message"> <section id="contents"> <include file="Addons/_nav" /> <if condition="$add_button || $del_button || $search_button || !empty($top_more_button)"> <div class="table-bar"> <div class="fl"> <empty name="model.extend"> <div class="tools"> <if condition="$add_button"><php> $add_url || $add_url = U('add?model='.$model['id'], $get_param);</php><a class="btn" href="{$add_url}">新 增</a></if> <if condition="$del_button"><php> $del_url || $del_url = U('del?model='.$model['id'], $get_param);</php><button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">删 除</button></if> <php>$url=addons_url ( 'WeiSite://Cms/lists' ); $geturl= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; </php> <if condition="$url eq $geturl"><button class="btn ajax-post confirm create" target-form="ids">生成群发</button> </if> <volist name="top_more_button" id="vo"> <if condition="$vo[is_buttion]"> <button class="btn {$vo.class}" target-form="ids" url="{$vo.url}">{$vo.title}</button> <else /> <a class="btn" href="{$vo.url}">{$vo.title}</a> </if> </volist> </div> </empty> </div> <!-- 高级搜索 --> <if condition="$search_button"> <div class="search-form fr cf"> <div class="sleft"> <php> $get_param[model]=$model['name']; $search_url || $search_url = addons_url($_REQUEST ['_addons'].'://'.$_REQUEST ['_controller'].'/lists', $get_param);</php> <php>empty($search_key) && $search_key=$model['search_key'];empty($search_key) && $search_key='title';</php> <input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}" placeholder="{$placeholder}"> <a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a> </div> </div> </if> </div> </if> <!-- 数据列表 --> <div class="data-table"> <div class="table-striped"> <table cellspacing="1"> <!-- 表头 --> <thead> <tr> <if condition="$check_all"><th class="row-selected row-selected"> <input type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label></th></if> <volist name="list_grids" id="field"> <th <notempty name="field.width">width="{$field.width}%"</notempty> >{$field.title}</th> </volist> </tr> </thead> <!-- 列表 --> <tbody> <volist name="list_data" id="data"> <tr> <if condition="$check_all"><td><input class="ids regular-checkbox" type="checkbox" value="{$data['id']}" name="ids[]" id="check_{$data['id']}"><label for="check_{$data['id']}"></label></td></if> <volist name="list_grids" id="grid"> <td>{:get_list_field($data,$grid,$model)}</td> </volist> </tr> </volist> </tbody> </table> </div> </div> <div class="page"> {$_page|default=''} </div> </section> </div> </block> <block name="script"> <script type="text/javascript"> $(function(){ //搜索功能 $("#search").click(function(){ var url = $(this).attr('url'); var query = $('.search-form').find('input').serialize(); query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,''); query = query.replace(/^&/g,''); if( url.indexOf('?')>0 ){ url += '&' + query; }else{ url += '?' + query; } window.location.href = url; }); //回车自动提交 $('.search-form').find('input').keyup(function(event){ if(event.keyCode===13){ $("#search").click(); } }); }) </script> <script> $(function(){ $(".create").click(function(){ var checkid = new Array(); $("input[type=checkbox]:checked").each(function(){ // checkid= $(this).val(); if(!(isNaN($(this).val()))) checkid.push($(this).val()); //return checkid; }); //alert(checkid); //var checkid= '1'; $.ajax( { url: '/index.php?s=/addon/Qunsend/Qunsend/allcreate/id/'+checkid+'.html', //这里是静态页的地址 type: "GET", //静态页用get方法,否则服务器会抛出405错误 beforeSend: function(){ }, success: function(data){ return false; alert(data); if(data && data!=0) location.href = '/index.php?s=/addon/Qunsend/Qunsend/lists.html'; else{ alert('生成失败,请重试!'); location.href = '/index.php?s=/addon/WeiSite/Cms/lists.html'; } } }); }); }); </script> </block>
"author"=>$nconfig['bbyueyuesjttsyywxh'],//发布者 "digest"=> $a['intro'],//简介 "show_cover_pic"=> 1,//是否显示封面?
#825
#826
也是放到网站根目录
#827
#828
<?php /** * * 插件机制的实现核心类 */ class PluginManager { /** * 监听已注册的插件 * * @access private * @var array */ private $_listeners = array(); /** * 构造函数 * * @access public * @return void */ public function __construct() { #这里$plugin数组包含我们获取已经由用户激活的插件信息 #为演示方便,我们假定$plugin中至少包含 #$plugin = array( # 'name' => '插件名称', # 'directory'=>'插件安装目录' #); $plugins = get_active_plugins();#这个函数请自行实现 if($plugins) { foreach($plugins as $plugin) {//假定每个插件文件夹中包含一个actions.php文件,它是插件的具体实现 if (@file_exists(STPATH .'plugins/'.$plugin['directory'].'/actions.php')) { include_once(STPATH .'plugins/'.$plugin['directory'].'/actions.php'); $class = $plugin['name'].'_actions'; if (class_exists($class)) { //初始化所有插件 new $class($this); } } } } #此处做些日志记录方面的东西 } /** * 注册需要监听的插件方法(钩子) * * @param string $hook * @param object $reference * @param string $method */ function register($hook, &$reference, $method) { //获取插件要实现的方法 $key = get_class($reference).'->'.$method; //将插件的引用连同方法push进监听数组中 $this->_listeners[$hook][$key] = array(&$reference, $method); #此处做些日志记录方面的东西 } /** * 触发一个钩子 * * @param string $hook 钩子的名称 * @param mixed $data 钩子的入参 * @return mixed */ function trigger($hook, $data='') { $result = ''; //查看要实现的钩子,是否在监听数组之中 if (isset($this->_listeners[$hook]) && is_array($this->_listeners[$hook]) && count($this->_listeners[$hook]) > 0) { // 循环调用开始 foreach ($this->_listeners[$hook] as $listener) { // 取出插件对象的引用和方法 $class =& $listener[0]; $method = $listener[1]; if(method_exists($class,$method)) { // 动态调用插件的方法 $result .= $class->$method($data); } } } #此处做些日志记录方面的东西 return $result; } }
<?php /** * 这是一个Hello World简单插件的实现 */ /** *需要注意的几个默认规则: * 1. 本插件类的文件名必须是action * 2. 插件类的名称必须是{插件名_actions} */ class DEMO_actions { //解析函数的参数是pluginManager的引用 function __construct(&$pluginManager) { //注册这个插件 //第一个参数是钩子的名称 //第二个参数是pluginManager的引用 //第三个是插件所执行的方法 $pluginManager->register('demo', $this, 'say_hello'); } function say_hello() { echo 'Hello World'; } }
$pluginManager->trigger('demo','');
#829
/*webkit内核*/ .scroll_content::-webkit-scrollbar { width:0px; height:0px; } .scroll_content::-webkit-scrollbar-button { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-track { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-track-piece { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-thumb{ background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-corner { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar-resizer { background-color:rgba(0,0,0,0); } .scroll_content::-webkit-scrollbar { width:10px; height:10px; } /*o内核*/ .scroll_content .-o-scrollbar{ -moz-appearance: none !important; background: rgba(0,255,0,0) !important; } .scroll_content::-o-scrollbar-button { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-track { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-track-piece { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-thumb{ background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-corner { background-color:rgba(0,0,0,0); } .scroll_content::-o-scrollbar-resizer { background-color:rgba(0,0,0,0); } /*IE10,IE11,IE12*/ .scroll_content{ -ms-scroll-chaining: chained; -ms-overflow-style: none; -ms-content-zooming: zoom; -ms-scroll-rails: none; -ms-content-zoom-limit-min: 100%; -ms-content-zoom-limit-max: 500%; -ms-scroll-snap-type: proximity; -ms-scroll-snap-points-x: snapList(100%, 200%, 300%, 400%, 500%); -ms-overflow-style: none; overflow: auto; } <script src="lib/jquery.min.js"></script> <script src="lib/jquery.nicescroll.min.js"></script> $(function(){ //FF下用JS实现自定义滚动条 $(".scroll_content").niceScroll({cursorborder:"",cursorcolor:"rgba(0,0,0,0)",boxzoom:true}); })
#830
htmlshiv.js
<!--[if lt IE 9]> <script src="dist/html5shiv.js"></script> <![endif]-->
selectivizr.js
<!--[if lte IE 8]><script src="js/libs/selectivizr.js"></script><![endif]-->
<html>条件判断注释
<!DOCTYPE html> <!--[if lt IE 7 ]> <html class="ie6 lazy " lang="en"> <![endif]--> <!--[if IE 7 ]> <html class="ie7 lazy " lang="en"> <![endif]--> <!--[if IE 8 ]> <html class="ie8 lazy " lang="en"> <![endif]--> <!--[if IE 9 ]> <html class="ie9 lazy " lang="en"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
这段代码不需要JavaScript,不需要等待JavaScript的加载,你定义的CSS样式会立即生效起作用,没有那种因为加载延迟而出现的样式闪变。
#831
1,reload 方法,该方法强迫浏览器刷新当前页面。 语法:location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前页。true, 则以 GET 方式,从服务端取最新的页面, 相当于客户端点击 F5("刷新") 2,replace 方法,该方法通过指定URL替换当前缓存在历史里(客户端)的项目,因此当使用replace方法之后,你不能通过“前进”和“后退”来访问已经被替换的URL。 语法: location.replace(URL) 通常使用: location.reload() 或者是 history.go(0) 来做。 此方法类似客户端点F5刷新页面,所以页面method="post"时,会出现"网页过期"的提示。 因为Session的安全保护机制。 当调用 location.reload() 方法时, aspx页面此时在服务端内存里已经存在, 因此必定是 IsPostback 的。 如果有这种应用: 需要重新加载该页面,也就是说期望页面能够在服务端重新被创建,期望是 Not IsPostback 的。 这里,location.replace() 就可以完成此任务。被replace的页面每次都在服务端重新生成。 代码: location.replace(location.href); 返回并刷新页面: location.replace(document.referrer); document.referrer //前一个页面的URL 不要用 history.go(-1),或 history.back();来返回并刷新页面,这两种方法不会刷新页面。
<a href="javascript:history.go(-1);">后退</a> <a href="javascript:history.go(1);">前进</a>
Javascript:history.go()和history.back()的用法和区别
go(-1): 返回上一页,原页面表单中的内容会丢失;history.go(-1):后退+刷新;history.go(1) :前进
back(): 返回上一页,原页表表单中的内容会保留; history.back():后退 ; history.back(0) 刷新; history.back(1):前进
不同的浏览器的后退行为也是有区别的,而区别就跟Javascript:history.go()和history.back()的区别类似。
chrome和ff浏览器后退页面,会刷新后退的页面,若有数据请求也会提交数据申请。类似于
history.go(-1)
而safari(包括桌面版和ipad版本)的后退按钮则不会刷新页面,也不会提交数据申请。类似于
Javascript:history.back()。
windows.location.reload();//刷新
windows.location.forward;前进
#832
#833
外链图片bug,非src图片img
$content=$s['content']; $content=str_ireplace("data-src=","src=",$content); preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match);
#834
1.用户发消息给你,你收到的xml中有user的openid
2.或者去拉取用户列表
#835
微官网微信订阅号通过点击菜单栏获取openid用户信息
有的认证订阅号有网页授权获取用户基本信息
有的认证订阅号没有网页授权获取用户基本信息
认证服务号是有这个接口权限的,所以用认证服务号开发,不用担心这个接口权限问题
#836
上线前清空
关注粉丝数据
清空会员数据,保留管理员登录账号
禁用后台需要服务号接口权限插件
当用户和订阅号有互动的时候可以获取用户的openid,比如关注事件,点击自定义菜单事件
订阅号开放了获取用户基本信息的接口,但openid怎么取?
即时认证 也无法获取 订阅号没有此功能
但可以通过再申请一个服务号用认证服务号获取,然后通过后台同步到订阅号统计页
\Application\Common\Common\function.php
// 判断公众号的类型:是订阅号还是服务号 function get_token_type($token = '') { empty ( $token ) && $token = get_token ();//修复订阅号 服务号判断权限bug $info = get_token_appinfo ( $token ); return intval ( $info ['type'] ); }
function OAuthWeixin($callback) { $isWeixinBrowser = isWeixinBrowser (); $info = get_token_appinfo (); if (! $isWeixinBrowser || empty ( $info ['appid'] )) { redirect ( $callback . '&openid=-1' ); } $param ['appid'] = $info ['appid']; //dump($_GET ['state']);exit; //$_GET ['getOpenId']=1; if (! isset ( $_GET ['getOpenId'] ) && $info['type']==1) { //修复订阅号 服务号判断权限bug $param ['redirect_uri'] = $callback . '&getOpenId=1'; $param ['response_type'] = 'code'; $param ['scope'] = 'snsapi_base'; $param ['state'] = 123; $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query ( $param ) . '#wechat_redirect'; redirect ( $url ); } elseif ($_GET ['state']) { $param ['secret'] = $info ['secret']; $param ['code'] = I ( 'code' ); $param ['grant_type'] = 'authorization_code'; $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?' . http_build_query ( $param ); $content = file_get_contents ( $url ); $content = json_decode ( $content, true ); redirect ( $callback . '&openid=' . $content ['openid'] ); } }