小编Kee*_*fer的帖子

.htaccess/.htpasswd绕过某个IP地址

是否可以为给定目录设置.htaccess/.htpasswd访问控制设置,但如果它们来自特定IP地址,则绕过登录/密码身份验证?

我知道你可以在.htaccess文件中做这样的事情:

order deny,allow
deny from all
allow from 000.000.000.000
Run Code Online (Sandbox Code Playgroud)

但是如果你沿着这些方向添加一些东西:

AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/.htpasswd
require valid-user
Run Code Online (Sandbox Code Playgroud)

然后它会提示输入密码.有没有办法做一个if/else类型设置,或其他一些解决方案,以便用户作为给定的IP(或一组IP)不会被提示输入密码,但其他人都这样做?

.htaccess apache2 basic-authentication

43
推荐指数
5
解决办法
6万
查看次数

如何修复与时区相关的PHP错误(function.strtotime和function.date)

升级到新服务器,我两次重复错误:

警告:strtotime()[function.strtotime]:依赖系统的时区设置是不安全的.您需要使用date.timezone设置或date_default_timezone_set()函数.如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符.我们在'EST/-5.0/no DST'中选择'America/New_York'代替......

警告:date()[function.date]:依赖系统的时区设置是不安全的.您需要使用date.timezone设置或date_default_timezone_set()函数.如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符.我们在'EST/-5.0/no DST'中选择'America/New_York'代替

我该如何解决这些问题?

有问题的代码是这样的:

'date' => date("Y-M-d",strtotime($Array['_dateCreated'])),
Run Code Online (Sandbox Code Playgroud)

我已经尝试将它放在我所有页面顶部的包含中:

<?php
date_default_timezone_set('America/New_York');
?>
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助.

php

14
推荐指数
2
解决办法
8万
查看次数

如何使Web浏览器缓存内容无效

我一直在深入研究Google Page Speed,优化了我正在努力获得的很多网站 - 而且非常成功,我很自豪地说.

我遇到的唯一缺点是,通过一些缓存工作,对JS和CSS的小改动往往不会导致下载文件的新副本.

有什么方法可以对JS,CSS(或其他资源)进行更改以强制下载新副本吗?

browser caching browser-cache

9
推荐指数
2
解决办法
1万
查看次数

jQuery动画高斯模糊

在我正在设计的网站的主页上,我希望最初的英雄形象能够从模糊(高斯)到尖锐的动画.我环顾四周,并且惊讶于没有一个明显的jQuery解决方案来做这件事.我错过了什么吗?

由于我已经在网站上为其他东西加载jQuery核心,我真的很喜欢使用jQuery.我找到了这个例子,但它正在使用YUI,我宁愿不在jQuery之上加载YUI只是为了这个效果.

jquery gaussian blurry jquery-plugins jquery-animate

7
推荐指数
1
解决办法
5666
查看次数

file_get_contents的相对PHP路径

这似乎是一个简单而常见的任务,但我们无法让它工作:

我们有两个人在一个项目上工作,我们的机器都设置为本地服务器,最终有一个生产环境.

在我们所有项目的负责人中,我们已经获得了PHP,如下所示:

$feed = "/lib/php/backend/gateway.php?action=history";
$json = file_get_contents($feed, true);
Run Code Online (Sandbox Code Playgroud)

让它工作的唯一方法是将其设置为完整的URL,如http://dev01.domain.com/lib/php/backend/gateway.php?action=history,或者将其设置为localhost,如下所示:

$feed = "http://localhost/lib/php/backend/gateway.php?action=history";
$json = file_get_contents($feed, true);
Run Code Online (Sandbox Code Playgroud)

后者显然适用于我们当地的盒子,并且可能也适用于生产,但有没有办法使用相对路径更清洁?

php

6
推荐指数
1
解决办法
1万
查看次数

使用绝对与图像的相对路径

一位同事刚刚问我是否有任何理由为什么提到相对路径的图像会妨碍网站速度.

虽然为了清洁,最好使用相对路径中较少的字符,但想知道使用绝对/完整路径是否存在其他减速/后果?我认为通过拥有完整路径可能会涉及DNS查找.

如果有其他后果,会有什么后果?

html performance networking path

6
推荐指数
1
解决办法
7451
查看次数

Google Analytics在Hash Change上设置PageView

我正在尝试在Isotope下获得一堆包含大量内容的主页

