-
Notifications
You must be signed in to change notification settings - Fork 25
/
redirect.php
29 lines (28 loc) · 1.06 KB
/
redirect.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
<?php
namespace subconverter;
$param = $_GET['token'] ?? null;
if (empty($param)) {
$arr = array('msg' => "failed", 'data' => "empty value");
echo json_encode($arr, 320);
exit();
} else {
$token = urldecode($_GET['token']);
require __DIR__ . '/config/connect.php';
$sql = 'SELECT `jslist`,`filterlist` FROM `mdfive` WHERE `inilist` = ?';
$stmt = $db->prepare($sql);
$inilist = $token;
$stmt->execute([$inilist]);
$arr = end($stmt->fetchAll());
$jsname = $arr['jslist'];
$filtername = $arr['filterlist'];
$jsreg = "/script\/(.)*.js/i";
$replacement = "script/$jsname.js";
$pref = "../pref.toml";
$newpref = preg_replace($jsreg, $replacement, file_get_contents($pref));
file_put_contents($pref, $newpref);
$filterreg = "/filter\/(.)*.js/i";
$freplace = "filter/$filtername.js";
$secondpref = preg_replace($filterreg, $freplace, file_get_contents($pref));
file_put_contents($pref, $secondpref);
header("Location: https://api.d1.mk/getprofile?name=profiles/subconverter/$token.ini&token=subconverter");
}