switch ($site->data_source) {
        case "API":
            $data['notice']['invalid_request'] = "API source is not allowed";
            break;
        case "DB":
            $result = $site->fetch_live_data();
            //debug_show($result);
            if ($result === FALSE) {
                $data['notice']['invalid_request'] = "DB Error";
            }
            break;
    }
}
//echo $site->request_value."xxx";
// check for errors
if ($data['notice']['invalid_request'] == "") {
    $data['result'] = $site->get_active_sport($result, $site->request_value);
} else {
    echo $data['notice']['invalid_request'];
    exit;
}
//debug_show($data['result']);
//exit;
// test-case
//unset($data['result']['volleyball']);
if ($data['result'] == "NOTFOUND") {
    echo "NOTFOUND";
} else {
    debug_show($data['result']);
}
//print_r(json_encode($data['result'], true));
Example #2
0
function debug_array()
{
    $str = '{"strokes":[{"points":[{"x":60,"y":66},{"x":61,"y":67},
{"x":63,"y":70},{"x":66,"y":77},{"x":69,"y":84},{"x":71,"y":91},
{"x":71,"y":91}]},{"points":[{"x":36,"y":130},{"x":37,"y":130},
{"x":38,"y":130},{"x":38,"y":131},{"x":40,"y":131},{"x":47,"y":132},
{"x":53,"y":132},{"x":57,"y":130},{"x":67,"y":127},{"x":82,"y":121},
{"x":87,"y":119},{"x":91,"y":116},{"x":92,"y":115},{"x":93,"y":115},
{"x":92,"y":115},{"x":91,"y":116},{"x":89,"y":119},{"x":86,"y":123},
{"x":85,"y":126},{"x":83,"y":131},{"x":80,"y":135},{"x":78,"y":143},
{"x":75,"y":152},{"x":72,"y":162},{"x":68,"y":175},{"x":65,"y":188},
{"x":64,"y":200},{"x":64,"y":212},{"x":64,"y":222},{"x":64,"y":231},
{"x":64,"y":239},{"x":65,"y":242},{"x":66,"y":244},{"x":67,"y":246},
{"x":69,"y":248},{"x":71,"y":248},{"x":72,"y":248},{"x":75,"y":248},
{"x":79,"y":246},{"x":88,"y":241},{"x":98,"y":235},{"x":104,"y":231},
{"x":104,"y":230},{"x":104,"y":230}]},{"points":[{"x":132,"y":56},
{"x":132,"y":57},{"x":133,"y":60},{"x":137,"y":68},{"x":145,"y":78},
{"x":149,"y":84},{"x":150,"y":85},{"x":150,"y":85}]},{"points":
[{"x":243,"y":59},{"x":242,"y":59},{"x":227,"y":72},{"x":214,"y":82},
{"x":205,"y":88},{"x":205,"y":88}]},{"points":[{"x":183,"y":46},
{"x":183,"y":47},{"x":174,"y":75},{"x":154,"y":116},{"x":143,"y":132},
{"x":141,"y":133},{"x":140,"y":133},{"x":139,"y":133},{"x":138,"y":133},
{"x":137,"y":133},{"x":136,"y":134},{"x":135,"y":134},{"x":133,"y":134},
{"x":132,"y":134},{"x":129,"y":134},{"x":127,"y":134},{"x":125,"y":134},
{"x":124,"y":134},{"x":123,"y":134},{"x":120,"y":134},{"x":119,"y":134},
{"x":119,"y":134}]},{"points":[{"x":164,"y":99},{"x":165,"y":99},
{"x":166,"y":100},{"x":170,"y":104},{"x":172,"y":107},{"x":182,"y":116},
{"x":188,"y":122},{"x":196,"y":128},{"x":203,"y":132},{"x":211,"y":135},
{"x":212,"y":135},{"x":213,"y":135},{"x":214,"y":135},{"x":215,"y":135},
{"x":215,"y":135}]},{"points":[{"x":131,"y":174},{"x":132,"y":175},
{"x":139,"y":183},{"x":153,"y":196},{"x":161,"y":203},{"x":164,"y":206},
{"x":165,"y":206},{"x":165,"y":206}]},{"points":[{"x":249,"y":172},
{"x":248,"y":172},{"x":243,"y":178},{"x":234,"y":186},{"x":227,"y":192},
{"x":219,"y":196},{"x":217,"y":197},{"x":217,"y":197}]},{"points":
[{"x":194,"y":164},{"x":193,"y":164},{"x":186,"y":180},{"x":172,"y":213},
{"x":163,"y":228},{"x":130,"y":247},{"x":130,"y":247}]},{"points":
[{"x":177,"y":211},{"x":177,"y":212},{"x":184,"y":225},{"x":196,"y":246},
{"x":202,"y":253},{"x":205,"y":257},{"x":209,"y":259},{"x":209,"y":260},
{"x":209,"y":260}]}],"width":213,"height":214,"left":36,"top":46,"type":1}';
    $obj = json_decode($str);
    debug_show($obj);
    $test = new Recognizer();
    $nodePairs = array();
    $test->tomoe_recognizer_get_candidates($obj, $obj);
    //echo $res->distance."<br>";
    //echo $res->point->x.":".$res->point->y;
    //echo var_dump($nodePairs);
    //debug_show($new_points);
}