<?php 
if(!defined('IN_DEMOSOSO')) {
	exit('this is wrong page,please back to homepage');
}
$res = array();
 

$act = @htmlentitdm($_GET['act']);

//echo $act;
if($act=='insert') {
	//pre($_POST);
	$postData = file_get_contents('php://input');
	$postData = json_decode($postData, true);
	//  echo gettype($postData);

	 $id = $postData['id'];
    $title = $postData['title'];
    $timeOn = $postData['timeOn'];
    $timeOff = $postData['timeOff']; 


$ss = "insert into wu_squad  (title,timeOn,timeOff) values ('$title','$timeOn','$timeOff')"; 
	iquery($ss);

    $res['data'] = $postData;
    $res['code'] = ['code'=>200];
}
else if($act=='update') {
	//$arr = @htmlentitdm($_POST);
	$postData = file_get_contents('php://input');
	$postData = json_decode($postData, true);
	// echo gettype($postData);


    $id = $postData['id'];
    $title = $postData['title'];
    $timeOn = $postData['timeOn'];
    $timeOff = $postData['timeOff']; 


	 $ss = "update wu_squad set title='$title',timeOn='$timeOn',timeOff='$timeOff'  where  id='$id'  limit 1";
       //echo $ss;exit;
      iquery($ss);  


	//pre($postData);
$res['data'] = $postData;
$res['code'] = ['code'=>200];


	
}
else{



$sql = "SELECT * from  wu_squad    order by timeOn limit 100";

 // echo $sql;
    /*begin page roll*/
     $num_rows = get_numrows($sql);
     if($num_rows>0){
		 $result = getall($sql);
		 


	  
		 
	 }
	 else {
		$res['datares'] = '没有查到相关数据。';
	 }

	 $res = $result;

	 
 }


	 if($test=='y') pre($res);

	 		// pre($_SERVER['HTTP_ACCEPT']);
			 $jsonv = json_encode($res,JSON_UNESCAPED_UNICODE);
			 //echo $jsonv;
			  echo api_jsonp_encode($jsonv); 

 

		
?>