Exemplo n.º 1
0
 public function init()
 {
     $assets = dirname(__FILE__) . '/assets';
     $this->assetsPath = Yii::app()->assetManager->publish($assets, false, 1, YII_DEBUG);
     if (empty($this->data)) {
         $data[] = array('file' => $this->assetsPath . '/default.mp3', 'label' => '128K');
         $data[] = array('file' => $this->assetsPath . '/default.mp3', 'label' => '320K VIP');
         //$source = json_encode($data);
     }
     $song = SongModel::model()->findByPk($this->songId);
     $source = SongModel::model()->builDataPlayerSong($this->songId, $song);
     $cs = Yii::app()->clientScript;
     $cs->registerScriptFile($this->assetsPath . '/jwplayer.js', CClientScript::POS_END);
     $cs->registerScript('play_audio_mobile' . $this->id, "\n            jwplayer('" . $this->id . "').setup({\n                width: '" . $this->width . "',\n                height: '" . $this->height . "',\n                stretching: 'none',\n                sources: {$source},\n                skin:'" . $this->assetsPath . "/vega-skin-audio-min-2.xml',\n                autostart: " . $this->autostart . ",\n                primary: '" . $this->primary . "'\n            });", CClientScript::POS_END);
     //log and track
     $deviceType = 'mobile';
     $cs->registerScript('play_audio_mobile_current' . $this->id, "\n            var device_type = '" . $deviceType . "';\n            var listPlayed =Array();\n            var logPlayAudioFlag = true;\n\t\t\tjwplayer().onBeforePlay(function() {\n\t\t\t\tlogPlayAudioFlag = true;\n\t\t\t\tconsole.log('set flag again|'+logPlayAudioFlag);\n\t\t\t});\n\t\t\tjwplayer().onTime(function(event) {\n\t\t\t\tif(Math.round(event.position) >=5){\n\t\t\t\t\tif(logPlayAudioFlag) {\n\t\t\t\t\t\tlogPlayAudioFlag = false;\n                        var action = 'Play Song';\n\t\t\t\t\t\tif(in_array_item(listPlayed,'song_'+" . $song->id . ")){\n\t\t\t\t\t\t\tvar action = 'Replay Song';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar item = 'song_" . $song->id . "';\n                        if(!in_array_item(listPlayed,item)){\n                            listPlayed.push(item);\n                        }\n                        console.log(device_type+'-'+action);\n\t\t\t\t\t\tga('send', 'event', device_type, action,'" . CHtml::encode($song->name . "-" . $song->artist_name . "-" . $song->id) . "');\n\t\t\t\t\t\tajax_load('/player/logSong',{'id':" . $song->id . "});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});", CClientScript::POS_END);
     /*$cs->registerScript('play_audio_cookie'.$this->id,"
           var primaryCookie = 'html5';
           var cookies = document.cookie.split(';');
           for (i=0; i < cookies.length; i++) {
               var x = cookies[i].substr(0, cookies[i].indexOf('='));
               var y = cookies[i].substr(cookies[i].indexOf('=') + 1);
               x = x.replace(/^\s+|\s+$/g,'');
               if (x == 'primaryCookie') {
                   primaryCookie = y;
               }
           }
       ",CClientScript::POS_END);*/
     parent::init();
 }
