-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.php
executable file
·67 lines (66 loc) · 1.78 KB
/
send.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
<?php
if ($_GET["roomid"]=="" || !file_exists("config/".$_GET["roomid"].".php")){
echo '{"status":"fail","message":"房间号不存在"}';
// http_response_code(404);
die();
}
include "config/".$_GET["roomid"].".php";
date_default_timezone_set('Asia/Shanghai');
$tm=time();
{
$flag=0;
for($i=0;$i<count($bgn);$i++){
if($tm>=$bgn[$i] && $tm<=$end[$i]){
$flag=1;
break;
}
}
if($flag==0){
echo '{"status":"fail","message":"不在规定时间内"}';
http_response_code(403);
die();
}
}
// 处理基本的链接限额
{
// http_response_code(404);
$fdata=fopen("data/".$_GET["roomid"]."/time.txt","r");
fscanf($fdata,"%d %d",$lst,$cishu);
fclose($fdata);
$cishu=intval($cishu);
$lst=intval($lst);
$cishu=intval($cishu);
// echo sprintf("%d %d %d",$tm,$lst,$cishu);
$fdata=fopen("data/".$_GET["roomid"]."/time.txt","w");
if($tm-$lst<=0){
if($cishu>=$fqnc_limit){
fprintf($fdata,"%d %d",$tm,$cishu);
fclose($fdata);
// echo '{"status":"fail","message":"弹幕池已满,请重新发送"}';
// http_response_code(404);
// die();
}
$cishu++;
}else{
$cishu=1;
$lst=$tm;
}
fprintf($fdata,"%d %d",$tm,$cishu);
}
$arr=array();
$arr["userid"]=$_POST["userid"];
$arr["color"]=$_POST["color"];
$arr["text"]=$_POST["text"];
$arr["type"]=$_POST["type"];
$arr["status"]="OK";
// $arr["process"]="ignore";
$arr["time"]=$tm;
$json=json_encode($arr);
echo $json;
$file=fopen("data/".$_GET["roomid"]."/getdata.txt","a");
$file2=fopen("data/".$_GET["roomid"]."/history.txt","a");
// fprintf($file,"%s\n",$json);
$json=json_encode($arr);
fwrite($file,$json."\r\n");
fwrite($file2,$json."\r\n");
?>