diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index f2ae6fe86..d7ba2d192 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -23,7 +23,9 @@ date_default_timezone_set('UTC'); date_default_timezone_set(Application_Model_Preference::GetTimezone()); global $CC_CONFIG; -$CC_CONFIG['airtime_version'] = Application_Model_Preference::GetAirtimeVersion(); +$airtime_version = Application_Model_Preference::GetAirtimeVersion(); +$uniqueid = Application_Model_Preference::GetUniqueId(); +$CC_CONFIG['airtime_version'] = md5($airtime_version + $uniqueid); require_once __DIR__."/configs/navigation.php"; diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index 5aab66d38..6cef61761 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -100,6 +100,12 @@ class LoginController extends Zend_Controller_Action public function passwordRestoreAction() { + global $CC_CONFIG; + + $request = $this->getRequest(); + $baseUrl = $request->getBaseUrl(); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/login/password-restore.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + if (!Application_Model_Preference::GetEnableSystemEmail()) { $this->_redirect('login'); } diff --git a/airtime_mvc/application/forms/PasswordRestore.php b/airtime_mvc/application/forms/PasswordRestore.php index 54bfbd47a..5544e0ec1 100644 --- a/airtime_mvc/application/forms/PasswordRestore.php +++ b/airtime_mvc/application/forms/PasswordRestore.php @@ -29,5 +29,13 @@ class Application_Form_PasswordRestore extends Zend_Form 'ViewHelper' ) )); + + $cancel = new Zend_Form_Element_Button("cancel"); + $cancel->class = 'ui-button ui-widget ui-state-default ui-button-text-only center'; + $cancel->setLabel("Cancel") + ->setIgnore(True) + ->setAttrib('onclick', 'redirectToLogin();') + ->setDecorators(array('ViewHelper')); + $this->addElement($cancel); } } \ No newline at end of file diff --git a/airtime_mvc/application/models/LiveLog.php b/airtime_mvc/application/models/LiveLog.php index b641ef6ef..5635f1e66 100644 --- a/airtime_mvc/application/models/LiveLog.php +++ b/airtime_mvc/application/models/LiveLog.php @@ -20,58 +20,77 @@ class Application_Model_LiveLog if ($rows != null) { $last_row = self::UpdateLastLogEndTime(array_pop($rows)); array_push($rows, $last_row); + $skip = false; + } else { + $sql = "SELECT * FROM CC_LIVE_LOG" + ." WHERE state = 'L'" + ." ORDER BY id"; + $rows = $con->query($sql)->fetchAll(); + + if ($rows != null) { + $last_row = self::UpdateLastLogEndTime(array_pop($rows)); + array_push($rows, $last_row); + foreach ($rows as $row) { + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); + } + } + $skip = true; } $hours = 0; $minutes = 0; $seconds = 0; - foreach ($rows as $row) { - $end = new DateTime($row['end_time']); - $start = new DateTime($row['start_time']); - $duration = $start->diff($end); - $duration = $duration->format("%H:%i:%s"); - $intervals = explode(":", $duration); - for ($i = 0; $i < sizeof($intervals); $i++) { - if (!isset($intervals[$i])) { - $intervals[$i] = 0; + if (!$skip) { + foreach ($rows as $row) { + $end = new DateTime($row['end_time']); + $start = new DateTime($row['start_time']); + $duration = $start->diff($end); + $duration = $duration->format("%H:%i:%s"); + $intervals = explode(":", $duration); + for ($i = 0; $i < sizeof($intervals); $i++) { + if (!isset($intervals[$i])) { + $intervals[$i] = 0; + } + } + + // Trim milliseconds (DateInterval does not support) + $sec = explode(".", $intervals[2]); + if (isset($sec[0])) { + $intervals[2] = $sec[0]; + } + + $seconds += $intervals[2]; + if ($seconds / 60 >= 1) { + $minutes += 1; + $seconds -= 60; + } + + $minutes += $intervals[1]; + if ($minutes / 60 >= 1) { + $hours += 1; + $minutes -= 60; + } + + $hours += $intervals[0]; + + if (!$p_keepData) { + // Delete data we just used to start a new log history + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); } } - - // Trim milliseconds (DateInterval does not support) - $sec = explode(".", $intervals[2]); - if (isset($sec[0])) { - $intervals[2] = $sec[0]; + //Trim milliseconds + $seconds = explode(".", $seconds); + if (isset($seconds[0])) { + $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); } - - $seconds += $intervals[2]; - if ($seconds / 60 >= 1) { - $minutes += 1; - $seconds -= 60; + else { + $minutes = (double)(($hours*60)+$minutes); } - - $minutes += $intervals[1]; - if ($minutes / 60 >= 1) { - $hours += 1; - $minutes -= 60; - } - - $hours += $intervals[0]; - - if (!$p_keepData) { - // Delete data we just used to start a new log history - $sql_delete = "DELETE FROM CC_LIVE_LOG" - ." WHERE id = '{$row['id']}'"; - $con->exec($sql_delete); - } - } - //Trim milliseconds - $seconds = explode(".", $seconds); - if (isset($seconds[0])) { - $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); - } - else { - $minutes = (double)(($hours*60)+$minutes); } return $minutes; } catch (Exception $e) { @@ -99,121 +118,141 @@ class Application_Model_LiveLog if ($rows != null) { $last_row = self::UpdateLastLogEndTime(array_pop($rows)); array_push($rows, $last_row); + $skip = false; + } + else { + $sql = "SELECT * FROM CC_LIVE_LOG" + ." WHERE state = 'S'" + ." ORDER BY id"; + $rows = $con->query($sql)->fetchAll(); + + if ($rows != null) { + $last_row = self::UpdateLastLogEndTime(array_pop($rows)); + array_push($rows, $last_row); + foreach ($rows as $row) { + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); + } + } + $skip = true; } $hours = 0; $minutes = 0; $seconds = 0; - /* Get all shows and tracks from cc_schedule that played - * during a scheduled state - */ - foreach ($rows as $row) { - $sql_get_tracks = "SELECT * FROM cc_schedule" - ." WHERE starts >= '{$row['start_time']}'" - ." AND starts < '{$row['end_time']}'" - ." AND file_id IS NOT NULL" - ." AND media_item_played IS TRUE"; - $tracks = $con->query($sql_get_tracks)->fetchAll(); - foreach ($tracks as $track) { - if ($track['ends'] > $row['end_time']) { - $scheduled_ends = new DateTime($row['end_time']); - $track_ends = new DateTime($track['ends']); - $extra_time = $scheduled_ends->diff($track_ends); + if (!$skip) { + /* Get all shows and tracks from cc_schedule that played + * during a scheduled state + */ + foreach ($rows as $row) { + $sql_get_tracks = "SELECT * FROM cc_schedule" + ." WHERE starts >= '{$row['start_time']}'" + ." AND starts < '{$row['end_time']}'" + ." AND file_id IS NOT NULL" + ." AND media_item_played IS TRUE"; + $tracks = $con->query($sql_get_tracks)->fetchAll(); + foreach ($tracks as $track) { + if ($track['ends'] > $row['end_time']) { + $scheduled_ends = new DateTime($row['end_time']); + $track_ends = new DateTime($track['ends']); + $extra_time = $scheduled_ends->diff($track_ends); - /* Get difference between clip_length - * and the extra time. We need to subtract - * this difference from the track's - * clip length. - */ - $clip_length = $track['clip_length']; - //Convert clip_length into seconds - $clip_length_intervals = explode(":", $clip_length); - for ($i = 0; $i < sizeof($clip_length_intervals); $i++) { - if (!isset($clip_length_intervals[$i])) { - $clip_length_intervals[$i] = 0; + /* Get difference between clip_length + * and the extra time. We need to subtract + * this difference from the track's + * clip length. + */ + $clip_length = $track['clip_length']; + //Convert clip_length into seconds + $clip_length_intervals = explode(":", $clip_length); + for ($i = 0; $i < sizeof($clip_length_intervals); $i++) { + if (!isset($clip_length_intervals[$i])) { + $clip_length_intervals[$i] = 0; + } } - } - $clip_length_seconds = $clip_length_intervals[0]*3600 + $clip_length_intervals[1]*60 + $clip_length_intervals[2]; - - $extra_time = $extra_time->format("%H:%i:%s"); - //Convert extra_time into seconds; - $extra_time_intervals = explode(":", $extra_time); - for ($i = 0; $i < sizeof($extra_time_intervals); $i++) { - if (!isset($extra_time_intervals[$i])) { - $extra_time_intervals[$i] = 0; + $clip_length_seconds = $clip_length_intervals[0]*3600 + $clip_length_intervals[1]*60 + $clip_length_intervals[2]; + + $extra_time = $extra_time->format("%H:%i:%s"); + //Convert extra_time into seconds; + $extra_time_intervals = explode(":", $extra_time); + for ($i = 0; $i < sizeof($extra_time_intervals); $i++) { + if (!isset($extra_time_intervals[$i])) { + $extra_time_intervals[$i] = 0; + } } - } - $extra_time_seconds = $extra_time_intervals[0]*3600 + $extra_time_intervals[1]*60 + $extra_time_intervals[2]; + $extra_time_seconds = $extra_time_intervals[0]*3600 + $extra_time_intervals[1]*60 + $extra_time_intervals[2]; - $clip_length_seconds -= $extra_time_seconds; - - //Convert new clip_length into "H-i-s" format - $clip_length_arr = array(); - if ($clip_length_seconds / 3600 >= 1) { - array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 3600), 2, "0", STR_PAD_LEFT)); - $clip_length_seconds -= floor($clip_length_seconds / 3600); + $clip_length_seconds -= $extra_time_seconds; + + //Convert new clip_length into "H-i-s" format + $clip_length_arr = array(); + if ($clip_length_seconds / 3600 >= 1) { + array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 3600), 2, "0", STR_PAD_LEFT)); + $clip_length_seconds -= floor($clip_length_seconds / 3600); + } + else { + array_push($clip_length_arr, "00"); + } + if ($clip_length_seconds / 60 >= 1) { + array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 60), 2, "0", STR_PAD_LEFT)); + $clip_length_seconds -= floor($clip_length_seconds / 60); + } + else { + array_push($clip_length_arr, "00"); + } + + array_push($clip_length_arr, str_pad($clip_length_seconds, 2, "0", STR_PAD_LEFT)); + $clip_length = implode(":", $clip_length_arr); } else { - array_push($clip_length_arr, "00"); - } - if ($clip_length_seconds / 60 >= 1) { - array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 60), 2, "0", STR_PAD_LEFT)); - $clip_length_seconds -= floor($clip_length_seconds / 60); - } - else { - array_push($clip_length_arr, "00"); + $clip_length = $track['clip_length']; } - array_push($clip_length_arr, str_pad($clip_length_seconds, 2, "0", STR_PAD_LEFT)); - $clip_length = implode(":", $clip_length_arr); - } - else { - $clip_length = $track['clip_length']; - } - - $intervals = explode(":", $clip_length); - for ($i = 0; $i < sizeof($intervals); $i++) { - if (!isset($intervals[$i])) { - $intervals[$i] = 0; + $intervals = explode(":", $clip_length); + for ($i = 0; $i < sizeof($intervals); $i++) { + if (!isset($intervals[$i])) { + $intervals[$i] = 0; + } } - } - // Trim milliseconds (DateInteral does not support) - $sec = explode(".", $intervals[2]); - if (isset($sec[0])) { - $intervals[2] = $sec[0]; + // Trim milliseconds (DateInteral does not support) + $sec = explode(".", $intervals[2]); + if (isset($sec[0])) { + $intervals[2] = $sec[0]; + } + + $seconds += $intervals[2]; + if ($seconds / 60 >= 1) { + $minutes += 1; + $seconds -= 60; + } + + $minutes += $intervals[1]; + if ($minutes / 60 >= 1) { + $hours += 1; + $minutes -= 60; + } + + $hours += $intervals[0]; } - $seconds += $intervals[2]; - if ($seconds / 60 >= 1) { - $minutes += 1; - $seconds -= 60; + if (!$p_keepData) { + //Delete row because we do not need data anymore + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); } - - $minutes += $intervals[1]; - if ($minutes / 60 >= 1) { - $hours += 1; - $minutes -= 60; - } - - $hours += $intervals[0]; } - if (!$p_keepData) { - //Delete row because we do not need data anymore - $sql_delete = "DELETE FROM CC_LIVE_LOG" - ." WHERE id = '{$row['id']}'"; - $con->exec($sql_delete); + + $seconds = explode(".", $seconds); + if (isset($seconds[0])) { + $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); + } + else { + $minutes = (double)(($hours*60)+$minutes); } - } - - - $seconds = explode(".", $seconds); - if (isset($seconds[0])) { - $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); - } - else { - $minutes = (double)(($hours*60)+$minutes); } return $minutes; } catch (Exception $e) { diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 4e37a2bad..d69e28e19 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -888,7 +888,7 @@ Logging::log("getting media! - 2"); // Check if file is playable $command = sprintf("/usr/bin/airtime-liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))' 2>&1", $audio_file); exec($command, $output, $rv); - if ($rv != 0 || $output[0] == 'TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.') { + if ($rv != 0 || (!empty($output) && $output[0] == 'TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.')) { $result = array("code" => 110, "message" => "This file appears to be corrupted and will not be added to media library."); } else { diff --git a/airtime_mvc/application/views/scripts/form/password-restore.phtml b/airtime_mvc/application/views/scripts/form/password-restore.phtml index 5c8d099ac..a617ec971 100644 --- a/airtime_mvc/application/views/scripts/form/password-restore.phtml +++ b/airtime_mvc/application/views/scripts/form/password-restore.phtml @@ -21,5 +21,8 @@