Exemplo n.º 1
0
$error = "";
$json = "";
$empty = '"status" : "failed"';
// 订场失败
// 接口检查
if (!isset($_GET["u"]) && !isset($_GET["p"]) && !isset($_GET["n"]) && !isset($_GET["t"]) && !isset($_GET["d"])) {
    echo '{' . $empty . ', "error":"not enough arguments."}';
    exit(0);
}
$user = $_GET["u"];
$passwd = $_GET["p"];
$number = $_GET["n"];
$time = $_GET["t"];
$date = $_GET["d"];
// 登录体育馆
$cookies = stadium::Login($user, $passwd, $error);
if ("" == $cookies) {
    echo '{' . $empty . ', "error" : "' . $error . '"}';
    exit(0);
}
// 预定场馆
$status = stadium::Order($cookies, $date, $time, $number, $error);
// 移除Cookies
if (file_exists($cookies)) {
    unlink($cookies);
}
if (!$status) {
    echo '{' . $empty . ', "error" : "' . $error . '"}';
    exit(0);
}
echo '{"status" : "success"}';
Exemplo n.º 2
0
 static function Query($cookies, $type, $date, $time, &$error)
 {
     $error = "";
     $url = "http://113.106.49.136:860/bs/biz_preconcert_PreconcertPlaceTimeView.htm";
     $regex = '/<input type="checkbox" name="timeval" value="([\\d:-]+)"( disabled="true"|)\\/>/';
     if ($time != "") {
         $regex = '/<input type="checkbox" name="timeval" value="(' . $time . ')"( disabled="true"|)\\/>/';
     }
     $numberList = stadium::$numbers[$type];
     $json = '{"list":{';
     foreach ($numberList as $k => $v) {
         $data = "place_no=" . $v . "&currentDateStr=" . $date;
         $html = curl::Post($url, $cookies, $data);
         if (stadium::isSystemError($html)) {
             $error = "参数不合法。";
             return false;
         }
         if (preg_match_all($regex, $html, $matches)) {
             $json .= '"' . $v . '":{';
             for ($i = 0; $i < count($matches[1]); $i++) {
                 $json .= '"' . $matches[1][$i] . '":"' . ($matches[2][$i] == '' ? 'on' : 'off') . '",';
             }
             $json = trim($json, ",") . "},";
         }
     }
     $json = trim($json, ",") . "}}";
     return $json;
 }
Exemplo n.º 3
0
$error = "";
$json = "";
$empty = '{list:[]}';
// 查询不到
// 接口检查
if (!isset($_GET["k"]) && !isset($_GET["d"])) {
    echo '{' . $empty . ', "error":"not enough arguments."}';
    exit(0);
}
$user = "******";
$passwd = "123456";
$kind = $_GET["k"];
$date = $_GET["d"];
$time = isset($_GET["t"]) ? $_GET["t"] : "";
// 登录体育馆
$cookies = stadium::Login($user, $passwd, $error);
if ("" == $cookies) {
    echo '{' . $empty . ', "error" : "' . $error . '"}';
    exit(0);
}
// 查询订场信息
$json = stadium::Query($cookies, $kind, $date, $time, $error);
// 移除Cookies
if (file_exists($cookies)) {
    unlink($cookies);
}
if ($error != "") {
    echo '{' . $empty . ', "error" : "' . $error . '"}';
    exit(0);
}
echo $json;