JS - F12 网页跳转

js

function collect() {
    //开始javascript执行过程的数据收集
    console.profile();
    //配合profile方法,作为数据收集的结束
    console.profileEnd();
    //我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!!  
    if (console.clear) {
        //清空控制台
        console.clear()
    };
    if (typeof console.profiles == "object") {
        return console.profiles.length > 0;
    }
}
function check() {
    if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) {
        jump();
    }
    if (typeof console.profiles == "object" && console.profiles.length > 0) {
        jump();
    }
}
check();
window.onresize = function() {
    //判断当前窗口内页高度和窗口高度
    if ((window.outerHeight - window.innerHeight) > 200)
    jump();
}
function jump() {
    window.location = "http://xiaowiba.com";
}

  翻  牌  子

JS - 鼠标点击彩色爱心特效

js

(function(window, document, undefined) {
    var hearts = [];
    window.requestAnimationFrame = (function() {
        return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
        function(callback) {
            setTimeout(callback, 1000 / 60);
        }
    })();
    init();
    function init() {
        css(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
        attachEvent();
        gameloop();
    }
    function gameloop() {
        for (var i = 0; i < hearts.length; i++) {
            if (hearts[i].alpha <= 0) {
                document.body.removeChild(hearts[i].el);
                hearts.splice(i, 1);
                continue;
            }
            hearts[i].y--;
            hearts[i].scale += 0.004;
            hearts[i].alpha -= 0.013;
            hearts[i].el.style.cssText = "left:" + hearts[i].x + "px;top:" + hearts[i].y + "px;opacity:" + hearts[i].alpha + ";transform:scale(" + hearts[i].scale + "," + hearts[i].scale + ") rotate(45deg);background:" + hearts[i].color;
        }
        requestAnimationFrame(gameloop);
    }
    function attachEvent() {
        var old = typeof window.onclick === "function" && window.onclick;
        window.onclick = function(event) {
            old && old();
            createHeart(event);
        }
    }
    function createHeart(event) {
        var d = document.createElement("div");
        d.className = "heart";
        hearts.push({
            el: d,
            x: event.clientX - 5,
            y: event.clientY - 5,
            scale: 1,
            alpha: 1,
            color: randomColor()
        });
        document.body.appendChild(d);
    }
    function css(css) {
        var style = document.createElement("style");
        style.type = "text/css";
        try {
            style.appendChild(document.createTextNode(css));
        } catch (ex) {
            style.styleSheet.cssText = css;
        }
        document.getElementsByTagName('head')[0].appendChild(style);
    }
    function randomColor() {
        return "rgb(" + (~~ (Math.random() * 255)) + "," + (~~ (Math.random() * 255)) + "," + (~~ (Math.random() * 255)) + ")";
    }
})(window, document);

JS - 全部选择、取消全部选择 - 1

js

window.onload = function() {
                //全部选择
                document.getElementById('checkall').onclick = function() {
                    //获取文档中所有的input元素
                    var obj = document.getElementsByTagName('input');
                    for (var i = 0; i < obj.length; i ++) {
                        if (obj[i].type == 'checkbox') {
                            obj[i].checked = true;
                            //设置复选框元素对象的checked属性值为true就能勾选该复选框
                            //false即为取消选择
                        }
                    }
                }
                //全部取消选择
                document.getElementById('deselect').onclick = function() {
                    var obj = document.getElementsByTagName('input');
                    for (var i = 0; i < obj.length; i ++) {
                        if (obj[i].type == 'checkbox') {
                            obj[i].checked = false;
                        }
                    }
                }
            }

  翻  牌  子

ajax - 提交 checkbox

html

<button class="batchdel" id="submitbatchdel" type="submit">
    <a href="" onclick="if(confirm('确定要删除数据吗?')) return true;else return false;">批量删除</a>
</button>

  翻  牌  子

PHP - 清空目录下文件

//清空文件操作
function delDirAndFile($dirName){
    if($handle = opendir("$dirName")){
        while(false !== ($item = readdir($handle))){
            if($item != "." && $item != ".."){
                if(is_dir("$dirName/$item")){
                    delDirAndFile("$dirName/$item");
                }else{
                    if(unlink("$dirName/$item")){
                        //echo "成功删除文件: $dirName/$item\n";
                    }
                }
            }
        }
        closedir($handle);
        if(rmdir($dirName)){
            //echo "成功删除目录: $dirName\n";
        }
    }
}

PHP - 遍历目录下的文件

//遍历目录下的文件
function rmdi_r($dirname){
    //判断是否为一个目录,非目录直接关闭
    if(is_dir($dirname)){
        //如果是目录,打开他
        $name = opendir($dirname);
        //使用while循环遍历
        $i = 0;
        while($file = readdir($name)){
            //去掉本目录和上级目录的点
            if($file == "." || $file == ".."){
                continue;
            }
            //如果目录里面还有一个目录,再次回调
            if(is_dir($dirname."/".$file)){
                rmdi_r($dirname."/".$file);
            }
            //exit();
            //如果目录里面是个文件,那么输出文件名
            if(is_file($dirname."/".$file)){
                echo "<li class=''>序号:".($i+1)."|路径:".$dirname."/".$file."</li>";
            }
            $i++;
        }
        //遍历完毕关闭文件
        closedir($name);
        //输出目录名
        //echo("目录名称:".$dirname);
        echo "<b>当下目录内还有".$i."个文件</b>";
        if($i == 0){//目录为空提示语
            echo "该目录为空";
        }else{}
    }
}

jQuery - 回车提交

$(document).keyup(function(e){
    if(e.keyCode == 13){
        $('#submitform').trigger('click');
    }
})
$("#submitform").bind('click', function () {
    var login = {};
    login['username'] = $.trim($("input[name=username]").val());
    login['pwd'] = $.trim($("input[name=pwd]").val());
    login['code'] = $.trim($("input[name=code]").val());
    $('.login-error').html('');
    if (login['username'] == '') {
        errorDis('请输入用户名/手机/邮箱');
        return false;
    }
    if(login['pwd']=='')
    {
        errorDis('请输入密码');
        return false;
    }
    if (login['code'] == '') {
        errorDis('请输入验证码');
        return false;
    }
    $.ajax({
        url: '/login/checkloginmsg',
        type: 'POST',
        dataType: 'json',
        data: login,
        success: function (data) {
        if (data.code == 200) {
            window.location.href = "/main";
        } else {
            errorDis(data.info);//返回错误提示
            return false;
        }
        }
    })
});

  翻  牌  子

PHP - authcode

 在网站的重置密码功能一般都会有通过账号的邮箱来实现重置密码的功能。
在重置密码界面输入邮箱账号,服务器就会向该邮箱发送一封邮件。
邮件内容一般会有一个链接,你点击链接便会跳转到设置新密码界面。
为什么扯这么多呢?好像很文章标题毫无关系呢 OωO
好的,开始文章主题了。

  翻  牌  子