Removed repeated code
This commit is contained in:
parent
03f383f764
commit
6da9b6bf42
|
@ -315,44 +315,33 @@ 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');
|
||||||
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
if (empty($days)) {$days = 7;}
|
||||||
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
|
|
||||||
$utcDayStart = $utcDayEnd;
|
for ($i=0; $i<$days; $i++) {
|
||||||
|
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
||||||
Application_Model_Show::convertToLocalTimeZone($shows,
|
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
|
||||||
array("starts", "ends", "start_timestamp",
|
$utcDayStart = $utcDayEnd;
|
||||||
"end_timestamp"));
|
|
||||||
|
|
||||||
$result[$i] = $shows;
|
|
||||||
}
|
|
||||||
// XSS exploit prevention
|
|
||||||
for ($i=0; $i<$number_of_days; $i++) {
|
|
||||||
foreach ($result[$i] as &$show) {
|
|
||||||
$show["name"] = htmlspecialchars($show["name"]);
|
|
||||||
$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"));
|
|
||||||
|
|
||||||
|
Application_Model_Show::convertToLocalTimeZone($shows,
|
||||||
|
array("starts", "ends", "start_timestamp",
|
||||||
|
"end_timestamp"));
|
||||||
|
|
||||||
|
if ($days==7) { //return with day of week index - standard
|
||||||
$result[$dow[$i]] = $shows;
|
$result[$dow[$i]] = $shows;
|
||||||
}
|
}
|
||||||
// XSS exploit prevention
|
else{ //return with number index - days has been specified
|
||||||
foreach ($dow as $d) {
|
$result[$i] = $shows;
|
||||||
foreach ($result[$d] as &$show) {
|
}
|
||||||
$show["name"] = htmlspecialchars($show["name"]);
|
|
||||||
$show["url"] = htmlspecialchars($show["url"]);
|
}
|
||||||
}
|
// XSS exploit prevention
|
||||||
}
|
for ($i=0; $i<$days; $i++) {
|
||||||
|
foreach ($result[$i] as &$show) {
|
||||||
|
$show["name"] = htmlspecialchars($show["name"]);
|
||||||
|
$show["url"] = htmlspecialchars($show["url"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue