设置“href”在样式表中链接到可执行脚本? [英] Setting the "href" in a stylesheet link to an executable script?

查看:69
本文介绍了设置“href”在样式表中链接到可执行脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近注意到html页面中的样式表链接有一个href设置

到PHP脚本,如:


< LINK REL = "样式表" HREF =" some_css.php" type =" text / css">


大概是被引用的文件实际上是一个可执行的PHP

脚本而不是碰巧有的css文件一个.php扩展名。

基于这个假设,我用Perl脚本尝试了同样的事情

(正在测试的网络服务器碰巧安装了mod_perl但没有安装

mod_php),如:


< LINK REL =" stylesheet" HREF =" dyn_css.pl" type =" text / css">


结果是一个服务器错误,其中包含error_log条目:


Bareword找到了运营商预期的位置在

/srv/www/plwa/test/dyn_css.html第4行,靠近" dyn_css.pl输入

(类型之前缺少运算符?)


Perl脚本返回一个简单的样式表对象...


body {

background-color:#000000;

font-family:Verdana;

font-size:10px;

颜色:#FFFFFF;

边框:5px实心#AAAAAA;

}


....这正是上面提到的PHP脚本在wget检索

时返回的内容。


因此,问题是:是否可以在
样式表链接?如果是这样的话,可以随便评论我为什么会从服务器上获得上述错误吗?


O / S:SuSE Linux 8.x

服务器:带有mod_perl的Apache 2.x(.pl文件与使用AddHandler语句的

perl-script处理程序相关联)。


谢谢!

-

Dave H.

解决方案

" ;戴夫哈蒙德 < DH **** @ gmail.com>在新闻中写道:1126876909.069914.315680

@ f14g2000cwb.googlegroups.com:

因此,问题是:是否可以在
样式表链接中引用可执行脚本?如果有的话,可以随便评论为什么我可能会从服务器上获得上述错误吗?




如果能够做到这一点,这是非常有趣的..你有没有看过服务器为php文件返回的内容类型?
内容类型?使用wget获取返回的

标头(wget -S)。很可能他们已经将内容类型设置为

text / css而不是php脚本常用的文本/ html。


在PHP中你会改变这样的标题:

header(" Content-Type:text / css")

在将任何内容输出到客户端之前。


这可能是他们正在做的事情。


Stian


一个很好的假设,但根据wget -S返回的类型是

text / html:


发送HTTP请求,等待响应...

1 HTTP /1.1 200 OK

2日期:2005年9月16日星期五12:45:45 GMT

3服务器:Apache / 2.0.46(红帽)

4接受范围:字节

5 X-Powered-By:PHP / 4.3.2

6连接:关闭

7内容类型:text / html; charset = UTF-8

[< => ] 867 846.68K / s

10:55:29(846.68 KB / s) - `gp_css.php''已保存[867]


-

Dave H.


Dave Hammond写道:


< LINK REL = QUOT;样式表" HREF =" dyn_css.pl" type =" text / css">

结果是带有error_log条目的服务器错误:

Bareword找到了运营商在
/ srv /期望的位置www / plwa / test / dyn_css.html第4行,靠近"" dyn_css.pl"键入
(类型之前缺少运算符?)



您的服务器是否配置为对具有扩展名的文件运行perl

" pl" ?

-

jmm dash list(at)sohnen-moe(dot)com

(删除电子邮件的.AXSPAMGN)


I recently noticed the stylesheet link in an html page had the href set
to a PHP script, as in:

<LINK REL="stylesheet" href="some_css.php" type="text/css">

Presumably the file being referenced was actually an executable PHP
script and not a css file that happened to have a .php extension.
Based on that assumption, I tried the same thing with a Perl script
(the webserver being tested happens to have mod_perl installed but not
mod_php), as in:

<LINK REL="stylesheet" href="dyn_css.pl" type="text/css">

The result was a server error with the error_log entry:

Bareword found where operator expected at
/srv/www/plwa/test/dyn_css.html line 4, near ""dyn_css.pl" type"
(Missing operator before type?)

The Perl script returns a simple stylesheet object...

body {
background-color: #000000;
font-family: Verdana;
font-size: 10px;
color: #FFFFFF;
border: 5px solid #AAAAAA;
}

.... which is exactly what the aforementioned PHP script returned when
retrieved by wget.

So, the question is: can an executable script be referenced in a
stylesheet link? If so, can anyome comment on why I might be getting
the above error from the server?

O/S: SuSE Linux 8.x
Server: Apache 2.x with mod_perl (.pl files associated with the
perl-script handler using an AddHandler statement).

Thanks!
--
Dave H.

解决方案

"Dave Hammond" <dh****@gmail.com> wrote in news:1126876909.069914.315680
@f14g2000cwb.googlegroups.com:

So, the question is: can an executable script be referenced in a
stylesheet link? If so, can anyome comment on why I might be getting
the above error from the server?



This is quite interesting if it can be done ... have you looked into what
content-type the server is returning for the php file? Use wget to get the
headers returned (wget -S). Most likely they have set the content-type to
text/css and not text/html which is usual for php scripts.

In PHP you would change the header something like this:
header("Content-Type: text/css")
before any content is output to the client.

It might be what they are doing.

Stian


A good hypothesis, but according to wget -S the type being returned is
text/html:

HTTP request sent, awaiting response...
1 HTTP/1.1 200 OK
2 Date: Fri, 16 Sep 2005 12:45:45 GMT
3 Server: Apache/2.0.46 (Red Hat)
4 Accept-Ranges: bytes
5 X-Powered-By: PHP/4.3.2
6 Connection: close
7 Content-Type: text/html; charset=UTF-8

[ <=> ] 867 846.68K/s
10:55:29 (846.68 KB/s) - `gp_css.php'' saved [867]

--
Dave H.


Dave Hammond wrote:


<LINK REL="stylesheet" href="dyn_css.pl" type="text/css">

The result was a server error with the error_log entry:

Bareword found where operator expected at
/srv/www/plwa/test/dyn_css.html line 4, near ""dyn_css.pl" type"
(Missing operator before type?)


Is your server configured to run perl on files that have the extension
"pl"?
--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)


这篇关于设置“href”在样式表中链接到可执行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