forked from nielsbaloe/webrtc-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverPost.php
More file actions
34 lines (28 loc) · 772 Bytes
/
Copy pathserverPost.php
File metadata and controls
34 lines (28 loc) · 772 Bytes
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
<?
// A unique identifier (not necessary when working with websockets)
if (!isset($_GET['unique'])) {
die('no identifier');
}
$unique=$_GET['unique'];
if (strlen($unique)==0 || ctype_digit($unique)===false) {
die('not a correct identifier');
}
// A main lock to ensure save safe writing/reading
$mainlock = fopen('serverGet.php','r');
if ($mainlock===false) {
die('could not create main lock');
}
flock($mainlock, LOCK_EX);
// Add the new message to file
$filename = '_file_' /*.$room*/ . $unique;
$file = fopen($filename,'ab');
if (filesize($filename)!=0) {
fwrite($file,'_MULTIPLEVENTS_');
}
$posted = file_get_contents('php://input');
fwrite($file,$posted);
fclose($file);
// Unlock main lock
flock($mainlock,LOCK_UN);
fclose($mainlock);
?>