-
Notifications
You must be signed in to change notification settings - Fork 5
/
manage_stream.php
75 lines (62 loc) · 2.05 KB
/
manage_stream.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
<?php
include('config.php');
logincheck();
$message = [];
$title = "Create stream";
$stream = new Stream;
$categories = Category::all();
$transcodes = Transcode::all();
if (isset($_GET['id'])) {
$title = "Edit stream";
$stream = Stream::find($_GET['id']);
}
if (isset($_POST['submit'])) {
$stream->name = $_POST['name'];
$stream->streamurl = $_POST['streamurl'];
$stream->cat_id = $_POST['category'];
$stream->trans_id = $_POST['transcode'];
$stream->streamurl2 = $_POST['streamurl2'];
$stream->streamurl3 = $_POST['streamurl3'];
$stream->restream = 0;
if (isset($_POST['restream'])) {
$stream->restream = 1;
}
$stream->bitstreamfilter = 0;
if (isset($_POST['bitstreamfilter'])) {
$stream->bitstreamfilter = 1;
}
if (empty($_POST['name'])) {
$message['type'] = "error";
$message['message'] = "Name field is empty";
} else if (empty($_POST['streamurl'])) {
$message['type'] = "error";
$message['message'] = "streamurl is empty";
} else if (empty($_POST['category'])) {
$message['type'] = "error";
$message['message'] = "Select one category";
} else {
if (isset($_GET['id'])) {
$message['type'] = "success";
$message['message'] = "Stream saved";
$stream->save();
} else {
$exists = Stream::where('name', '=', $_POST['name'])->get();
if (count($exists) > 0) {
$message['type'] = "error";
$message['message'] = "streamname already in use";
} else {
$message['type'] = "success";
$message['message'] = "Stream created";
$stream->save();
redirect("manage_stream.php?id=" . $stream->id, 1000);
}
}
}
}
echo $template->view()->make('manage_stream')
->with('stream', $stream)
->with('categories', $categories)
->with('transcodes', $transcodes)
->with('message', $message)
->with('title', $title)
->render();