-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathindex.php
30 lines (24 loc) · 1.14 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require 'vendor/autoload.php';
$app = new Slim\App();
$app->get('/', function (\Slim\Http\Request $request, \Slim\Http\Response $response, $args) {
$plain = file_get_contents('node.txt');
$ssr = collect(explode(PHP_EOL,$plain))->filter(function($line){
return \Illuminate\Support\Str::contains($line,"ssr://");
});
return $response->getBody()->write(base64_encode(implode(PHP_EOL,$ssr->all())));
});
$app->get('/add', function (\Slim\Http\Request $request, \Slim\Http\Response $response, $args) {
$ssr = $request->getParam('node');
file_put_contents('node.txt',$ssr.PHP_EOL,FILE_APPEND);
return $response->getBody()->write('done !');
});
$app->get('/sub', function (\Slim\Http\Request $request, \Slim\Http\Response $response, $args) {
$client = new GuzzleHttp\Client(['verify'=>false]);
$link = $request->getParam('link');
$plain = base64_decode($client->get($link)->getBody());
file_put_contents('node.txt',PHP_EOL."## {$link} ".PHP_EOL,FILE_APPEND);
file_put_contents('node.txt',$plain.PHP_EOL,FILE_APPEND);
return $response->getBody()->write('done !');
});
$app->run();