-
Notifications
You must be signed in to change notification settings - Fork 9
/
app-functions.php
123 lines (80 loc) · 2.66 KB
/
app-functions.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
<?php
//app functions needed by app calls, depend on integration
//For more advanced implementations see WordPress plugin and its php source code:
//https://wordpress.org/plugins/ppv-live-webcams/
//https://plugins.svn.wordpress.org/ppv-live-webcams/trunk/inc/h5videochat.php
//demo setup saves variables in plain files in uploads folder: integration should use framework database
function varSave($path, $var)
{
if (!file_exists('uploads')) mkdir('uploads');
file_put_contents('uploads/' . $path, serialize($var));
}
function varLoad($path)
{
if (!file_exists('uploads/' . $path)) return false;
return unserialize(file_get_contents('uploads/' . $path));
}
function arrayLoad($path)
{
$res = varLoad($path);
if (is_array($res)) return $res;
else return array();
}
// app parameter functions
function __( $text, $domain = 'default' )
{
return $text;
}
function path2url($file)
{
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
return dirname($url) . '/' . str_replace( dirname(__FILE__) , '', $file);
}
function appFail($message = 'Request Failed', $response = null)
{
//bad request: fail
if (!$response) $response = array();
$response['error'] = $message;
$response['VideoWhisper'] = 'https://videowhisper.com';
echo json_encode($response);
die();
}
function appSfx()
{
//sound effects sources
$base = VW_H5V_URL. 'sounds/';
return array(
//
);
}
function appText()
{
//implement translations
//returns texts
return array(
'Send' => __('Send', 'ppv-live-webcams'),
);
}
function appPublicRoom($roomID, $userID, $options, $welcome ='')
{
//public room parameters, specific for this user
//depends on integration
$room = array();
$room['ID'] = $roomID;
$room['name'] = 'Room' . $roomID;
$room['performer'] = 'Performer' . (10000+$roomID);
$room['performerID'] = (10000+$roomID);
$isPerformer = ($userID == (10000+$roomID));
//screen
$room['screen'] = 'RecorderScreen';
//$room['actionPrivate'] = !$isPerformer;
$room['privateUID'] = 0;
$room['actionID'] = 0;
//custom buttons
$actionButtons = array();
$roomURL = $_SERVER['REQUEST_SCHEME'] .'://'. $_SERVER['HTTP_HOST'] . dirname(explode('?', $_SERVER['REQUEST_URI'], 2)[0]) . '/?r=' . $roomID;
//_ will be added to target
$actionButtons['exitDashboard'] = array('name'=> 'exitDashboard', 'icon'=>'close', 'color'=> 'red', 'floated'=>'right', 'target' => 'top', 'url'=> $roomURL, 'text'=>'Exit', 'tooltip'=> __('Exit', 'ppv-live-webcams'));
$room['actionButtons'] = $actionButtons;
return $room;
}