-
Notifications
You must be signed in to change notification settings - Fork 96
/
install.php
188 lines (146 loc) · 6.14 KB
/
install.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
include('config.php');
// TODO: version control
// TODO: update tables
$db = $databasemanagar;
if( isset($_GET['install'])) {
$arraynamesexist = [];
$tables = $databasemanagar::select('SHOW TABLES');
foreach ($tables as $key => $val) {
$tableName = (array)$val;
$tableName = array_shift($tableName);
array_push($arraynamesexist, $tableName);
}
if ($_GET['install'] == 'fresh') {
$db::schema()->dropIfExists('admins');
$db::schema()->dropIfExists('categories');
$db::schema()->dropIfExists('category_user');
$db::schema()->dropIfExists('settings');
$db::schema()->dropIfExists('streams') ;
$db::schema()->dropIfExists('users');
$arraynamesexist = [];
}
if (!in_array('admins', $arraynamesexist)) {
$db->schema()->create('admins', function ($table) {
$table->increments('id');
$table->string('username')->unique();
$table->string('password');
$table->timestamps();
});
$admin = new Admin;
$admin->username = 'admin';
$admin->password = md5('admin');
$admin->save();
echo "created admin table <br>" . PHP_EOL;
echo "admin created: username: admin and password: admin <br>" . PHP_EOL;
}
if (!in_array('categories', $arraynamesexist)) {
$db->schema()->create('categories', function ($table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
echo "created categories table <br>" . PHP_EOL;
}
if (!in_array('category_user', $arraynamesexist)) {
$db->schema()->create('category_user', function ($table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('category_id');
$table->timestamps();
});
echo "created category_user table <br>" . PHP_EOL;
}
if (!in_array('settings', $arraynamesexist)) {
$db->schema()->create('settings', function ($table) {
$table->increments('id');
$table->string('ffmpeg_path')->default('/usr/local/bin/ffmpeg');
$table->string('ffprobe_path')->default('/usr/local/bin/ffprobe');
$table->string('webport')->default('8000');
$table->string('webip');
$table->string('hlsfolder')->default('hl');
$table->tinyInteger('less_secure');
$table->timestamps();
});
echo "created settings table <br>" . PHP_EOL;
}
if (!in_array('streams', $arraynamesexist)) {
$db->schema()->create('streams', function ($table) {
$table->increments('id');
$table->string('name');
$table->string('streamurl');
$table->string('streamurl2');
$table->string('streamurl3');
$table->tinyInteger('running');
$table->tinyInteger('status');
$table->integer('cat_id');
$table->integer('trans_id');
$table->integer('pid');
$table->tinyInteger('restream');
$table->string('video_codec_name');
$table->string('audio_codec_name');
$table->tinyInteger('bitstreamfilter');
$table->tinyInteger('checker');
$table->timestamps();
});
echo "created streams table <br>" . PHP_EOL;
}
if (!in_array('users', $arraynamesexist)) {
$db->schema()->create('users', function ($table) {
$table->increments('id');
$table->string('username')->unique();
$table->string('password');
$table->tinyInteger('active');
$table->string('lastconnected_ip');
$table->date('exp_date');
$table->integer('last_stream');
$table->timestamps();
});
echo "created users table <br>" . PHP_EOL;
}
if (!in_array('transcodes', $arraynamesexist)) {
$db->schema()->create('transcodes', function ($table) {
$table->increments('id');
$table->string('name')->unique();
$table->BigInteger('probesize');
$table->BigInteger('analyzeduration');
$table->string('video_codec');
$table->string('audio_codec');
$table->string('profile');
$table->string('preset_values');
$table->string('scale');
$table->string('aspect_ratio');
$table->BigInteger('video_bitrate');
$table->integer('audio_channel');
$table->BigInteger('audio_bitrate');
$table->integer('fps');
$table->integer('minrate');
$table->integer('maxrate');
$table->integer('bufsize');
$table->integer('audio_sampling_rate');
$table->integer('crf');
$table->integer('threads');
$table->tinyInteger('deinterlance');
$table->timestamps();
});
echo "created transcodes table <br>" . PHP_EOL;
}
}
if( isset($_GET['update'])) {
$db->schema()->table('streams', function ($table) use ($db) {
$db->schema()->hasColumn('streams', 'bitstreamfilter') ? '' : $table->tinyInteger('bitstreamfilter');
$db->schema()->hasColumn('streams', 'trans_id') ? '' : $table->Integer('trans_id');
$db->schema()->hasColumn('streams', 'streamurl2') ? '' : $table->string('streamurl2');
$db->schema()->hasColumn('streams', 'streamurl3') ? '' : $table->string('streamurl3');
$db->schema()->hasColumn('streams', 'checker') ? '' : $table->tinyInteger('checker');
});
$db->schema()->table('users', function ($table) use ($db) {
$db->schema()->hasColumn('users', 'lastconnected_ip') ? '' : $table->string('lastconnected_ip');
$db->schema()->hasColumn('users', 'exp_date') ? '' : $table->date('exp_date');
$db->schema()->hasColumn('users', 'last_stream') ? '' : $table->integer('last_stream');
});
$db->schema()->table('settings', function ($table) use ($db) {
$db->schema()->hasColumn('settings', 'less_secure') ? '' : $table->tinyInteger('less_secure');
});
echo "update <br>" . PHP_EOL;
}