-
Notifications
You must be signed in to change notification settings - Fork 33
/
lb_status.php
92 lines (75 loc) · 2.06 KB
/
lb_status.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
<?php
/*
POST Variables:
u=Username
s=Session, usually same as username
r=Room
ct=session time (in milliseconds)
lt=last session time received from this script in (milliseconds)
cam, mic = 0 none, 1 disabled, 2 enabled
*/
$room=$_POST[r];
$session=$_POST[s];
$username=$_POST[u];
$message=$_POST[m];
$cam=$_POST[cam];
$mic=$_POST[mic];
$currentTime=$_POST[ct];
$lastTime=$_POST[lt];
$disconnect=""; //anything else than "" will disconnect with that message
include_once("settings.php");
//code to keep track of online broadcasters and total channel time:
//all usage time ads up (broadcaster + viewers): 10 min broadcast to 2 viewers = 30 min total usage
//do not allow uploads to other folders
include_once("incsan.php");
sanV($room);
sanV($session);
if ($room&&$session)
{
if ($limitChannel)
{
$dir= "uploads";
if (!file_exists($dir)) mkdir($dir);
@chmod($dir, 0777);
$dir.="/$room";
if (!file_exists($dir)) mkdir($dir);
@chmod($dir, 0777);
$dir.="/online";
if (!file_exists($dir)) mkdir($dir);
@chmod($dir, 0777);
//reset counter after some time
$toReset=0;
$resetFile = "$dir/$session.reset";
$counterFile = "$dir/$session";
if (file_exists($resetFile))
{
$lastReset = implode(file($resetFile));
if ($lastReset+$resetTime<time()) $toReset=1;
}else $toReset=1;
//reset counter
if ($toReset)
{
$dfile = fopen($counterFile,"w");
fputs($dfile, "0");
fclose($dfile);
$dfile = fopen($resetFile ,"w");
fputs($dfile, time());
fclose($dfile);
}
//get time
if (file_exists($counterFile ))
{
$oldTime = implode(file($counterFile));
$timeUsed = $oldTime + ($currentTime-$lastTime);
}
//save time
$dfile = fopen($counterFile ,"w");
fputs($dfile, $timeUsed);
fclose($dfile);
} else $timeUsed = $currentTime;
}
else
{
$disconnect = "No valid room or session!";
}
?>timeTotal=<?php echo $maximumSessionTime?>&timeUsed=<?php echo $timeUsed?>&lastTime=<?php echo $currentTime?>&disconnect=<?php echo $disconnect?>&loadstatus=1