Skip to content

Commit 23d996e

Browse files
committed
修复bug,去掉包中的receiver.php,避免安全性问题
1 parent e32b391 commit 23d996e

File tree

4 files changed

+18
-48
lines changed

4 files changed

+18
-48
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@
3030
...
3131
}
3232
```
33-
33+
34+
## 服务端配置
35+
36+
[receiver.php](https://gist.github.com/jinzhan/131858820f998acca568b374dcfd88e2),部署到远程机器,并保证`receiver.php`能被正常访问
37+
38+
39+
直接访问`http://YOUR_HOST/YOUR_PATH/receiver.php`时,页面应该显示这行字
40+
41+
```
42+
I'm ready for that, you know.
43+
```
3444

3545
## Reference
3646

fsr.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ function requireToken(validateApi, info, cb) {
109109
}
110110

111111
function getTmpFile() {
112-
return require('os').homedir() + '/.deploy-tmp/deploy.json';
112+
const dir = require('os').homedir() + '/.deploy-tmp';
113+
if (!fs.existsSync(dir)) {
114+
fs.mkdirSync(dir);
115+
}
116+
return dir + '/deploy.json';
113117
}
114118

115119
function deployInfo(options) {
@@ -202,4 +206,4 @@ module.exports = function (modified, options, callback) {
202206
current(next);
203207
};
204208
}, callback)();
205-
};
209+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deploy-files",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "deploy files with node",
55
"main": "index.js",
66
"dependencies": {

receiver.php

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +0,0 @@
1-
<?php
2-
3-
// 如果是 debug 模式,就输出所有错误
4-
if(isset($_GET['debug']) && $_GET['debug'] == "true"){
5-
@error_reporting(E_ALL);
6-
ini_set('display_errors', '1');
7-
}else{
8-
@error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
9-
}
10-
11-
function mkdirs($path, $mod = 0777) {
12-
if (is_dir($path)) {
13-
return chmod($path, $mod);
14-
} else {
15-
$old = umask(0);
16-
if(mkdir($path, $mod, true) && is_dir($path)){
17-
umask($old);
18-
return true;
19-
} else {
20-
umask($old);
21-
}
22-
}
23-
return false;
24-
}
25-
26-
// if($_POST['to'] && isset($_POST['token']) && $_POST['token'] == "xxxxxx"){ // 以增加 token 字段为例, 举一反三
27-
if($_POST['to']){
28-
$to = urldecode($_POST['to']);
29-
if(is_dir($to) || $_FILES["file"]["error"] > 0){
30-
header("Status: 500 Internal Server Error");
31-
} else {
32-
if(file_exists($to)){
33-
unlink($to);
34-
} else {
35-
$dir = dirname($to);
36-
if(!file_exists($dir)){
37-
mkdirs($dir);
38-
}
39-
}
40-
echo move_uploaded_file($_FILES["file"]["tmp_name"], $to) ? 0 : 1;
41-
}
42-
} else {
43-
echo 'I\'m ready for that, you know.';
44-
}

0 commit comments

Comments
 (0)