$url = Url::current();
例:/mobile/hmConnections/user/verify-user
//获取当前路径 - 相对路径
$url = Url::current([’id’ => 1], false);
如: /mobile/hmConnections/user/verify-user?id=1
//获取当前路径 - 绝对路径
阅读全文...$url = Url::current([’id’ => 1], true);
如: http://000000.com/mobile/hmConnections/user/verify-user?id=1
访问控制过滤器是检查当前用户是否能执行访问的controller action的初步授权模式。这种授权模式基于用户名,客户IP地址和访问类型。
访问控制过滤器,适用于简单的验证。需要复杂的访问控制,需要使用基于角色访问控制(role-based access (RBAC))。
打在最前面,如下摘自yiichina里面,估计是yii2普通版本的方式,我没具体研究,如下为高级模板的siteController控制器里的权限控制方式,写法有不同,
阅读全文.../**
* @inheritdoc
*/
public function behaviors()
{
return [
’access’ => [
’class’ => AccessControl::className(),
’rules’ => [
[
’actions’ => [’login’,’error’,’captcha’],
’allow’ => true, //直接允许访问,captcha不加在下面的actions里,不然会出现验证码不显示的问题
],
[
’actions’ => [’logout’, ’index’],
’allow’ => true,
’roles’ => [’@’], // @ 表示验证通过的用户才有权限 * 任何用户 ? 匿名用户
],
],
],
’verbs’ => [
’class’ => VerbFilter::className(),
’actions’ => [
’logout’ => [’post’],
],
],
];
}
阅读全文...$query =
$model->find()->where([’status’=>1]); echo $query->createCommand()->getRawSql();
Yii2自带验证码使用详细例子,测试了好久,终于弄成了,可以自由控制验证码图片的样式,css样式,验证码输入框属性调整,验证码手动校验或自动校验
Yii2自带验证码, 可以直接就使用, 头一次用弄了老长时间,总算可以随意用了,
1.控制器controller
在要使用验证码的控制器controller里面重写方法actions(),有的控制器里默认重写了,不要重复
/**
* @inheritdoc
*/
public function actions()
{
return [
’captcha’ => [
’fixedVerifyCode’ => YII_ENV_TEST ? ’testme’ : null,
’maxLength’ => 4, //最大显示个数
’minLength’ => 4,//最少显示个数
//’backColor’=>’#f7feec’,//背景颜色
//’foreColor’=>0xffffff, //字体颜色
//’padding’ => 5,//间距
’height’=>30,//高度
’width’ => 70, //宽度
//’offset’=>4, //设置字符偏移量 有效果
],
];
}
阅读全文...阅读全文...$data = (new yiidbQuery())
->select(['id','user','ip','dateline'])
->from('`i_comment`')
->where(['id'=>$id])
->offset($start)
->limit($size)
->orderby('id desc')
->all();
整个修改主要是路径,其它基本没改变
前台入口修改方法
1. 打开wwwyii2advancedfrontendweb 文件夹,将里面的index.php文件复制(或剪切)至根目录wwwyii2advanced 。然后编辑里面的内容为:
阅读全文...defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
error_reporting(E_ALL & ~E_NOTICE);
require(__DIR__.'/vendor/autoload.php');
require(__DIR__.'/vendor/yiisoft/yii2/Yii.php');
require(__DIR__.'/common/config/bootstrap.php');
require(__DIR__.'/frontend/config/bootstrap.php');
$config = yiihelpersArrayHelper::merge(
require(__DIR__.'/common/config/main.php'),
require(__DIR__.'/common/config/main-local.php'),
require(__DIR__.'/frontend/config/main.php'),
require(__DIR__.'/frontend/config/main-local.php')
);
(new yiiwebApplication($config))->run();
可兼容火狐FF, IE浏览器,谷歌浏览器,其它浏览器基于IE内核应该也支持
阅读全文...cobj = document.getElementById(
"comment"
);
//
cobj.value=
'内容 '
+cont+
':'
;
//加上内容
//cobj.focus();
cobj.focus();
//得到焦点
var
len = cobj.value.length;
if
(document.selection) {
var
sel = cobj.createTextRange();
sel.moveStart(
'character'
,len);
sel.collapse();
sel.select();
}
else
if
(
typeof
cobj.selectionStart ==
'number'
&&
typeof
cobj.selectionEnd ==
'number'
) {
cobj.selectionStart = cobj.selectionEnd = len;
}
第一行标题栏用,(逗号)隔开成列标题,未尾加"n"换行,(注意是双引号)
然后查询数据表循环数据,与上面列数相同的数据同样使用,(逗号)隔开,未尾加"n"换行,(注意是双引号)
最后数据查询处理完毕之后使用函数输出excel格式的.cvs文件
//列标题
1
|
$str = 'A名称,类型,版本号,开发者,联系方式,MD5,下载链接,简介' . "n" ; |
阅读全文...<script type="text/javascript" src="js/zeroclipboard/ZeroClipboard.js"></script>
<script type="text/javascript">
ZeroClipboard.setMoviePath('js/zeroclipboard/ZeroClipboard.swf');
ZeroClipboard.setMoviePath('js/zeroclipboard/ZeroClipboard10.swf'); //两个swf不可少
$(function(){
var clip = new ZeroClipboard.Client();
clip.setHandCursor( true );
clip.setCSSEffects( true );
clip.addEventListener( 'mouseDown', function(client){
clip.setText($('#myText').attr("href")); //要复制的内容
});
clip.addEventListener('complete', function(){alert('复制成功');}); //内容复制成功后提示文字
clip.glue('myText'); //这个为连接或按纽的id
});
</script>