Esempio n. 1
0
        $app->response()->header('Content-Type', 'application/json');
        echo json_encode($layersAvailable);
    });
    // Créer les points de terminaison API
    foreach ($xml_reqs as $req) {
        $endPoint = sprintf('/layers/%s', $req['name']);
        $app->get($endPoint, function () use($app, $req) {
            $httpReq = $app->request;
            $env = $app->environment();
            $dbh = $env['db_conn'];
            $lon = floatval($app->request->params("x"));
            $lat = floatval($app->request->params("y"));
            if (validWKT($lon) == false || validWKT($lat) == false) {
                throw new Exception("Format des points incorrect", 1);
            }
            $query = $dbh->query(bindParams((string) $req->sql, $lat, $lon), PDO::FETCH_OBJ);
            $oResult = $query->fetch(PDO::FETCH_OBJ);
            if ($oResult == FALSE) {
                throw new Exception(sprintf("Aucun résultat pour le point [x=%s y=%s]", $lon, $lat), 1);
            }
            $app->response()->header('Content-Type', 'application/json');
            echo json_encode($oResult);
        });
    }
    /** @todo : tout layers d'un coup ? */
    $app->run();
} catch (Exception $ex) {
    echo json_encode(array('result' => false, 'message' => $ex->getMessage()));
}
/**
 * 
Esempio n. 2
0
 public static function updateOrInsertVerifyCode($phone, $code)
 {
     $sql = "SELECT count(1) from VerifyCode where phone=?";
     bindParams($sql, array($phone));
     $count = db_fetch_value($sql);
     $date = date('Y-m-d H:i:s', time());
     if ($count > 0) {
         $sql = "UPDATE VerifyCode set status=0, time=?, code=? where phone=?";
         bindParams($sql, array($date, $code, $phone));
         $r = db_execute($sql);
         return $r;
     }
     $sql = "INSERT INTO VerifyCode(phone, code, status, time) VALUES(?, ?, 0, ?)";
     bindParams($sql, array($phone, $code, $date));
     $r = db_execute($sql);
     return $r;
 }