thinkphp禁止、允许访问模块

// 设置禁止访问的模块列表
'MODULE_DENY_LIST' =>  array('Common','Runtime','Api'),

同样也可设置可以访问的模块和默认模块,代码如下:

'MODULE_ALLOW_LIST'    =>    array('Home','Admin','User'),
'DEFAULT_MODULE'       =>    'Home',

如果项目比较简单,还可以设置单模块,代码如下:

// 关闭多模块访问
'MULTI_MODULE' => false,
'DEFAULT_MODULE' => 'Home',

 

h5 video 自定义播放进度条

来源:http://www.cnblogs.com/moqiutao/-风雨后见彩虹

// 为了不随意的创建全局变量,我们将我们的代码放在一个自己调用自己的匿名函数中,这是一个好的编程习惯
        (function(window, document){
            // 获取要操作的元素
            var video = document.getElementById("video");
            var videoControls = document.getElementById("videoControls");
            var videoContainer = document.getElementById("videoContainer");
            var controls = document.getElementById("video_controls");
            var playBtn = document.getElementById("playBtn");
            var fullScreenBtn = document.getElementById("fullScreenBtn");
            var progressWrap = document.getElementById("progressWrap");
            var playProgress = document.getElementById("playProgress");
            var fullScreenFlag = false;
            var progressFlag;

            // 创建我们的操作对象,我们的所有操作都在这个对象上。
            var videoPlayer = {
                init: function(){
                    var that = this;
                    video.removeAttribute("controls");
                    bindEvent(video, "loadeddata", videoPlayer.initControls);
                    videoPlayer.operateControls();
                },
                initControls: function(){
                    videoPlayer.showHideControls();
                },
                showHideControls: function(){
                    bindEvent(video, "mouseover", showControls);
                    bindEvent(videoControls, "mouseover", showControls);
                    bindEvent(video, "mouseout", hideControls);
                    bindEvent(videoControls, "mouseout", hideControls);
                },
                operateControls: function(){
                    bindEvent(playBtn, "click", play);
                    bindEvent(video, "click", play);
                    bindEvent(fullScreenBtn, "click", fullScreen);
                    bindEvent(progressWrap, "mousedown", videoSeek);
                }
            }

            videoPlayer.init();

            // 原生的JavaScript事件绑定函数
            function bindEvent(ele, eventName, func){
                if(window.addEventListener){
                    ele.addEventListener(eventName, func);
                }
                else{
                    ele.attachEvent('on' + eventName, func);
                }
            }
            // 显示video的控制面板
            function showControls(){
                videoControls.style.opacity = 1;
            }
            // 隐藏video的控制面板
            function hideControls(){
                // 为了让控制面板一直出现,我把videoControls.style.opacity的值改为1
                videoControls.style.opacity = 1;
            }
            // 控制video的播放
            function play(){
                if ( video.paused || video.ended ){              
                    if ( video.ended ){ 
                        video.currentTime = 0;
                        } 
                    video.play();
                    playBtn.innerHTML = "暂停"; 
                    progressFlag = setInterval(getProgress, 60);
                } 
                else{ 
                    video.pause(); 
                    playBtn.innerHTML = "播放";
                    clearInterval(progressFlag);
                } 
            }
            // 控制video是否全屏,额这一部分没有实现好,以后有空我会接着研究一下
            function fullScreen(){
                if(fullScreenFlag){
                    videoContainer.webkitCancelFullScreen();
                }
                else{
                    videoContainer.webkitRequestFullscreen();
                }
            }
            // video的播放条
            function getProgress(){
                var percent = video.currentTime / video.duration;
                playProgress.style.width = percent * (progressWrap.offsetWidth) - 2 + "px";
                showProgress.innerHTML = (percent * 100).toFixed(1) + "%";
            }
            // 鼠标在播放条上点击时进行捕获并进行处理
            function videoSeek(e){
                if(video.paused || video.ended){
                    play();
                    enhanceVideoSeek(e);
                }
                else{
                    enhanceVideoSeek(e);
                }

            }
            function enhanceVideoSeek(e){
                clearInterval(progressFlag);
                var length = e.pageX - progressWrap.offsetLeft;
                var percent = length / progressWrap.offsetWidth;
                playProgress.style.width = percent * (progressWrap.offsetWidth) - 2 + "px";
                video.currentTime = percent * video.duration;
                progressFlag = setInterval(getProgress, 60);
            }

        }(this, document))

 

js返回顶部

慢慢收集

这个在手机还挺流畅的

//返回顶部
var sdelay=0;
function returnTop() {
 window.scrollBy(0,-100);//Only for y vertical-axis
 if(document.body.scrollTop>0) {
  sdelay= setTimeout('returnTop()',10);
 }
}

 

 

 

lnmp的nginx 配置 Thinkphp 艰辛记

本文不定时更新,主要为了记录 linux服务器上搭建lnmp 的水土不服
参考
http://www.cnblogs.com/echosoar/p/4723892.html-EchoSoar
https://bbs.vpser.net/viewthread.php?tid=10068&page=1&fromuid=3#pid29934-军哥

什么是Thinkphp的URL模式

http://document.thinkphp.cn/manual_3_2.html#url

简单点说

PATHINFO模式 1 ?localhost/index.php/Home/Index(需要index.php)
REWRITE模式 2 ??localhost/Home/Index(这样就可以了)

为什么会404 Not?Found

apache?的?PATHINFO 默认开启

nginx 的?PATHINFO 默认关闭

怎么拯救Thinkphp的PATHINFO模式

*我使用了Thinkphp3.2 ? ?lnmp1.3 搭建环境??| ?PATHINFO、REWRITE两种模式二选一*

首先的首先

SSH运行下面的代码

cat > /usr/local/nginx/conf/pathinfo.conf << 'EOF'
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "(.+?\.php)(/.*)") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
EOF

1.thinkphp配置文件下定义

'URL_MODEL' => 1,////PATHINFO URL模式

2.修改Linux服务器下?/usr/local/nginx/conf/vhost/网站配置文件

  • 用#注释 #include enable-php.conf; 在它下一行添加?include enable-php-pathinfo.conf;
  • 再下一行添加以下代码
    location ~ .*\.php
    {
    	try_files $uri =404;
    	fastcgi_pass  unix:/tmp/php-cgi.sock;
    	fastcgi_index index.php;
    	include fastcgi.conf;//注意,我参考那篇写成 fcgi.conf; 应该是版本不同
    	include pathinfo.conf;
    }
    
    location /status 
    {
    	stub_status on;
    	access_log   off;
    }
    

3.修改nginx.conf ?Linux服务器下?/usr/local/nginx/conf/nginx.conf

  • 用#注释 #include enable-php.conf; 在它下一行添加?include enable-php-pathinfo.conf;
  • SSH里面运行 lnmp nginx restart 来重启nginx

4.修改php.ini? Linux服务器下?/usr/local/php/etc/php.ini

  • cgi.fix_pathinfo=1 修改为?cgi.fix_pathinfo=0
  • SSH里面运行lnmp php-fpm restart 来重启php-fpm

5.好了,现在可以访问 ? localhost/index.php/Home/Index 了

怎么拯救Thinkphp的REWRITE模式

*我使用了Thinkphp3.2 ? ?lnmp1.3 搭建环境 ?| ?PATHINFO、REWRITE两种模式二选一*