Skip to content

Commit 32738f8

Browse files
committed
Update
1 parent c181dd7 commit 32738f8

12 files changed

+63
-63
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## VideoCall-HTML5-Videochat-PHP / 2 Way Video Calls - Standalone PHP
22

3-
- [Video Call PHP / HTML5 Videochat on VideoWhisper WebRTC](https://demo.videowhisper.com/p2p-html5-videocall/)
4-
- [Video Call PHP / HTML5 Videochat on Wowza SE](https://demo.videowhisper.com/videocall-html5-videochat-php/)
3+
- [Video Call PHP / HTML5 Videochat on P2P WebRTC](https://demo.videowhisper.com/p2p-html5-videocall/)
4+
- [Video Call PHP / HTML5 Videochat on Wowza SE relay](https://demo.videowhisper.com/videocall-html5-videochat-php/)
55

66
![PHP HTML5 Videochat / Video Call](/snapshots/h5a-2way-call.jpg)
77

@@ -81,4 +81,4 @@ For a quick setup, see [VideoWhisper Turnkey Stream Hosting Plans](https://webrt
8181
- [Video Calls & Random Chat Turnkey Site - WordPress](https://wordpress.org/plugins/webcam-2way-videochat/)
8282
- [WebRTC Signaling Server](https://github.com/videowhisper/videowhisper-webrtc/)
8383

84-
For a free consultation [Consult VideoWhisper](https://consult.videowhisper.com) related to commercial services like turnkey site platforms, compatible hosting, custom development services.
84+
[Consult VideoWhisper](https://consult.videowhisper.com) for commercial services like turnkey site platforms, compatible hosting, custom development services.

app-call.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
$roomID = intval($VideoWhisper['roomID']);
1717
$sessionKey = intval($VideoWhisper['sessionKey']);
1818

19-
$privateUID = intval($VideoWhisper['privateUID']);
20-
$roomActionID = intval($VideoWhisper['roomActionID']);
19+
$privateUID = intval($VideoWhisper['privateUID'] ?? 0);
20+
$roomActionID = intval($VideoWhisper['roomActionID'] ?? 0);
2121
}
2222

2323
$response['VideoWhisper'] = 'https://videowhisper.com';
@@ -60,9 +60,9 @@
6060

6161
//config params, const
6262
$response['config'] = [
63-
'serverType' => $options['serverType'],
64-
'vwsSocket' => $options['vwsSocket'],
65-
'vwsToken' => $options['vwsToken'],
63+
'serverType' => $options['serverType'] ?? '',
64+
'vwsSocket' => $options['vwsSocket'] ?? '',
65+
'vwsToken' => $options['vwsToken'] ?? '',
6666

6767
'wss' => $options['wsURLWebRTC'],
6868
'application' => $options['applicationWebRTC'],
@@ -377,8 +377,8 @@
377377

378378

379379
//update time
380-
$lastMessage = intval($_POST['lastMessage']);
381-
$lastMessageID = intval($_POST['lastMessageID']);
380+
$lastMessage = intval($_POST['lastMessage'] ?? 0);
381+
$lastMessageID = intval($_POST['lastMessageID'] ?? 0);
382382

383383
//retrieve only messages since user came online / updated
384384
$sdate = 0;
@@ -468,7 +468,7 @@
468468
$response['timestamp'] = $ztime; //update time
469469
///update message
470470

471-
$response['lastMessageID'] = $idMax;
471+
$response['lastMessageID'] = $idMax ?? 0;
472472

473473
$response['roomUpdate']['users'] = appRoomUsers($roomID, $options);
474474

app-functions.php

+31-31
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
//For more advanced implementations see WordPress plugin and its php source code:
55
//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
77

88

99
//demo setup saves variables in plain files in uploads folder: integration should use framework database
@@ -20,15 +20,15 @@ function varLoad($path)
2020

2121
return unserialize(file_get_contents('uploads/' . $path));
2222
}
23-
23+
2424
function arrayLoad($path)
2525
{
2626
$res = varLoad($path);
27-
27+
2828
if (is_array($res)) return $res;
2929
else return array();
3030
}
31-
31+
3232
// app parameter functions
3333

3434
function __( $text, $domain = 'default' )
@@ -41,11 +41,11 @@ function path2url($file)
4141
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
4242
return dirname($url) . '/' . str_replace( dirname(__FILE__) , '', $file);
4343
}
44-
44+
4545
function appFail($message = 'Request Failed', $response = null)
4646
{
4747
//bad request: fail
48-
48+
4949
if (!$response) $response = array();
5050

5151
$response['error'] = $message;
@@ -56,26 +56,26 @@ function appFail($message = 'Request Failed', $response = null)
5656

5757
die();
5858
}
59-
60-
59+
60+
6161
function appSfx()
6262
{
6363
//sound effects sources
64-
64+
6565
$base = VW_H5V_URL. 'sounds/';
66-
67-
66+
67+
6868
return array(
6969
'message' => $base . 'message.mp3',
7070
'hello' => $base . 'hello.mp3',
71-
'leave' => $base . 'leave.mp3',
71+
'leave' => $base . 'leave.mp3',
7272
'call' => $base . 'call.mp3',
7373
'warning' => $base . 'warning.mp3',
7474
'error' => $base . 'error.mp3',
7575
'buzz' => $base . 'buzz.mp3',
7676
);
7777
}
78-
78+
7979
function appText()
8080
{
8181
//implement translations
@@ -148,18 +148,18 @@ function appText()
148148

149149
function appRoomUsers($roomID, $options)
150150
{
151-
151+
152152
$sessions = arrayLoad($roomID . '_sessions');
153-
153+
154154
foreach ($sessions as $key => $session)
155155
{
156-
if (!is_array($userMeta = unserialize($session['meta']))) $userMeta = array();
156+
if (!is_array($userMeta = unserialize($session['meta'] ?? ''))) $userMeta = array();
157157

158158
$item = [];
159159
$item['userID'] = intval($session['uid']);
160-
$item['userName'] = $session['username'];
160+
$item['userName'] = $session['username'] ?? '';
161161
if (!$item['userName']) $item['userName'] = '#' . $session['uid'];
162-
162+
163163
$item['sdate'] = intval($session['sdate']);
164164
$item['meta'] = $userMeta;
165165
$item['updated'] = intval($session['edate']);
@@ -168,11 +168,11 @@ function appRoomUsers($roomID, $options)
168168

169169
$items[intval($session['uid'])] = $item;
170170
}
171-
171+
172172
return $items;
173173
}
174174

175-
175+
176176
function appTipOptions($options)
177177
{
178178

@@ -224,17 +224,17 @@ function appPublicRoom($roomID, $userID, $options, $welcome ='')
224224
$isPerformer = ($userID == (10000+$roomID));
225225

226226
$clientID = $roomID;
227-
227+
228228
// $privateUID = the other user ID
229-
229+
230230
if ($isPerformer) $privateUID = $clientID;
231231
else $privateUID = $room['performerID'];
232232
$room['privateUID'] = $privateUID;
233233

234-
234+
235235
//screen
236236
$room['screen'] = 'Way2Screen';
237-
237+
238238

239239
$room['streamBroadcast'] = appStream($userID, $roomID, $options);
240240
$room['streamBroadcastName'] = appStreamName($userID, $roomID, $options);
@@ -264,15 +264,15 @@ function appPublicRoom($roomID, $userID, $options, $welcome ='')
264264
$room['welcome'] .= "\n".'You are invited participant (client).';
265265
}
266266

267-
267+
268268
//if ($options['videochatNext']) if (!$isPerformer) $room['next'] = true;
269269

270270
if ($welcome) $room['welcome'] .= "\n" . $welcome;
271271

272272
//configure tipping options for clients
273273
$room['tips'] = false;
274274
if ($options['tips'])
275-
if (!$session->broadcaster)
275+
if (!isset($session) || !$session->broadcaster)
276276
{
277277
$tipOptions = appTipOptions($options);
278278
if (count($tipOptions))
@@ -283,16 +283,16 @@ function appPublicRoom($roomID, $userID, $options, $welcome ='')
283283
}
284284
}
285285

286-
//demo goal
286+
//demo goal
287287
$room['welcome'] .= "\n 🎁 " . 'Current gifts goal' .': '. 'Demo Goal';
288288
$room['welcome'] .= "\n " . 'Chat can display goals that can be achieved with gifts/donations.';
289289
$room['welcomeProgressValue'] = 8;
290290
$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
294294
$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';;
296296

297297
return $room;
298298
}

index.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//access existing room or create a new one as performer
77
//all IDs generated randomly for demonstrative purposes; on integrations should be from database
88

9-
$roomID = intval($_GET['r']);
9+
$roomID = intval($_GET['r'] ?? 0);
1010

1111
if (!$roomID)
1212
{
@@ -27,17 +27,17 @@
2727

2828

2929
//embed the app: all integrations should contain this part
30-
$dataCode .= "window.VideoWhisper = {userID: $userID, sessionID: $sessionID, sessionKey: '$sessionKey', roomID: $roomID, performer: $isPerformer, serverURL: '" . VW_H5V_CALL . "', modeVersion: ''}";
30+
$dataCode = "window.VideoWhisper = {userID: $userID, sessionID: $sessionID, sessionKey: '$sessionKey', roomID: $roomID, performer: $isPerformer, serverURL: '" . VW_H5V_CALL . "', modeVersion: ''}";
3131

32-
$bodyCode .= <<<HTMLCODE
32+
$bodyCode = <<<HTMLCODE
3333
<!--VideoWhisper.com - HTML5 Videochat web app - uid:$userID p:$isPerformer s:$sessionID-->
3434
<noscript>You need to enable JavaScript to run this app.</noscript>
3535
<div style="display:block;min-height:600px;background-color:#eee;position:relative;z-index:102!important;"><div style="display:block;width:100%; height:100%; position:absolute;z-index:102!important;" id="videowhisperVideochat"></div></div>
3636
<script>$dataCode;</script>
3737
HTMLCODE;
3838

3939
//app requires semantic ui
40-
$headCode .= '<link href="//cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css" rel="stylesheet" type="text/css">';
40+
$headCode = '<link href="//cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css" rel="stylesheet" type="text/css">';
4141

4242
//app css & js
4343
$CSSfiles = scandir(dirname( __FILE__ ) . '/static/css/');
@@ -53,7 +53,7 @@
5353

5454
//room link
5555
$roomURL = $_SERVER['REQUEST_SCHEME'] .'://'. $_SERVER['HTTP_HOST'] . explode('?', $_SERVER['REQUEST_URI'], 2)[0] . '?r=' . $roomID;
56-
if (!$_GET['r'])
56+
if (!isset($_GET['r']))
5757
{
5858
$bodyCode .= '<div class="ui segment"><h4 class="ui header">Invite URL</h4>Invite the other person (client) with this call room URL:<br>' . $roomURL ;
5959
$bodyCode .= '<br><a class="ui button" href="' . $roomURL . '" target="_answer"><i class="phone icon"></i> Answer </a> - Use a different device or browser to answer! Camera works only from 1 tab in same browser.';

static/css/2.07aa08a5.chunk.css

-1
This file was deleted.

0 commit comments

Comments
 (0)