```php```

2026-04-03 13:591阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计305个文字,预计阅读时间需要2分钟。

```php```

创建代码文件`compress.php`,内容如下:

php

```php```

运行命令行:bashphp compress.php

或通过浏览器访问:httphttp://localhost/compress.php

主要用于将网站生成的单个文件上传到FTP空间。

假设代码文件存为compress.php
可以命令行运行
php ./compress.php '/home/zhouchun/www'
也可以放网站目录后运行
localhost/compress.php
主要用于将网站生成单一文件上传到ftp空间,这样比单独上传快,然后运行即可释放,不需要zip支持
标签: <无>

<?php function readFileFromDir($dir,$trimDir,$list=array()) { if(!is_dir($dir)){ return $list; } $handle=opendir($dir); while(($file=readdir($handle))!==false){ if($file=='.'||$file=='..'||$file==basename($_SERVER['SCRIPT_NAME'])){ continue; } $file=$dir.DIRECTORY_SEPARATOR.$file; if($trimDir!='.'){ $trimPath=str_replace($trimDir,'.',$file); } else{ $trimPath=$file; } if(is_file($file)){ $list[]=array('type'=>'file','path'=>$trimPath,'content'=>base64_encode(file_get_contents($file))); } else if(is_dir($file)){ $list[]=array('type'=>'dir','path'=>$trimPath); $list=readFileFromDir($file,$trimDir,$list); } } closedir($handle); return $list; } if(isset($argv)){ $dir=$argv[1]; } else{ $dir='.'; } $list=readFileFromDir($dir,$dir); $code=array(); $data=base64_encode(json_encode($list)); $code[]='<?php'; $code[]='$list=json_decode(base64_decode("'.$data.'"),true);'; $code[]='foreach($list as $item){if($item["type"]=="dir"){mkdir($item["path"],0777);}else{file_put_contents($item["path"],base64_decode($item["content"]));}}'; $code[]='echo "ok";'; $code[]='?>'; $code=implode(PHP_EOL,$code); $name=date('YmdHis').'.php'; file_put_contents($name,$code); echo 'ok->'.$name; ?>

标签:

本文共计305个文字,预计阅读时间需要2分钟。

```php```

创建代码文件`compress.php`,内容如下:

php

```php```

运行命令行:bashphp compress.php

或通过浏览器访问:httphttp://localhost/compress.php

主要用于将网站生成的单个文件上传到FTP空间。

假设代码文件存为compress.php
可以命令行运行
php ./compress.php '/home/zhouchun/www'
也可以放网站目录后运行
localhost/compress.php
主要用于将网站生成单一文件上传到ftp空间,这样比单独上传快,然后运行即可释放,不需要zip支持
标签: <无>

<?php function readFileFromDir($dir,$trimDir,$list=array()) { if(!is_dir($dir)){ return $list; } $handle=opendir($dir); while(($file=readdir($handle))!==false){ if($file=='.'||$file=='..'||$file==basename($_SERVER['SCRIPT_NAME'])){ continue; } $file=$dir.DIRECTORY_SEPARATOR.$file; if($trimDir!='.'){ $trimPath=str_replace($trimDir,'.',$file); } else{ $trimPath=$file; } if(is_file($file)){ $list[]=array('type'=>'file','path'=>$trimPath,'content'=>base64_encode(file_get_contents($file))); } else if(is_dir($file)){ $list[]=array('type'=>'dir','path'=>$trimPath); $list=readFileFromDir($file,$trimDir,$list); } } closedir($handle); return $list; } if(isset($argv)){ $dir=$argv[1]; } else{ $dir='.'; } $list=readFileFromDir($dir,$dir); $code=array(); $data=base64_encode(json_encode($list)); $code[]='<?php'; $code[]='$list=json_decode(base64_decode("'.$data.'"),true);'; $code[]='foreach($list as $item){if($item["type"]=="dir"){mkdir($item["path"],0777);}else{file_put_contents($item["path"],base64_decode($item["content"]));}}'; $code[]='echo "ok";'; $code[]='?>'; $code=implode(PHP_EOL,$code); $name=date('YmdHis').'.php'; file_put_contents($name,$code); echo 'ok->'.$name; ?>

标签: