Removed repeated code
This commit is contained in:
parent
03f383f764
commit
6da9b6bf42
1 changed files with 25 additions and 36 deletions
|
@ -315,8 +315,11 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
if(isset($_GET['number_of_days'])){ //allows for schedule to be returned for multiple days
|
$request = $this->getRequest();
|
||||||
for ($i=0; $i<$number_of_days; $i++) {
|
$days = $request->getParam('days');
|
||||||
|
if (empty($days)) {$days = 7;}
|
||||||
|
|
||||||
|
for ($i=0; $i<$days; $i++) {
|
||||||
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
||||||
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
|
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
|
||||||
$utcDayStart = $utcDayEnd;
|
$utcDayStart = $utcDayEnd;
|
||||||
|
@ -325,35 +328,21 @@ class ApiController extends Zend_Controller_Action
|
||||||
array("starts", "ends", "start_timestamp",
|
array("starts", "ends", "start_timestamp",
|
||||||
"end_timestamp"));
|
"end_timestamp"));
|
||||||
|
|
||||||
|
if ($days==7) { //return with day of week index - standard
|
||||||
|
$result[$dow[$i]] = $shows;
|
||||||
|
}
|
||||||
|
else{ //return with number index - days has been specified
|
||||||
$result[$i] = $shows;
|
$result[$i] = $shows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// XSS exploit prevention
|
// XSS exploit prevention
|
||||||
for ($i=0; $i<$number_of_days; $i++) {
|
for ($i=0; $i<$days; $i++) {
|
||||||
foreach ($result[$i] as &$show) {
|
foreach ($result[$i] as &$show) {
|
||||||
$show["name"] = htmlspecialchars($show["name"]);
|
$show["name"] = htmlspecialchars($show["name"]);
|
||||||
$show["url"] = htmlspecialchars($show["url"]);
|
$show["url"] = htmlspecialchars($show["url"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
for ($i=0; $i<7; $i++) {
|
|
||||||
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
|
||||||
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
|
|
||||||
$utcDayStart = $utcDayEnd;
|
|
||||||
|
|
||||||
Application_Model_Show::convertToLocalTimeZone($shows,
|
|
||||||
array("starts", "ends", "start_timestamp",
|
|
||||||
"end_timestamp"));
|
|
||||||
|
|
||||||
$result[$dow[$i]] = $shows;
|
|
||||||
}
|
|
||||||
// XSS exploit prevention
|
|
||||||
foreach ($dow as $d) {
|
|
||||||
foreach ($result[$d] as &$show) {
|
|
||||||
$show["name"] = htmlspecialchars($show["name"]);
|
|
||||||
$show["url"] = htmlspecialchars($show["url"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//used by caller to determine if the airtime they are running or widgets in use is out of date.
|
//used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue