为什么当我在 Ubunutu 中运行 .php 脚本时,它只是回显脚本本身?

发布于 2024-12-07 03:18:59 字数 1122 浏览 0 评论 0 原文

我必须解码我命名为 cache.log 的 Chrome 缓存文件之一的二进制内容数据。我尝试解码它的方法是使用我在这里找到的 php 脚本

http://www.frozax.com/blog/2011/05/recover-file-google-chrome-cache-gzipped/

我已经使用以下命令安装了 php

sudo apt-get install php5 libapache2-mod-php5
sudo apt-get install php5-cgi

当我尝试运行 index1.php 脚本我在终端中得到以下内容

s3z@s3z-laptop:~/Desktop$ php index1.php 
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
// cache.log is a copy of chrome cache page with only the file content section
$cacheString = file_get_contents("cache.log");
$matches = array();
preg_match_all('/\s[0-9a-f]{2}\s/', $cacheString, $matches);
$f = fopen("t.bin","wb");
foreach ($matches[0] as $match)
{
  fwrite($f,chr(hexdec($match)));
}
fclose($f);

ob_start();
readgzfile("t.bin");
$decoded_data=ob_get_clean();
echo $decoded_data;

如您所见,它所做的只是回显脚本。

我如何实际运行脚本?

I have to decode the binary content data of one of my Chrome cache files which I name cache.log. The way I am trying to decode it is by using a php script I found here

http://www.frozax.com/blog/2011/05/recover-file-google-chrome-cache-gzipped/

I have installed php with the following command already

sudo apt-get install php5 libapache2-mod-php5
sudo apt-get install php5-cgi

When I try to run the index1.php script I get the following in Terminal

s3z@s3z-laptop:~/Desktop$ php index1.php 
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
// cache.log is a copy of chrome cache page with only the file content section
$cacheString = file_get_contents("cache.log");
$matches = array();
preg_match_all('/\s[0-9a-f]{2}\s/', $cacheString, $matches);
$f = fopen("t.bin","wb");
foreach ($matches[0] as $match)
{
  fwrite($f,chr(hexdec($match)));
}
fclose($f);

ob_start();
readgzfile("t.bin");
$decoded_data=ob_get_clean();
echo $decoded_data;

As you can see, all it is doing is echoing the script.

How do I actually run the script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何止钟意 2024-12-14 03:18:59

它看起来不像代码被包装在:

<?php 

?> 

如果没有,它只会回显而不是执行。原因是 PHP 允许您在同一个文件中混合服务器脚本和 HTML。

<html>
    <head><title></title></head>
    <body>
    <?php 
        //Inside the php block so it gets executed and prints 'Hello World'
        echo "Hello, World!"; 
    ?>
    <!--Outside the php block so it just gets echoed and prints 'echo "Hello, World!";' -->
    echo "Hello, World!"; 
    </body>
</html>

It doesn't look like the code is wrapped in:

<?php 

?> 

If it doesn't have that, it will just echo instead of executing. The reason for this is that PHP lets you mix server scripting and HTML in the same file.

<html>
    <head><title></title></head>
    <body>
    <?php 
        //Inside the php block so it gets executed and prints 'Hello World'
        echo "Hello, World!"; 
    ?>
    <!--Outside the php block so it just gets echoed and prints 'echo "Hello, World!";' -->
    echo "Hello, World!"; 
    </body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文