forked from science-ation/science-ation
Add conferences and dates api
This commit is contained in:
parent
2c7e23b276
commit
57f7bd5212
@ -6,4 +6,5 @@ RewriteCond %{SCRIPT_FILENAME} !-f
|
||||
RewriteCond %{SCRIPT_FILENAME} !-l
|
||||
RewriteCond %{SCRIPT_FILENAME} !-d
|
||||
RewriteRule ^web/(.*)$ cms.php?f=$1 [L]
|
||||
RewriteRule ^api/(.*)$ api.php?request=$1 [L]
|
||||
|
||||
|
66
api.php
Normal file
66
api.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2010 Youth Science Ontario <info@youthscienceontario.ca>
|
||||
Copyright (C) 2010 James Grant <james@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
include "common.inc.php";
|
||||
|
||||
$request=explode("/",$_GET['request']);
|
||||
|
||||
switch($request[0]) {
|
||||
case "conferences":
|
||||
$ret['status']="ok";
|
||||
$ret['conferences']=array();
|
||||
|
||||
$response=array();
|
||||
$q=mysql_query("SELECT id,name,type FROM conferences WHERE status='running' ORDER BY id");
|
||||
while($r=mysql_fetch_assoc($q)) {
|
||||
$response[]=$r;
|
||||
}
|
||||
$ret['conferences']=$response;
|
||||
break;
|
||||
|
||||
case "dates":
|
||||
if($request[1]) {
|
||||
$ret['status']="ok";
|
||||
$ret['dates']=array();
|
||||
$q=mysql_query("SELECT date,name,description FROM dates WHERE conferences_id='{$request[1]}' ORDER BY date");
|
||||
$dates=array();
|
||||
while($r=mysql_fetch_assoc($q)) {
|
||||
$dates[]=$r;
|
||||
}
|
||||
$ret['dates']=$dates;
|
||||
}
|
||||
else {
|
||||
$ret['status']="error";
|
||||
$ret['error']="Conference ID is required";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ret['status']="error";
|
||||
$ret['error']="Invalid API command ({$request[0]})";
|
||||
|
||||
}
|
||||
echo json_encode($ret);
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user