Exemplo n.º 2
0
 public function publishAssets()
 {
     if ($this->freeWifi) {
         if (!Yii::app()->user->getState('is3G')) {
             $localConfig = (require Yii::getPathOfAlias('application.config') . '/local.php');
             Yii::app()->params['storage'] = $localConfig['params']['storage'];
         }
     }
     $list = "";
     $deviceId = yii::app()->session['deviceId'];
     $deviceProfile = SongModel::model()->getSongProfileIdSuport($deviceId, 'http');
     foreach ($this->songList as $song) {
         //$audioTest = 'http://audio.chacha.vn/songs/output/22/184609/4.mp3';
         $playUrl = WapSongModel::model()->getAudioFileUrl($song->id, $deviceId, 'http', $song->profile_ids, $deviceProfile);
         $playeCount = $song->song_statistic ? $song->song_statistic->played_count : 0;
         $songName = str_replace("'", "\\'", $song->name);
         $songArtist = str_replace("'", "\\'", $song->artist_name);
         $list .= "{\n\t\t\t\ttitle:'{$songName}',\n\t\t\t\tmp3:'{$playUrl}',\n\t\t\t\tsong_id:'{$song->id}',\n\t\t\t\tartist:'{$songArtist}',\n\t\t\t\tplay_count:'{$playeCount}',\n\t\t\t },";
     }
     $this->listJs = $list;
     Yii::app()->clientScript->registerCoreScript('jquery');
     Yii::app()->clientScript->registerCoreScript('jquery.ui');
     $assets = dirname(__FILE__) . '/assets';
     $baseUrl = Yii::app()->assetManager->publish($assets);
     $this->basePath = $baseUrl;
     if (is_dir($assets)) {
         //Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jquery.jplayer.min.js', CClientScript::POS_HEAD);
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jquery.jplayer.js', CClientScript::POS_HEAD);
         //Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jplayer.playlist.min.js', CClientScript::POS_HEAD);
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/js/jplayer.playlist.js', CClientScript::POS_HEAD);
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/player.js', CClientScript::POS_HEAD);
         Yii::app()->clientScript->registerCssFile($baseUrl . '/skin/jplayer-custom.css');
         Yii::app()->clientScript->registerCssFile($baseUrl . '/skin/jplayer.blue.monday.css');
         Yii::app()->clientScript->registerCssFile('http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css');
     } else {
         throw new CHttpException(500, 'Player - Error: Couldn\'t find assets to publish.');
     }
 }
Exemplo n.º 3
0
 public function actionCharge()
 {
     $id = Yii::app()->request->getParam('id');
     $song = SongModel::model()->findByPk($id);
     $action = Yii::app()->request->getParam('action', 'playSong');
     $deviceId = yii::app()->session['deviceId'];
     $msg = "";
     $playUrl = '';
     if (!$song) {
         $this->forward("/site/error", true);
     }
     $artist_name = Common::makeFriendlyUrl($song->artist_name);
     $back_url = Yii::app()->params['base_url'] . Yii::app()->createUrl('song/view', array('id' => $song->id, 'url_key' => Common::makeFriendlyUrl($song->name), 'artist' => $artist_name));
     if (Yii::app()->user->isGuest) {
         if ($action == 'downloadSong') {
             $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url)));
             Yii::app()->end();
         } else {
             //cho nghe 5 lan free
             $limit = isset(Yii::app()->session["limit_play"]) ? Yii::app()->session["limit_play"] : 0;
             if ($limit >= 5) {
                 $msg = Yii::app()->params['message']['limit_content'];
             } else {
                 Yii::app()->session["limit_play"] = Yii::app()->session["limit_play"] + 1;
                 $playUrl = WapSongModel::model()->getAudioFileUrl($song->id, $deviceId, 'rtsp', $song->profile_ids);
                 $this->redirect($this->createUrl("song/view", array('url' => $playUrl, "id" => $id, 'url_key' => $song->url_key)));
             }
             $this->render('play', compact('msg', 'back_url', 'playUrl'));
             exit;
         }
     }
     if ($action == 'downloadSong' && empty($this->isSub)) {
         $msg = "Quý khách vui lòng đăng ký dịch vụ để tải miễn phí nội dung";
         $this->render('download', compact('msg', 'back_url'));
         exit;
     }
     $bmUrl = Yii::app()->params['bmConfig']['remote_wsdl'];
     $client = new SoapClient($bmUrl, array('trace' => 1));
     if ($action == 'downloadSong') {
         $params = array('code' => $song->code, 'from_phone' => yii::app()->user->getState('msisdn'), 'to_phone' => yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0, 'smsId' => '', 'noteOptions' => array());
         $result = $client->__soapCall('downloadSong', $params);
     } elseif ($action == 'playSong') {
         $params = array('code' => $song->code, 'from_phone' => Yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0);
         $result = $client->__soapCall('playSong', $params);
     }
     $errorCode = $result->message;
     // Log url trả về cho user
     if ($errorCode == "success") {
         if ($action == 'playSong') {
             $playUrl = WapSongModel::model()->getAudioFileUrl($song->id, $deviceId, 'rtsp', $song->profile_ids);
         } else {
             $playUrl = WapSongModel::model()->getNiceDownloadUrl($song->id, $deviceId, 'http', $song->profile_ids, $song->url_key, $song->artist_name);
         }
         $this->redirect($this->createUrl("song/view", array('url' => $playUrl, "id" => $id, 'url_key' => $song->url_key)));
     } else {
         $msg = Yii::app()->params['subscribe'][$errorCode];
     }
     $this->render('play', compact('msg', 'back_url', 'playUrl'));
 }
