/** * Main claim method. * * @param string $media_type */ protected function setClaimGlobal($media_type) { $id = intval($_REQUEST['id']); $type = $_REQUEST['real_type']; $this->db->insert('media_claims_log', array('media_type' => $media_type, 'media_id' => $id, 'type' => $type, 'uid' => $this->stb->id, 'added' => 'NOW()')); $total_media_claims = $this->db->from('media_claims')->where(array('media_type' => $media_type, 'media_id' => $id))->get()->first(); $sound_counter = 0; $video_counter = 0; $no_epg_counter = 0; $wrong_epg_counter = 0; if ($type == 'video') { $video_counter++; } else { if ($type == 'sound') { $sound_counter++; } else { if ($type == 'no_epg') { $no_epg_counter++; } else { if ($type == 'wrong_epg') { $wrong_epg_counter++; } } } } if (!empty($total_media_claims)) { $this->db->update('media_claims', array('sound_counter' => $total_media_claims['sound_counter'] + $sound_counter, 'video_counter' => $total_media_claims['video_counter'] + $video_counter, 'no_epg' => $total_media_claims['no_epg'] + $no_epg_counter, 'wrong_epg' => $total_media_claims['wrong_epg'] + $wrong_epg_counter), array('media_type' => $media_type, 'media_id' => $id)); } else { $this->db->insert('media_claims', array('sound_counter' => $sound_counter, 'video_counter' => $video_counter, 'no_epg' => $no_epg_counter, 'wrong_epg' => $wrong_epg_counter, 'media_type' => $media_type, 'media_id' => $id)); } $total_daily_claims = $this->db->from('daily_media_claims')->where(array('date' => 'CURDATE()'))->get()->first(); $media_name = 'undefined'; if ($media_type == 'itv') { $media = Itv::getById($id); if (!empty($media['name'])) { $media_name = $media['name']; } } elseif ($media_type == 'vclub') { $media = Video::getById($id); if (!empty($media['name'])) { $media_name = $media['name']; } } elseif ($media_type == 'karaoke') { $media = Karaoke::getById($id); if (!empty($media['name'])) { $media_name = $media['name']; } } if (Config::exist('administrator_email')) { $message = sprintf(_("New claim on %s - %s (%s, id: %s). From %s"), $media_type, $type, $media_name, $id, $this->stb->mac); mail(Config::get('administrator_email'), 'New claim on ' . $media_type . ' - ' . $type, $message, "Content-type: text/html; charset=UTF-8\r\n"); } if (!empty($total_daily_claims)) { return $this->db->update('daily_media_claims', array($media_type . '_sound' => $total_daily_claims[$media_type . '_sound'] + $sound_counter, $media_type . '_video' => $total_daily_claims[$media_type . '_video'] + $video_counter, 'no_epg' => $total_daily_claims['no_epg'] + $no_epg_counter, 'wrong_epg' => $total_daily_claims['wrong_epg'] + $wrong_epg_counter), array('date' => 'CURDATE()'))->result(); } else { return $this->db->insert('daily_media_claims', array($media_type . '_sound' => $sound_counter, $media_type . '_video' => $video_counter, 'no_epg' => $no_epg_counter, 'wrong_epg' => $wrong_epg_counter, 'date' => 'CURDATE()'))->insert_id(); } }
function parse_param($action, $param, $type){ if($action == 'play'){ switch ($type){ case 1: // TV $channel = Mysql::getInstance() ->from('itv') ->where(array( 'cmd' => $param, 'status' => 1 )) ->get()->first(); if (!empty($channel)){ $ch_name = $channel['name']; }else{ $ch_name = htmlspecialchars($param); } $name = '['._('Channel').'] '.$ch_name; break; case 2: // Video Club if (!preg_match("/(\d+)\.[a-z0-9]*$/", $param, $tmp_arr)){ $name = $param; break; } $media_id = $tmp_arr[1]; $video = Video::getById($media_id); if (!empty($video)){ $video_name = $video['name']; }else{ $video_name = htmlspecialchars($param); } $name = '['._('Video').'] '.$video_name; break; case 3: // Karaoke preg_match("/(\d+)\.[a-z]*$/", $param, $tmp_arr); $karaoke_id = $tmp_arr[1]; $karaoke = Karaoke::getById($karaoke_id); if (!empty($karaoke)){ $karaoke_name = $karaoke['name']; }else{ $karaoke_name = htmlspecialchars($param); } $name = '['._('Karaoke').'] '.$karaoke_name; break; case 4: // Audio Club preg_match("/(\d+).mp3$/", $param, $tmp_arr); $audio_id = $tmp_arr[1]; $audio = Mysql::getInstance()->from('audio')->where(array('id' => $audio_id))->get()->first(); if (!empty($audio)){ $audio_name = $audio['name']; }else{ $audio_name = htmlspecialchars($param); } $name = '['._('Audio').'] '.$audio_name; break; case 5: // Radio $radio = Mysql::getInstance()->from('radio')->where(array('cmd' => $param, 'status' => 1))->get()->first(); if (empty($radio)){ $ch_name = $radio['name']; }else{ $ch_name = htmlspecialchars($param); } $name = '['._('Radio').'] '.$ch_name; break; case 6: // My Records preg_match("/\/(\d+).mpg/", $param, $tmp_arr); $my_record_id = $tmp_arr[1]; $record = Mysql::getInstance() ->select('t_start, itv.name') ->from('users_rec') ->join('itv', 'users_rec.ch_id', 'itv.id', 'INNER') ->where(array( 'users_rec.id' => $my_record_id )) ->get() ->first(); if (!empty($record)){ $my_record_name = $record['t_start'].' '.$record['name']; }else{ $my_record_name = htmlspecialchars($param); } $name = '['._('My records').'] '.$my_record_name; break; case 7: // Shared Records preg_match("/(\d+).mpg$/", $param, $tmp_arr); $shared_record_id = $tmp_arr[1]; $record = Mysql::getInstance() ->from('video_records') ->where(array( 'id' => $shared_record_id )) ->get() ->first(); if (!empty($record)){ $shared_record_name = $record['descr']; }else{ $shared_record_name = htmlspecialchars($param); } $name = '['._('Records').'] '.$shared_record_name; break; case 8: // Video clips preg_match("/(\d+).mpg$/", $param, $tmp_arr); $media_id = $tmp_arr[1]; $video = Mysql::getInstance()->from('video_clips')->where(array('id' => $media_id))->get()->first(); if (!empty($video)){ $video_name = $video['name']; }else{ $video_name = htmlspecialchars($param); } $name = '['._('Clip').'] '.$video_name; break; default: $name = 'unknown media'; } }else{ if($param == '""'){ $name = ''; }else{ $name = htmlspecialchars($param); } } return $name; }
function get_done_karaoke($id) { $karaoke = Karaoke::getById($id); return $karaoke['done']; }
function get_status($id = 0) { $karaoke = Karaoke::getById($id); if (!empty($karaoke['rtsp_url'])) { return 2; } return $karaoke['status']; }