-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
139 lines (115 loc) · 3.89 KB
/
setup.php
File metadata and controls
139 lines (115 loc) · 3.89 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$config = [
'database' => 'kochbuch',
'username' => 'root',
'password' => '',
'base_url' => 'http://localhost/Kochbuch/',
'gemini_token' => '',
'bring_email' => '',
'bring_password' => '',
];
if (file_exists('config.ini')) {
$config = array_merge($config, parse_ini_file('config.ini'));
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$config['database'] = $_POST['database'];
$config['username'] = $_POST['username'];
$config['password'] = $_POST['password'];
$config['base_url'] = $_POST['base_url'];
$config['gemini_token'] = $_POST['gemini_token'];
$config['bring_email'] = $_POST['bring_email'];
$config['bring_password'] = $_POST['bring_password'];
$configString = '';
foreach ($config as $key => $value) {
$configString .= "$key = \"$value\"\n";
}
file_put_contents('config.ini', $configString);
header('Location: ' . str_replace('localhost', $_SERVER['HTTP_HOST'], $config['base_url']));
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Setup</title>
<link rel="stylesheet" href="style.css">
<style>
body {
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 1.6;
color: var(--color);
margin: 0 auto;
max-width: 800px;
padding: 20px;
overflow: auto;
}
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
}
h1 {
font-size: 36px;
border-bottom: 1px solid var(--nonSelected);
text-align: left;
}
form {
display: grid;
gap: 10px;
}
label {
display: grid;
}
input {
display: grid;
padding: 10px;
background-color: var(--secondaryBackground);
color: var(--color);
border: none;
border-radius: 5px;
outline: none;
}
button {
display: grid;
padding: 10px;
background-color: var(--secondaryBackground);
color: var(--color);
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Setup</h1>
<form action="setup.php" method="post">
<h2>Database</h2>
<label for="database">Database Name</label>
<input type="text" name="database" id="database" required value="<?php echo $config['database']; ?>">
<label for="username">Database Username</label>
<input type="text" name="username" id="username" required value="<?php echo $config['username']; ?>">
<label for="password">Database Password</label>
<input type="password" name="password" id="password" value="<?php echo $config['password']; ?>">
<h2>Base URL</h2>
<label for="base_url">Base URL</label>
<input type="text" name="base_url" id="base_url" required value="<?php echo $config['base_url']; ?>">
<h2>Gemini</h2>
<label for="gemini_token">Gemini Token</label>
<input type="text" name="gemini_token" id="gemini_token" value="<?php echo $config['gemini_token']; ?>">
<h2>Bring!</h2>
<label for="bring_email">Email</label>
<input type="text" name="bring_email" id="bring_email" value="<?php echo $config['bring_email']; ?>">
<label for="bring_password">Password</label>
<input type="password" name="bring_password" id="bring_password" value="<?php echo $config['bring_password']; ?>">
<h2>Save</h2>
<button type="submit">Save</button>
</form>
</body>
</html>