CatPtain commited on
Commit
b3c6d2c
·
verified ·
1 Parent(s): 75565db

Upload 3 files

Browse files
Files changed (3) hide show
  1. config.php +1 -0
  2. save.php +0 -48
  3. storage.php +44 -0
config.php CHANGED
@@ -18,6 +18,7 @@
18
  <h1>VvvebJs Configuration Status</h1>
19
 
20
  <?php
 
21
  require_once __DIR__ . '/storage.php';
22
 
23
  echo '<h3>Authentication</h3>';
 
18
  <h1>VvvebJs Configuration Status</h1>
19
 
20
  <?php
21
+ // Include the storage configuration classes
22
  require_once __DIR__ . '/storage.php';
23
 
24
  echo '<h3>Authentication</h3>';
save.php CHANGED
@@ -20,54 +20,6 @@ https://github.com/givanz/VvvebJs
20
  // Include storage classes
21
  require_once __DIR__ . '/storage.php';
22
 
23
- // Configuration for external storage
24
- class StorageConfig {
25
- public static function getEnvVar($key, $default = '') {
26
- return $_ENV[$key] ?? getenv($key) ?: $default;
27
- }
28
-
29
- // EdgeOne KV configuration
30
- public static function getKVConfig() {
31
- return [
32
- 'api_key' => self::getEnvVar('EDGEONE_KV_API_KEY'),
33
- 'secret_key' => self::getEnvVar('EDGEONE_KV_SECRET_KEY'),
34
- 'zone_id' => self::getEnvVar('EDGEONE_KV_ZONE_ID'),
35
- 'namespace' => self::getEnvVar('EDGEONE_KV_NAMESPACE', 'vvvebjs'),
36
- 'endpoint' => self::getEnvVar('EDGEONE_KV_ENDPOINT', 'https://edgeone.tencentcloudapi.com')
37
- ];
38
- }
39
-
40
- // GitHub configuration
41
- public static function getGitHubConfig() {
42
- return [
43
- 'token' => self::getEnvVar('GITHUB_TOKEN'),
44
- 'owner' => self::getEnvVar('GITHUB_OWNER'),
45
- 'repo' => self::getEnvVar('GITHUB_REPO'),
46
- 'branch' => self::getEnvVar('GITHUB_BRANCH', 'main'),
47
- 'path' => self::getEnvVar('GITHUB_PATH', 'pages/')
48
- ];
49
- }
50
-
51
- // User authentication
52
- public static function getUsers() {
53
- $users = [];
54
- $i = 1;
55
- while (true) {
56
- $username = self::getEnvVar("USER_{$i}_NAME");
57
- $password = self::getEnvVar("USER_{$i}_PASSWORD");
58
- if (!$username || !$password) break;
59
- $users[$username] = $password;
60
- $i++;
61
- }
62
- return $users;
63
- }
64
-
65
- // Storage type preference
66
- public static function getStorageType() {
67
- return self::getEnvVar('STORAGE_TYPE', 'github'); // 'github' or 'kv' or 'both'
68
- }
69
- }
70
-
71
  // Authentication check
72
  function checkAuth() {
73
  if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
 
20
  // Include storage classes
21
  require_once __DIR__ . '/storage.php';
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  // Authentication check
24
  function checkAuth() {
25
  if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
storage.php CHANGED
@@ -1,4 +1,48 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  // External storage handlers
3
  class KVStorage {
4
  private $config;
 
1
  <?php
2
+ // Configuration management class
3
+ class StorageConfig {
4
+ public static function getUsers() {
5
+ $users = [];
6
+ $i = 1;
7
+ while (true) {
8
+ $username = $_ENV["USER_{$i}_NAME"] ?? '';
9
+ $password = $_ENV["USER_{$i}_PASSWORD"] ?? '';
10
+
11
+ if (empty($username) || empty($password)) {
12
+ break;
13
+ }
14
+
15
+ $users[$username] = $password;
16
+ $i++;
17
+ }
18
+ return $users;
19
+ }
20
+
21
+ public static function getStorageType() {
22
+ return $_ENV['STORAGE_TYPE'] ?? 'github';
23
+ }
24
+
25
+ public static function getGitHubConfig() {
26
+ return [
27
+ 'token' => $_ENV['GITHUB_TOKEN'] ?? '',
28
+ 'owner' => $_ENV['GITHUB_OWNER'] ?? '',
29
+ 'repo' => $_ENV['GITHUB_REPO'] ?? '',
30
+ 'branch' => $_ENV['GITHUB_BRANCH'] ?? 'main',
31
+ 'path' => $_ENV['GITHUB_PATH'] ?? 'pages/'
32
+ ];
33
+ }
34
+
35
+ public static function getKVConfig() {
36
+ return [
37
+ 'api_key' => $_ENV['EDGEONE_KV_API_KEY'] ?? '',
38
+ 'secret_key' => $_ENV['EDGEONE_KV_SECRET_KEY'] ?? '',
39
+ 'zone_id' => $_ENV['EDGEONE_KV_ZONE_ID'] ?? '',
40
+ 'namespace' => $_ENV['EDGEONE_KV_NAMESPACE'] ?? 'vvvebjs',
41
+ 'endpoint' => $_ENV['EDGEONE_KV_ENDPOINT'] ?? 'https://edgeone.tencentcloudapi.com'
42
+ ];
43
+ }
44
+ }
45
+
46
  // External storage handlers
47
  class KVStorage {
48
  private $config;