basic functions

master
hhCandy 5 years ago
parent b74e5236c1
commit 8eaf71b3ca
  1. 24
      aj_action.php
  2. 13
      aj_ishost.php
  3. 13
      aj_join.php
  4. 24
      aj_new.php
  5. 15
      aj_sethost.php
  6. 118
      index.php
  7. 9
      play.php

@ -0,0 +1,24 @@
<?php
include '../../functions.php';
$code=$_REQUEST['code'];
$name=$_REQUEST['name'];
$artist=$_REQUEST['artist'];
$url=$_REQUEST['url'];
$cover=$_REQUEST['cover'];
$lrc=$_REQUEST['lrc'];
$theme=$_REQUEST['theme'];
$planstatus=$_REQUEST['planstatus'];
$plantime=$_REQUEST['plantime'];
$planseek=$_REQUEST['planseek'];
$index=substr(md5(time()),6);
$timestamp=time();
db__pushData(db__connect(),"tp_action",array("index_"=>$index,"timestamp"=>$timestamp,"code"=>$code,"name"=>$name,"artist"=>$artist,"url"=>$url,"cover"=>$cover,"lrc"=>$lrc,"theme"=>$theme,"planstatus"=>$planstatus,"plantime"=>$plantime,"planseek"=>$planseek));
echo json_encode(array("code"=>1));
die();

@ -0,0 +1,13 @@
<?php
include '../../functions.php';
$fp=$_REQUEST['fp'];
$code=$_REQUEST['code'];
$conn=db__connect();
$res=db__getData($conn,"tp_host","code",$code);
if($res[0]['fp']==$fp) echo json_encode(array("code"=>1));
else echo json_encode(array("code"=>0));

@ -0,0 +1,13 @@
<?php
include '../../functions.php';
$fp=$_REQUEST['fp'];
$code=$_REQUEST['code'];
if(strlen($code)!=4) die();
$conn=db__connect();
db__pushData($conn,"tp_fp",array("fp"=>$fp,"timestamp"=>time(),"code"=>$code),array("fp"=>$fp));
echo json_encode(array("code"=>$code));

@ -0,0 +1,24 @@
<?php
include '../../functions.php';
$fp=$_REQUEST['fp'];
$conn=db__connect();
$res=db__getData($conn,"tp_fp","fp",$fp);
$count=count($res);
if(isset($res[$count-1]['code'])&&$res[$count-1]['code']!=null&&$res[$count-1]['timestamp']>time()-3600*12)
{
echo json_encode(array("code"=>$res[$count-1]['code']));
}
else
{
db__pushData($conn,"tp_fp",array("fp"=>$fp,"timestamp"=>time(),"code"=>substr(strval(rand(10000,19999)),1,4)));
$res=db__getData($conn,"tp_fp","fp",$fp);
$count=count($res);
echo json_encode(array("code"=>$res[$count-1]['code']));
}
die();

@ -0,0 +1,15 @@
<?php
include '../../functions.php';
$fp=$_REQUEST['fp'];
$code=$_REQUEST['code'];
if(strlen($code)==4)
{
db__pushData(db__connect(),"tp_host",array("code"=>$code,"fp"=>$fp),array("code"=>$code));
echo json_encode(array("code"=>1));
}
else
echo json_encode(array("code"=>-1));
die();

@ -0,0 +1,118 @@
<?php
include '../../functions.php';
yimian__header();
yimian__headerEnd();
?>
<?php aplayer__element()?>
<?php aplayer__setup()?>
<?php $rand=rand(0,300);aplayer__netease(808097971,$rand,$rand+10);?>
<h2 id="code"></h2>
<input type="text" id="room" />
<button id="join">Join a Room</button>
<h3 id="ishost"></h3>
<button id="host">Set Room Host</button>
<script>
var code='';
var planSeek;
var tp_host='';
function ishost()
{
$.ajax({
type: "GET",
url: 'https://cn.yimian.xyz/etc/TPlayer/aj_ishost.php',
data: { "fp":fp,
"code":code
},
traditional: true,
dataType: 'json',
success: function (msg) {
if(msg.code==1) {tp_host='host';$("#ishost").html('You are the room Host!');}
else {tp_host='';$("#ishost").html('Not Host');}
}
});
}
ap.on('play', function () {
ishost();
var i=$.inArray(ap.audio.currentSrc,urlList);
var planTime=Math.round(Number(new Date())/1000)+2;
planSeek=ap.audio.currentTime;
if(tp_host=='host')
$.ajax({
type: "GET",
url: 'https://cn.yimian.xyz/etc/TPlayer/aj_action.php',
data: { "code":code,
"name":nameList[i],
"artist":artistList[i],
"url":urlList[i],
"cover":coverList[i],
"lrc":lrcList[i],
"theme":themeList[i],
"planstatus":"play",
"planseek":planSeek,
"plantime":planTime
},
traditional: true,
dataType: 'json',
success: function (msg) {
var timeLeft=planTime*1000-Number(new Date());
setTimeout("ap.seek(planSeek)",timeLeft);
}
});
});
</script>
<script>
function rc(){
$.ajax({
type: "GET",
url: 'https://cn.yimian.xyz/etc/TPlayer/aj_new.php',
data: { "fp": fp},
traditional: true,
dataType: 'json',
success: function (msg) {
$("#code").html('Your Room Code: '+msg.code);
code=msg.code;
ishost();
}
});}
rc();
</script>
<script>
$("#join").click(function(){
$.ajax({
type: "GET",
url: 'https://cn.yimian.xyz/etc/TPlayer/aj_join.php',
data: { "fp": fp,"code":$("#room").val()},
traditional: true,
dataType: 'json',
success: function (msg) {
$("#code").html('Your Room Code: '+msg.code);
code=msg.code;
ishost();
}
});
})
$("#host").click(function(){
$.ajax({
type: "GET",
url: 'https://cn.yimian.xyz/etc/TPlayer/aj_sethost.php',
data: { "fp": fp,"code":code},
traditional: true,
dataType: 'json',
success: function (msg) {
ishost();
}
});
})
</script>
<?php yimian__footer()?>

@ -1,4 +1,11 @@
<?php
include '../../functions.php';
yimian__header();
yimian__headerEnd();
?>
<?php aplayer__element()?>
<?php aplayer__setup()?>
<?php $rand=rand(0,300);aplayer__netease(808097971,$rand,$rand+10);?>
<?php yimian__footer();?>

Loading…
Cancel
Save