public function add() { $ch_id = @intval($_REQUEST['ch_id']); $program_id = $_REQUEST['program_id']; $fire_ts = @intval($_REQUEST['fire_ts']); $program_name = $_REQUEST['program_name']; $memo = $this->db->from('tv_reminder')->where(array('mac' => $this->stb->mac, 'tv_program_real_id' => $program_id))->get()->first(); if (!empty($memo)) { return false; } $channel = Itv::getById($ch_id); if (empty($channel)) { $dvb_channels = Itv::getInstance()->getDvbChannels(); foreach ($dvb_channels as $dvb_channel) { if ($dvb_channel['id'] == $ch_id) { $channel = $dvb_channel; break; } } } if (empty($channel)) { return false; } if (isset($channel['type']) && $channel['type'] == 'dvb') { $program = array('id' => 0, 'real_id' => $program_id, 'time' => date("Y-m-d H:i:s", $fire_ts)); } else { $program = Epg::getByRealId($program_id); if (empty($program)) { return false; } } $id = $this->db->insert('tv_reminder', array('mac' => $this->stb->mac, 'ch_id' => $ch_id, 'tv_program_id' => $program['id'], 'tv_program_real_id' => $program['real_id'], 'fire_time' => $program['time'], 'tv_program_name' => $program_name, 'added' => 'NOW()'))->insert_id(); if (intval($id) <= 0) { return false; } return $this->getRaw()->where(array('tv_reminder.id' => $id))->get()->first(); }
public function getNextPartUrl() { $program_id = $_REQUEST['id']; if (!$program_id) { return false; } $program = Epg::getByRealId($program_id); if (empty($program)) { if (preg_match("/(\\d+)_(\\d+)/", $program_id, $match)) { $next = Mysql::getInstance()->from('epg')->where(array('ch_id' => (int) $match[1], 'time>' => date("Y-m-d H:i:s", (int) $match[2])))->orderby('time')->limit(1)->get()->first(); } else { return false; } } else { $next = Mysql::getInstance()->from('epg')->where(array('ch_id' => $program['ch_id'], 'time>' => $program['time']))->orderby('time')->limit(1)->get()->first(); } if (empty($next)) { return false; } try { if ($next['time'] != $program['time_to'] && !isset($match)) { $program = array('name' => '[' . _('Break in the program') . ']', 'ch_id' => $next['ch_id'], 'time' => $program['time_to'], 'time_to' => $next['time'], 'real_id' => $next['ch_id'] . '_' . strtotime($program['time_to'])); return Config::getSafe('tv_archive_player_solution', 'ffmpeg') . ' ' . $this->getUrlByProgramId(0, true, $program); } else { return Config::getSafe('tv_archive_player_solution', 'ffmpeg') . ' ' . $this->getUrlByProgramId($next['id'], true); } } catch (StorageSessionLimitException $e) { return false; } }