-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddddbc8
commit 6a7308f
Showing
5 changed files
with
297 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
//building api endpoints: just populate $error if there's an error | ||
// populate $data to return | ||
// call finish() | ||
|
||
require_once('../../headers/db_header.php'); | ||
|
||
|
||
function finish(){ | ||
|
||
global $error; | ||
global $data; | ||
global $query; | ||
|
||
if($error != ''){ | ||
echo $error; | ||
// header('HTTP/1.0 400 '.$error); | ||
} else { | ||
|
||
if ( is_array($data) && sizeof($data) == 1 ) $data = $data[0]; | ||
|
||
foreach($data as $i => $v){ | ||
|
||
if(!is_array($v)) $data[$i] = html_entity_decode(html_entity_decode($v, ENT_QUOTES), ENT_HTML5); | ||
} | ||
|
||
|
||
// echo $query.'<hr>'; | ||
// echo '<pre>'; | ||
header("Content-Type:application/json; charset=utf-8"); | ||
echo json_encode( $data, JSON_PRETTY_PRINT ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: brad | ||
* Date: 3/5/15 | ||
* Time: 8:23 PM | ||
*/ | ||
|
||
|
||
require_once('../api_common.php'); | ||
|
||
if (isset($_GET['ID'])) $id = $_GET['ID']; else $error = 'no id specified'; | ||
|
||
$query = 'SELECT | ||
playlists.id as playlist_id, | ||
playlists.show_id, | ||
playlists.start_time, | ||
playlists.end_time, | ||
playlists.edit_date, | ||
playlists.type as playlist_type, | ||
playlists.spokenword as transcript, | ||
playlists.podcast_episode as pid, | ||
hosts.name as host_name, | ||
podcast_episodes.summary as description | ||
FROM playlists | ||
JOIN shows on shows.id = playlists.show_id | ||
LEFT JOIN hosts on hosts.id = playlists.host_id | ||
LEFT JOIN podcast_episodes on podcast_episodes.id = playlists.podcast_episode | ||
WHERE playlists.status = 2 AND playlists.id ='.$id; | ||
|
||
$rawdata = []; | ||
|
||
if ($result = mysqli_query($db, $query) ) { | ||
|
||
while ($row = mysqli_fetch_assoc($result)) { | ||
$rawdata = $row; | ||
|
||
} | ||
|
||
$plays = []; | ||
|
||
$query = 'SELECT songs.artist, songs.title, songs.song, songs.composer FROM playitems JOIN songs ON playitems.song_id = songs.id WHERE playitems.playsheet_id='.$id; | ||
|
||
if ($result2 = mysqli_query($db, $query)){ | ||
if (mysqli_num_rows($result2) == 0){ | ||
$error = "no plays in this playlist!"; | ||
} else { | ||
|
||
while ($row = mysqli_fetch_assoc($result2)){ | ||
foreach($row as $i => $v){ | ||
$row[$i] = html_entity_decode($v, ENT_HTML5); | ||
} | ||
$plays [] = $row; | ||
} | ||
|
||
|
||
|
||
} | ||
} else { | ||
$error = mysqli_error($db); | ||
} | ||
|
||
|
||
|
||
|
||
$rawdata['songs'] = $plays; | ||
|
||
|
||
|
||
} else { | ||
$error = mysqli_error($db); | ||
} | ||
|
||
|
||
|
||
|
||
$data = $rawdata; | ||
|
||
|
||
finish(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
|
||
require_once('../api_common.php'); | ||
|
||
|
||
if(isset($_GET['OFFSET'])) $offset = $_GET['OFFSET']; else $offset = 0; | ||
if(isset($_GET['LIMIT'])) $limit = $_GET['LIMIT']; else $limit = 100; | ||
|
||
$query = 'SELECT id, edit_date FROM playlists WHERE status = 2 ORDER BY edit_date DESC limit '.$limit.' OFFSET '.$offset; | ||
|
||
$rawdata = []; | ||
|
||
if ($result = mysqli_query($db, $query) ) { | ||
|
||
while ($row = mysqli_fetch_assoc($result)) { | ||
|
||
$rawdata [] = $row; | ||
|
||
} | ||
} | ||
|
||
$data = $rawdata; | ||
|
||
finish(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: brad | ||
* Date: 3/5/15 | ||
* Time: 2:52 PM | ||
*/ | ||
|
||
|
||
require_once('../api_common.php'); | ||
|
||
$rawdata = []; | ||
$error = ''; | ||
$query = 'SELECT '. | ||
"shows.id as show_id, | ||
shows.name, | ||
shows.last_show, | ||
shows.create_date, | ||
shows.edit_date, | ||
shows.active, | ||
shows.genre, | ||
shows.website, | ||
shows.rss, | ||
shows.show_desc, | ||
shows.alerts, | ||
shows.show_img, | ||
hosts.name as host_name, | ||
social.social_name, | ||
social.social_url, | ||
social.short_name, | ||
social.unlink ". | ||
"FROM shows LEFT JOIN hosts on hosts.id = shows.host_id ". | ||
"JOIN social on show_id = shows.id "; | ||
|
||
if ( isset($_GET['ID'])){ | ||
// fetch id | ||
$id = $_GET['ID']; | ||
|
||
$query .=' WHERE shows.id = '.$id.''; | ||
|
||
} else { | ||
$error = "please supply show id ( show?id=##)"; | ||
//error | ||
} | ||
|
||
|
||
if ($result = mysqli_query($db, $query) ) { | ||
|
||
if (mysqli_num_rows($result) == 0) { | ||
|
||
// now try again without socials | ||
$query = 'SELECT '. | ||
"shows.id as show_id, | ||
shows.name, | ||
shows.last_show, | ||
shows.create_date, | ||
shows.edit_date, | ||
shows.active, | ||
shows.genre, | ||
shows.website, | ||
shows.rss, | ||
shows.show_desc, | ||
shows.alerts, | ||
shows.show_img, | ||
hosts.name as host_name ". | ||
"FROM shows LEFT JOIN hosts on hosts.id = shows.host_id "; | ||
$query .=' WHERE shows.id = '.$id.''; | ||
|
||
if($result2 = mysqli_query($db, $query)){ | ||
|
||
if (mysqli_num_rows($result2) == 0) { | ||
|
||
$error = 'empty data (are all parameters supplied correctly?). '.$query; | ||
|
||
} else { | ||
|
||
while ($row = mysqli_fetch_assoc($result2)) { | ||
|
||
$rawdata [] = $row; | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} else { | ||
|
||
while ($row = mysqli_fetch_assoc($result)) { | ||
|
||
$rawdata [] = $row; | ||
|
||
} | ||
|
||
} | ||
|
||
} else { | ||
|
||
$error = 'database error: problem query: '.$query; | ||
|
||
} | ||
|
||
|
||
|
||
$data = $rawdata[0]; | ||
|
||
$social_array = []; | ||
|
||
foreach($rawdata as $i => $show){ | ||
|
||
$social_array []= [ | ||
'type' => html_entity_decode($show['social_name'],ENT_QUOTES), | ||
'url' => html_entity_decode($show['social_url'],ENT_QUOTES), | ||
'name' => html_entity_decode($show['short_name'],ENT_QUOTES) | ||
]; | ||
} | ||
|
||
|
||
$data['social_links'] = $social_array; | ||
|
||
unset($data['social_name']); | ||
unset($data['social_url']); | ||
unset($data['short_name']); | ||
unset($data['unlink']); | ||
|
||
|
||
finish(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: brad | ||
* Date: 3/5/15 | ||
* Time: 8:10 PM | ||
*/ | ||
|
||
require_once('../api_common.php'); | ||
|
||
|
||
if(isset($_GET['OFFSET'])) $offset = $_GET['OFFSET']; else $offset = 0; | ||
if(isset($_GET['LIMIT'])) $limit = $_GET['LIMIT']; else $limit = 999999999; | ||
|
||
$query = 'SELECT id, edit_date FROM shows ORDER BY edit_date DESC limit '.$limit.' OFFSET '.$offset; | ||
|
||
$rawdata = []; | ||
|
||
if ($result = mysqli_query($db, $query) ) { | ||
|
||
while ($row = mysqli_fetch_assoc($result)) { | ||
|
||
$rawdata [] = $row; | ||
|
||
} | ||
} | ||
|
||
$data = $rawdata; | ||
|
||
finish(); |