Exemplo n.º 4
0
 public function actionDownloadRbt()
 {
     $flag = true;
     $userPhone = false;
     if (!Yii::app()->user->isGuest) {
         $userPhone = Yii::app()->user->getState('msisdn');
     }
     if (Yii::app()->getRequest()->ispostRequest && isset($_POST['rbt_code'])) {
         $flag = false;
         $toPhone = Yii::app()->request->getParam('to_phone');
         $code = Yii::app()->request->getParam('rbt_code');
         $result = new stdClass();
         if (!Formatter::isMobiPhoneNumber($userPhone)) {
             $result->errorCode = 1;
             $result->message = "Chức năng nhạc chờ chỉ áp dụng cho các tài khoản là thuê bao Mobifone";
             echo json_encode($result);
             Yii::app()->end();
         }
         if (!Formatter::isMobiPhoneNumber($toPhone)) {
             $result->errorCode = 1;
             $result->message = "Số điện thoại người nhận không phải là thuê bao Mobifone";
             echo json_encode($result);
             Yii::app()->end();
         }
         $flagCRBT = false;
         $msisdn = Formatter::removePrefixPhone($userPhone);
         $msisdn = substr($msisdn, 1);
         $funringStatus = FunringHelper::getInstance()->checkStatus($msisdn);
         if ($funringStatus == -1) {
             $result->errorCode = -1;
             $result->message = "Không kết nối được đến hệ thống CRBT";
             echo json_encode($result);
             Yii::app()->end();
         }
         if ($funringStatus == 4) {
             // Chua dang ky => thuc hien dang ky cho TB
             $retRegister = FunringHelper::getInstance()->register($msisdn);
             if ($retRegister != 0) {
                 $result->errorCode = -1;
                 $result->message = "Không kết nối được đến hệ thống CRBT";
                 echo json_encode($result);
                 Yii::app()->end();
             }
         }
         if ($userPhone == $toPhone) {
             $ret = FunringHelper::getInstance()->orderTone($msisdn, $code);
             if ($ret == 0) {
                 $error = "Bạn đã tải nhạc chờ thành công!";
             } else {
                 $error = "Bạn tải nhạc chờ chưa thành công. Vui lòng kiểm tra và thao tác lại.";
             }
         } else {
             $toPhone = Formatter::removePrefixPhone($toPhone);
             $toPhone = substr($toPhone, 1);
             $ret = FunringHelper::getInstance()->giftTone($msisdn, $code, $toPhone);
             if ($ret == 0) {
                 $error = "Bạn đã tặng nhạc chờ thành công cho số thuê bao 0{$toPhone}.";
             } else {
                 $error = "Bạn tặng nhạc chờ cho số thuê bao 0{$toPhone} chưa thành công. Vui lòng kiểm tra và thao tác lại.";
             }
         }
         $result->errorCode = $ret;
         $result->message = $error;
         echo json_encode($result);
     }
     if ($flag) {
         $rbts = array();
         $id = Yii::app()->request->getParam('id');
         $song = SongModel::model()->findByPk($id);
         if ($song->rbt_codes != "") {
             $code = explode(",", trim($song->rbt_codes));
             $rbts = RbtModel::model()->getByCodes($code);
         }
         $this->renderPartial('_popupRbt', compact("song", "rbts", "userPhone"), false, true);
     }
 }
