diff --git a/key.php b/key.php index e60ea22..9e97325 100644 --- a/key.php +++ b/key.php @@ -2,264 +2,545 @@ $content = ""; session_start(); if ((isset($_SESSION['admin'])) && ($_SESSION['admin'] == true)) { - if (isset($_POST["message"])) { - if ($_POST["action"] == "save") { - $handle = fopen(__DIR__ . "/apikey.php", "w") or die("Writing file failed."); - if ($handle) { - fwrite($handle, "\n" . $_POST["message"]); - fclose($handle); - exit; - } - } elseif ($_POST["action"] == "check") { - $lines = explode("\n", $_POST["message"]); - $i = 0; - $validkey = ""; - $invalidkey = ""; - while ($i < count($lines)) { - $line = $lines[$i]; - $headers = [ - 'Accept: application/json', - 'Content-Type: application/json', - 'Authorization: Bearer ' . $line - ]; - $ch = curl_init(); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); - curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/models/gpt-3.5-turbo'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - $response = curl_exec($ch); - curl_close($ch); - $complete = json_decode($response); - if (isset($complete->error)) { - $invalidkey .= $line . "\n"; - } else { - $validkey .= $line . "\n"; - } - $i++; - } - echo $validkey; - exit; + if (isset($_POST["message"])) { + if ($_POST["action"] == "save") { + $handle = fopen(__DIR__ . "/apikey.php", "w") or die("Writing file failed."); + if ($handle) { + fwrite($handle, "\n" . $_POST["message"]); + fclose($handle); + exit; + } + } elseif ($_POST["action"] == "check") { + $lines = explode("\n", $_POST["message"]); + $i = 0; + $validkey = ""; + $invalidkey = ""; + while ($i < count($lines)) { + $line = $lines[$i]; + $headers = [ + 'Accept: application/json', + 'Content-Type: application/json', + 'Authorization: Bearer ' . $line + ]; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); + curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/models/gpt-3.5-turbo'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $response = curl_exec($ch); + curl_close($ch); + $complete = json_decode($response); + if (isset($complete->error)) { + $invalidkey .= $line . "\n"; + } else { + $validkey .= $line . "\n"; } + $i++; + } + echo $validkey; + exit; } - $line = 0; - $handle = @fopen(__DIR__ . "/apikey.php", "r"); - if ($handle) { - while (($buffer = fgets($handle)) !== false) { - $line++; - if ($line > 1) { - $content .= $buffer; - } - } - fclose($handle); + } + $line = 0; + $handle = @fopen(__DIR__ . "/apikey.php", "r"); + if ($handle) { + while (($buffer = fgets($handle)) !== false) { + $line++; + if ($line > 1) { + $content .= $buffer; + } } + fclose($handle); + } ?> + + + + + + + API_KEY配置信息 + + + + - - - - - - - API_KEY配置信息 - - - - - - -
-

API_KEY配置信息

- - -
- + +
+

API_KEY配置信息

+ + + + + + +
+ + + + + + + + + + + + + +
API KEY总额度已使用剩余额度截止日期最高模型是否绑卡
+ - + + + + - - - 登录页面 - + p.error { + color: red; + margin-top: 10px; + } + - - - -
-

API_KEY管理后台

-

-

-

-
+ + + +
+

API_KEY管理后台

+

+

+

+
- \ No newline at end of file +