将每个哈希更改显示为Google Analytics中的综合浏览量.最初,我打算将此作为事件,但它确实应该是网页浏览.

所以我设置了修改后的GA:

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-X', {'allowAnchor': true});
ga('send', 'pageview', { 'page': location.pathname + location.search + location.hash});
Run Code Online (Sandbox Code Playgroud)

在Google Analytics中,如果有人访问特定的网址,我会立即看到哈希标记 - 例如:http://www.example.com/#pet-health 如果他们重新加载页面,我会在GA中看到哈希,但是如果他们点击Isotope"nav"链接进入它.如果他们点击,我只是看到"/"

在同位素射击中,我所拥有的似乎没有起作用:

//Sets up filtering on click of Isotope navigational elements 
    $('#isotopeFilters a, .subnav a, #isotopeContainer .isotopeNav a, .page-template-page-home-php #logo').click(function(){
        var selector = $(this).attr('data-filter');
        var prettyselector = selector.substr(1);
        ga('send', 'pageview', location.pathname+location.search+location.hash);

        location.hash = prettyselector;

        $('#isotopeFilters a, .subnav a').removeClass('active');
        $('a[class="' + prettyselector + '"]').addClass('active');

        $container.isotope({ 
            filter: selector,
            itemSelector: '.item',
            masonry: …
Run Code Online (Sandbox Code Playgroud)

javascript jquery google-analytics pageviews jquery-isotope

5
推荐指数
2
解决办法
3233
查看次数

JSLint错误:意外' - '

我在JS文件中遇到两个错误,都是"意外" - "." 它是用于鼠标滚轮滚动的代码(两次都是this.addEventListener( types[--i], handler, false );).我以前从未见过这种语法.它是什么,我应该如何纠正它,使JSLint更快乐?

(function($) {
var types = ['DOMMouseScroll', 'mousewheel'];
$.event.special.mousewheel = {
    setup: function() {
        var i;
        if ( this.addEventListener ) {
            i = types.length;
            while ( i >= 0 ) {
                this.addEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = handler;
        }
    },

    teardown: function() {
        if ( this.removeEventListener ) {
            i = types.length;
            while ( i >= 0 ) {
                this.removeEventListener( types[--i], handler, false );
            }
        } else …
Run Code Online (Sandbox Code Playgroud)

javascript syntax jquery jslint

4
推荐指数
1
解决办法
1977
查看次数

是否有document.createElement多个元素的简写方法?

当你创建一堆元素时,JS中有一个简写方法来记录document.createElement.

为了最大限度地利用HTML5,并且仍然让网站在旧浏览器中运行,我倾向于在每个站点都有类似JS的片段:

// Allows HTML5 tags to work in older browsers
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('footer');
Run Code Online (Sandbox Code Playgroud)

有没有办法通过一个语句添加它们 - 逗号分隔或类似的东西?

javascript html5

3
推荐指数
1
解决办法
3598
查看次数

将服务器设置为CDN

我们现在有一个服务器和域名,现在基本上用作带有视频文件和图像的大硬盘(由MediaTemple托管).将此服务器和域设置为CDN需要什么?

我看到这篇文章:http: //www.riyaz.net/blog/how-to-setup-your-own-cdn-in-30-minutes/technology/890/

但这看起来是对框的别名,而不是实际移动内容.我们的内容实际上托管在不同的盒子上.

optimization performance cdn

1
推荐指数
1
解决办法
3783
查看次数

带有.a​​nimate的jQuery Custom Easing插件

我正在使用jQuery插件进行自定义Easing(jQuery Easing v1.3 -http://gsgd.co.uk/sandbox/jquery/easing/),为我的jQuery Tools可滚动实例添加自定义缓动,如下所示:

$(".historyScrollable").scrollable({ easing:"easeInOutCubic"}).navigator();

我希望也能使用jQuery Easing插件与.animate函数一起使用

我试过像这样使用它:

$(this).find('div').stop().animate({'marginLeft':'-280px'},200,easeInOutCubic);

但它说没有定义"easeInOutCubic".我正在做的是什么,而我的语法错了?我也试过使用specialEasing,但似乎也没有用:

$(this).find('div').stop().animate({'marginLeft':'-280px'},{duration:200, customEasing:{'marginLeft':'easeInOutCubic'}});

jquery jquery-easing easing jquery-animate

1
推荐指数
1
解决办法
1719
查看次数