简体   繁体   English

静态html上的动态网站

[英]Dynamic Website on static html

I am trying to create a script that will display the contents of a folder, onto a newsticker, and I was wondering if anyone had a script that could run this. 我正在尝试创建一个脚本,该脚本将在新贴纸上显示文件夹的内容,我想知道是否有人可以运行此脚本。 I was thinking probably php, but it has no been working for me. 我当时在想php,但是它对我没有用。

Thanks for the help 谢谢您的帮助

The software I am using is dreamweaver cs4 我使用的软件是Dreamweaver CS4

I'm guessing that you have written some PHP, but are trying to run it locally without a server - for PHP to work you need a server. 我猜您已经编写了一些PHP,但是试图在没有服务器的情况下在本地运行它-要使PHP正常工作,您需要一台服务器。 XAMPP is a good bet to do this locally, or you'll need to upload your file to some hosting that supports PHP. XAMPP是在本地进行此操作的不错选择,或者您需要将文件上传到一些支持PHP的主机。

I'm thinking why you're having trouble with it is because you just copy and pasted the code in a .html file and opening it on your local environment. 我在想为什么您会遇到麻烦,因为您只是将代码复制并粘贴到.html文件中,然后在本地环境中打开它。

With that said, in order for it to run locally, you have to install php and a http server. 话虽如此,为了使其在本地运行,您必须安装php和http服务器。 The code is done on server side, not client side. 该代码在服务器端而不是客户端上完成。 So either get a hosting service that supports php or download and install your own server and php. 因此,要么获得支持php的托管服务,要么下载并安装自己的服务器和php。

Also, if you already have the above, the code has to be surrounded by a < ?php and ? 另外,如果您已经有了上述内容,则代码必须用<?php和?包围。 > tags(without spaces). >标签(无空格)。 If you're running it on cli, then you need to make sure you give it execution permission with the path to php, OR execute php < name of script >. 如果您在cli上运行它,则需要确保通过php路径授予它执行许可,或者执行php <脚本名称>。

Last, the code you presented provides major security flaws. 最后,您提供的代码存在主要的安全漏洞。 The first of which is where will the "$dir_path" variable be set? 第一个是在哪里设置“ $ dir_path”变量? Will that be user given, or will you specify the variable? 是给用户指定的,还是指定变量?

Whenever you allow users to view your file system, always make sure you give limitations to it. 每当您允许用户查看您的文件系统时,请务必确保对其进行限制。 For example, let's say you did this: 例如,假设您这样做:

www.example.com/newsticker.php?path=/www/files/newsticker www.example.com/newsticker.php?path=/www/files/newsticker

looks innocent enough, but a clever hacker could say let me try.... 看起来足够无辜,但是一个聪明的黑客可以说让我尝试...。

www.example.com/newsticker.php?path=/ www.example.com/newsticker.php?path=/

And so fort. 等等。

So be careful and don't allow users to specify directories or execute code. 所以要小心,不要让用户指定目录或执行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM