我希望能够更改文件的修改日期以便在Web应用程序中使用.我暂时在命令行上测试它.在我的Mac上正常工作,但是当我在linux服务器上执行此操作时会出错.
命令:/ bin/touch -m -t 200906041200 /foo/bar/file.whatever
错误:/ bin/touch:设置`/foo/bar/file.whatever'的时间:不允许操作
有问题的文件是777.
我正在通过PHP提供图像,并设置一些问题,以回应304标头,以节省加载时间.
我在php.net上找到的大部分代码.它工作,但总是以200响应.由于某种原因,即使我最初发送Last-Modified标头,也没有在任何请求上收到If-Modified-Since标头.这是在Apache服务器上完成的.知道什么可能是错的吗?
此页面将从磁盘加载图像并将其显示到浏览器,同时发送Last-Modified标头.如果刷新页面,浏览器不会像它应该发送If-Modified-Since标头.
define('SITEPATH', (dirname($_SERVER['SCRIPT_NAME']) == '/') ? '/' : dirname($_SERVER['SCRIPT_NAME']).'/');
$load_path = $_SERVER['DOCUMENT_ROOT'] . SITEPATH . 'fpo_image.jpg';
// Get headers sent by the client.
$headers = apache_request_headers();
$file_time = filemtime($load_path);
header('Cache-Control: must-revalidate');
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $file_time).' GMT');
if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == $file_time)) {
header('HTTP/1.1 304 Not Modified');
header('Connection: close');
} else {
header('HTTP/1.1 200 OK');
header('Content-Length: '. filesize($load_path));
header('Content-type: image/jpeg');
readfile($load_path);
}
Run Code Online (Sandbox Code Playgroud) 我在xsl中有以下节点:
<foo>
<bar>1</bar>
<bar>2</bar>
<bar>3</bar>
<bar>4</bar>
<bar>5</bar>
<bar>6</bar>
<bar>7</bar>
<bar>8</bar>
<bar>9</bar>
</foo>
Run Code Online (Sandbox Code Playgroud)
并希望将其转换为以下html:
<ul class="one">
<li>1</li>
<li>4</li>
<li>7</li>
</ul>
<ul class="two">
<li>2</li>
<li>5</li>
<li>8</li>
</ul>
<ul class="three">
<li>3</li>
<li>6</li>
<li>9</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
很难弄清楚如何循环并获得每个第三项,想要做这样的事情:
<ul class="one">
<xsl:for-each select="exlt:node-set($blah)/foo/bar[X1]">
<li><xsl:value-of select="node()"/></li>
</xsl:for-each>
</ul>
<ul class="two">
<xsl:for-each select="exlt:node-set($blah)/foo/bar[X2]">
<li><xsl:value-of select="node()"/></li>
</xsl:for-each>
</ul>
<ul class="three">
<xsl:for-each select="exlt:node-set($blah)/foo/bar[X3]">
<li><xsl:value-of select="node()"/></li>
</xsl:for-each>
</ul>
Where:
X1 = Every third item starting from position 1
X2 = Every third item starting from position 2
X3 = Every third item …
Run Code Online (Sandbox Code Playgroud) 有一些问题让这个工作.PLEEEEEEASE帮助.
我希望一个元素固定在视口顶部,当用户向下滚动页面时,它仍保留在视口的顶部...很容易.如果窗口较窄,则会出现960px的水平滚动条.如果窗口是水平滚动的,我希望这个固定元素内的内容与它一起滚动.
请查看演示,两个绿色框应始终排成一行.让你的窗户缩小并滚动水平,注意他们不再排队.
没有JavaScript,这可能吗?应该在IE7 +中工作,而不是完全打破IE6.
我在一个目录中做了一堆更新,并希望添加它们,但它们位于我的.gitignore中的目录旁边.不应该git add
只是忽略这不是抱怨的?
如何添加所有内容并跳过被忽略的内容?
$ git add assets/*
The following paths are ignored by one of your .gitignore files:
assets/avatars
Use -f if you really want to add them.
fatal: no files added
Run Code Online (Sandbox Code Playgroud) 我发誓,我曾经在某个方面看过一篇关于此事的文章但却找不到......
如何在另一个域上执行POST类型的jQuery ajax请求?必须在没有代理的情况下完成.这可能吗?
在PHP中使用本机XSL库.是否有可能在变量中获取节点值而无需每次都通过exslt:node-set调用它......它很长而且很难看.
<xsl:variable name="mydata">
<foo>1</foo>
<bar>2</bar>
</xsl:variable>
<!-- How currently being done -->
<xsl:value-of select="exslt:node-set($mydata)/foo" />
<!-- I want to be able to do this -->
<xsl:value-of select="$mydata/foo" />
Run Code Online (Sandbox Code Playgroud) 我在Javascript中有以下字符串,需要删除<?xml ... ?>
和<!DOCTYPE .... ]>
标签.无法将其转换为dom,因为BR标记错误未关闭 - 并且无法编辑实际内容.
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html [<!ENTITY amp "&#38;">]><div>Blah<br> Blah</div>
Run Code Online (Sandbox Code Playgroud)
尝试用.replace做到这一点,但似乎无法到达那里
text.replace(/\<\?xml.+\?\>/g, '');
Run Code Online (Sandbox Code Playgroud) 我想创建一个php脚本,它将ping一个域并列出响应时间以及请求的总大小.
这将用于监控网站网络.我尝试过curl
,这是我到目前为止的代码:
function curlTest2($url) {
clearstatcache();
$return = '';
if(substr($url,0,4)!="http") $url = "http://".$url;
$userAgent =
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
$execute = curl_exec($ch);
// Check if any error occured
if(!curl_errno($ch)) {
$bytes = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
$total_time = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
$return = 'Took ' . $total_time . ' / Bytes: '. …
Run Code Online (Sandbox Code Playgroud) 对于下面的代码,我在IE中遇到了一些问题.传递给函数的第二个参数应该是对单击项目的引用.这在FF和Safari中运行良好,但是当我在IE7中测试它时会出错.IE似乎得到了元素(如在控制台中看到的),但每当我尝试用它做任何事情时,我都会得到错误:
"对象不支持此属性或方法"
谢谢您的帮助.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
<script language="javascript" type="text/javascript">
var Test = {
doIt: function(str, btn) {
console.log(str);
console.log(btn);
if (btn.hasClassName('red')) {
console.log('has red');
} else {
console.log('doesn\'t');
}
}
};
</script>
<a href="#" onClick="Test.doIt('hello', this)" class="red">Test</a>
</body></html>
Run Code Online (Sandbox Code Playgroud) 我是Cake用户的开始,并尝试在已有的应用程序上做一些工作.在创建新控制器时遇到问题.我创建了StoreController,当我尝试调用其中的方法时,我得到下面的错误.没有表'store',但似乎它正在尝试自动加载与控制器相关的模型.如何阻止我的应用程序尝试加载此控制器的模型?
Missing Database Table
Error: Database table stores for model Store was not found.
Run Code Online (Sandbox Code Playgroud) 参考这个链接(打开firebug)。我有一个“下拉”html 元素,其中有一个寻找鼠标悬停的事件观察者。它正在工作,但是当您将鼠标悬停在其中的其他元素上时,它会不断触发鼠标悬停事件。我猜这是因为冒泡。
有没有办法让它只在初始鼠标悬停时触发事件?我想让它产生一个效果,但这破坏了效果。我确信这只是我没有做的一些基本事情。
谢谢您的帮助。