-
Notifications
You must be signed in to change notification settings - Fork 96
/
stream_importer.php
83 lines (63 loc) · 2.45 KB
/
stream_importer.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
<?php
include('config.php');
logincheck();
$message = [];
$title = "Playlist importer";
$stream = new Stream;
$categories = Category::all();
$transcodes = Transcode::all();
if (isset($_POST['submit'])) {
if (empty($_POST['category'])) {
$message['type'] = "error";
$message['message'] = "Select one category";
} else {
$lines = preg_split('~[\r\n]+~', $_POST['import']);
foreach($lines as $key => $line){
if(empty($line) or ctype_space($line)) continue;
if (substr($line, 0, 1) === '#') {
$splitline = explode(',', $lines[$key]);
$stream = new Stream;
if(isset($splitline[1])) {
$stream->name = $splitline[1];
$stream->cat_id = $_POST['category'];
$stream->trans_id = $_POST['transcode'];
$stream->restream = 0;
if(isset($_POST['restream'])) {
$stream->restream = 1;
}
$stream->bitstreamfilter = 0;
if(isset($_POST['bitstreamfilter'])) {
$stream->bitstreamfilter = 1;
}
$stream->streamurl = $lines[$key + 1];
if($splitline[1] != null || $lines[$key + 1] != null) {
$stream->save();
} $stream->name = $splitline[1];
$stream->cat_id = $_POST['category'];
$stream->trans_id = $_POST['transcode'];
$stream->restream = 0;
if(isset($_POST['restream'])) {
$stream->restream = 1;
}
$stream->bitstreamfilter = 0;
if(isset($_POST['bitstreamfilter'])) {
$stream->bitstreamfilter = 1;
}
$stream->streamurl = $lines[$key + 1];
if($splitline[1] != null || $lines[$key + 1] != null) {
$stream->save();
}
}
$message['type'] = "success";
$message['message'] = "Streams created";
}
}
}
}
echo $template->view()->make('stream_importer')
->with('stream', $stream)
->with('categories', $categories)
->with('transcodes', $transcodes)
->with('message', $message)
->with('title', $title)
->render();