3
3
4
4
//For more advanced implementations see WordPress plugin and its php source code:
5
5
//https://wordpress.org/plugins/ppv-live-webcams/
6
- //https://plugins.svn.wordpress.org/ppv-live-webcams/trunk/inc/h5videochat.php
6
+ //https://plugins.svn.wordpress.org/ppv-live-webcams/trunk/inc/h5videochat.php
7
7
8
8
9
9
//demo setup saves variables in plain files in uploads folder: integration should use framework database
@@ -20,15 +20,15 @@ function varLoad($path)
20
20
21
21
return unserialize (file_get_contents ('uploads/ ' . $ path ));
22
22
}
23
-
23
+
24
24
function arrayLoad ($ path )
25
25
{
26
26
$ res = varLoad ($ path );
27
-
27
+
28
28
if (is_array ($ res )) return $ res ;
29
29
else return array ();
30
30
}
31
-
31
+
32
32
// app parameter functions
33
33
34
34
function __ ( $ text , $ domain = 'default ' )
@@ -41,11 +41,11 @@ function path2url($file)
41
41
$ url = (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] === 'on ' ? "https " : "http " ) . ":// $ _SERVER [HTTP_HOST ]$ _SERVER [REQUEST_URI ]" ;
42
42
return dirname ($ url ) . '/ ' . str_replace ( dirname (__FILE__ ) , '' , $ file );
43
43
}
44
-
44
+
45
45
function appFail ($ message = 'Request Failed ' , $ response = null )
46
46
{
47
47
//bad request: fail
48
-
48
+
49
49
if (!$ response ) $ response = array ();
50
50
51
51
$ response ['error ' ] = $ message ;
@@ -56,26 +56,26 @@ function appFail($message = 'Request Failed', $response = null)
56
56
57
57
die ();
58
58
}
59
-
60
-
59
+
60
+
61
61
function appSfx ()
62
62
{
63
63
//sound effects sources
64
-
64
+
65
65
$ base = VW_H5V_URL . 'sounds/ ' ;
66
-
67
-
66
+
67
+
68
68
return array (
69
69
'message ' => $ base . 'message.mp3 ' ,
70
70
'hello ' => $ base . 'hello.mp3 ' ,
71
- 'leave ' => $ base . 'leave.mp3 ' ,
71
+ 'leave ' => $ base . 'leave.mp3 ' ,
72
72
'call ' => $ base . 'call.mp3 ' ,
73
73
'warning ' => $ base . 'warning.mp3 ' ,
74
74
'error ' => $ base . 'error.mp3 ' ,
75
75
'buzz ' => $ base . 'buzz.mp3 ' ,
76
76
);
77
77
}
78
-
78
+
79
79
function appText ()
80
80
{
81
81
//implement translations
@@ -148,18 +148,18 @@ function appText()
148
148
149
149
function appRoomUsers ($ roomID , $ options )
150
150
{
151
-
151
+
152
152
$ sessions = arrayLoad ($ roomID . '_sessions ' );
153
-
153
+
154
154
foreach ($ sessions as $ key => $ session )
155
155
{
156
- if (!is_array ($ userMeta = unserialize ($ session ['meta ' ]))) $ userMeta = array ();
156
+ if (!is_array ($ userMeta = unserialize ($ session ['meta ' ] ?? '' ))) $ userMeta = array ();
157
157
158
158
$ item = [];
159
159
$ item ['userID ' ] = intval ($ session ['uid ' ]);
160
- $ item ['userName ' ] = $ session ['username ' ];
160
+ $ item ['userName ' ] = $ session ['username ' ] ?? '' ;
161
161
if (!$ item ['userName ' ]) $ item ['userName ' ] = '# ' . $ session ['uid ' ];
162
-
162
+
163
163
$ item ['sdate ' ] = intval ($ session ['sdate ' ]);
164
164
$ item ['meta ' ] = $ userMeta ;
165
165
$ item ['updated ' ] = intval ($ session ['edate ' ]);
@@ -168,11 +168,11 @@ function appRoomUsers($roomID, $options)
168
168
169
169
$ items [intval ($ session ['uid ' ])] = $ item ;
170
170
}
171
-
171
+
172
172
return $ items ;
173
173
}
174
174
175
-
175
+
176
176
function appTipOptions ($ options )
177
177
{
178
178
@@ -224,17 +224,17 @@ function appPublicRoom($roomID, $userID, $options, $welcome ='')
224
224
$ isPerformer = ($ userID == (10000 +$ roomID ));
225
225
226
226
$ clientID = $ roomID ;
227
-
227
+
228
228
// $privateUID = the other user ID
229
-
229
+
230
230
if ($ isPerformer ) $ privateUID = $ clientID ;
231
231
else $ privateUID = $ room ['performerID ' ];
232
232
$ room ['privateUID ' ] = $ privateUID ;
233
233
234
-
234
+
235
235
//screen
236
236
$ room ['screen ' ] = 'Way2Screen ' ;
237
-
237
+
238
238
239
239
$ room ['streamBroadcast ' ] = appStream ($ userID , $ roomID , $ options );
240
240
$ room ['streamBroadcastName ' ] = appStreamName ($ userID , $ roomID , $ options );
@@ -264,15 +264,15 @@ function appPublicRoom($roomID, $userID, $options, $welcome ='')
264
264
$ room ['welcome ' ] .= "\n" .'You are invited participant (client). ' ;
265
265
}
266
266
267
-
267
+
268
268
//if ($options['videochatNext']) if (!$isPerformer) $room['next'] = true;
269
269
270
270
if ($ welcome ) $ room ['welcome ' ] .= "\n" . $ welcome ;
271
271
272
272
//configure tipping options for clients
273
273
$ room ['tips ' ] = false ;
274
274
if ($ options ['tips ' ])
275
- if (!$ session ->broadcaster )
275
+ if (!isset ( $ session ) || ! $ session ->broadcaster )
276
276
{
277
277
$ tipOptions = appTipOptions ($ options );
278
278
if (count ($ tipOptions ))
@@ -283,16 +283,16 @@ function appPublicRoom($roomID, $userID, $options, $welcome ='')
283
283
}
284
284
}
285
285
286
- //demo goal
286
+ //demo goal
287
287
$ room ['welcome ' ] .= "\n 🎁 " . 'Current gifts goal ' .': ' . 'Demo Goal ' ;
288
288
$ room ['welcome ' ] .= "\n " . 'Chat can display goals that can be achieved with gifts/donations. ' ;
289
289
$ room ['welcomeProgressValue ' ] = 8 ;
290
290
$ room ['welcomeProgressTotal ' ] = 10 ;
291
- $ room ['welcomeProgressDetails ' ] = 'Demo Goal ' ;
292
-
293
- //offline snapshot (poster) and video
291
+ $ room ['welcomeProgressDetails ' ] = 'Demo Goal ' ;
292
+
293
+ //offline snapshot (poster) and video
294
294
$ room ['snapshot ' ] = VW_H5V_URL . 'images/no-picture.png ' ;
295
- $ room ['videoOffline ' ] = VW_H5V_URL . 'videos/hamsterad.mp4 ' ;;
295
+ $ room ['videoOffline ' ] = VW_H5V_URL . 'videos/hamsterad.mp4 ' ;;
296
296
297
297
return $ room ;
298
298
}
0 commit comments