Exemplo n.º 5
0
 public function actionHide()
 {
     $songId = Yii::app()->request->getParam('song_id', 0);
     $reason = "hide";
     $result = new stdClass();
     $result->errorCode = 1;
     $result->message = "success";
     $result->completed = 0;
     $songs = ToolsSongModel::model()->getSongToHide();
     /* echo '<pre>';print_r($songs);die('stop'); */
     $i = 0;
     if ($songs) {
         $song = $songs[0];
         $songId = $song['song_id'];
         $reason = $song['reason'];
         if ($songId > 0) {
             $connection = Yii::app()->db;
             $transaction = $connection->beginTransaction();
             try {
                 //UPDATE SONG_STATUS
                 $sql1 = "\tUPDATE song_status t1\n\t\t\t\t\t\tSET t1.approve_status=" . AdminSongStatusModel::REJECT . "\n\t\t\t\t\t\tWHERE t1.song_id = :song_id";
                 $command1 = $connection->createCommand($sql1);
                 $command1->bindParam(':song_id', $songId, PDO::PARAM_INT);
                 $res1 = $command1->execute();
                 // Insert to song_delete
                 $sql2 = "INSERT INTO song_deleted(song_id, deleted_by, deleted_reason, deleted_time)\n\t\t\t\t\t\tVALUE(:song_id, 1, :reason, NOW())\n\t\t\t\t\t\tON DUPLICATE KEY UPDATE song_id=:song_id, deleted_reason=:reason\n\t\t\t\t\t\t";
                 $command2 = $connection->createCommand($sql2);
                 $command2->bindParam(':song_id', $songId, PDO::PARAM_INT);
                 $command2->bindParam(':reason', $reason, PDO::PARAM_STR);
                 $res2 = $command2->execute();
                 //update song
                 $songModel = SongModel::model()->findByPk($songId);
                 if ($songModel) {
                     $songModel->updated_time = date("Y-m-d H:i:s");
                     $songModel->save(false);
                 } else {
                     $transaction->rollback();
                     $result->errorCode = 3;
                     $result->message = "Song Id Not Avaiable ({$songId}) <br />";
                     ToolsSongModel::model()->updateStatus($song['id'], $result->errorCode);
                     echo CJSON::encode($result);
                     Yii::app()->end();
                 }
                 //.... other SQL executions
                 $transaction->commit();
                 $result->message = "Hide success {$songId}";
                 /* $log = new KLogger('HIDE_LOG', KLogger::INFO);
                 			$log->LogInfo("Hide LOG: |sql1:".$sql1.$songId." |sql2: ".$sql2.$reason, false); */
             } catch (Exception $e) {
                 $result->errorCode = 2;
                 $result->message = "Exception " . $e->getMessage();
                 $transaction->rollback();
             }
         } else {
             $result->errorCode = 3;
             $result->message = "Song Id Not Avaiable ({$songId})";
         }
         ToolsSongModel::model()->updateStatus($song['id'], $result->errorCode);
     } else {
         $result->completed = 1;
         $result->message = "Completed";
     }
     $result->message .= "<br />";
     echo CJSON::encode($result);
     Yii::app()->end();
 }
