Tvindex.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. class Tvindex extends Api
  6. {
  7. protected $noNeedLogin = ['indexdata','video_list','videoinfo','zhuanti','tudingc','search','history'];
  8. protected $noNeedRight = '*';
  9. //首页
  10. public function indexdata(){
  11. //左上角 logo,名称,4个按钮
  12. $data['index_logo'] = localpath_to_netpath(config('site.index_logo'));
  13. $data['index_appname'] = config('site.index_appname');
  14. $data['index_tuiding_switch'] = config('site.index_tuiding_switch');
  15. $data['index_search_switch'] = config('site.index_search_switch');
  16. $data['index_history_switch'] = config('site.index_history_switch');
  17. $data['index_dinggou_switch'] = config('site.index_dinggou_switch');
  18. //右上角 三行
  19. $data['index_right_1'] = config('site.index_right_1');
  20. $data['index_right_2'] = config('site.index_right_2');
  21. $data['index_right_3'] = config('site.index_right_3');
  22. //固定五个
  23. $data['index_top_video_image'] = localpath_to_netpath(config('site.index_top_video_image'));
  24. $data['index_top_video'] = localpath_to_netpath(config('site.index_top_video'));
  25. $page_wenzhen = Db::name('page_wenzhen')->field('id,name,image,url')->where('status',1)->order('weigh asc')->select();
  26. $data['page_wenzhen'] = list_domain_image($page_wenzhen,['image']);
  27. //大分类+剧集
  28. $video_type = Db::name('video_type')->field('id,name,showtype')->where('status',1)->where('type','neq',3)->order('weigh asc, id desc')->select();
  29. $video = Db::name('video')->field('id, video_type_id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])->order('weigh asc, id desc')->select();
  30. $video = list_domain_image($video, ['image']);
  31. //分布:1=左一右四,2=两行八个,3=一行四个,4=一行三个
  32. $more = [
  33. 'id' => 0,
  34. 'video_type_id' => 0,
  35. 'title' => '查看更多',
  36. 'image' => 'https://jiankang-1304634122.cos.ap-nanjing.myqcloud.com/uploads/20240529/37bd30cf2b80186b51f3bbfedb10a7d5.png',
  37. 'is_pay'=> 0,
  38. ];
  39. foreach($video_type as $key => $type){
  40. $type['child'] = [];
  41. //循环放入child
  42. $child = [];
  43. foreach($video as $k => $v){
  44. if($type['id'] == $v['video_type_id']){
  45. $child[] = $v;
  46. }
  47. }
  48. //查看更多
  49. if($type['showtype'] == 1){
  50. if(count($child) > 5){
  51. $child = array_chunk($child,4)[0];
  52. $child[] = $more;
  53. }
  54. }
  55. if($type['showtype'] == 2){
  56. if(count($child) > 8){
  57. $child = array_chunk($child,7)[0];
  58. $child[] = $more;
  59. }
  60. }
  61. if($type['showtype'] == 3){
  62. if(count($child) > 4){
  63. $child = array_chunk($child,3)[0];
  64. $child[] = $more;
  65. }
  66. }
  67. if($type['showtype'] == 4){
  68. if(count($child) > 3){
  69. $child = array_chunk($child,2)[0];
  70. $child[] = $more;
  71. }
  72. }
  73. $type['child'] = $child;
  74. $video_type[$key] = $type;
  75. }
  76. $data['video_type'] = $video_type;
  77. //精彩专题
  78. $data['buttom_name'] = '精彩专题';
  79. $buttom_list = Db::name('video_type')->field('id,name,image')->where('status',1)->where('type',3)->order('weigh asc,id desc')->limit(3)->select();
  80. $data['buttom_list'] = list_domain_image($buttom_list,['image']);
  81. $this->success('首页',$data);
  82. }
  83. //更多页
  84. //视频列表
  85. public function video_list() {
  86. $type_id = input('type_id', 0, 'intval'); //分类id
  87. if (!$type_id) {
  88. $this->error('您的网络开小差了~');
  89. }
  90. $video_type = Db::name('video_type')->where('id',$type_id)->value('name');
  91. $list = Db::name('video')->field('id, title, image, is_pay')->where(['video_type_id' => $type_id, 'status' => 1, 'inject_status' => 2])
  92. ->order('weigh asc, id desc')->select();
  93. $list = list_domain_image($list, ['image']);
  94. $result = [
  95. 'typename' => $video_type,
  96. 'videolist' => $list,
  97. ];
  98. $this->success('视频更多', $result);
  99. }
  100. //视频详情
  101. public function videoinfo() {
  102. $id = input('id', 0, 'intval'); //视频id
  103. if (!$id) {
  104. $this->error('您的网络开小差了');
  105. }
  106. $info = Db::name('video')->field('id,video_type_id, title, image, desc, is_pay, status, inject_status, seriesid, programid, movieid')
  107. ->where(['id' => $id])->find();
  108. if (!$info) {
  109. $this->error('数据不存在');
  110. }
  111. if ($info['status'] != 1) {
  112. $this->error('视频丢失');
  113. }
  114. if ($info['inject_status'] != 2) {
  115. $this->error('视频丢失');
  116. }
  117. $info['image'] = one_domain_image($info['image']);
  118. $info['is_collection'] = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
  119. $info['is_good'] = Db::name('video_good')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
  120. //剧集列表
  121. $juji = [];
  122. $video_list = Db::name('video')->field('id, title, image, is_pay')->where(['video_type_id' => $info['video_type_id'], 'status' => 1, 'inject_status' => 2])
  123. ->order('weigh asc, id desc')->select();
  124. if(!empty($video_list)){
  125. $video_list = list_domain_image($video_list, ['image']);
  126. $video_list = array_chunk($video_list,10);
  127. foreach($video_list as $page => $ten){
  128. $juji[] = [
  129. 'name'=> ($page*10 + 1) .'-'. ($page*10 + 10),
  130. 'list'=>$ten,
  131. ];
  132. }
  133. }
  134. //猜你喜欢
  135. $guess_list = Db::name('video')->field('id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])
  136. ->orderRaw('rand()')->limit(4)->select();
  137. $guess_list = list_domain_image($guess_list, ['image']);
  138. //记录浏览历史
  139. if($this->auth->isLogin()){
  140. $view_map = [
  141. 'user_id' => $this->auth->id,
  142. 'video_id' => $id,
  143. ];
  144. $check_view = Db::name('video_view')->where($view_map)->find();
  145. if($check_view){
  146. Db::name('video_view')->where($view_map)->update(['updatetime'=>time()]);
  147. }else{
  148. $view_map['createtime'] = time();
  149. $view_map['updatetime'] = time();
  150. Db::name('video_view')->insertGetId($view_map);
  151. }
  152. }
  153. //
  154. $result = [
  155. 'video_info' => $info,
  156. 'juji_list' => $juji,
  157. 'guess_list' => $guess_list,
  158. ];
  159. $this->success('详情', $result);
  160. }
  161. public function videoinfo_simple() {
  162. $id = input('id', 0, 'intval'); //视频id
  163. if (!$id) {
  164. $this->error('您的网络开小差了');
  165. }
  166. $info = Db::name('video')->field('id,video_type_id, title, image, desc, is_pay, status, inject_status, seriesid, programid, movieid')
  167. ->where(['id' => $id])->find();
  168. if (!$info) {
  169. $this->error('数据不存在');
  170. }
  171. if ($info['status'] != 1) {
  172. $this->error('视频丢失');
  173. }
  174. if ($info['inject_status'] != 2) {
  175. $this->error('视频丢失');
  176. }
  177. $info['image'] = one_domain_image($info['image']);
  178. $info['is_collection'] = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
  179. $info['is_good'] = Db::name('video_good')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
  180. //记录浏览历史
  181. if($this->auth->isLogin()){
  182. $view_map = [
  183. 'user_id' => $this->auth->id,
  184. 'video_id' => $id,
  185. ];
  186. $check_view = Db::name('video_view')->where($view_map)->find();
  187. if($check_view){
  188. Db::name('video_view')->where($view_map)->update(['updatetime'=>time()]);
  189. }else{
  190. $view_map['createtime'] = time();
  191. $view_map['updatetime'] = time();
  192. Db::name('video_view')->insertGetId($view_map);
  193. }
  194. }
  195. //
  196. $result = [
  197. 'video_info' => $info,
  198. ];
  199. $this->success('详情', $result);
  200. }
  201. //专题页
  202. public function zhuanti(){
  203. $type_id = input('type_id', 0, 'intval'); //分类id
  204. if (!$type_id) {
  205. $this->error('您的网络开小差了~');
  206. }
  207. $list = Db::name('video')->field('id, title, image, is_pay, status, inject_status, seriesid, programid, movieid')->where(['video_type_id' => $type_id, 'status' => 1, 'inject_status' => 2])->order('weigh asc, id desc')->limit(5)->select();
  208. $list = list_domain_image($list, ['image']);
  209. $this->success('视频', $list);
  210. }
  211. //退订服务
  212. public function tudingc()
  213. {
  214. $data = config('site.text_tuiding');
  215. $this->success('', $data);
  216. }
  217. //搜索页
  218. public function search(){
  219. $keyword = input('keyword','');
  220. //热门推荐4个
  221. if(empty($keyword)){
  222. $list = Db::name('video')->field('id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])
  223. ->orderRaw('rand()')->limit(12)->select();
  224. $list = list_domain_image($list, ['image']);
  225. }else{
  226. $list = Db::name('video')->field('id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])->where('search_title','LIKE','%'.$keyword.'%')->order('is_pay asc,weigh asc,id desc')->select();
  227. $list = list_domain_image($list, ['image']);
  228. }
  229. $this->success('视频', $list);
  230. }
  231. //浏览历史
  232. public function history(){
  233. if($this->auth->isLogin()){
  234. $video_view = Db::name('video_view')->where('user_id',$this->auth->id)->order('updatetime desc')->group('video_id')->column('video_id,updatetime');
  235. if(!empty($video_view)){
  236. $video_ids = implode(',',array_keys($video_view));
  237. $list = Db::name('video')->field('id, title, image, is_pay')->where(['status' => 1, 'inject_status' => 2])->where('id','IN',$video_ids)->orderRaw('field(id,'.$video_ids.')')->page($this->page,$this->pagenum)->select();
  238. $list = list_domain_image($list, ['image']);
  239. foreach($list as $key => $val){
  240. $list[$key]['history_time'] = $video_view[$val['id']];
  241. }
  242. }else{
  243. $list = [];
  244. }
  245. }else{
  246. $list = [];
  247. }
  248. $this->success('视频', $list);
  249. }
  250. //视频收藏/取消收藏
  251. public function video_collection() {
  252. $id = input('id', 0, 'intval');
  253. if (!$id) {
  254. $this->error('您的网络开小差了');
  255. }
  256. $info = Db::name('video')->where(['id' => $id])->find();
  257. if (!$info) {
  258. $this->error('数据不存在');
  259. }
  260. $info['image'] = one_domain_image($info['image']);
  261. //查询是否收藏
  262. $count = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
  263. //开启事务
  264. if ($count) {
  265. $result = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->delete();
  266. Db::name('video')->where('id',$id)->setDec('collect_number',1); //收藏数减少
  267. } else {
  268. $result = Db::name('video_collection')->insertGetId(['user_id' => $this->auth->id, 'video_id' => $id, 'createtime' => time()]);
  269. Db::name('video')->where('id',$id)->setInc('collect_number',1); //收藏数增加
  270. }
  271. if (!$result) {
  272. Db::rollback();
  273. $this->error('操作失败');
  274. }
  275. $url = 'http://meta-history.unso.gitv.tv/OTT/jscmcc/addThirdPartyCollectionRecord';
  276. $content = [
  277. 'cpPrvdName' => '健康e家',
  278. 'cpPrvCode' => '41000144',
  279. 'cpPrvType' => '1006',
  280. 'content' => $info['title'],
  281. 'ChnCode' => '1000020',
  282. 'contentId' => (string)$info['movieid'],
  283. 'extraContentID' => '',
  284. 'isEffective' => $info['status'],
  285. 'isPaid' => $info['is_pay'],
  286. 'collectionFlag' => $count ? 0 : 1,
  287. 'account' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'),
  288. 'cpPermission' => 'GITV',
  289. 'intent' => [
  290. 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
  291. 'package' => 'com.huxiu.heh.tv',
  292. 'component' => [
  293. 'pkg' => 'com.huxiu.heh.tv',
  294. 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
  295. ],
  296. 'extras' => [
  297. /*'cmd' => '',
  298. 'from' => '',
  299. 'media_id' => ''*/
  300. 'type_id' => $info['video_type_id'],
  301. 'id' => $info['id']
  302. ]
  303. ],
  304. 'imageURL' => $info['image']
  305. ];
  306. $content = json_encode($content, 320);
  307. $rt = httpRequest($url, 'POST', $content);
  308. file_put_contents('shoucang.txt',$id.'_'.$rt.PHP_EOL, FILE_APPEND);
  309. if (!$rt) {
  310. Db::rollback();
  311. $this->error('操作失败');
  312. }
  313. $rt = json_decode($rt, true);
  314. if (empty($rs) || $rt['code'] != 0) {
  315. Db::rollback();
  316. $this->error('操作失败');
  317. }
  318. //大数据上报
  319. $data = [
  320. 'favid' => (string)(config('data_cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
  321. 'UserID' => $this->auth->mobile,
  322. 'time' => date('Y-m-d H:i:s'),
  323. 'type' => $count ? 0 : 1,
  324. 'cpid' => config('data_cp_id'),
  325. 'albumid' => $id,
  326. 'albumname' => $info['title']
  327. ];
  328. $data = join(json_decode('"\u0001"', true), $data);
  329. $filename = date('Ymd').'_'.config('data_cp_id').'_userfavdata_1.dat';
  330. $check_filename = date('Ymd').'_'.config('data_cp_id').'_userfavdata_1.chk';
  331. error_log(print_r($data, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  332. error_log('', 3, './dashuju/' . $check_filename);
  333. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userfavdata.finish';
  334. error_log('', 3, './dashuju/' . $finish_filename);
  335. Db::commit();
  336. $this->success('操作成功');
  337. }
  338. //点赞视频、取消点赞
  339. public function video_good() {
  340. $id = input('id', 0, 'intval');
  341. if (!$id) {
  342. $this->error('您的网络开小差了');
  343. }
  344. $info = Db::name('video')->where(['id' => $id])->find();
  345. if (!$info) {
  346. $this->error('数据不存在');
  347. }
  348. //查询是否收藏
  349. $check = Db::name('video_good')->where(['user_id' => $this->auth->id, 'video_id' => $id])->find();
  350. //开启事务
  351. if ($check) {
  352. $result = Db::name('video_good')->where(['user_id' => $this->auth->id, 'video_id' => $id])->delete();
  353. Db::name('video')->where('id',$id)->setDec('good_number',1); //点赞数减少
  354. } else {
  355. $result = Db::name('video_good')->insertGetId(['user_id' => $this->auth->id, 'video_id' => $id, 'createtime' => time()]);
  356. Db::name('video')->where('id',$id)->setInc('good_number',1); //点赞数增加
  357. }
  358. $this->success('操作成功');
  359. }
  360. //用户观看行为(支付)
  361. public function payuserplay() {
  362. $id = input('id', 0, 'intval'); //视频id
  363. $sn = input('sn', '', 'trim'); //SN号
  364. $start_time = input('start_time', '', 'trim'); //yyyymmddhhmmss (24小时制),节目开始播放时间
  365. $end_time = input('end_time', '', 'trim'); //yyyymmddhhmmss (24小时制),节目结束播放时间,如果播放未结束,但是此时需要同步数据,填当前时间
  366. $csource = input('csource', 0, ''); //1:从搜索结果访问2:从用户收藏/书签访问3:从EPG访问4:从推荐页面访问5、其他
  367. if (!$id) {
  368. $this->error('您的网络开小差了');
  369. }
  370. $info = Db::name('video')->where(['id' => $id])->find();
  371. if (!$info) {
  372. $this->error('数据不存在');
  373. }
  374. $content = [
  375. 'UserID' => $this->auth->mobile,
  376. 'city' => '14',
  377. 'start_time' => $start_time,
  378. 'end_time' => $end_time,
  379. 'service_type' => 1,
  380. 'albumid' => $id,
  381. 'albumname' => $info['title'],
  382. 'csource' => $csource,
  383. 'SN' => $sn,
  384. 'ip' => request()->ip(),
  385. 'fee_type' => $info['is_pay'] == 1 ? 1 : '',
  386. 'flow' => '',
  387. 'product' => '',
  388. 'product_name' => '',
  389. 'info_source' => '02'
  390. ];
  391. $content = join('|', $content);
  392. $filename = date('YmdH').'_'.config('cp_id').'_userviewdata_1.dat';
  393. $check_filename = date('YmdH').'_'.config('cp_id').'_userviewdata_1.chk';
  394. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  395. error_log('', 3, './dashuju/' . $check_filename);
  396. $this->success('');
  397. }
  398. //视频播放记录
  399. public function playrecord() {
  400. $id = input('id', 0, 'intval');
  401. $total_time = input('total_time', 0, 'intval'); //总时长
  402. $start_time = input('start_time', 0, 'intval'); //开始看时间:相对时间
  403. $end_time = input('end_time', 0, 'intval'); //结束看时间:相对时间
  404. $log_type = input('log_type', 'watching', 'trim'); //begin:开始播放;watching:正在播放;end:结束播放
  405. if (!$id) {
  406. $this->error('您的网络开小差了');
  407. }
  408. $info = Db::name('video')->where(['id' => $id])->find();
  409. if (!$info) {
  410. $this->error('数据不存在');
  411. }
  412. if ($info['inject_status'] != 2) {
  413. $this->error('视频丢失');
  414. }
  415. $info['image'] = one_domain_image($info['image']);
  416. $url = 'http://meta-history.unso.gitv.tv/OTT/jscmcc/addThirdPartyHistoryRecord';
  417. $content = [
  418. 'cpPrvdName' => '健康e家',
  419. 'cpPrvCode' => '41000144',
  420. 'cpPrvType' => '1006',
  421. 'contentName' => $info['title'],
  422. 'ChnName' => '健康',
  423. 'ChnCode' => '1000020',
  424. 'contentId' => (string)$info['movieid'],
  425. 'extraContentID' => '',
  426. 'isEffective' => $info['status'],
  427. 'isPaid' => $info['is_pay'],
  428. 'contentTotalTime' => $total_time,
  429. 'startWatchTime' => $start_time,
  430. 'endWatchTime' => $end_time,
  431. 'playTime' => $end_time - $start_time,
  432. 'logType' => $log_type,
  433. 'account' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'),
  434. 'cpPermission' => 'GITV',
  435. 'intent' => [
  436. 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
  437. 'package' => 'com.huxiu.heh.tv',
  438. 'component' => [
  439. 'pkg' => 'com.huxiu.heh.tv',
  440. 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
  441. ],
  442. 'extras' => [
  443. /*'cmd' => '',
  444. 'from' => '',
  445. 'media_id' => ''*/
  446. 'type_id' => $info['video_type_id'],
  447. 'id' => $info['id']
  448. ]
  449. ],
  450. 'imageURL' => $info['image']
  451. ];
  452. $content = json_encode($content, 320);
  453. $rt = httpRequest($url, 'POST', $content);
  454. file_put_contents('bofang.txt',$id.'_'.$rt.PHP_EOL, FILE_APPEND);
  455. if (!$rt) {
  456. $this->error('同步失败');
  457. }
  458. $rt = json_decode($rt, true);
  459. if ($rt['code'] != 0) {
  460. $this->error('同步失败');
  461. }
  462. $this->success('同步成功');
  463. }
  464. //用户观看行为(大数据)
  465. public function userplay() {
  466. $id = input('id', 0, 'intval'); //视频id
  467. $sn = input('sn', '', 'trim'); //SN号
  468. $start_time = input('start_time', '', 'trim'); //YYYY-MM-DD HH:MM:SS(24小时制)节目开始播放时间
  469. $end_time = input('end_time', '', 'trim'); //YYYY-MM-DD HH:MM:SS(24小时制)节目结束播放时间
  470. $csource = input('csource', 0, ''); //1:从搜索结果访问2:从用户收藏/书签访问3:从EPG访问4:从推荐页面访问5:从猜你喜欢个性化推荐页面访问(带上推荐接口的trace_id)99:其他
  471. $trace_id = input('trace_id', '', 'trim');
  472. $istry = input('istry', 0, 'intval'); //0非试看 1试看
  473. $start_posi = input('start_posi', 0, 'intval'); //播放起始点相对于影片起始点的时长,单位秒,例如从影片第 600 秒开始观看
  474. if (!$id) {
  475. $this->error('您的网络开小差了');
  476. }
  477. $info = Db::name('video')->where(['id' => $id])->find();
  478. if (!$info) {
  479. $this->error('数据不存在');
  480. }
  481. $content = [
  482. 'playid' => (string)(config('data_cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
  483. 'UserID' => $this->auth->mobile,
  484. 'SN' => $sn,
  485. 'start_time' => $start_time,
  486. 'end_time' => $end_time,
  487. 'service_type' => 1,
  488. 'cpid' => config('data_cp_id'),
  489. 'albumid' => $id,
  490. 'albumname' => $info['title'],
  491. 'videoid' => $id,
  492. 'videoname' => $info['title'],
  493. 'csource' => $csource,
  494. 'trace_id' => $trace_id,
  495. 'fee_type' => $info['is_pay'] == 1 ? 1 : 4,
  496. 'istry' => $istry,
  497. 'iscon' => 0,
  498. 'start_posi' => $start_posi
  499. ];
  500. $content = join(json_decode('"\u0001"', true), $content);
  501. $filename = date('Ymd').'_'.config('data_cp_id').'_userplaydata_1.dat';
  502. $check_filename = date('Ymd').'_'.config('data_cp_id').'_userplaydata_1.chk';
  503. error_log(print_r($content, 1) . PHP_EOL, 3, './dashuju/' . $filename);
  504. error_log('', 3, './dashuju/' . $check_filename);
  505. $finish_filename = date('Ymd') . '_' . config('data_cp_id') . '_userplaydata.finish';
  506. error_log('', 3, './dashuju/' . $finish_filename);
  507. $this->success('');
  508. }
  509. //获取特殊机型
  510. public function special_models() {
  511. $special_models = config('site.special_models');
  512. $special_models = explode(',', $special_models);
  513. $this->success('获取特殊机型', $special_models);
  514. }
  515. //前端报错记录
  516. public function app_error() {
  517. $this->success('');
  518. }
  519. /** * * @param string $string 需要加密的字符串 * @param string $key 密钥 * @return string */
  520. private function encrypt($string, $key) {
  521. // $key = substr(openssl_digest(openssl_digest($key, 'sha1', true), 'sha1', true), 0, 16);
  522. $data = openssl_encrypt($string, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
  523. $data = bin2hex($data);
  524. return $data;
  525. }
  526. /** * @param string $string 需要解密的字符串 * @param string $key 密钥 * @return string */
  527. private function decrypt($string, $key) {
  528. // $key = substr(openssl_digest(openssl_digest($key, 'sha1', true), 'sha1', true), 0, 16);
  529. $decrypted = openssl_decrypt(hex2bin($string), 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
  530. return $decrypted;
  531. }
  532. }