コード例 #1
0
 public static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
 public function get(RESTApiRequest $request, $params)
 {
     if (empty($this->params['users.id'])) {
         throw new RESTBadRequest("User required");
     }
     if (is_array($params) && count($params) != 4) {
         throw new RESTBadRequest("Bad params");
     }
     $user_id = $this->params['users.id'];
     $user = \Stb::getById($user_id);
     if (empty($user)) {
         throw new RESTNotFound("User not found");
     }
     if (is_array($params)) {
         $karaoke_id = (int) $params[0];
     } else {
         $karaoke_id = (int) $params;
     }
     $karaoke = \Karaoke::getInstance();
     try {
         $url = $karaoke->getUrlByKaraokeId($karaoke_id);
     } catch (\Exception $e) {
         throw new RESTServerError("Failed to obtain url");
     }
     if (preg_match("/(\\S+:\\/\\/\\S+)/", $url, $match)) {
         $url = $match[1];
     }
     return $url;
 }
コード例 #3
0
 /**
  * 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();
     }
 }
コード例 #4
0
function get_done_karaoke($id)
{
    $karaoke = Karaoke::getById($id);
    return $karaoke['done'];
}
コード例 #5
0
ファイル: userlog.php プロジェクト: saydulk/stalker_portal
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;
}
コード例 #6
0
function get_status($id = 0)
{
    $karaoke = Karaoke::getById($id);
    if (!empty($karaoke['rtsp_url'])) {
        return 2;
    }
    return $karaoke['status'];
}