Exemplo n.º 6
0
 public function actionAjaxMap()
 {
     Yii::import("application.models.web.*");
     $fileId = Yii::app()->request->getParam('fileId');
     $offset = Yii::app()->request->getParam('offset', 0);
     $return = new stdClass();
     $return->error = 0;
     $return->errorMessage = "";
     $return->success = 0;
     $return->data = array();
     try {
         $c = new CDbCriteria();
         $c->condition = "id=:FID";
         $c->params = array(":FID" => $fileId);
         $fileInfo = CopyrightInputFileModel::model()->find($c);
         if (isset($fileInfo)) {
             $content_type = $fileInfo->content_type;
             $c = new CDbCriteria();
             $c->condition = "input_file=:FID";
             $c->params = array(":FID" => $fileId);
             $c->order = "id ASC";
             $c->limit = 1;
             $c->offset = $offset;
             $item = CopyrightInputContentModel::model()->find($c);
             $Log = new KLogger("log_map", KLogger::INFO);
             if (empty($item)) {
                 $return->success = 1;
             } else {
                 $inputId = $item->id;
                 $countMapSong = $countMapVideo = 0;
                 if ($content_type == 'song') {
                     $cr = new CDbCriteria();
                     $cr->condition = "LOWER(TRIM(name)) LIKE :NAME AND cp_id=1";
                     $cr->params = array(":NAME" => strtolower(trim($item->name)) . "%");
                     $items = SongModel::model()->findAll($cr);
                     foreach ($items as $song) {
                         if (isset($song['cp_id']) && $song['cp_id'] == 1) {
                             $songName = strtoupper(trim($song['name']));
                             $songArtist = strtoupper(trim($song['artist_name']));
                             $songArtist = Common::strNormal($songArtist);
                             $itemName = strtoupper(trim($item->name));
                             $itemArtist = strtoupper(trim($item->artist));
                             $itemArtist = Common::strNormal($itemArtist);
                             if ($item->id == 574692) {
                                 $s = strlen($songName) - strlen($itemName);
                                 $d = strrpos($songArtist, $itemArtist);
                                 $Log->LogInfo("songName: {$songName} | itemName:{$itemName} |{$s}|| songArtist:{$songArtist} | itemArtist:{$itemArtist} " . json_encode($d), false);
                             }
                             if (strlen($songName) - strlen($itemName) > 3) {
                                 continue;
                             }
                             if (strrpos($songArtist, $itemArtist) === false) {
                                 continue;
                             }
                             $sql = "\n                                                                    INSERT INTO copyright_content_map(input_id,content_id,content_name,content_artist,content_type)\n                                                                    VALUES(:INPUT_ID,:CONTENT_ID,:CONTENT_NAME,:CONTENT_ARTIST,'song')\n                                                                    ON DUPLICATE KEY UPDATE content_name=:CONTENT_NAME_2, content_artist=:CONTENT_ARTIST_2\n                                                                ";
                             $contentId = $song['id'];
                             $contentName = $song['name'];
                             $contentArtist = $song['artist_name'];
                             $dataCmd = Yii::app()->db->createCommand($sql);
                             $dataCmd->bindParam(":INPUT_ID", $inputId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_ID", $contentId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_NAME", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_NAME_2", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST_2", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->execute();
                             $countMapSong++;
                         }
                     }
                     $return->error = 0;
                     $return->errorMessage = $item->name . ">> Bài hát ({$countMapSong})";
                 }
                 if ($content_type == 'video') {
                     $cr = new CDbCriteria();
                     $cr->condition = "LOWER(TRIM(name)) LIKE :NAME AND cp_id=1";
                     $cr->params = array(":NAME" => strtolower(trim($item->name)) . "%");
                     $items = VideoModel::model()->findAll($cr);
                     foreach ($items as $video) {
                         if (isset($video['cp_id']) && $video['cp_id'] == 1) {
                             $videoName = strtoupper(trim($video['name']));
                             $videoArtist = strtoupper(trim($video['artist_name']));
                             $videoArtist = Common::strNormal($videoArtist);
                             $itemName = strtoupper(trim($item->name));
                             $itemArtist = strtoupper(trim($item->artist));
                             $itemArtist = Common::strNormal($itemArtist);
                             if (strlen($videoName) - strlen($itemName) > 3) {
                                 continue;
                             }
                             if (strrpos($videoArtist, $itemArtist) === false) {
                                 continue;
                             }
                             $sql = "\n                                                                    INSERT INTO copyright_content_map(input_id,content_id,content_name,content_artist,content_type)\n                                                                    VALUES(:INPUT_ID,:CONTENT_ID,:CONTENT_NAME,:CONTENT_ARTIST,'video')\n                                                                    ON DUPLICATE KEY UPDATE content_name=:CONTENT_NAME_2, content_artist=:CONTENT_ARTIST_2\n                                                                ";
                             $contentId = $video['id'];
                             $contentName = $video['name'];
                             $contentArtist = $video['artist_name'];
                             $dataCmd = Yii::app()->db->createCommand($sql);
                             $dataCmd->bindParam(":INPUT_ID", $inputId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_ID", $contentId, PDO::PARAM_INT);
                             $dataCmd->bindParam(":CONTENT_NAME", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_NAME_2", $contentName, PDO::PARAM_STR);
                             $dataCmd->bindParam(":CONTENT_ARTIST_2", $contentArtist, PDO::PARAM_STR);
                             $dataCmd->execute();
                             $countMapVideo++;
                         }
                     }
                     $return->error = 0;
                     $return->errorMessage = $item->name . ">> Video ({$countMapVideo})";
                 }
             }
         }
     } catch (Exception $e) {
         $return->error = 500;
         $return->errorMessage = $e->getMessage();
     }
     echo json_encode($return);
     Yii::app()->end();
 }