Skip to content

Commit bcd8939

Browse files
author
Taois
committed
add: 增加php自动配置
1 parent f5b6905 commit bcd8939

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

spider/php/config.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
// 设置返回为 JSON
3+
// http://127.0.0.1:9980/config.php
4+
header('Content-Type: application/json; charset=utf-8');
5+
6+
// 当前目录
7+
$dir = __DIR__;
8+
9+
// 当前脚本名
10+
$self = basename(__FILE__);
11+
12+
// 扫描目录
13+
$files = scandir($dir);
14+
15+
$sites = [];
16+
17+
foreach ($files as $file) {
18+
// 只处理 php 文件
19+
if (pathinfo($file, PATHINFO_EXTENSION) !== 'php') {
20+
continue;
21+
}
22+
23+
// 排除自身和 index.php
24+
if ($file === $self || $file === 'index.php') {
25+
continue;
26+
}
27+
28+
// 文件名(不含 .php)
29+
$filename = pathinfo($file, PATHINFO_FILENAME);
30+
31+
$sites[] = [
32+
"key" => "php_" . $filename,
33+
"name" => $filename . "(PHP)",
34+
"type" => 4,
35+
"api" => "http://127.0.0.1:9980/" . $filename . ".php",
36+
"searchable" => 1,
37+
"quickSearch" => 1,
38+
"changeable" => 0
39+
];
40+
}
41+
42+
// 输出 JSON
43+
echo json_encode(
44+
["sites" => $sites],
45+
JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT
46+
);

0 commit comments

Comments
 (0)