add sps service
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
include_once "../../global.inc.php";
|
||||
include_once PATH_DATABASE . "/SQLManager.php";
|
||||
include_once PATH_DATABASE . "/SqlManager.php";
|
||||
require_once PATH_3PARTY . "/Slim/Slim.php";
|
||||
\Slim\Slim::registerAutoloader();
|
||||
|
||||
@@ -10,22 +10,24 @@ abstract class Api extends \Slim\Slim {
|
||||
protected $sqlManager;
|
||||
|
||||
public function __construct() {
|
||||
if (!$this->sqlManager) {
|
||||
echo "bla";
|
||||
$this->sqlManager = new SQLManager();
|
||||
}
|
||||
$this->connect();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
$this->close();
|
||||
$this->sqlManager = null;
|
||||
//parent::__destruct();
|
||||
}
|
||||
|
||||
public function connect() {
|
||||
private function connect() {
|
||||
$this->sqlManager->connect();
|
||||
}
|
||||
|
||||
private function close() {
|
||||
$this->sqlManager->close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
include_once "../../global.inc.php";
|
||||
|
||||
include_once "../../global.inc.php";
|
||||
include_once PATH_DATABASE . "/SpsSqlManager.php";
|
||||
require_once PATH_API . "/Api.php";
|
||||
|
||||
/*
|
||||
@@ -16,12 +17,18 @@ require_once PATH_API."/Api.php";
|
||||
class SpsApi extends Api {
|
||||
|
||||
public function __construct() {
|
||||
$this->sqlManager = new SpsSqlManager();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
public function sendSpsQuery($queryArgs = array()) {
|
||||
return $this->sqlManager->sendSpsQuery($queryArgs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
include_once "../../global.inc.php";
|
||||
include_once PATH_DATABASE . "/SQLManager.php";
|
||||
include_once PATH_DATABASE . "/SqlManager.php";
|
||||
|
||||
/**
|
||||
* The SQLManager manage the SQL-Connection for an API
|
||||
*
|
||||
* @author stubbfel
|
||||
*/
|
||||
class HelloApiSQLManager extends SQLManager{
|
||||
class HelloApiSQLManager extends SqlManager{
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
<?php
|
||||
include_once "../../global.inc.php";
|
||||
include_once PATH_DATABASE . "/SQLManager.php";
|
||||
include_once PATH_DATABASE . "/SpsSqlManager.php";
|
||||
include_once PATH_DATABASE . "/SqlManager.php";
|
||||
|
||||
/**
|
||||
* Description of SpsSqlManager
|
||||
*
|
||||
* @author stubbfel
|
||||
*/
|
||||
class SpsSqlManager {
|
||||
//put your code here
|
||||
class SpsSqlManager extends SQLManager{
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
public function sendSpsQuery($queryArgs = array()) {
|
||||
// TODO Input validitaion
|
||||
$alias = $queryArgs["alias"];
|
||||
return $this->query("SELECT * FROM sps Where alias = \"$alias\"");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -7,7 +7,7 @@ include_once "../../global.inc.php";
|
||||
*
|
||||
* @author stubbfel
|
||||
*/
|
||||
class SQLManager {
|
||||
abstract class SqlManager {
|
||||
|
||||
private $serverAddress;
|
||||
private $userName;
|
||||
@@ -39,6 +39,7 @@ class SQLManager {
|
||||
public function close() {
|
||||
if ($this->link) {
|
||||
mysql_close($this->link);
|
||||
$this->link =null;
|
||||
}
|
||||
}
|
||||
|
||||
2
geoapi/service/sps/.htaccess
Normal file
2
geoapi/service/sps/.htaccess
Normal file
@@ -0,0 +1,2 @@
|
||||
RewriteEngine on
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
15
geoapi/service/sps/index.php
Normal file
15
geoapi/service/sps/index.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
include_once "../../global.inc.php";
|
||||
require_once PATH_API . "/SpsApi.php";
|
||||
|
||||
|
||||
$app = new SpsApi();
|
||||
|
||||
$app->get('/alias/:alias', function ($alias) use ($app) {
|
||||
$args =array();
|
||||
$args["alias"] = $alias;
|
||||
print_r($app->sendSpsQuery($args));
|
||||
});
|
||||
|
||||
$app->run();
|
||||
?>
|
||||
Reference in New Issue
Block a user