<?php

header("Content-type: text/html; charset=utf-8");
//Init
if (isset($_GET['role']) && isset($_GET['hash']) && isset($_GET['sid']) && isset($_GET['password']) && isset($_GET['ecard_id']) && isset($_GET['start_date']) && isset($_GET['end_date']) && $_GET['sid'] != '' && $_GET['password'] != '' && $_GET['ecard_id'] != '' && $_GET['start_date'] != '' && $_GET['end_date'] != '') {
    $role = $_GET['role'];
    $hash = $_GET['hash'];
    $sid = $_GET['sid'];
    $password = $_GET['password'];
    $ecardID = $_GET['ecard_id'];
    $startDate = $_GET['start_date'];
    $endDate = $_GET['end_date'];
} else {
    exit('{"code":65535,"msg":"缺失参数"}');
}
//Verify Hash
include 'lib/VerifyHash.class.php';
$verify = new VerifyHash($role, $hash);
if (!$verify->checkRole()) {
    exit('{"code":-1,"msg":"接口调用身份验证失败"}');
}
//Get Data
include 'lib/EcardBilling.class.php';
$api = new EcardBilling($sid, $password, $ecardID, $startDate, $endDate);
echo $api->getData();
session_start();
include 'config.php';
include 'lib/EcardBilling.class.php';
if (isset($_POST['sid']) && isset($_POST['password']) && isset($_POST['ecard_id']) && isset($_POST['start_date']) && isset($_POST['end_date'])) {
    $sid = $_POST['sid'];
    $password = $_POST['password'];
    $ecardID = $_POST['ecard_id'];
    $startTemp = strtotime($_POST['start_date']);
    $startDate = date('Ymd', $startTemp);
    $endTemp = strtotime($_POST['end_date']);
    $endDate = date('Ymd', $endTemp);
} else {
    header('Location: ecard.php');
    exit;
}
$api = new EcardBilling($sid, $password, $ecardID, $startDate, $endDate);
$jsonData = $api->getData();
$jsonArray = json_decode($jsonData, 'true');
?>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="<?php 
echo $description;
?>
">
	<title>查饭卡 - <?php