Yii中利用filters来控制访问
摘要:filters()方法定义在CController里,用Gii生成Controller时里面就有filters方法,代码如下:public function filters(){ // return the filter configuration for this controller, e.g.: return array( 'inlineFilterName', array( 'class'=>'path.to.FilterClass', 'propertyName'=>'propertyValue
阅读全文
posted @
2013-12-25 11:03
FreeSpider
阅读(8015)
推荐(0) 编辑
Yii中使用RBAC完全指南
摘要:开始准备Yii提供了强大的配置机制和很多现成的类库。在Yii中使用RBAC是很简单的,完全不需要再写RBAC代码。所以准备工作就是,打开编辑器,跟我来。设置参数、建立数据库在配置数组中,增加以下内容:‘components‘ => array(//……‘authManager‘=>array(‘class‘=>‘CDbAuthManager‘,//认证类名称‘defaultRoles‘=>array(‘guest‘),//默认角色‘itemTable‘ => ‘pre_auth_item‘,//认证项表名称‘itemChildTable‘ => ‘pre_a
阅读全文
posted @
2013-12-23 16:21
FreeSpider
阅读(621)
推荐(0) 编辑
自动把\r\n 替换成<p></p>
摘要:function nl2p($string, $line_breaks = true, $xml = true){ // Remove existing HTML formatting to avoid double-wrapping things $string = str_replace(array('', '', '', ''), '', $string); // It is conceivable that people might still want single line-breaks // with
阅读全文
posted @
2013-12-17 09:28
FreeSpider
阅读(3661)
推荐(0) 编辑
统计汉字
摘要:$str="hello world 你好世界~"; $num = preg_match_all("/[a-zA-Z]/",$str,$words); echo $num; print_r($words); $num = preg_match_all("/[\xB0-\xF7][\xA1-\xFE]/",iconv('UTF-8','GBK',$str),$words);
阅读全文
posted @
2013-12-17 09:25
FreeSpider
阅读(130)
推荐(0) 编辑
php执行linux函数
摘要:function B(){ if(defined('LOCK') && LOCK == 'lock') return false; $addPort = sprintf('-A INPUT -p tcp -m tcp --dport %d -j ACCEPT%s',PORT,PHP_EOL); //确定是否是centos if(is_file('/etc/redhat-release')){ //添加防火墙设置 $iptables = file('/etc/sysconfig/iptables');
阅读全文
posted @
2013-12-15 23:00
FreeSpider
阅读(365)
推荐(0) 编辑
PHP截取中文不乱吗
摘要:function utf_substr($str, $len){ for ($i = 0; $i 127) { $i++; if ($i < $len) { $new_str[] = substr($str, 0, 3); $str = substr($str, 3); } } else { $new_str[] = substr($str, 0, 1); $str = substr($str, 1); ...
阅读全文
posted @
2013-12-12 20:41
FreeSpider
阅读(383)
推荐(0) 编辑
php HTTP请求
摘要:function request($host){ $url = parse_url($host); $port = !empty($url['port']) ? $url['port'] : 80; $query = !empty($url['query']) ? sprintf('?%s', $url['query']) : null; $path = !empty($url['path']) ? $url['path'] : '/index.php'; $requ
阅读全文
posted @
2013-12-10 17:08
FreeSpider
阅读(526)
推荐(0) 编辑
回到顶部最简单的JQuery实现代码
摘要:CSS代码,使用了fixed让对象固定于浏览器窗口:top{position:fixed;bottom:0;right:10px;}jQuery代码,注意正常使用的几个条件:$('#top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);return false;});800 是调节移动速度的,可以自己调节!
阅读全文
posted @
2013-12-09 11:25
FreeSpider
阅读(201)
推荐(0) 编辑
linux学习(别人指出来的), 回头有针对性的学下!
摘要:应该是 会linux 基本操作吧linux 安装 lamp lnmp php拓展这些基本都得会把知道subversion 和 github 这俩吧windows的代码同步到linux上无需ftp 会跟踪进程会查看安装位置知道端口是哪个进程占用掌握这些就行了会释放内存缓存把这些配置配置 就能工作了比如内存8G 缓存占了7G多你得知道如何释放嗯 还有就是会编写计划任务搜索文件位置差不多就这些谢谢简单的shell
阅读全文
posted @
2013-12-08 21:30
FreeSpider
阅读(185)
推荐(0) 编辑
一个压缩算法 可以适当的用来编码
摘要:function encode($string) { $dict = array_flip(range("\0", "\xFF")); $dict_size = 256; $word = $string[0]; $dict_count = 256; $bits = 8; $bits_max = 256; $return = ""; $rest = 0; $rest_length = 0; for ($i = 1, $j = strlen($string); $i $bits_max) { $bits_...
阅读全文
posted @
2013-12-07 16:38
FreeSpider
阅读(236)
推荐(0) 编辑
YII 自带验证码实现
摘要:共三步,分别controllers,models,views各一层添置一行代码即可实现 第一步在controllers添加 public function actions() {return array( 'captcha' =>array('class' => 'CCaptchaAction','backColor' => 0xF5F5F5,'transparent'=>true,'minLength'=>4, //最短为4位'maxLength'=&
阅读全文
posted @
2013-12-04 15:16
FreeSpider
阅读(619)
推荐(0) 编辑
Yii 引入js css jquery 执行操作
摘要:在布局中引用通用到js,或者css:clientScript->registerCoreScript('jquery');?> //注意这个将会插到标签上..所以title标签要放在head文档顶部防止.jquery没有第一个加入在view中引用单独的js,css这样做:$cs=Yii::app()->clientScript;//引入本地站点$cs->registerScriptFile(Yii::app()->baseUrl . '/js/star-rating/jquery.rating.pack.js', CClientSc
阅读全文
posted @
2013-12-04 14:17
FreeSpider
阅读(311)
推荐(0) 编辑
YII cookie和session的使用方法
摘要:设置cookie://首先新建cookie$cookie = new CHttpCookie(‘mycookie’, ‘this is my cookie’);//定义cookie的有效期$cookie->expire = time()+60*60*24*30; //有限期30天//把cookie写入cookies使其生效Yii::app()->request->cookies['mycookie']=$cookie;注意:CHttpCookie定义的cookie名”mycookie”与Yii::app()->request->cookies[&#
阅读全文
posted @
2013-12-04 14:14
FreeSpider
阅读(2408)
推荐(0) 编辑