MediaonesixController.class.php 143 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588
  1. <?php
  2. namespace bibidd\Controller;
  3. use Think\Controller;
  4. use Bibidd\Controller\CommonBaseController;
  5. class MediaonesixController extends CommonBaseController
  6. {
  7. /**
  8. * 测试功能
  9. * @param $templateid []
  10. * @return $type 消息类型
  11. */
  12. public function testone()
  13. {
  14. $jinri_start_time = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
  15. $jinri_end_time = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
  16. $zuo_start_time = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
  17. $zuo_end_time = mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 1;
  18. echo PHP_EOL.$jinri_start_time;
  19. echo PHP_EOL.$jinri_end_time;
  20. echo PHP_EOL.$zuo_start_time;
  21. echo PHP_EOL.$zuo_end_time;
  22. echo PHP_EOL."q---9951";
  23. // $yn_ip_yiyou = M("ip_jilasdasu")->where("ip='$ip'")->getField("id");
  24. }
  25. //封装返回的数据
  26. /**
  27. * 视频列表相关 视频列表
  28. *首页视频列表
  29. * @param type [zuixin 最新,remen 热门,tuijian 推荐,resou 热搜,]
  30. * @param page [页数]
  31. * @return $type 消息类型
  32. */
  33. public function video_info_list()
  34. {
  35. header('Content-Type:text/json;charset=utf-8');
  36. header('Access-Control-Allow-Origin:*');
  37. header("Access-Contr-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  38. header('Access-Control-Allow-Methods:POST');
  39. header('Access-Control-Expose-Headers:*');
  40. if (!empty($_POST)) {
  41. $uid = $_POST['uid'];
  42. if ($uid == '') {
  43. $uid = 0;
  44. }
  45. $type = $_POST['type'];
  46. $page = $_POST['page'];
  47. $one_size = 36;
  48. $page_one = ($page - 1) * $one_size;
  49. $jiben = $_POST['jiben_type'];
  50. switch ($jiben) {
  51. case 'zuixin':
  52. $jiben_sql = 'id desc';
  53. break;
  54. case 'remen':
  55. $jiben_sql = 'views desc';
  56. break;
  57. case 'guankan':
  58. $jiben_sql = 'views desc';
  59. break;
  60. case 'dianzan':
  61. $jiben_sql = 'thumbs_up desc';
  62. break;
  63. case 'shichang':
  64. $jiben_sql = 'time_chuo desc';
  65. break;
  66. default:
  67. $jiben_sql = '';
  68. break;
  69. }
  70. switch ($type) {
  71. //最新
  72. case 'zuixin':
  73. $ip = get_client_ip();
  74. $user_list['ip'] = $ip;
  75. $user_list['uid'] = $uid;
  76. $user_list['time'] = time();
  77. $yn_ip_yiyou = M("ip_jilu")->where("ip='$ip'")->getField("id");
  78. if ($yn_ip_yiyou) {
  79. M("ip_jilu")->where("ip='$ip'")->save($user_list);
  80. } else {
  81. $user_list['add_time'] = time();
  82. M("ip_jilu")->add($user_list);
  83. }
  84. // $data['all_num'] = M("video_list_test")->count();
  85. if ($page == 1) {
  86. $video_list = M("tuijian_video")->where("id=1")->getField("str");
  87. $video_list = json_decode($video_list, $assoc = true);
  88. foreach ($video_list as $key1 => $value1) {
  89. $video_id = $value1['id'];
  90. $video_list[$key1]['views'] = M("video_list_test")->where("id=$video_id")->getField("views");;
  91. $video_list[$key1]['thumbs_up'] = M("video_list_test")->where("id=$video_id")->getField("thumbs_up");;
  92. $video_list[$key1]['favorite'] = M("video_list_test")->where("id=$video_id")->getField("favorite");;
  93. $video_list[$key1]['time_chuo'] = M("video_list_test")->where("id=$video_id")->getField("time_chuo");;
  94. $video_list[$key1]['top_img'] = 'https://www.bibidd.com/bibidd_testtest/A.jpg';
  95. $video_list[$key1]['title'] = '102411';
  96. }
  97. $data['code'] = '200';
  98. $data['data'] = $video_list;
  99. echo json_encode($data);
  100. die();
  101. }
  102. $video_list = M("video_list_test")->order("id desc")->LIMIT($page_one, 60)->select();
  103. // echo PHP_EOL.M("video_list_test")->_sql();
  104. $data['code'] = '200';
  105. $data['data'] = $video_list;
  106. echo json_encode($data);
  107. break;
  108. //热门
  109. case 'remen':
  110. //获取该获取那天的数据
  111. $jintian = M("suiji_num")->where("id=1")->getField("time");
  112. //获取今日页数
  113. $video_list_suiji_list = M("video_twelve_suiji")->where("time='$jintian'")->LIMIT($page_one, $one_size)->order('rand()')->Field('v_id')->select();
  114. $id_list = array_column($video_list_suiji_list, 'v_id');
  115. $sql_charu = "";
  116. foreach ($video_list_suiji_list as $key1 => $value1) {
  117. $duifang_id = $value1['v_id'];;
  118. $xianzhi_one = " or id='$duifang_id'";
  119. $sql_charu .= $xianzhi_one;
  120. }
  121. $video_list = M("video_list_test")->where("id=0 $sql_charu")->select();
  122. //牛逼
  123. foreach ($video_list as $key => $value) {
  124. $id = $value['id'];
  125. $suozai_num = array_search("$id", $id_list);
  126. $id_list[$suozai_num] = $value;
  127. }
  128. $data['all_num'] = M("video_twelve_suiji")->where("time='$jintian'")->count();
  129. $data['code'] = '200';
  130. //推荐1
  131. case 'tuijian':
  132. //获取该获取那天的数据
  133. $jintian = M("suiji_num")->where("id=1")->getField("time");
  134. //获取今日页数
  135. $video_list_suiji_list = M("video_twelve_suiji")->where("type='tuijian' and time='$jintian'")->LIMIT($page_one, $one_size)->Field('v_id')->select();
  136. $id_list = array_column($video_list_suiji_list, 'v_id');
  137. $sql_charu = "";
  138. foreach ($video_list_suiji_list as $key1 => $value1) {
  139. $duifang_id = $value1['v_id'];;
  140. $xianzhi_one = " or id='$duifang_id'";
  141. $sql_charu .= $xianzhi_one;
  142. }
  143. $video_list = M("video_list_test")->where("id=0 $sql_charu")->select();
  144. //牛逼
  145. foreach ($video_list as $key => $value) {
  146. $id = $value['id'];
  147. $suozai_num = array_search("$id", $id_list);
  148. $id_list[$suozai_num] = $value;
  149. }
  150. $data['all_num'] = M("video_twelve_suiji")->where("type='tuijian' and time='$jintian'")->count();
  151. $data['code'] = '200';
  152. break;
  153. //动漫1列表
  154. case 'Anime':
  155. //获取该获取那天的数据
  156. $jintian = M("suiji_num")->where("id=1")->getField("time");
  157. //获取今日页数
  158. $video_list_suiji_list = M("video_twelve_suiji")->where("type='Anime' and time='$jintian'")->LIMIT($page_one, $one_size)->Field('v_id')->select();
  159. $id_list = array_column($video_list_suiji_list, 'v_id');
  160. $sql_charu = "";
  161. foreach ($video_list_suiji_list as $key1 => $value1) {
  162. $duifang_id = $value1['v_id'];;
  163. $xianzhi_one = " or id='$duifang_id'";
  164. $sql_charu .= $xianzhi_one;
  165. }
  166. $video_list = M("video_list_test")->where("id=0 $sql_charu")->select();
  167. //牛逼
  168. foreach ($video_list as $key => $value) {
  169. $id = $value['id'];
  170. $suozai_num = array_search("$id", $id_list);
  171. $id_list[$suozai_num] = $value;
  172. }
  173. $data['all_num'] = M("video_twelve_suiji")->where("type='Anime' and time='$jintian'")->count();
  174. $data['code'] = '200';
  175. break;
  176. //热搜亚洲1
  177. case 'Asian':
  178. $jintian = M("suiji_num")->where("id=1")->getField("time");
  179. //获取今日页数
  180. $video_list_suiji_list = M("video_twelve_suiji")->where("type='Asian' and time='$jintian'")->LIMIT($page_one, $one_size)->Field('v_id')->select();
  181. $id_list = array_column($video_list_suiji_list, 'v_id');
  182. $sql_charu = "";
  183. foreach ($video_list_suiji_list as $key1 => $value1) {
  184. $duifang_id = $value1['v_id'];;
  185. $xianzhi_one = " or id='$duifang_id'";
  186. $sql_charu .= $xianzhi_one;
  187. }
  188. $video_list = M("video_list_test")->where("id=0 $sql_charu")->select();
  189. //牛逼
  190. foreach ($video_list as $key => $value) {
  191. $id = $value['id'];
  192. $suozai_num = array_search("$id", $id_list);
  193. $id_list[$suozai_num] = $value;
  194. }
  195. $data['all_num'] = M("video_twelve_suiji")->where("type='Asian' and time='$jintian'")->count();
  196. $data['code'] = '200';
  197. break;
  198. //黑料
  199. case 'HL':
  200. $id_list = M("video_list_test")->where("site='HL'")->order("id desc")->LIMIT($page_one, $one_size)->select();
  201. $data['all_num'] =M("video_list_test")->where("site='HL'")->order("id desc")->count();
  202. $data['code'] = '200';
  203. break;
  204. //海角
  205. case 'WB':
  206. $id_list = M("video_list_test")->where("site='WB'")->order("id desc")->LIMIT($page_one, $one_size)->select();
  207. $data['all_num'] =M("video_list_test")->where("site='WB'")->order("id desc")->count();
  208. $data['code'] = '200';
  209. break;
  210. //反差
  211. case 'FC':
  212. $six = 0;
  213. $id_list = M("video_list_test")->where("site='FC'")->order("id desc")->LIMIT($page_one, $one_size)->select();
  214. $goumai_str_list = M("hj_fc_buy_record")->where("uid=$uid")->field("v_id")->select();
  215. $goumai_str = ',';
  216. foreach ($goumai_str_list as $key1 => $value1) {
  217. $vv_id = $value1['v_id'];
  218. $goumai_str .= "$vv_id".",";
  219. }
  220. // echo PHP_EOL.$goumai_str;
  221. //废弃需求 6个钟有个免费的
  222. foreach ($id_list as $key => $value) {
  223. $six++;
  224. $now_vid = $value['id'];
  225. $needle = ",$now_vid,";
  226. if (strpos($goumai_str, $needle) !== false){
  227. $id_list[$key]['coins'] = "-1";
  228. }
  229. }
  230. // else{
  231. // if ($six % 6 == 0) {
  232. // $id_list[$key]['coins'] = "0";
  233. // }
  234. // }
  235. $data['all_num'] = M("video_list_test")->where("site='FC'")->count();
  236. $data['code'] = '200';
  237. break;
  238. default:
  239. echo "type error";
  240. }
  241. //获取广告列表
  242. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  243. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  244. $jia_num = 6;
  245. $qishi_num = 0;
  246. $data_list_number = count($id_list);
  247. $quzheng_num = floor($data_list_number / 6);
  248. foreach ($adv_list as $key => $value) {
  249. $charu_array = array();
  250. $charu_array = array($adv_list[$key]);
  251. array_splice($id_list, $jia_num, 0, $charu_array);
  252. $jia_num += 7;
  253. $qishi_num += 1;
  254. if ($qishi_num >= $quzheng_num) {
  255. break;
  256. }
  257. }
  258. $data['data'] = $id_list;
  259. echo json_encode($data);
  260. } else {
  261. echo $this->returnData();
  262. }
  263. }
  264. /**
  265. * 推荐第一页
  266. * @param $templateid []
  267. * @return $type 消息类型
  268. */
  269. public function tuijian_one_page($uid, $page_one)
  270. {
  271. $yn_look_video = M("views_video_type_jilu")->where("uid=$uid")->field("video_type_str")->select();
  272. if ($yn_look_video) {
  273. $yan_feng_view_type_str = $yn_look_video[0]['video_type_str'];
  274. $feng_view_type_str = explode(',', $yan_feng_view_type_str);
  275. $new_type_num = array_count_values($feng_view_type_str);
  276. print_r($new_type_num);
  277. arsort($new_type_num);
  278. // var_dump($new_type_num);
  279. $sql_charu = "";
  280. $new_type_num = array_slice($new_type_num, 0, 5);
  281. echo PHP_EOL.'----------';
  282. print_r($new_type_num);
  283. foreach ($new_type_num as $key => $value) {
  284. $type_name = $key;
  285. $xianzhi_one = " or type like '%,$type_name,%' or china_type like '%,$type_name,%' ";
  286. $sql_charu .= $xianzhi_one;
  287. }
  288. $video_list = M("video_list_test")->where("id=0 $sql_charu")->LIMIT($page_one, 60)->order('rand()')->select();
  289. $data['code'] = '200';
  290. //获取广告列表
  291. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  292. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  293. $jia_num = 5;
  294. $qishi_num = 0;
  295. $data_list_number = count($video_list);
  296. $quzheng_num = floor($data_list_number / 5);
  297. foreach ($adv_list as $key => $value) {
  298. $charu_array = array($adv_list[$key]);
  299. array_splice($video_list, $jia_num, 0, $charu_array);
  300. $jia_num += 6;
  301. $qishi_num += 1;
  302. if ($qishi_num >= $quzheng_num) {
  303. break;
  304. }
  305. }
  306. $data['data'] = $video_list;
  307. echo json_encode($data);
  308. } else {
  309. $video_list = M("video_list_test")->order("thumbs_up desc")->LIMIT($page_one, 60)->select();
  310. $data['code'] = '200';
  311. //获取广告列表
  312. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  313. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  314. $jia_num = 5;
  315. $qishi_num = 0;
  316. $data_list_number = count($video_list);
  317. $quzheng_num = floor($data_list_number / 5);
  318. foreach ($adv_list as $key => $value) {
  319. $charu_array = array($adv_list[$key]);
  320. array_splice($video_list, $jia_num, 0, $charu_array);
  321. $jia_num += 6;
  322. $qishi_num += 1;
  323. if ($qishi_num >= $quzheng_num) {
  324. break;
  325. }
  326. }
  327. $data['data'] = $video_list;
  328. echo json_encode($data);
  329. }
  330. }
  331. protected function returnData()
  332. {
  333. header('Content-Type:text/json;charset=utf-8');
  334. header('Access-Control-Allow-Origin:*');
  335. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  336. header('Access-Control-Allow-Methods:POST');
  337. header('Access-Control-Expose-Headers:*');
  338. $data['status'] = '0';
  339. $data['code'] = '202';//未携带参数,请求失败
  340. $data['message'] = 'error';
  341. echo json_encode($data);
  342. }
  343. /**
  344. * 视频详情
  345. * @param video_id [video_id]
  346. * @return $type 消息类型
  347. * 1.2更新 进入详情后 将用户观看视频次数加1
  348. */
  349. public function video_detail()
  350. {
  351. header('Content-Type:text/json;charset=utf-8');
  352. header('Access-Control-Allow-Origin:*');
  353. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  354. header('Access-Control-Allow-Methods:POST');
  355. header('Access-Control-Expose-Headers:*');
  356. if (!empty($_POST)) {
  357. $LNG = $_POST['LNG'];
  358. $uid = $_POST['uid'];
  359. $video_id = $_POST['video_id'];
  360. //判断用户是否是异常用户
  361. //判读是否登录
  362. if ($uid == '0' or $uid == '' or $uid=='undefined') {
  363. $data['message'] = 'error';
  364. echo json_encode($data);
  365. die();
  366. }
  367. $huiyuan_time =M("user_info")->where("id=$uid")->getField("vip_over_time");
  368. $now_time = time();
  369. if ($huiyuan_time>$now_time) {
  370. $video_url = M("video_info_test")->where("video_id=$video_id")->getField("video_url");
  371. $now_views = M("user_info")->where("id=$uid")->getField("views_num");
  372. //如果用户当日观看超过1000则关进小黑屋 异常处理
  373. $yn_black = M("black_box")->where("uid=$uid")->getField("id");
  374. if ($yn_black) {
  375. $data['message'] = 'error_403';
  376. echo json_encode($data);
  377. die();
  378. }
  379. if ($now_views==3000 or $now_views>3000) {
  380. $data['message'] = 'error_403';
  381. $userip = $this->get_bb_ip();
  382. $ttime = time();
  383. $ddate = date("Y-m-d H:i:s",$ttime);
  384. $last_login_list['time'] = $ttime;
  385. $last_login_list['time_date'] = $ddate;
  386. $last_login_list['uid'] = $uid;
  387. $last_login_list['ip'] = $userip;
  388. M("black_box")->add($last_login_list);
  389. echo json_encode($data);
  390. die();
  391. }
  392. } else {
  393. $video_url = M("video_info_test")->where("video_id=$video_id")->getField("video_url");
  394. }
  395. switch ($LNG) {
  396. case 'CN':
  397. $now_zan_num_list = M("video_list_test")->where("id=$video_id")->Field("views,thumbs_up,china_type,title")->select();
  398. $video_type_list_map = $now_zan_num_list[0]['china_type'];
  399. break;
  400. case 'EN':
  401. $now_zan_num_list = M("video_list_test")->where("id=$video_id")->Field("views,thumbs_up,type,title")->select();
  402. $video_type_list_map = $now_zan_num_list[0]['type'];
  403. break;
  404. default:
  405. echo "type error";
  406. }
  407. $dianzan_num =$now_zan_num_list[0]['thumbs_up'];
  408. $guankan_num = $now_zan_num_list[0]['views'];
  409. $video_name = $now_zan_num_list[0]['title'];
  410. $vidoe_tpe_list = explode(',', $video_type_list_map);
  411. $vidoe_tpe_list = array_filter($vidoe_tpe_list);
  412. $vidoe_tpe_list = array_values($vidoe_tpe_list);
  413. //1.2更新处
  414. //查询当前用户观看次数并加1更新
  415. $now_views = M("user_info")->where("id=$uid")->getField("views_num");
  416. $free_list = M("free_video_zb")->where("id=1")->field("free_video,url")->select();
  417. $free_id = $free_list[0]['free_video'];
  418. if ($free_id==$video_id) {
  419. $video_url = M("video_info_test")->where("video_id=$video_id")->getField("video_url");
  420. }else{
  421. $new_views_num['views_num'] = $now_views + 1;
  422. }
  423. M("user_info")->where("id=$uid")->save($new_views_num);
  424. $adv_list = M("slgj_advert_list")->where("type='片头广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(1)->select();
  425. M('video_list_test')->where("id=$video_id")->setInc('v_really',1);
  426. if ($video_url==null){
  427. $heiliao_list = M("heiliao_haijiao_books")->where("id=$video_id")->field("hj_video_url,head_img")->select()[0];
  428. $video_url = $heiliao_list['hj_video_url'];
  429. }
  430. $data['adv'] = $adv_list[0];
  431. $data['data'] = $video_url;
  432. $data['views'] = $guankan_num;
  433. $data['thumbs_up'] = $dianzan_num;
  434. $data['video_name'] = $video_name;
  435. $data['type_list'] = $vidoe_tpe_list;
  436. echo json_encode($data);
  437. } else {
  438. echo $this->returnData();
  439. }
  440. }
  441. /**
  442. * 图片列表相关
  443. * @param $templateid []
  444. * @return $type 消息类型
  445. */
  446. public function imgs_info_list()
  447. {
  448. header('Content-Type:text/json;charset=utf-8');
  449. header('Access-Control-Allow-Origin:*');
  450. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  451. header('Access-Control-Allow-Methods:POST');
  452. header('Access-Control-Expose-Headers:*');
  453. if (!empty($_POST)) {
  454. $type = $_POST['type'];
  455. $page = $_POST['page'];
  456. $page_one = ($page - 1) * 36;
  457. switch ($type) {
  458. //最新
  459. case 'zuixin':
  460. $video_list = M("imgs_list")->LIMIT($page_one, 36)->order("id desc")->select();
  461. $data['all_num'] = M("imgs_list")->count();
  462. $data['code'] = '200';
  463. $data['data'] = $video_list;
  464. echo json_encode($data);
  465. break;
  466. //热门
  467. case 'remen':
  468. $video_list = M("imgs_list")->LIMIT($page_one, 36)->order("views desc")->select();
  469. $data['all_num'] = M("imgs_list")->count();
  470. $data['code'] = '200';
  471. $data['data'] = $video_list;
  472. echo json_encode($data);
  473. break;
  474. //推荐
  475. case 'tuijian':
  476. $video_list = M("imgs_list")->LIMIT($page_one, 36)->order("thumbs_up desc")->select();
  477. $data['all_num'] = M("imgs_list")->count();
  478. $data['code'] = '200';
  479. $data['data'] = $video_list;
  480. echo json_encode($data);
  481. break;
  482. //热搜
  483. case 'resou':
  484. break;
  485. default:
  486. echo "type error";
  487. }
  488. } else {
  489. echo $this->returnData();
  490. }
  491. }
  492. /**
  493. * 图片详情
  494. * @param imgs_id [图片id]
  495. * @return $type 消息类型
  496. */
  497. public function img_detail()
  498. {
  499. header('Content-Type:text/json;charset=utf-8');
  500. header('Access-Control-Allow-Origin:*');
  501. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  502. header('Access-Control-Allow-Methods:POST');
  503. header('Access-Control-Expose-Headers:*');
  504. if (!empty($_POST)) {
  505. $img_id = $_POST['imgs_id'];
  506. $img_list_str = M("imgs_info")->where("imgs_id=$img_id")->getField("imgs_url");
  507. $now_zan_num = M("video_list_test")->where("id=$img_id")->getField("views");
  508. $now_zan_num += 1;
  509. $new_zan['views'] = $now_zan_num;
  510. $yn_save = M("imgs_list")->where("id=$img_id")->save($new_zan);
  511. $img_list = explode(',', $img_list_str);
  512. $data['data'] = $img_list;
  513. echo json_encode($data);
  514. } else {
  515. echo $this->returnData();
  516. }
  517. }
  518. /**
  519. * 发送评论
  520. * @param type [需要评论的类型 video or img]
  521. * @param cid [这个视频或者图片的 id]
  522. * @param uid [用户id]
  523. * @param username [用户名称]
  524. * @param content [评论内容]
  525. * @return $type 消息类型
  526. */
  527. public function add_comments()
  528. {
  529. header('Content-Type:text/json;charset=utf-8');
  530. header('Access-Control-Allow-Origin:*');
  531. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  532. header('Access-Control-Allow-Methods:POST');
  533. header('Access-Control-Expose-Headers:*');
  534. if (!empty($_POST)) {
  535. $type = $_POST['type'];
  536. $cid = $_POST['cid'];
  537. $uid = $_POST['uid'];
  538. $username = M("user_info")->where("id=$uid")->getField("name");;
  539. $comment_list['time'] = time();
  540. $comment_list['content'] = $_POST['content'];
  541. $comment_list['uid'] = $uid;
  542. $comment_list['username'] = $username;
  543. switch ($type) {
  544. case 'video':
  545. $comment_list['video_id'] = $cid;
  546. $yn_add = M("video_comments")->add($comment_list);
  547. if ($yn_add) {
  548. $data['message'] = 'ok';
  549. echo json_encode($data);
  550. } else {
  551. $data['message'] = 'error';
  552. echo json_encode($data);
  553. }
  554. break;
  555. case 'img':
  556. $comment_list['img_id'] = $cid;
  557. $yn_add = M("img_comments")->add($comment_list);
  558. if ($yn_add) {
  559. $data['message'] = 'ok';
  560. echo json_encode($data);
  561. } else {
  562. $data['message'] = 'error';
  563. echo json_encode($data);
  564. }
  565. break;
  566. default:
  567. echo "type error";
  568. }
  569. } else {
  570. echo $this->returnData();
  571. }
  572. }
  573. /**
  574. * 评论列表
  575. * @param type [video or img]
  576. * @param cid [这个视频或者图片的 id]
  577. * @return $type 消息类型
  578. */
  579. public function comments_list()
  580. {
  581. header('Content-Type:text/json;charset=utf-8');
  582. header('Access-Control-Allow-Origin:*');
  583. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  584. header('Access-Control-Allow-Methods:POST');
  585. header('Access-Control-Expose-Headers:*');
  586. if (!empty($_POST)) {
  587. $type = $_POST['type'];
  588. $cid = $_POST['cid'];
  589. switch ($type) {
  590. case 'video':
  591. $yn_se = M("video_comments")->where("video_id=$cid")->field("id,content,time,username,uid,time")->select();
  592. if ($yn_se) {
  593. $data['message'] = 'ok';
  594. $data['data'] = $yn_se;
  595. echo json_encode($data);
  596. } else {
  597. $data['message'] = 'ok';
  598. $data['data'] = [];
  599. echo json_encode($data);
  600. }
  601. break;
  602. case 'img':
  603. $yn_se = M("img_comment")->where("img_id=$cid")->field("id,content,time,username,uid,time")->select();
  604. if ($yn_se) {
  605. $data['message'] = 'ok';
  606. $data['data'] = $yn_se;
  607. echo json_encode($data);
  608. } else {
  609. $data['message'] = 'ok';
  610. $data['data'] = [];
  611. echo json_encode($data);
  612. }
  613. break;
  614. default:
  615. echo "type error";
  616. }
  617. } else {
  618. echo $this->returnData();
  619. }
  620. }
  621. /**
  622. * 点赞视频或图片
  623. * @param uid [用户id]
  624. * @param type [img or video]
  625. * @param cid [这个视频或者图片的 id]
  626. * @return $type 消息类型
  627. */
  628. public function dianzan_img_video()
  629. {
  630. header('Content-Type:text/json;charset=utf-8');
  631. header('Access-Control-Allow-Origin:*');
  632. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  633. header('Access-Control-Allow-Methods:POST');
  634. header('Access-Control-Expose-Headers:*');
  635. if (!empty($_POST)) {
  636. $uid = $_POST['uid'];
  637. $type = $_POST['type'];
  638. $cid = $_POST['cid'];
  639. switch ($type) {
  640. case 'video':
  641. $now_zan_num = M("video_list_test")->where("id=$cid")->getField("thumbs_up");
  642. $now_zan_num += 1;
  643. $new_zan['thumbs_up'] = $now_zan_num;
  644. $yn_save = M("video_list_test")->where("id=$cid")->save($new_zan);
  645. //添加到点赞表
  646. $dianzan_list['uid'] = $uid;
  647. $dianzan_list['v_id'] = $cid;
  648. if ($uid != 0) {
  649. M("dianzan_video")->add($dianzan_list);
  650. }
  651. if ($yn_save) {
  652. $data['message'] = 'ok';
  653. echo json_encode($data);
  654. } else {
  655. $data['message'] = 'erroe';
  656. echo json_encode($data);
  657. }
  658. break;
  659. case 'img':
  660. $now_zan_num = M("imgs_list")->where("id=$cid")->getField("thumbs_up");
  661. $now_zan_num += 1;
  662. $new_zan['thumbs_up'] = $now_zan_num;
  663. $yn_save = M("imgs_list")->where("id=$cid")->save($new_zan);
  664. if ($yn_save) {
  665. $data['message'] = 'ok';
  666. echo json_encode($data);
  667. } else {
  668. $data['message'] = 'erroe';
  669. echo json_encode($data);
  670. }
  671. break;
  672. default:
  673. echo "type error";
  674. }
  675. } else {
  676. echo $this->returnData();
  677. }
  678. }
  679. /**
  680. * 取消点赞
  681. * @param uid [用户id]
  682. * @param v_id [视频id]
  683. * @return $type 消息类型
  684. */
  685. public function close_video_up()
  686. {
  687. header('Content-Type:text/json;charset=utf-8');
  688. header('Access-Control-Allow-Origin:*');
  689. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  690. header('Access-Control-Allow-Methods:POST');
  691. header('Access-Control-Expose-Headers:*');
  692. if (!empty($_POST)) {
  693. $uid = $_POST['uid'];
  694. $v_id = $_POST['v_id'];
  695. $now_zan_num = M("video_list_test")->where("id=$v_id")->getField("thumbs_up");
  696. $now_zan_num -= 1;
  697. $new_zan['thumbs_up'] = $now_zan_num;
  698. $yn_sa = M("video_list_test")->where("id=$v_id")->save($new_zan);
  699. $yn_de = M("dianzan_video")->where("uid=$uid and v_id=$v_id")->delete();
  700. if ($yn_sa and $yn_de) {
  701. $data['message'] = 'close_yes';
  702. echo json_encode($data);
  703. } else {
  704. $data['message'] = 'close_no';
  705. echo json_encode($data);
  706. }
  707. } else {
  708. echo $this->returnData();
  709. }
  710. }
  711. /**
  712. * 判断是否点赞过
  713. * @param uid [用户id]
  714. * @param v_id [视频id]
  715. * @return $type 消息类型
  716. */
  717. public function yn_me_up()
  718. {
  719. header('Content-Type:text/json;charset=utf-8');
  720. header('Access-Control-Allow-Origin:*');
  721. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  722. header('Access-Control-Allow-Methods:POST');
  723. header('Access-Control-Expose-Headers:*');
  724. if (!empty($_POST)) {
  725. $uid = $_POST['uid'];
  726. $v_id = $_POST['v_id'];
  727. $yn_you = M("dianzan_video")->where("uid=$uid and v_id=$v_id")->getField("id");
  728. if ($yn_you) {
  729. $data['message'] = 'yes_like';
  730. echo json_encode($data);
  731. } else {
  732. $data['message'] = 'no_like';
  733. echo json_encode($data);
  734. }
  735. } else {
  736. echo $this->returnData();
  737. }
  738. }
  739. /**
  740. * 更新视频分类数量
  741. * @param $templateid []
  742. * @return $type 消息类型
  743. */
  744. public function save_video_type_num()
  745. {
  746. header('Content-Type:text/json;charset=utf-8');
  747. header('Access-Control-Allow-Origin:*');
  748. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  749. header('Access-Control-Allow-Methods:POST');
  750. header('Access-Control-Expose-Headers:*');
  751. $video_type_num = array();
  752. $video_list = M("video_list_test")->where("id!=''")->field('type')->select();
  753. foreach ($video_list as $key => $value) {
  754. $type2 = $value['type'];
  755. $type2_list = explode(',', $type2);
  756. $type2_list = array_unique($type2_list);
  757. foreach ($type2_list as $key1 => $value1) {
  758. # code...
  759. array_push($video_type_num, $value1);
  760. }
  761. }
  762. $count = array_count_values($video_type_num);
  763. // var_dump($count);
  764. // die();
  765. foreach ($count as $key11 => $value11) {
  766. // if ($key11 == '') {
  767. // echo PHP_EOL . '空?';
  768. // continue;
  769. // }
  770. $domain = strstr($key11, "'");
  771. if ($domain) {
  772. continue;
  773. }
  774. $yn_type = M("video_type_num")->where("name='$key11'")->getField("name");
  775. if (!empty($yn_type)) {
  776. $add_video_type['num'] = $value11;
  777. echo PHP_EOL . '已有跳过';
  778. echo PHP_EOL . $key11 . '-' . $value11;
  779. // continue;
  780. // print
  781. M("video_type_num")->where("name='$key11'")->save($add_video_type);
  782. } else {
  783. echo PHP_EOL . '没有新增';
  784. $add_video_type['name'] = $key11;
  785. $add_video_type['num'] = $value11;
  786. M("video_type_num")->add($add_video_type);
  787. }
  788. }
  789. }
  790. /**
  791. * 新同步视频标签数量
  792. * @param $templateid []
  793. * @return $type 消息类型
  794. */
  795. public function newtongbubiaoqiannum()
  796. {
  797. header('Content-Type:text/json;charset=utf-8');
  798. header('Access-Control-Allow-Origin:*');
  799. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  800. header('Access-Control-Allow-Methods:POST');
  801. header('Access-Control-Expose-Headers:*');
  802. $video_type_num = array();
  803. $video_list = M("video_list_test")->where("id!=''")->field('type')->select();
  804. $long_str = '';
  805. foreach ($video_list as $key => $value) {
  806. $type2 = $value['type'];
  807. $long_str .= $type2;
  808. # code...
  809. }
  810. // print_r($long_str);
  811. $new_long_list = explode(',', $long_str);
  812. $new_type_num = array_count_values($new_long_list);
  813. print_r($new_type_num);
  814. echo PHP_EOL . '';
  815. print_r(count($new_type_num));
  816. // $last = end($new_type_num);
  817. // $last_key = key($new_type_num);
  818. //分割数组一次新增3000
  819. $chunkArr = array_chunk($new_type_num, 2500, true);
  820. //更改此处!!!!
  821. foreach ($chunkArr[3] as $key1 => $value1) {
  822. $add_video_type['num'] = $value1;
  823. $add_video_type['name'] = $key1;;
  824. M("video_type_num")->add($add_video_type);
  825. }
  826. exit();
  827. }
  828. /**
  829. * 测试功能
  830. * @param $templateid []
  831. * @return $type 消息类型
  832. */
  833. public function shuzu_last_key()
  834. {
  835. $a = [
  836. 'one' => 1,
  837. 'two' => 2,
  838. 'three' => 3
  839. ];
  840. // 拆分数组
  841. $chunkArr = array_chunk($a, 2, true);
  842. // 输出原数组
  843. // var_dump($a);
  844. // 输出拆分后的数组
  845. print_r($chunkArr);
  846. // var_dump($chunkArr);
  847. }
  848. /**
  849. * 更新图片分类数量
  850. * @param $templateid []
  851. * @return $type 消息类型
  852. */
  853. public function save_img_type_num()
  854. {
  855. header('Content-Type:text/json;charset=utf-8');
  856. header('Access-Control-Allow-Origin:*');
  857. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  858. header('Access-Control-Allow-Methods:POST');
  859. header('Access-Control-Expose-Headers:*');
  860. $imgs_type_num = array();
  861. $video_list = M("imgs_list")->field('type')->select();
  862. foreach ($video_list as $key => $value) {
  863. $type2 = $value['type'];
  864. $type2_list = explode(',', $type2);
  865. $type2_list = array_unique($type2_list);
  866. foreach ($type2_list as $key1 => $value1) {
  867. # code...
  868. array_push($imgs_type_num, $value1);
  869. }
  870. }
  871. $count = array_count_values($imgs_type_num);
  872. var_dump($count);
  873. foreach ($count as $key11 => $value11) {
  874. if ($key11 == '') {
  875. continue;
  876. }
  877. $yn_type = M("imgs_type_num")->where("name='$key11'")->getField("name");
  878. if ($yn_type) {
  879. // if ($yn_type == $value11) {
  880. // echo PHP_EOL . '已有不动';
  881. // var_dump($value11);
  882. // continue;
  883. // }
  884. echo PHP_EOL . '已有更新';
  885. $add_video_type['num'] = $value11;
  886. M("imgs_type_num")->where("name='$key11'")->save($add_video_type);
  887. } else {
  888. echo PHP_EOL . '没有新增';
  889. $add_video_type['name'] = $key11;
  890. $add_video_type['num'] = $value11;
  891. M("imgs_type_num")->add($add_video_type);
  892. }
  893. // M("video_type_num")->where("name=''")->getField("");
  894. }
  895. }
  896. /**
  897. * 热搜标签列表,分类列表
  898. * @param type [img or video or novel]
  899. * @param page [页数]
  900. * @return $type 消息类型
  901. */
  902. public function shouye_resou_img_video()
  903. {
  904. header('Content-Type:text/json;charset=utf-8');
  905. header('Access-Control-Allow-Origin:*');
  906. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  907. header('Access-Control-Allow-Methods:POST');
  908. header('Access-Control-Expose-Headers:*');
  909. if (!empty($_POST)) {
  910. $type = $_POST['type'];
  911. $page = $_POST['page'];
  912. $LNG = $_POST['LNG'];
  913. $page_one = ($page - 1) * 30;
  914. if ($page < 0) {
  915. $page = 1;
  916. }
  917. switch ($type) {
  918. case 'video':
  919. switch ($LNG) {
  920. case 'CN':
  921. $video_list = M("video_type_num")->LIMIT($page_one, 30)->order("num desc")->Field("id,china_name,num")->select();
  922. break;
  923. case 'EN':
  924. $video_list = M("video_type_num")->LIMIT($page_one, 30)->order("num desc")->Field("id,name,num")->select();
  925. break;
  926. default:
  927. echo "type error";
  928. }
  929. $data['all_num'] = M("video_type_num")->count();
  930. $data['data'] = $video_list;
  931. echo json_encode($data);
  932. break;
  933. case 'img':
  934. $video_list = M("imgs_type_num")->LIMIT($page_one, 30)->order("num desc")->select();
  935. $data['all_num'] = M("imgs_type_num")->count();
  936. $data['data'] = $video_list;
  937. echo json_encode($data);
  938. break;
  939. case 'novel':
  940. $video_list = M("novel_type_num")->LIMIT($page_one, 30)->order("num desc")->select();
  941. $data['all_num'] = count($video_list);
  942. $data['data'] = $video_list;
  943. echo json_encode($data);
  944. break;
  945. default:
  946. echo "type error";
  947. }
  948. } else {
  949. echo $this->returnData();
  950. }
  951. }
  952. /**
  953. * 标签详情
  954. * @param type_name [标签名称]
  955. * @param type [img or video]
  956. * @param page [页数]
  957. *
  958. * @return $type 消息类型
  959. */
  960. public function select_type_detail()
  961. {
  962. header('Content-Type:text/json;charset=utf-8');
  963. header('Access-Control-Allow-Origin:*');
  964. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  965. header('Access-Control-Allow-Methods:POST');
  966. header('Access-Control-Expose-Headers:*');
  967. if (!empty($_POST)) {
  968. $LNG = $_POST['LNG'];
  969. $type_name = $_POST['type_name'];
  970. $type = $_POST['type'];
  971. $page = $_POST['page'];
  972. $page_one = ($page - 1) * 30;
  973. $jiben = $_POST['jiben_type'];
  974. switch ($jiben) {
  975. case 'zuixin':
  976. $jiben_sql = 'id desc';
  977. break;
  978. case 'remen':
  979. $jiben_sql = 'views desc';
  980. break;
  981. case 'guankan':
  982. $jiben_sql = 'views desc';
  983. break;
  984. case 'dianzan':
  985. $jiben_sql = 'thumbs_up desc';
  986. break;
  987. case 'shichang':
  988. $jiben_sql = 'time_chuo desc';
  989. break;
  990. default:
  991. $jiben_sql = '';
  992. break;
  993. }
  994. switch ($type) {
  995. case 'video':
  996. switch ($LNG) {
  997. case 'EN':
  998. if ($jiben_sql=='') {
  999. $wula = M("video_list_test")->where("type like '%,$type_name,%' and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'")->LIMIT($page_one, 60)->order('rand()')->select();
  1000. }else{
  1001. $wula = M("video_list_test")->where("type like '%,$type_name,%' and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'")->LIMIT($page_one, 60)->order("$jiben_sql")->select();
  1002. }
  1003. break;
  1004. case 'CN':
  1005. if ($jiben_sql=='') {
  1006. $wula = M("video_list_test")->where("china_type like '%,$type_name,%' and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'")->LIMIT($page_one, 60)->order('rand()')->select();
  1007. }else{
  1008. $wula = M("video_list_test")->where("china_type like '%,$type_name,%' and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'")->LIMIT($page_one, 60)->order("$jiben_sql")->select();
  1009. }
  1010. break;
  1011. default:
  1012. echo "type error";
  1013. }
  1014. $data['all_num'] = M("video_list_test")->where("type like '%,$type_name,%' and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'")->count();
  1015. $data['message'] = 'ok';
  1016. //获取广告列表
  1017. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  1018. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  1019. $jia_num = 5;
  1020. $qishi_num = 0;
  1021. $data_list_number = count($wula);
  1022. $quzheng_num = floor($data_list_number / 5);
  1023. foreach ($adv_list as $key => $value) {
  1024. $charu_array = array($adv_list[$key]);
  1025. array_splice($wula, $jia_num, 0, $charu_array);
  1026. $jia_num += 6;
  1027. $qishi_num += 1;
  1028. if ($qishi_num >= $quzheng_num) {
  1029. break;
  1030. }
  1031. }
  1032. $data['data'] = $wula;
  1033. echo json_encode($data);
  1034. break;
  1035. case 'img':
  1036. $wula = M("imgs_list")->where("type like '%,$type_name,%'")->LIMIT($page_one, 36)->select();
  1037. $data['all_num'] = M("imgs_list")->where("type like '%,$type_name%,'")->count();
  1038. $data['message'] = 'ok';
  1039. $data['data'] = $wula;
  1040. echo json_encode($data);
  1041. break;
  1042. case 'novel':
  1043. $wula = M("novel_list")->where("type like '%,$type_name,%'")->LIMIT($page_one, 36)->select();
  1044. $data['all_num'] = count($wula);
  1045. $data['message'] = 'ok';
  1046. $data['data'] = $wula;
  1047. echo json_encode($data);
  1048. break;
  1049. default:
  1050. echo "type error";
  1051. }
  1052. } else {
  1053. echo $this->returnData();
  1054. }
  1055. }
  1056. /**
  1057. * 推荐视频
  1058. * (2+2+1)
  1059. * @return $type 消息类型
  1060. */
  1061. public function tuijian_shipin()
  1062. {
  1063. header('Content-Type:text/json;charset=utf-8');
  1064. header('Access-Control-Allow-Origin:*');
  1065. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1066. header('Access-Control-Allow-Methods:POST');
  1067. header('Access-Control-Expose-Headers:*');
  1068. $oumei_list =M("video_list_test")->where("type not LIKE '%,Asian,%' and type not LIKE '%,Anime,%'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader")->order("rand()")->LIMIT(8)->select();
  1069. $yazhou_list =M("video_list_test")->where("type LIKE '%,Asian,%'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader")->order("rand()")->LIMIT(8)->select();
  1070. $dongman_list = M("video_list_test")->where("type LIKE '%,Anime,%'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader")->order("rand()")->LIMIT(4)->select();
  1071. $tuijian_video_list = array($oumei_list[0], $oumei_list[1], $yazhou_list[0], $yazhou_list[1], $dongman_list[0],
  1072. $oumei_list[2],$oumei_list[3],$yazhou_list[2],$yazhou_list[3],$dongman_list[1],
  1073. $oumei_list[4],$oumei_list[5],$yazhou_list[4],$yazhou_list[5],$dongman_list[2],
  1074. $oumei_list[6],$oumei_list[7],$yazhou_list[6],$yazhou_list[7],$dongman_list[3],);
  1075. if (!empty($tuijian_video_list)) {
  1076. $data['message'] = 'ok';
  1077. //获取广告列表
  1078. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  1079. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  1080. $jia_num = 0;
  1081. $qishi_num = 0;
  1082. $data_list_number = count($tuijian_video_list);
  1083. $quzheng_num = floor($data_list_number / 5);
  1084. foreach ($adv_list as $key => $value) {
  1085. if ($qishi_num==0) {
  1086. $jia_num += 5;
  1087. $qishi_num += 1;
  1088. }else{
  1089. $jia_num += 6;
  1090. $qishi_num += 1;
  1091. }
  1092. $charu_array = array($adv_list[$key]);
  1093. array_splice($tuijian_video_list, $jia_num, 0, $charu_array);
  1094. if ($qishi_num >= $quzheng_num) {
  1095. break;
  1096. }
  1097. }
  1098. $data['data'] = $tuijian_video_list;
  1099. echo json_encode($data);
  1100. } else {
  1101. $data['message'] = 'null';
  1102. $data['data'] = [];
  1103. echo json_encode($data);
  1104. }
  1105. }
  1106. /**
  1107. * 推荐视频
  1108. * (2+2+1)
  1109. * @return $type 消息类型
  1110. */
  1111. public function tuijian_shipin_video_detali()
  1112. {
  1113. header('Content-Type:text/json;charset=utf-8');
  1114. header('Access-Control-Allow-Origin:*');
  1115. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1116. header('Access-Control-Allow-Methods:POST');
  1117. header('Access-Control-Expose-Headers:*');
  1118. $oumei_list =M("video_list_test")->where("type not LIKE '%,Asian,%' and type not LIKE '%,Anime,%'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site")->order("rand()")->LIMIT(8)->select();
  1119. $yazhou_list =M("video_list_test")->where("type LIKE '%,Asian,%'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site")->order("rand()")->LIMIT(8)->select();
  1120. $dongman_list = M("video_list_test")->where("type LIKE '%,Anime,%'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site")->order("rand()")->LIMIT(4)->select();
  1121. $tuijian_video_list = array($oumei_list[0], $oumei_list[1], $yazhou_list[0], $yazhou_list[1], $dongman_list[0],
  1122. $oumei_list[2],$oumei_list[3],$yazhou_list[2],$yazhou_list[3],$dongman_list[1],
  1123. $oumei_list[4],$oumei_list[5],$yazhou_list[4],$yazhou_list[5],$dongman_list[2],
  1124. $oumei_list[6],$oumei_list[7],$yazhou_list[6],$yazhou_list[7],$dongman_list[3],);
  1125. if (!empty($tuijian_video_list)) {
  1126. $data['message'] = 'ok';
  1127. //获取广告列表
  1128. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  1129. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  1130. $jia_num = 0;
  1131. $qishi_num = 0;
  1132. $data_list_number = count($tuijian_video_list);
  1133. $quzheng_num = floor($data_list_number / 5);
  1134. foreach ($adv_list as $key => $value) {
  1135. $charu_array = array($adv_list[$key]);
  1136. array_splice($tuijian_video_list, $jia_num, 0, $charu_array);
  1137. $jia_num += 6;
  1138. $qishi_num += 1;
  1139. if ($qishi_num >= $quzheng_num) {
  1140. break;
  1141. }
  1142. }
  1143. $data['data'] = $tuijian_video_list;
  1144. echo json_encode($data);
  1145. } else {
  1146. $data['message'] = 'null';
  1147. $data['data'] = [];
  1148. echo json_encode($data);
  1149. }
  1150. }
  1151. /**
  1152. * 黑料海角反差视频详情推荐
  1153. * @param $templateid []
  1154. * @return $type 消息类型
  1155. */
  1156. public function new_tuijian_shipin_video_detali(){
  1157. header('Content-Type:text/json;charset=utf-8');
  1158. header('Access-Control-Allow-Origin:*');
  1159. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1160. header('Access-Control-Allow-Methods:POST');
  1161. header('Access-Control-Expose-Headers:*');
  1162. if (!empty($_POST)){
  1163. $uid = $_POST['uid'];
  1164. $video_type = $_POST['type'];
  1165. switch ($video_type) {
  1166. case 'HL':
  1167. $tuijian_video_list = M("video_list_test")->where("site='HL'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site")->order("rand()")->LIMIT(36)->select();
  1168. break;
  1169. case 'WB':
  1170. $tuijian_video_list = M("video_list_test")->where("site='WB'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site")->order("rand()")->LIMIT(36)->select();
  1171. break;
  1172. case 'FC':
  1173. $tuijian_video_list = M("video_list_test")->where("site='FC'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("rand()")->LIMIT(8)->select();
  1174. break;
  1175. default:
  1176. echo "type error";
  1177. }
  1178. if (!empty($tuijian_video_list)) {
  1179. $goumai_str_list = M("hj_fc_buy_record")->where("uid=$uid")->field("v_id")->select();
  1180. $goumai_str = ',';
  1181. foreach ($goumai_str_list as $key1 => $value1) {
  1182. $vv_id = $value1['v_id'];
  1183. $goumai_str .= "$vv_id".",";
  1184. }
  1185. foreach ($tuijian_video_list as $key => $value) {
  1186. $now_vid = $value['id'];
  1187. $needle = ",$now_vid,";
  1188. if (strpos($goumai_str, $needle) !== false){
  1189. $tuijian_video_list[$key]['coins'] = "-1";
  1190. }
  1191. }
  1192. $data['message'] = 'ok';
  1193. //获取广告列表
  1194. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  1195. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  1196. $jia_num = 0;
  1197. $qishi_num = 0;
  1198. $data_list_number = count($tuijian_video_list);
  1199. $quzheng_num = floor($data_list_number / 6);
  1200. foreach ($adv_list as $key => $value) {
  1201. $charu_array = array($adv_list[$key]);
  1202. array_splice($tuijian_video_list, $jia_num, 0, $charu_array);
  1203. $jia_num += 7;
  1204. $qishi_num += 1;
  1205. if ($qishi_num >= $quzheng_num) {
  1206. break;
  1207. }
  1208. }
  1209. $data['data'] = $tuijian_video_list;
  1210. echo json_encode($data);
  1211. } else {
  1212. $data['message'] = 'null';
  1213. $data['data'] = [];
  1214. echo json_encode($data);
  1215. }
  1216. }else{
  1217. echo $this->returnData();
  1218. }
  1219. }
  1220. /**
  1221. * 收藏列表
  1222. * @param uid [用户id]
  1223. * @param type [img or video]
  1224. * @return $type 消息类型
  1225. */
  1226. public function shoucang_list()
  1227. {
  1228. header('Content-Type:text/json;charset=utf-8');
  1229. header('Access-Control-Allow-Origin:*');
  1230. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1231. header('Access-Control-Allow-Methods:POST');
  1232. header('Access-Control-Expose-Headers:*');
  1233. if (!empty($_POST)) {
  1234. $uid = $_POST['uid'];
  1235. $page = $_POST['page'];
  1236. $page_one = ($page - 1) * 30;
  1237. $one_size = 30;
  1238. $all_img_video = array();
  1239. $sql_charu = "";
  1240. //视频
  1241. $duifang_id_list_num = M("video_shoucang")->where("uid=$uid")->count();
  1242. //插入sql语句 的限制条件
  1243. //视频
  1244. $duifang_id_list = M("video_shoucang")->where("uid=$uid")->Field("vid,time")->order("id desc")->LIMIT($page_one, $one_size)->select();
  1245. //插入sql语句 的限制条件
  1246. foreach ($duifang_id_list as $key => $value) {
  1247. # code...
  1248. $duifang_id = $value['vid'];
  1249. if (!$duifang_id) {
  1250. $duifang_id = 0;
  1251. }
  1252. $xianzhi_one = " or id=$duifang_id";
  1253. $sql_charu .= $xianzhi_one;
  1254. }
  1255. $wula_video = M("video_list_test")->where("id='' $sql_charu")->select();
  1256. foreach ($wula_video as $key1 => $value1) {
  1257. $id = $value1['id'];
  1258. $suozai_num = array_search($id, $duifang_id_list);
  1259. $wula_video[$key1]['time'] = $duifang_id_list[array_search("$id",array_column($duifang_id_list, 'vid'))]['time'];
  1260. }
  1261. array_multisort(array_column($wula_video, 'time'), SORT_DESC, $wula_video);
  1262. //获取广告列表
  1263. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  1264. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  1265. $c = $wula_video;
  1266. $jia_num = 5;
  1267. $qishi_num = 0;
  1268. $data_list_number = count($c);
  1269. $quzheng_num = floor($data_list_number / 5);
  1270. foreach ($adv_list as $key => $value) {
  1271. $charu_array = array();
  1272. $charu_array = array($adv_list[$key]);
  1273. array_splice($c, $jia_num, 0, $charu_array);
  1274. $jia_num += 6;
  1275. $qishi_num += 1;
  1276. if ($qishi_num >= $quzheng_num) {
  1277. break;
  1278. }
  1279. }
  1280. $data['message'] = 'ok';
  1281. $data['data'] = $c;
  1282. $data['all_num'] = $duifang_id_list_num;
  1283. echo json_encode($data);
  1284. } else {
  1285. echo $this->returnData();
  1286. }
  1287. }
  1288. /**
  1289. * 取消收藏
  1290. * @param $templateid []
  1291. * @return $type 消息类型
  1292. */
  1293. public function quxiao_shoucang()
  1294. {
  1295. header('Content-Type:text/json;charset=utf-8');
  1296. header('Access-Control-Allow-Origin:*');
  1297. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1298. header('Access-Control-Allow-Methods:POST');
  1299. header('Access-Control-Expose-Headers:*');
  1300. if (!empty($_POST)) {
  1301. $cid = $_POST['cid'];
  1302. $uid = $_POST['uid'];
  1303. $type = $_POST['type'];
  1304. switch ($type) {
  1305. case 'video':
  1306. $yn_de = M("video_shoucang")->where("uid='$uid' and vid='$cid'")->delete();
  1307. $now_zan_num = M("video_list_test")->where("id=$cid")->getField("favorite");
  1308. $now_zan_num -= 1;
  1309. $new_zan['favorite'] = $now_zan_num;
  1310. $yn_save = M("video_list_test")->where("id=$cid")->save($new_zan);
  1311. break;
  1312. default:
  1313. echo "type error";
  1314. }
  1315. if ($yn_de) {
  1316. $data['message'] = 'ok';
  1317. echo json_encode($data);
  1318. } else {
  1319. $data['message'] = 'erroe';
  1320. echo json_encode($data);
  1321. }
  1322. } else {
  1323. echo $this->returnData();
  1324. }
  1325. }
  1326. /**
  1327. * 同步视频标签
  1328. * @param $templateid []
  1329. * @return $type 消息类型
  1330. */
  1331. public function tongbu_video_biaoqian()
  1332. {
  1333. header('Content-Type:text/json;charset=utf-8');
  1334. header('Access-Control-Allow-Origin:*');
  1335. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1336. header('Access-Control-Allow-Methods:POST');
  1337. header('Access-Control-Expose-Headers:*');
  1338. $video_list = M("video_list_test")->Field("title,type")->select();
  1339. foreach ($video_list as $key => $value) {
  1340. # code...
  1341. $video_type = $value['type'];
  1342. if (!$video_type == '') {
  1343. echo PHP_EOL . '已有';
  1344. continue;
  1345. }
  1346. $name_video = $value['title'];
  1347. $wula = M("slgj_videos")->where("title='$name_video'")->Field("type,type1,type2")->select();
  1348. $type_str = '';
  1349. foreach ($wula as $key => $value) {
  1350. # code...
  1351. $type = $value['type'];
  1352. $type1 = $value['type1'];
  1353. $type2 = $value['type2'];
  1354. $type_str = ",$type,$type1,$type2,";
  1355. $video_listp['type'] = $type_str;
  1356. M("video_list_test")->where("title='$name_video'")->save($video_listp);
  1357. }
  1358. }
  1359. }
  1360. /**
  1361. * 同步图片标签
  1362. * @param $templateid []
  1363. * @return $type 消息类型
  1364. */
  1365. public function tongbu_img_biaoqian()
  1366. {
  1367. header('Content-Type:text/json;charset=utf-8');
  1368. header('Access-Control-Allow-Origin:*');
  1369. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1370. header('Access-Control-Allow-Methods:POST');
  1371. header('Access-Control-Expose-Headers:*');
  1372. $video_list = M("imgs_list")->where("id>16380")->Field("title,type")->select();
  1373. foreach ($video_list as $key => $value) {
  1374. # code...
  1375. $img_type = $value['type'];
  1376. if (!$img_type == '') {
  1377. echo PHP_EOL . '已有';
  1378. continue;
  1379. }
  1380. $name_video = $value['title'];
  1381. $wula = M("slgj_imgs")->where("title='$name_video'")->Field("type,type1,type2")->select();
  1382. $type_str = '';
  1383. foreach ($wula as $key => $value) {
  1384. # code...
  1385. $type = $value['type'];
  1386. $type1 = $value['type1'];
  1387. $type2 = $value['type2'];
  1388. $type_str = ",$type,$type1,$type2,";
  1389. $video_listp['type'] = $type_str;
  1390. M("imgs_list")->where("title='$name_video'")->save($video_listp);
  1391. echo PHP_EOL . M("imgs_list")->_sql();
  1392. }
  1393. }
  1394. }
  1395. /**
  1396. * 筛选
  1397. * id desc
  1398. * views desc
  1399. * thumbs_up desc
  1400. * $video_list = M("video_list_test")->order("thumbs_up desc")->LIMIT($page_one, 36)->select();
  1401. * @param page [页数]
  1402. * @param jiben_type [最新zuixin,热门remen,观看次数guankan,点赞数量dianzan,时长shichang]
  1403. * @param time_kaishi [时间筛选开始;例: 0就传0 10就传600 ]
  1404. * @param time_jeishu [时间筛选结束;例: 30就传1800 40+就传99999999 ]
  1405. * @param leixing_shaixuan [类型名称 ]
  1406. * @return $type 消息类型
  1407. */
  1408. public function video_shaixuan()
  1409. {
  1410. header('Content-Type:text/json;charset=utf-8');
  1411. header('Access-Control-Allow-Origin:*');
  1412. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1413. header('Access-Control-Allow-Methods:POST');
  1414. header('Access-Control-Expose-Headers:*');
  1415. if (!empty($_POST)) {
  1416. $LNG = $_POST['LNG'];
  1417. $page = $_POST['page'];
  1418. $page_one = ($page - 1) * 36;
  1419. //基本 最新,热门,观看次数,点赞数量,时长
  1420. $jiben = $_POST['jiben_type'];
  1421. switch ($jiben) {
  1422. case 'zuixin':
  1423. $jiben_sql = 'id desc';
  1424. break;
  1425. case 'remen':
  1426. $jiben_sql = 'views desc';
  1427. break;
  1428. case 'guankan':
  1429. $jiben_sql = 'views desc';
  1430. break;
  1431. case 'dianzan':
  1432. $jiben_sql = 'thumbs_up desc';
  1433. break;
  1434. case 'shichang':
  1435. $jiben_sql = 'time_chuo desc';
  1436. break;
  1437. default:
  1438. $jiben_sql = '';
  1439. break;
  1440. }
  1441. //时长筛选
  1442. $time_kaishi = $_POST['time_kaishi'];
  1443. $time_shaixuan = $_POST['time_jeishu'];
  1444. if ($time_kaishi == '') {
  1445. $time_kaishi = 0;
  1446. $time_shaixuan = 9999999999999;
  1447. }
  1448. //包含类型
  1449. $leixing_type = $_POST['leixing_shaixuan'];
  1450. if ($leixing_type != '') {
  1451. switch ($LNG) {
  1452. case '':
  1453. $sql_qujian = "(time_chuo between $time_kaishi and $time_shaixuan) and (type like '%,$leixing_type,%') and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'";
  1454. break;
  1455. case '':
  1456. $sql_qujian = "(time_chuo between $time_kaishi and $time_shaixuan) and (china_type like '%,$leixing_type,%') and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'";
  1457. break;
  1458. default:
  1459. echo "type error";
  1460. }
  1461. } else {
  1462. // echo PHP_EOL.'kkkk';
  1463. $sql_qujian = "(time_chuo between $time_kaishi and $time_shaixuan) and top_img!='https://www.bibidd.com/bibidd_testtest/A.jpg'";
  1464. }
  1465. $video_list = M("video_list_test")->where($sql_qujian)->order("$jiben_sql")->LIMIT($page_one, 36)->select();
  1466. $data['all_num'] = M("video_list_test")->where($sql_qujian)->order("$jiben_sql")->count();
  1467. $data['code'] = '200';
  1468. $data['data'] = $video_list;
  1469. echo json_encode($data);
  1470. } else {
  1471. echo $this->returnData();
  1472. }
  1473. }
  1474. //再次排序
  1475. /**
  1476. * 搜索
  1477. * @param $templateid []
  1478. * @return $type 消息类型
  1479. */
  1480. public function sousuo_img_video()
  1481. {
  1482. header('Content-Type:text/json;charset=utf-8');
  1483. header('Access-Control-Allow-Origin:*');
  1484. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1485. header('Access-Control-Allow-Methods:POST');
  1486. header('Access-Control-Expose-Headers:*');
  1487. $type_name = $_POST['type_name'];
  1488. $type = $_POST['type'];
  1489. $page = $_POST['page'];
  1490. $uid = $_POST['uid'];
  1491. $page_one = ($page - 1) * 36;
  1492. if (!empty($_POST)) {
  1493. switch ($type) {
  1494. case 'video':
  1495. $wula = M("video_list_test")->where("title like '%$type_name%' ")->Field("id,title,top_img,views,thumbs_up,favorite,time_chuo")->LIMIT($page_one, 36)->select();
  1496. $data['all_num'] = M("video_list_test")->where("title like '%$type_name%' ")->count();
  1497. break;
  1498. case 'img':
  1499. $wula = M("imgs_list")->where("title like '%$type_name%' ")->Field("id,title,top_img,views,thumbs_up,favorite,time_chuo")->LIMIT($page_one, 36)->select();
  1500. $data['all_num'] = M("imgs_list")->where("title like '%$type_name%'")->count();
  1501. break;
  1502. default:
  1503. echo "type error";
  1504. }
  1505. // 添加到用户搜索历史表
  1506. // $sousuo_jilu['uid'] =$uid ;
  1507. // $sousuo_jilu['title'] =$type_name ;
  1508. // M("sousuo_jilu")->add($sousuo_jilu);
  1509. if ($wula) {
  1510. $data['message'] = 'ok';
  1511. $data['data'] = $wula;
  1512. echo json_encode($data);
  1513. } else {
  1514. $data['message'] = 'null';
  1515. $data['data'] = array();
  1516. echo json_encode($data);
  1517. }
  1518. } else {
  1519. echo $this->returnData();
  1520. }
  1521. }
  1522. function list_sort_by($list, $field, $sortby = 'desc')
  1523. {
  1524. if (is_array($list)) {
  1525. $refer = $resultSet = array();
  1526. foreach ($list as $i => $data)
  1527. $refer[$i] = &$data[$field];
  1528. switch ($sortby) {
  1529. case 'asc': // 正向排序
  1530. asort($refer);
  1531. break;
  1532. case 'desc':// 逆向排序
  1533. arsort($refer);
  1534. break;
  1535. case 'nat': // 自然排序
  1536. natcasesort($refer);
  1537. break;
  1538. }
  1539. foreach ($refer as $key => $val)
  1540. $resultSet[] = &$list[$key];
  1541. return $resultSet;
  1542. }
  1543. return false;
  1544. }
  1545. /**
  1546. * 同步视频
  1547. * @param $templateid []
  1548. * @return $type 消息类型
  1549. */
  1550. public function tongbu_vidoe()
  1551. {
  1552. header('Content-Type:text/json;charset=utf-8');
  1553. header('Access-Control-Allow-Origin:*');
  1554. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1555. header('Access-Control-Allow-Methods:POST');
  1556. header('Access-Control-Expose-Headers:*');
  1557. // $select_slgj_video = M("slgj_videos")->where(" (site='P站' and m3u8 like '%slgj688.com/%') or (site='黄色仓库' and m3u8!='')")->Field('title,time2,one_img,m3u8')->select();
  1558. // $select_slgj_video = M("slgj_videos")->where("m3u8 like '%.html'")->Field('title,time2,one_img,m3u8')->select();
  1559. // $select_slgj_video = M("slgj_videos")->where("video_watch!='' and m3u8 like '%slgj688.com/%' and one_img like '%750_400%' and is_gengxin=''")->Field('title,time2,one_img,m3u8')->select();
  1560. // $select_slgj_video = M("slgj_videos")->where("video_watch!='' and m3u8 like '%slgj688.com/%' and one_img like '%750_400%' and is_gengxin='' and type like '%Anime%'")->Field('title,time2,one_img,m3u8')->select();
  1561. $select_slgj_video = M("slgj_videos")->where("m3u8 like '%slgj688.com/%' and site!='XVIDEOS'")->Field('title,time2,one_img,m3u8')->select();
  1562. print_r(count($select_slgj_video));
  1563. foreach ($select_slgj_video as $key => $value) {
  1564. //判断 video_list 和 video_info 是否已已有跳过
  1565. //标题
  1566. $sl_title = $value['title'];
  1567. $sl_title = str_replace("'", "", $sl_title);
  1568. //视频时长
  1569. $video_time = $value['time2'];
  1570. $video_time = '00:00';
  1571. if ($video_time == '') {
  1572. continue;
  1573. }
  1574. //头图片
  1575. $top_img = $value['one_img'];
  1576. if ($top_img == '') {
  1577. $top_img = 'https://www.bibidd.com/bibidd_testtest/A.jpg';
  1578. }
  1579. // $top_img = $value['one_img_yun'];
  1580. //m3u8
  1581. $video_m3u8 = $value['m3u8'];
  1582. // $video_m3u8 = $value['video_watch'];
  1583. #bibidd
  1584. $domain = strstr($sl_title, "'");
  1585. if ($domain) {
  1586. echo PHP_EOL . $sl_title;
  1587. continue;
  1588. }
  1589. // $where_id1 = sprintf('title="%d"', $sl_title);
  1590. // try {
  1591. $yn_yiyou = M("video_list_test")->where("title='$sl_title'")->getField("id");
  1592. // } catch (Exception $e) {
  1593. // echo PHP_EOL . $sl_title;
  1594. // continue;
  1595. // }
  1596. if ($yn_yiyou) {
  1597. // echo PHP_EOL . '有了';
  1598. } else {
  1599. echo PHP_EOL . '没有asdasdasdasd';
  1600. //观看点赞(1-999)
  1601. $video_list_addp['views'] = rand(200, 9999);
  1602. $video_list_addp['thumbs_up'] = rand(50, 9999);
  1603. $video_list_addp['title'] = $sl_title;
  1604. $video_list_addp['top_img'] = $top_img;
  1605. $video_list_addp['video_time'] = $video_time;
  1606. $add_list = M("video_list_test")->add($video_list_addp);
  1607. $video_info_addp['video_url'] = $video_m3u8;
  1608. $video_info_addp['video_id'] = $add_list;
  1609. $add_info = M("video_info_test")->add($video_info_addp);
  1610. }
  1611. }
  1612. }
  1613. /**
  1614. * 同步图片
  1615. * @param $templateid []
  1616. * @return $type 消息类型
  1617. */
  1618. public function tongbu_img()
  1619. {
  1620. header('Content-Type:text/json;charset=utf-8');
  1621. header('Access-Control-Allow-Origin:*');
  1622. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1623. header('Access-Control-Allow-Methods:POST');
  1624. header('Access-Control-Expose-Headers:*');
  1625. $select_slgj_video = M("slgj_imgs")->where("title!=''")->Field('title,num,one_img,imgs')->select();
  1626. foreach ($select_slgj_video as $key => $value) {
  1627. //判断 video_list 和 video_info 是否已已有跳过
  1628. //标题
  1629. $sl_title = $value['title'];
  1630. //图片数量
  1631. $img_num = $value['num'];
  1632. //头图片
  1633. $top_img = $value['one_img'];
  1634. //m3u8
  1635. $imgs_imgs = $value['imgs'];
  1636. // $where_id1 = sprintf('title="%d"', $sl_title);
  1637. $domain = strstr($sl_title, "'");
  1638. if ($domain) {
  1639. echo PHP_EOL . $sl_title;
  1640. continue;
  1641. }
  1642. try {
  1643. $yn_yiyou = M("imgs_list")->where("title='$sl_title'")->getField("id");
  1644. } catch (Exception $e) {
  1645. echo PHP_EOL . $sl_title;
  1646. continue;
  1647. }
  1648. if ($yn_yiyou) {
  1649. echo PHP_EOL . '有了';
  1650. } else {
  1651. echo PHP_EOL . '没有';
  1652. $video_list_addp['views'] = rand(1, 999);
  1653. $video_list_addp['thumbs_up'] = rand(1, 999);
  1654. $video_list_addp['title'] = $sl_title;
  1655. $video_list_addp['top_img'] = $top_img;
  1656. $video_list_addp['imgs_num'] = $img_num;
  1657. $add_list = M("imgs_list")->add($video_list_addp);
  1658. $video_info_addp['imgs_url'] = $imgs_imgs;
  1659. $video_info_addp['imgs_id'] = $add_list;
  1660. $add_info = M("imgs_info")->add($video_info_addp);
  1661. }
  1662. }
  1663. }
  1664. /**
  1665. * 测试功能
  1666. * @param $templateid []
  1667. * @return $type 消息类型
  1668. */
  1669. public function test_zhongwen()
  1670. {
  1671. header('Content-Type:text/json;charset=utf-8');
  1672. header('Access-Control-Allow-Origin:*');
  1673. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1674. header('Access-Control-Allow-Methods:POST');
  1675. header('Access-Control-Expose-Headers:*');
  1676. $str = "原字符串:";
  1677. $pattern = "/[^\x{4E00}-\x{9FFF}]+/u";
  1678. $newStr = preg_replace($pattern, '', $str);
  1679. if ($newStr === '') {
  1680. echo "字符串中不包含中文<br>";
  1681. } else {
  1682. echo "字符串中包含中文<br>";
  1683. }
  1684. }
  1685. /**
  1686. * 首页符合要求视频(封面完好 ,时长20+)
  1687. * @param $templateid []
  1688. * @return $type 消息类型
  1689. */
  1690. public function home_video_good()
  1691. {
  1692. header('Content-Type:text/json;charset=utf-8');
  1693. header('Access-Control-Allow-Origin:*');
  1694. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1695. header('Access-Control-Allow-Methods:POST');
  1696. header('Access-Control-Expose-Headers:*');
  1697. if (!empty($_POST)) {
  1698. $uid = $_POST['uid'];
  1699. $video_list = M("video_list_test")->where("time=")->select();
  1700. } else {
  1701. echo $this->returnData();
  1702. }
  1703. }
  1704. function randFloat($min, $max)
  1705. {
  1706. if ($min >= $max) {
  1707. throw new \Exception('最大值必须大于最小值', 501);
  1708. }
  1709. $rand = $min + mt_rand() / mt_getrandmax() * ($max - $min);
  1710. return floatval(sprintf('%.1f', $rand));
  1711. }
  1712. /**
  1713. * 所有视频随机(浏览,点赞1-999)
  1714. * @param $templateid []
  1715. * @return $type 消息类型
  1716. */
  1717. public function rangd_suijione()
  1718. {
  1719. header('Content-Type:text/json;charset=utf-8');
  1720. header('Access-Control-Allow-Origin:*');
  1721. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1722. header('Access-Control-Allow-Methods:POST');
  1723. header('Access-Control-Expose-Headers:*');
  1724. $user_list = M("video_list_test")->where("id!='' and views=0 and site='FC'")->Field("id")->select();
  1725. // $user_list = M("novel_list")->where("id!=''")->Field("id")->select();
  1726. // $user_list = M("imgs_list")->where("id!='' and biaoqian_yn=0")->Field("id")->select();
  1727. foreach ($user_list as $key => $value) {
  1728. echo PHP_EOL . '1';
  1729. $iid = $value['id'];
  1730. echo PHP_EOL . $iid;
  1731. //观看点赞(1-999)
  1732. echo PHP_EOL;
  1733. $video_list_addp['biaoqian_yn'] = 1;
  1734. $video_list_addp['views'] = $this->randFloat(10.1,99);
  1735. $video_list_addp['thumbs_up'] = $this->randFloat(3.1, 9);
  1736. M("video_list_test")->where("id=$iid")->save($video_list_addp);
  1737. // M("novel_list")->where("id=$iid")->save($video_list_addp);
  1738. // M("imgs_list")->where("id=$iid")->save($video_list_addp);
  1739. }
  1740. }
  1741. function randFloat11($min = 1, $max = 9) {
  1742. $wula = $this->randFloat(10, 99);
  1743. echo PHP_EOL.$wula;}
  1744. /**
  1745. * 测试功能
  1746. * @param $templateid []
  1747. * @return $type 消息类型
  1748. */
  1749. public function shijian_zhuanghuan_new()
  1750. {
  1751. print_r('可恶');
  1752. $user_list = M("video_list_test")->where("id!='' and time_chuo=0")->Field("id,video_time")->select();
  1753. print_r(count($user_list));
  1754. // $user_list = M("video_list_test")->where("id='80970'")->Field("id,video_time")->select();
  1755. foreach ($user_list as $key => $value) {
  1756. # code...
  1757. $id = $value['id'];
  1758. print_r($id);
  1759. $time = $value['video_time'];
  1760. $is_fuhao = strstr($time, ':');
  1761. if ($is_fuhao) {
  1762. $time_list = explode(':', $time);
  1763. $time_list_count = count($time_list);
  1764. if ($time_list_count == 2) {
  1765. $one = $time_list[0];
  1766. $two = $time_list[1];
  1767. $time_all = ($one * 60) + $two;
  1768. $time_chuo['time_chuo'] = $time_all;
  1769. M("video_list_test")->where("id=$id")->save($time_chuo);
  1770. } elseif ($time_list_count == 3) {
  1771. $one = $time_list[0];
  1772. $two = $time_list[1];
  1773. $three = $time_list[2];
  1774. $time_all = ($one * 3600) + ($two * 60) + $three;
  1775. $time_chuo['time_chuo'] = $time_all;
  1776. M("video_list_test")->where("id=$id")->save($time_chuo);
  1777. }
  1778. } else {
  1779. //带h
  1780. $is_fuhao = strstr($time, 'h');
  1781. if ($is_fuhao) {
  1782. $time_one = substr($time, 0, 1);
  1783. $time_two_mei = substr($time, 4, 9);
  1784. $time_two = str_replace("min", '', $time_two_mei);
  1785. $time_all = ($time_one * 3600) + ($time_two * 60);
  1786. $time_chuo['time_chuo'] = $time_all;
  1787. M("video_list_test")->where("id=$id")->save($time_chuo);
  1788. } else {
  1789. //min的
  1790. $time_one = substr($time, 0, 2);
  1791. $time_all = ($time_one * 60);
  1792. $time_chuo['time_chuo'] = $time_all;
  1793. M("video_list_test")->where("id=$id")->save($time_chuo);
  1794. }
  1795. }
  1796. }
  1797. }
  1798. /**
  1799. * 视频转时间
  1800. * @param $templateid []
  1801. * @return $type 消息类型
  1802. */
  1803. public function time_zhuanhuan()
  1804. {
  1805. print_r('可恶');
  1806. $user_list = M("video_list_test")->where("id!='' and time_chuo=0 or time_chuo is null")->Field("id,video_time")->select();
  1807. foreach ($user_list as $key => $value) {
  1808. # code...
  1809. $id = $value['id'];
  1810. $time = $value['video_time'];
  1811. $is_fuhao = strstr($time, ':');
  1812. if ($is_fuhao) {
  1813. $time_list = explode(':', $time);
  1814. $time_list_count = count($time_list);
  1815. if ($time_list_count == 2) {
  1816. $one = $time_list[0];
  1817. $two = $time_list[1];
  1818. $time_all = ($one * 60) + $two;
  1819. $time_chuo['time_chuo'] = $time_all;
  1820. M("video_list_test")->where("id=$id")->save($time_chuo);
  1821. } elseif ($time_list_count == 3) {
  1822. $one = $time_list[0];
  1823. $two = $time_list[1];
  1824. $three = $time_list[2];
  1825. $time_all = ($one * 3600) + ($two * 60) + $three;
  1826. $time_chuo['time_chuo'] = $time_all;
  1827. M("video_list_test")->where("id=$id")->save($time_chuo);
  1828. }
  1829. } else {
  1830. //带h
  1831. $is_fuhao = strstr($time, 'h');
  1832. if ($is_fuhao) {
  1833. $time_one = substr($time, 0, 1);
  1834. $time_two_mei = substr($time, 4, 9);
  1835. $time_two = str_replace("min", '', $time_two_mei);
  1836. $time_all = ($time_one * 3600) + ($time_two * 60);
  1837. $time_chuo['time_chuo'] = $time_all;
  1838. M("video_list_test")->where("id=$id")->save($time_chuo);
  1839. } else {
  1840. //min的
  1841. $time_one = substr($time, 0, 2);
  1842. $time_all = ($time_one * 60);
  1843. $time_chuo['time_chuo'] = $time_all;
  1844. M("video_list_test")->where("id=$id")->save($time_chuo);
  1845. }
  1846. }
  1847. }
  1848. }
  1849. /**
  1850. * 随机出首页数据 必须 时长20+ 0点更新
  1851. * @param $templateid []
  1852. * @return $type 消息类型
  1853. */
  1854. public function rand_video_tui()
  1855. {
  1856. header('Content-Type:text/json;charset=utf-8');
  1857. header('Access-Control-Allow-Origin:*');
  1858. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1859. header('Access-Control-Allow-Methods:POST');
  1860. header('Access-Control-Expose-Headers:*');
  1861. $tuijian = M("video_list_test")->where("time_chuo >1800 or time_chuo >600")->order("rand()")->LIMIT(0, 60)->select();
  1862. $tuijian = M("video_list_test")->order("rand()")->LIMIT(0, 60)->select();
  1863. //推荐视频json
  1864. $wula['str'] = json_encode($tuijian);
  1865. $wula['time'] = date("Y年m月d日 D h时i分s秒 A", time());
  1866. M("tuijian_video")->where("id=1")->save($wula);
  1867. }
  1868. /**
  1869. * 取出今天 随机的视频 并记录 ip
  1870. * @param $templateid []
  1871. * @return $type 消息类型
  1872. */
  1873. public function load_videos()
  1874. {
  1875. header('Content-Type:text/json;charset=utf-8');
  1876. header('Access-Control-Allow-Origin:*');
  1877. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1878. header('Access-Control-Allow-Methods:POST');
  1879. header('Access-Control-Expose-Headers:*');
  1880. $ip = get_client_ip();
  1881. $user_list['time'] = time();
  1882. $yn_ip_yiyou = M("ip_jilu")->where("ip='$ip'")->getField("id");
  1883. if ($yn_ip_yiyou) {
  1884. M("ip_jilu")->where("ip='$ip'")->save($user_list);
  1885. } else {
  1886. $user_list['add_time'] = time();
  1887. M("ip_jilu")->add($user_list);
  1888. }
  1889. }
  1890. /**
  1891. *视频类型中文
  1892. * @param $templateid []
  1893. * @return $type 消息类型
  1894. */
  1895. public function test_chinese()
  1896. {
  1897. header('Content-Type:text/json;charset=utf-8');
  1898. header('Access-Control-Allow-Origin:*');
  1899. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1900. header('Access-Control-Allow-Methods:POST');
  1901. header('Access-Control-Expose-Headers:*');
  1902. $video_list = M("video_type_num")->where("name!=''")->field("name")->select();
  1903. foreach ($video_list as $key => $value) {
  1904. $type_name = $value['name'];
  1905. $pattern = "/[^\x{4E00}-\x{9FFF}]+/u";
  1906. $newStr = preg_replace($pattern, '', $type_name);
  1907. if ($newStr === '') {
  1908. } else {
  1909. echo PHP_EOL . $type_name;
  1910. }
  1911. }
  1912. }
  1913. /**
  1914. * 测试功能
  1915. * @param $templateid []
  1916. * @return $type 消息类型
  1917. */
  1918. public function all_chinese_type_ec()
  1919. {
  1920. header('Content-Type:text/json;charset=utf-8');
  1921. header('Access-Control-Allow-Origin:*');
  1922. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1923. header('Access-Control-Allow-Methods:POST');
  1924. header('Access-Control-Expose-Headers:*');
  1925. $user_list = M("")->where("")->field("name,num")->select();
  1926. foreach ($user_list as $key => $value) {
  1927. # code...
  1928. $str = $value['name'];
  1929. $pattern = "/[^\x{4E00}-\x{9FFF}]+/u";
  1930. $newStr = preg_replace($pattern, '', $str);
  1931. if ($newStr === '') {
  1932. echo "字符串中不包含中文<br>";
  1933. } else {
  1934. echo "字符串中包含中文<br>";
  1935. }
  1936. $user_list[$key] = $value['id'];
  1937. }
  1938. }
  1939. /**
  1940. * 筛选的类型
  1941. * @param $templateid []
  1942. * @return $type 消息类型
  1943. */
  1944. public function shaixuan_type_list()
  1945. {
  1946. header('Content-Type:text/json;charset=utf-8');
  1947. header('Access-Control-Allow-Origin:*');
  1948. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1949. header('Access-Control-Allow-Methods:POST');
  1950. header('Access-Control-Expose-Headers:*');
  1951. if (!empty($_POST)) {
  1952. $LNG = $_POST['LNG'];
  1953. switch ($LNG) {
  1954. case 'EN':
  1955. $type_name_list = M("video_type_num")->where("name!=''")->order("num desc")->Field("name")->LIMIT(0, 100)->select();
  1956. // echo PHP_EOL.count($type_name_list);
  1957. foreach ($type_name_list as $key => $value) {
  1958. # code...
  1959. $type_list[$key]['name'] = $value['name'];
  1960. }
  1961. $data['code'] = '200';
  1962. $data['status'] = '1';
  1963. $data['data'] = $type_list;
  1964. echo json_encode($data);
  1965. break;
  1966. case 'CN':
  1967. $type_name_list = M("video_type_num")->where("name!=''")->order("num desc")->Field("china_name")->LIMIT(0, 100)->select();
  1968. // echo PHP_EOL.count($type_name_list);
  1969. foreach ($type_name_list as $key => $value) {
  1970. # code...
  1971. $type_list[$key]['name'] = $value['china_name'];
  1972. }
  1973. $data['code'] = '200';
  1974. $data['status'] = '1';
  1975. $data['data'] = $type_list;
  1976. echo json_encode($data);
  1977. break;
  1978. default:
  1979. echo "type error";
  1980. }
  1981. } else {
  1982. echo $this->returnData();
  1983. }
  1984. }
  1985. /**
  1986. * 搜索历史
  1987. * @param uid [用户id]
  1988. * @return $type 消息类型
  1989. */
  1990. public function search_history()
  1991. {
  1992. header('Content-Type:text/json;charset=utf-8');
  1993. header('Access-Control-Allow-Origin:*');
  1994. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  1995. header('Access-Control-Allow-Methods:POST');
  1996. header('Access-Control-Expose-Headers:*');
  1997. if (!empty($_POST)) {
  1998. $uid = $_POST['uid'];
  1999. $sousuo_lishi_list = M("sousuo_jilu")->where("uid=$uid")->field("title,id")->select();
  2000. $data['code'] = '200';
  2001. $data['status'] = '1';
  2002. $data['message'] = 'yes';
  2003. $data['data'] = $sousuo_lishi_list;
  2004. echo json_encode($data);
  2005. } else {
  2006. echo $this->returnData();
  2007. }
  2008. }
  2009. /**
  2010. * 删除搜索
  2011. * @param $templateid []
  2012. * @return $type 消息类型
  2013. */
  2014. public function delete_search_history()
  2015. {
  2016. header('Content-Type:text/json;charset=utf-8');
  2017. header('Access-Control-Allow-Origin:*');
  2018. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2019. header('Access-Control-Allow-Methods:POST');
  2020. header('Access-Control-Expose-Headers:*');
  2021. if (!empty($_POST)) {
  2022. $sousuo_id = $_POST['id'];
  2023. $yn_shanchu = M("sousuo_jilu")->where("id=$sousuo_id")->delete();
  2024. if ($yn_shanchu) {
  2025. $data['message'] = 'ok';
  2026. echo json_encode($data);
  2027. } else {
  2028. $data['message'] = 'no';
  2029. echo json_encode($data);
  2030. }
  2031. } else {
  2032. echo $this->returnData();
  2033. }
  2034. }
  2035. /**
  2036. * 同步视频 第二链接
  2037. * @param $templateid []
  2038. * @return $type 消息类型
  2039. */
  2040. public function tongbu_two_video_url()
  2041. {
  2042. header('Content-Type:text/json;charset=utf-8');
  2043. header('Access-Control-Allow-Origin:*');
  2044. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2045. header('Access-Control-Allow-Methods:POST');
  2046. header('Access-Control-Expose-Headers:*');
  2047. $bbvideo_titi = M("video_list_test")->field("title,id")->select();
  2048. foreach ($bbvideo_titi as $key => $value) {
  2049. # code...
  2050. $vtit = $value['title'];
  2051. $vid = $value['id'];
  2052. $sl_url = M("slgj_videos")->where("title='$vtit'")->getField("video_watch");
  2053. $wula_two['video_url_two'] = $sl_url;
  2054. $yn_sa = M("video_info_test")->where("video_id=$vid")->save($wula_two);
  2055. if ($yn_sa) {
  2056. echo PHP_EOL . '修改成功' . $sl_url;
  2057. } else {
  2058. echo PHP_EOL . '修改失败';
  2059. }
  2060. }
  2061. }
  2062. /**
  2063. * 将国产内容 同步标签
  2064. * @param $templateid []
  2065. * @return $type 消息类型
  2066. */
  2067. public function update_guochan()
  2068. {
  2069. header('Content-Type:text/json;charset=utf-8');
  2070. header('Access-Control-Allow-Origin:*');
  2071. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2072. header('Access-Control-Allow-Methods:POST');
  2073. header('Access-Control-Expose-Headers:*');
  2074. // SELECT * FROM `bb_slgj_videos` WHERE site='含羞草研究所' and m3u8 like '%slgj688.com/%' and is_gengxin='' and video_watch!=''
  2075. $select_slgj_video = M("slgj_videos")->where("site='含羞草研究所' and m3u8 like '%slgj688.com/%'")->Field('title')->order("id desc")->select();
  2076. print_r(count($select_slgj_video));
  2077. foreach ($select_slgj_video as $key => $value) {
  2078. $sl_tit = $value['title'];
  2079. $sl_tit = str_replace("'", "", $sl_tit);
  2080. $now_type_bb = M("video_list_test")->where("title='$sl_tit' and type not like '%Asian,Chinese%'")->getField("type");
  2081. if ($now_type_bb) {
  2082. print_r($now_type_bb);
  2083. echo PHP_EOL . $now_type_bb;
  2084. $new_type = $now_type_bb . ",Asian,Chinese,";
  2085. $update_type['type'] = $new_type;
  2086. M("video_list_test")->where("title='$sl_tit'")->save($update_type);
  2087. } else {
  2088. print_r('youle');
  2089. }
  2090. }
  2091. }
  2092. /**
  2093. * 亚洲类目下 各个type数量
  2094. * @param $templateid []
  2095. * @return $type 消息类型
  2096. */
  2097. public function yazhou_leimutype()
  2098. {
  2099. header('Content-Type:text/json;charset=utf-8');
  2100. header('Access-Control-Allow-Origin:*');
  2101. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2102. header('Access-Control-Allow-Methods:POST');
  2103. header('Access-Control-Expose-Headers:*');
  2104. $fenlei_num_all = M("video_type_num")->where("name='Japanese and Korean AV' or name='Mainland' or name='Japan and South Korea' or name='Hong Kong' or name='Taiwan' ")->select();
  2105. foreach ($fenlei_num_all as $key => $value) {
  2106. $leixing[$key]['name'] = $value['name'];
  2107. $leixing[$key]['num'] = $value['num'];;
  2108. }
  2109. $data['message'] = 'ok';
  2110. $data['data'] = $leixing;
  2111. echo json_encode($data);
  2112. }
  2113. /**
  2114. * 同步动漫时长 在格式化 时间
  2115. * @param $templateid []
  2116. * @return $type 消息类型
  2117. */
  2118. public function tongbu_anime()
  2119. {
  2120. header('Content-Type:text/json;charset=utf-8');
  2121. header('Access-Control-Allow-Origin:*');
  2122. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2123. header('Access-Control-Allow-Methods:POST');
  2124. header('Access-Control-Expose-Headers:*');
  2125. //查询time_chuo空的动漫
  2126. $null_chuo_anime_list = M("video_list_test")->where(" type like '%,Anime,%' and time_chuo =0")->field("title")->select();
  2127. foreach ($null_chuo_anime_list as $key => $value) {
  2128. $anime_title = $value['title'];
  2129. $list_test['video_time'] = M("slgj_videos")->where("title='$anime_title'")->getField("time2");
  2130. print_r($list_test);
  2131. echo PHP_EOL . '';
  2132. M("video_list_test")->where("title='$anime_title'")->save($list_test);
  2133. }
  2134. }
  2135. /**
  2136. * 将当前用户观看的视频类型 记录
  2137. * @param $templateid []
  2138. * @return $type 消息类型
  2139. */
  2140. public function add_user_views()
  2141. {
  2142. header('Content-Type:text/json;charset=utf-8');
  2143. header('Access-Control-Allow-Origin:*');
  2144. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2145. header('Access-Control-Allow-Methods:POST');
  2146. header('Access-Control-Expose-Headers:*');
  2147. if (!empty($_POST)) {
  2148. $uid = $_POST['uid'];
  2149. if ($uid == 0) {
  2150. exit();
  2151. }
  2152. $video_type = $_POST['video_type'];
  2153. //获取当前用户观看视频类型集合,观看视频数量
  2154. $now_views_jilu_lsit = M("views_video_type_jilu")->where("uid=$uid")->field("views_video_num")->select();
  2155. //已有记录更新 没有新增
  2156. if ($now_views_jilu_lsit) {
  2157. // $now_video_type_str = $now_views_jilu_lsit[0]['video_type_str'];
  2158. $now_views_video_num = $now_views_jilu_lsit[0]['views_video_num'];
  2159. //将当前用户观看的视频 类型 更新
  2160. // $new_video_type_str = $now_video_type_str . ',' . $video_type;
  2161. $new_views_video_num = $now_views_video_num + 1;
  2162. // $update_views_jilu['video_type_str'] = $new_video_type_str;
  2163. $update_views_jilu['views_video_num'] = $new_views_video_num;
  2164. $save_yn = M("views_video_type_jilu")->where("uid=$uid")->save($update_views_jilu);
  2165. if ($save_yn) {
  2166. $data['message'] = 'save_ok';
  2167. echo json_encode($data);
  2168. } else {
  2169. $data['message'] = 'save_no';
  2170. echo json_encode($data);
  2171. }
  2172. } else {
  2173. $update_views_jilu['uid'] = $uid;
  2174. $update_views_jilu['video_type_str'] = "";
  2175. $update_views_jilu['views_video_num'] = 1;
  2176. $add_yn = M("views_video_type_jilu")->add($update_views_jilu);
  2177. if ($add_yn) {
  2178. $data['message'] = 'add_ok';
  2179. echo json_encode($data);
  2180. } else {
  2181. $data['message'] = 'add_no';
  2182. echo json_encode($data);
  2183. }
  2184. }
  2185. } else {
  2186. echo $this->returnData();
  2187. }
  2188. }
  2189. //封装返回的数据
  2190. /**
  2191. * 测试功能
  2192. * @param $templateid []
  2193. * @return $type 消息类型
  2194. */
  2195. public function tuijian_duanhou(){
  2196. header('Content-Type:text/json;charset=utf-8');
  2197. header('Access-Control-Allow-Origin:*');
  2198. header("Access-Contr-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2199. header('Access-Control-Allow-Methods:POST');
  2200. header('Access-Control-Expose-Headers:*');
  2201. $type = $_POST['type'];
  2202. $page = $_POST['page'];
  2203. $page_one = ($page - 1) * 60;
  2204. }
  2205. /**
  2206. * 同步time2
  2207. * @param $templateid []
  2208. * @return $type 消息类型
  2209. */
  2210. public function tongbushipin_shijian_time()
  2211. {
  2212. $video_list = M("video_list_test")->where("time_chuo=0")->Field("title")->select();
  2213. echo PHP_EOL . M("video_list_test")->_sql();
  2214. foreach ($video_list as $key => $value) {
  2215. # code...
  2216. $name_video = $value['title'];
  2217. // $wula = M("slgj_videos")->where("title='$name_video'")->Field("time2")->select();
  2218. $ttime = M("slgj_videos")->where("title='$name_video'")->getField("time2");
  2219. $update_time['video_time'] = $ttime;
  2220. M("video_list_test")->where("title='$name_video'")->save($update_time);
  2221. echo PHP_EOL . M("video_list_test")->_sql();
  2222. }
  2223. }
  2224. /**
  2225. * 同步预热
  2226. * 将预热成功的数据同步到 video_list,video_list_test表中
  2227. * @param $templateid []
  2228. * @return $type 消息类型
  2229. */
  2230. public function yure_tongbu_bibidd()
  2231. {
  2232. //首先获取所有 预热成功的视频的id
  2233. // $yure_yes = M("slgj_videos")->where("yure=1")->field("id")->order("id desc")->select();
  2234. $yure_yes = M("slgj_videos")->where("yure=1")->field("id")->order("id asc")->select();
  2235. //
  2236. foreach ($yure_yes as $key => $value) {
  2237. $id = $value['id'];
  2238. //查询这个id是否已经更新
  2239. $yngengxin_wula = M("video_list_test")->where("sl_id=$id and yure=1")->getField("id");
  2240. if ($yngengxin_wula) {
  2241. echo PHP_EOL.'过了';
  2242. continue;
  2243. } else {
  2244. $yes_yure['yure'] = 1;
  2245. $a = M("video_list_test")->where("sl_id=$id and yure=0")->save($yes_yure);
  2246. echo PHP_EOL.'更新';
  2247. }
  2248. }
  2249. }
  2250. /**
  2251. * 将没有预热的数据进行处理
  2252. * @param $templateid []
  2253. * @return $type 消息类型
  2254. */
  2255. public function no_yure_chuli(){
  2256. $select_no_yure = M("video_list_test")->where("yure=0")->field("title,yure,sl_id")->select();
  2257. foreach ($select_no_yure as $key => $value) {
  2258. $sl_id = $value['sl_id'];
  2259. $bb_titile = $value['title'];
  2260. $slgj_id_yure = M("slgj_videos")->where("id=$sl_id")->field("title,one_img,yure")->select();
  2261. $sl_img = $slgj_id_yure[0]['one_img'];
  2262. $sl_yure = $slgj_id_yure[0]['yure'];
  2263. $sl_title = $slgj_id_yure[0]['title'];
  2264. if ($sl_yure == 0) {
  2265. echo PHP_EOL.$sl_yure;
  2266. M("video_list_test")->where("sl_id=$sl_id")->delete();
  2267. }
  2268. }
  2269. }
  2270. /**
  2271. * 测试功能
  2272. * @param $templateid []
  2273. * @return $type 消息类型
  2274. */
  2275. public function test(){
  2276. $data = $this->returnData();
  2277. if (!empty($_POST)){
  2278. }else{
  2279. echo $this->returnData();
  2280. }
  2281. }
  2282. /**
  2283. * 将slgj表id 同步到 video_list 表中
  2284. * @param $templateid []
  2285. * @return $type 消息类型
  2286. */
  2287. public function slgj_tongbu_bibidd_id()
  2288. {
  2289. $video_list_bibidd = M("video_list_test")->where("id!='' and sl_id is null")->field("title")->select();
  2290. foreach ($video_list_bibidd as $key => $value) {
  2291. $bb_title = $value['title'];
  2292. $slgj_id = M("slgj_videos")->where("title='$bb_title'")->getField("id");
  2293. $bb_sl_id_list['sl_id'] = $slgj_id;
  2294. M("video_list_test")->where("title='$bb_title'")->save($bb_sl_id_list);
  2295. }
  2296. }
  2297. /**
  2298. * 测试功能
  2299. * @param $templateid []
  2300. * @return $type 消息类型
  2301. */
  2302. public function test_tuiji_dmemo()
  2303. {
  2304. //获取该获取那天的数据
  2305. $jintian = M("suiji_num")->where("id=1")->getField("time");
  2306. //获取今日页数
  2307. $video_list_suiji_list = M("video_twelve_suiji")->where("type='tuijian' and time='$jintian'")->LIMIT(0, 60)->Field('v_id')->select();
  2308. // print_r($video_list_suiji_list);
  2309. $id_list = array_column($video_list_suiji_list, 'v_id');
  2310. // print_r($id_list);
  2311. $sql_charu = "";
  2312. foreach ($video_list_suiji_list as $key1 => $value1) {
  2313. $duifang_id = $value1['v_id'];;
  2314. $xianzhi_one = " or id='$duifang_id'";
  2315. $sql_charu .= $xianzhi_one;
  2316. }
  2317. // 首先判断用户是否登录 没登录
  2318. $all_suiji_list = array();
  2319. $video_list = M("video_list_test")->where("id=0 $sql_charu")->LIMIT(0, 60)->select();
  2320. // echo PHP_EOL.M("video_list_test")->_sql();
  2321. foreach ($video_list as $key => $value) {
  2322. $id = $value['id'];
  2323. $suozai_num = array_search("$id", $id_list);
  2324. $id_list[$suozai_num] = $value;
  2325. }
  2326. print_r($id_list);
  2327. // 131530
  2328. }
  2329. /**
  2330. * 测试功能
  2331. * @param $templateid []
  2332. * @return $type 消息类型
  2333. */
  2334. public function array_test_demo()
  2335. {
  2336. $key_lsit = array('A', 'B');
  2337. $demo = array('A' => array("a" => '11'), 'B' => array("b" => '22'));
  2338. array_search(array("b" => '2'), $demo);
  2339. }
  2340. /**
  2341. * 首页弹窗链接
  2342. * @param $templateid []
  2343. * @return $type 消息类型
  2344. */
  2345. public function shouye_lianjei()
  2346. {
  2347. header('Content-Type:text/json;charset=utf-8');
  2348. header('Access-Control-Allow-Origin:*');
  2349. header("Access-Contr-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2350. header('Access-Control-Allow-Methods:POST');
  2351. header('Access-Control-Expose-Headers:*');
  2352. $url_list = M("shouye_url")->field("url")->select();
  2353. if ($url_list) {
  2354. $data['message'] = 'ok';
  2355. $data['data'] = $url_list;
  2356. echo json_encode($data);
  2357. } else {
  2358. $data['message'] = 'no';
  2359. $data['data'] = 'no';
  2360. echo json_encode($data);
  2361. }
  2362. }
  2363. /**
  2364. * 返回广告方法
  2365. * @param $templateid []
  2366. * @return $type 消息类型
  2367. */
  2368. public function Return_to_ads()
  2369. {
  2370. if (!empty($_POST)) {
  2371. $avd_type = $_POST['adv_type'];
  2372. switch ($avd_type) {
  2373. case 'list_detail':
  2374. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  2375. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  2376. break;
  2377. case 'video_beg':
  2378. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(1)->select();
  2379. break;
  2380. default:
  2381. echo "type error";
  2382. }
  2383. if ($adv_list) {
  2384. $data['code'] = '200';
  2385. $data['status'] = '1';
  2386. $data['message'] = '';
  2387. $data['data'] = $adv_list;
  2388. echo json_encode($data);
  2389. } else {
  2390. $data['code'] = '200';
  2391. $data['status'] = '2';
  2392. $data['message'] = 'no';
  2393. $data['data'] = array();
  2394. echo json_encode($data);
  2395. }
  2396. } else {
  2397. echo $this->returnData();
  2398. }
  2399. }
  2400. /**
  2401. * 将A.jpg 的图片换成处理好的图片
  2402. * @param $templateid []
  2403. * @return $type 消息类型
  2404. */
  2405. public function tihuan_ajpg_()
  2406. {
  2407. //先找出所有A。jpg
  2408. $all_a_jpg = M("video_list_test")->limit(11000, 12000)->field("sl_id,id")->select();
  2409. foreach ($all_a_jpg as $key => $value) {
  2410. $bb_id = $value['id'];
  2411. $sl_id = $value['sl_id'];
  2412. $newnew_img = M("slgj_videos")->where("id=$sl_id")->getField("one_img");
  2413. if ($newnew_img == null) {
  2414. $newnew_img = 'https://www.bibidd.com/bibidd_testtest/A.jpg';
  2415. }
  2416. $now_update_list['top_img'] = $newnew_img;
  2417. $yn_chenggong = M("video_list_test")->where("id=$bb_id")->save($now_update_list);
  2418. echo PHP_EOL . M("video_list_test")->_sql();
  2419. if ($yn_chenggong) {
  2420. echo PHP_EOL . '成功';
  2421. } else {
  2422. echo PHP_EOL . '失败了!!!';
  2423. }
  2424. }
  2425. }
  2426. /**
  2427. * 将a.jpg图片替换
  2428. * @param $templateid []
  2429. * @return $type 消息类型
  2430. */
  2431. public function ajpg_tiuan_yes(){
  2432. $ajpg_list_map = M("video_list_test")->where("top_img='https://www.bibidd.com/bibidd_testtest/A.jpg'")->field("id,sl_id,title")->select();
  2433. foreach ($ajpg_list_map as $key => $value) {
  2434. $bb_id =$value['id'];
  2435. $slgj_id = $value['sl_id'];
  2436. $slgj_title = $value['title'];
  2437. $yn_youshuju = M("slgj_videos")->where("id=$slgj_id")->getField("one_img");
  2438. if ($yn_youshuju) {
  2439. $gegxin_list['top_img'] =$yn_youshuju;
  2440. M("video_list_test")->where("id=$bb_id")->save($gegxin_list);
  2441. echo PHP_EOL.$yn_youshuju;
  2442. echo PHP_EOL.'有数据';
  2443. }else{
  2444. M("video_list_test")->where("id=$bb_id")->delete();
  2445. echo PHP_EOL.$yn_youshuju;
  2446. echo PHP_EOL.'无数据';
  2447. }
  2448. }
  2449. }
  2450. /**
  2451. * 查询用户是否是会员
  2452. * @param $templateid []
  2453. * @return $type 消息类型
  2454. */
  2455. public function panduan_huiyuan(){
  2456. header('Content-Type:text/json;charset=utf-8');
  2457. header('Access-Control-Allow-Origin:*');
  2458. header("Access-Contr-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2459. header('Access-Control-Allow-Methods:POST');
  2460. header('Access-Control-Expose-Headers:*');
  2461. if (!empty($_POST)){
  2462. $uid = $_POST['uid'];
  2463. $huiyuan_time_list =M("user_info")->where("id=$uid")->field("vip_over_time,vip_yn,gold_coins_number")->select();
  2464. $huiyuan_time = $huiyuan_time_list[0]['vip_over_time'];
  2465. $huiyuan_type= $huiyuan_time_list[0]['vip_yn'];
  2466. $user_gold_coins= $huiyuan_time_list[0]['gold_coins_number'];
  2467. $now_time = time();
  2468. if ($huiyuan_time>$now_time) {
  2469. $data['code'] = '200';
  2470. $data['status'] = '1';
  2471. $data['type'] = $huiyuan_type;
  2472. $data['message'] = 'is_vip';
  2473. echo json_encode($data);
  2474. } else {
  2475. //不是会员判断是否有足够余额来
  2476. if ($user_gold_coins>=48){
  2477. $data['code'] = '200';
  2478. $data['status'] = '2';
  2479. $data['coins'] = 'yes_coins';
  2480. $data['message'] = 'no_vip';
  2481. echo json_encode($data);
  2482. }else{
  2483. $data['code'] = '200';
  2484. $data['status'] = '3';
  2485. $data['coins'] = 'no_coins';
  2486. $data['message'] = 'no_vip';
  2487. echo json_encode($data);
  2488. }
  2489. }
  2490. }else{
  2491. echo $this->returnData();
  2492. }
  2493. }
  2494. /**
  2495. *获取用户IP地址
  2496. * @param int $type
  2497. * @return mixed
  2498. */
  2499. private function get_bb_ip($type = 0)
  2500. {
  2501. $type = $type ? 1 : 0;
  2502. static $ip = NULL;
  2503. if ($ip !== NULL) return $ip[$type];
  2504. if ($_SERVER['HTTP_X_REAL_IP']) {//nginx 代理模式下,获取客户端真实IP
  2505. $ip = $_SERVER['HTTP_X_REAL_IP'];
  2506. } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {//客户端的ip
  2507. $ip = $_SERVER['HTTP_CLIENT_IP'];
  2508. } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {//浏览当前页面的用户计算机的网关
  2509. $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
  2510. $pos = array_search('unknown', $arr);
  2511. if (false !== $pos) unset($arr[$pos]);
  2512. $ip = trim($arr[0]);
  2513. } elseif (isset($_SERVER['REMOTE_ADDR'])) {
  2514. $ip = $_SERVER['REMOTE_ADDR'];//浏览当前页面的用户计算机的ip地址
  2515. } else {
  2516. $ip = $_SERVER['REMOTE_ADDR'];
  2517. }
  2518. // IP地址合法验证
  2519. $long = sprintf("%u", ip2long($ip));
  2520. $ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
  2521. return $ip[$type];
  2522. }
  2523. /**
  2524. * 非会员 观看视频
  2525. * @param $templateid []
  2526. * @return $type 消息类型
  2527. */
  2528. public function no_vip_views(){
  2529. header('Content-Type:text/json;charset=utf-8');
  2530. header('Access-Control-Allow-Origin:*');
  2531. header("Access-Contr-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2532. header('Access-Control-Allow-Methods:POST');
  2533. header('Access-Control-Expose-Headers:*');
  2534. if (!empty($_POST)){
  2535. $uid = $_POST['uid'];
  2536. $now_views = M("user_info")->where("id=$uid")->getField("views_num");
  2537. if ($now_views==5 or $now_views>5) {
  2538. $data['message'] = 'no';
  2539. echo json_encode($data);
  2540. }else{
  2541. $data['message'] = 'yes';
  2542. echo json_encode($data);
  2543. }
  2544. }else{
  2545. echo $this->returnData();
  2546. }
  2547. }
  2548. /**
  2549. * 添加至收藏
  2550. * @param cid [这个视频或者图片的 id]
  2551. * @param type [video or img]
  2552. * @param uid [用户id]
  2553. * @return $type 消息类型
  2554. */
  2555. public function add_to_shoucang()
  2556. {
  2557. header('Content-Type:text/json;charset=utf-8');
  2558. header('Access-Control-Allow-Origin:*');
  2559. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2560. header('Access-Control-Allow-Methods:POST');
  2561. header('Access-Control-Expose-Headers:*');
  2562. if (!empty($_POST)) {
  2563. $uid = $_POST['uid'];
  2564. $type = $_POST['type'];
  2565. $cid = $_POST['cid'];
  2566. switch ($type) {
  2567. case 'video':
  2568. $video_info_list = M("video_list_test")->where("id=$cid")->field("time_chuo,site,uploader")->select();
  2569. $video_time_chuo = $video_info_list[0]['time_chuo'];
  2570. $video_type= $video_info_list[0]['uploader'];
  2571. $video_list['uid'] = $uid;
  2572. $video_list['vid'] = $cid;
  2573. $video_list['time'] = time();
  2574. $video_list['video_type'] = $video_type;
  2575. $video_list['time_chuo'] = $video_time_chuo;
  2576. $yn_add = M("video_shoucang")->add($video_list);
  2577. break;
  2578. default:
  2579. echo "type error";
  2580. }
  2581. if ($yn_add) {
  2582. $data['message'] = 'ok';
  2583. echo json_encode($data);
  2584. } else {
  2585. $data['message'] = 'error';
  2586. echo json_encode($data);
  2587. }
  2588. } else {
  2589. echo $this->returnData();
  2590. }
  2591. }
  2592. /**
  2593. * 判断是否收藏
  2594. * @param cid [这个视频或者图片的 id]
  2595. * @param type [video or img]
  2596. * @param uid [用户id]
  2597. * @return $type 消息类型
  2598. */
  2599. public function yn_shoucang()
  2600. {
  2601. header('Content-Type:text/json;charset=utf-8');
  2602. header('Access-Control-Allow-Origin:*');
  2603. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2604. header('Access-Control-Allow-Methods:POST');
  2605. header('Access-Control-Expose-Headers:*');
  2606. if (!empty($_POST)) {
  2607. $cid = $_POST['cid'];
  2608. $uid = $_POST['uid'];
  2609. $type = $_POST['type'];
  2610. switch ($type) {
  2611. case 'video':
  2612. $yn_se = M("video_shoucang")->where("uid=$uid and vid=$cid")->getField("id");
  2613. break;
  2614. default:
  2615. echo "type error";
  2616. }
  2617. if ($yn_se) {
  2618. $data['message'] = 'ok';
  2619. echo json_encode($data);
  2620. } else {
  2621. $data['message'] = 'no';
  2622. echo json_encode($data);
  2623. }
  2624. } else {
  2625. echo $this->returnData();
  2626. }
  2627. }
  2628. /**
  2629. * 测试功能
  2630. * @param $templateid []
  2631. * @return $type 消息类型
  2632. */
  2633. public function last_login_jilu(){
  2634. header('Content-Type:text/json;charset=utf-8');
  2635. header('Access-Control-Allow-Origin:*');
  2636. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2637. header('Access-Control-Allow-Methods:POST');
  2638. header('Access-Control-Expose-Headers:*');
  2639. if (!empty($_POST)){
  2640. $uid = $_POST['uid'];
  2641. $ttime = time();
  2642. $ddate = date("Y-m-d H:i:s",$ttime);
  2643. $last_login_list['last_login_time'] = $ttime;
  2644. $last_login_list['last_login_date'] = $ddate;
  2645. $save_yn = M("user_info")->where("id=$uid")->save($last_login_list);
  2646. $jintian_riqi = date("Y-m-d");
  2647. //判断今天表中是是否存在
  2648. $yn_yiyou = M("huoyue_list")->where("uid=$uid and today='$jintian_riqi'")->getField("id");
  2649. if ($yn_yiyou) {
  2650. }else{
  2651. $add_list['today'] = $jintian_riqi;
  2652. $add_list['time'] = $ttime;
  2653. $add_list['uid'] = $uid;
  2654. M("huoyue_list")->add($add_list);
  2655. }
  2656. if ($save_yn) {
  2657. $data['message'] = 'ok';
  2658. echo json_encode($data);
  2659. } else {
  2660. $data['message'] = 'no';
  2661. echo json_encode($data);
  2662. }
  2663. }else{
  2664. echo $this->returnData();
  2665. }
  2666. }
  2667. /**
  2668. * 是否三十天
  2669. * @param $templateid []
  2670. * @return $type 消息类型
  2671. */
  2672. public function threty_dayyn(){
  2673. header('Content-Type:text/json;charset=utf-8');
  2674. header('Access-Control-Allow-Origin:*');
  2675. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2676. header('Access-Control-Allow-Methods:POST');
  2677. header('Access-Control-Expose-Headers:*');
  2678. if (!empty($_POST)){
  2679. $uid = $_POST['uid'];
  2680. $login_time = M("user_info")->where("id=$uid")->getField("add_time");
  2681. $now_time = time();
  2682. $cha_time = 3600 * 24 * 30;
  2683. $jisuan_time = $now_time - $login_time;
  2684. if ($jisuan_time>$cha_time) {
  2685. //chao
  2686. $data['message'] = 'ok';
  2687. echo json_encode($data);
  2688. } else {
  2689. //
  2690. $data['message'] = 'no';
  2691. echo json_encode($data);
  2692. }
  2693. }else{
  2694. echo $this->returnData();
  2695. }
  2696. }
  2697. /**
  2698. * 智博地址 和 免费视频
  2699. * 1.4修改
  2700. * 免费用户推荐1视频
  2701. * 付费用户推荐3视频
  2702. * @param $templateid []
  2703. * @return $type 消息类型
  2704. */
  2705. public function free_video_adv(){
  2706. header('Content-Type:text/json;charset=utf-8');
  2707. header('Access-Control-Allow-Origin:*');
  2708. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2709. header('Access-Control-Allow-Methods:POST');
  2710. header('Access-Control-Expose-Headers:*');
  2711. if (!empty($_POST)){
  2712. $user_type = $_POST['type'];
  2713. if ($user_type=='0') {
  2714. $free_list = M("free_video_zb")->where("id=1")->field("free_video,url")->select();
  2715. $free_id = $free_list[0]['free_video'];
  2716. $adv_url = $free_list[0]['url'];
  2717. $video_list = M("video_list_test")->where("id=$free_id")->select();
  2718. $data['code'] = '200';
  2719. $data['status'] = '1';
  2720. $data['data'] = array($video_list);
  2721. $data['data']['adv_url'] =$adv_url ;
  2722. echo json_encode($data);
  2723. } else {
  2724. $free_list = M("free_video_zb")->where("id is not null")->field("free_video,url")->select();
  2725. $free_id = $free_list[0]['free_video'];
  2726. $adv_url = $free_list[0]['url'];
  2727. $free_two_id =$free_list[1]['free_video'];
  2728. $free_three_id =$free_list[2]['free_video'];
  2729. $video_list_one = M("video_list_test")->where("id=$free_id")->select();
  2730. $video_list = M("video_list_test")->where("id=$free_two_id or id=$free_three_id")->select();
  2731. $video_list_list = array_merge($video_list_one,$video_list);
  2732. $data['code'] = '200';
  2733. $data['status'] = '1';
  2734. $data['data'] = array($video_list_list);
  2735. $data['data']['adv_url'] =$adv_url ;
  2736. echo json_encode($data);
  2737. }
  2738. }else{
  2739. $free_list = M("free_video_zb")->where("id=1")->field("free_video,url")->select();
  2740. $free_id = $free_list[0]['free_video'];
  2741. $adv_url = $free_list[0]['url'];
  2742. $video_list = M("video_list_test")->where("id=$free_id")->select();
  2743. $data['code'] = '200';
  2744. $data['status'] = '1';
  2745. $data['data'] = $video_list[0];
  2746. $data['data']['adv_url'] =$adv_url ;
  2747. echo json_encode($data);
  2748. }
  2749. }
  2750. /**
  2751. * 代理详情
  2752. * 一页50
  2753. * 本月代理
  2754. * 积累代理
  2755. * @param $templateid []
  2756. * @return $type 消息类型
  2757. */
  2758. public function agentlist(){
  2759. header('Content-Type:text/json;charset=utf-8');
  2760. header('Access-Control-Allow-Origin:*');
  2761. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2762. header('Access-Control-Allow-Methods:POST');
  2763. header('Access-Control-Expose-Headers:*');
  2764. if (!empty($_POST)){
  2765. $yue_start_time = strtotime('first day of this month midnight');;
  2766. $yue_end_time = strtotime('first day of next month midnight') - 1;
  2767. $uid = $_POST['uid'];
  2768. $page = $_POST['page'];
  2769. $page_one = ($page - 1) * 50;
  2770. $data_type = $_POST['data_type'];
  2771. switch ($data_type) {
  2772. case 'month':
  2773. // ->order("id desc")
  2774. $list_agent = M("pop_user")->where("uid=$uid and add_time BETWEEN $yue_start_time and $yue_end_time or uid=$uid and agent_money_time BETWEEN $yue_start_time and $yue_end_time")->order("id desc")->field("get_name,pay_brokerage,pay_money,add_date")->LIMIT($page_one, 50)->select();
  2775. $list_agent_num = M("pop_user")->where("uid=$uid and add_time BETWEEN $yue_start_time and $yue_end_time or uid=$uid and agent_money_time BETWEEN $yue_start_time and $yue_end_time")->count();
  2776. break;
  2777. case 'accumulate':
  2778. // ->order("id desc")
  2779. $list_agent = M("pop_user")->where("uid=$uid")->field("get_name,pay_brokerage,pay_money,add_date")->order("id desc")->LIMIT($page_one, 50)->select();
  2780. $list_agent_num = M("pop_user")->where("uid=$uid")->count();
  2781. break;
  2782. default:
  2783. $data['message'] = 'type_error';
  2784. echo json_encode($data);
  2785. die();
  2786. }
  2787. if (!empty($list_agent)) {
  2788. $data['code'] = '200';
  2789. $data['status'] = '1';
  2790. $data['status'] = 'ok';
  2791. $data['data'] = $list_agent;
  2792. $data['data_num'] = $list_agent_num;
  2793. echo json_encode($data);
  2794. }else{
  2795. $data['code'] = '200';
  2796. $data['status'] = '1';
  2797. $data['message'] = 'null';
  2798. $data['data'] = array();
  2799. $data['data_num'] = 0;
  2800. echo json_encode($data);
  2801. }
  2802. }else{
  2803. echo $this->returnData();
  2804. }
  2805. }
  2806. /**
  2807. * 积累 or 月 代理数量
  2808. * @param $templateid []
  2809. * @return $type 消息类型
  2810. */
  2811. public function accumulate_month_agent(){
  2812. header('Content-Type:text/json;charset=utf-8');
  2813. header('Access-Control-Allow-Origin:*');
  2814. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2815. header('Access-Control-Allow-Methods:POST');
  2816. header('Access-Control-Expose-Headers:*');
  2817. if (!empty($_POST)){
  2818. $yue_start_time = strtotime('first day of this month midnight');;
  2819. $yue_end_time = strtotime('first day of next month midnight') - 1;
  2820. $uid = $_POST['uid'];
  2821. $data_type = $_POST['data_type'];
  2822. switch ($data_type) {
  2823. case 'month':
  2824. //佣金
  2825. $agent_money_sum = M("user_info")->where("id=$uid")->getField('agent_money');
  2826. //用户数量
  2827. $agent_people_num = M("pop_user")->where("uid=$uid and add_time BETWEEN $yue_start_time and $yue_end_time")->count();
  2828. //会员数量
  2829. $agent_people_vip_num = M("pop_user")->where("uid=$uid and agent_money_time BETWEEN $yue_start_time and $yue_end_time and pay_money>0")->count();
  2830. break;
  2831. case 'accumulate':
  2832. //佣金
  2833. $agent_money_sum = M("agent_money")->where("uid=$uid")->sum('agent_money');
  2834. //用户数量
  2835. $agent_people_num = M("pop_user")->where("uid=$uid")->count();
  2836. //会员数量
  2837. $agent_people_vip_num = M("pop_user")->where("uid=$uid and pay_money>0")->count();
  2838. break;
  2839. default:
  2840. $data['message'] = 'type_error';
  2841. echo json_encode($data);
  2842. die();
  2843. }
  2844. if (empty($agent_money_sum)) {
  2845. $agent_money_sum=0;
  2846. }
  2847. if (empty($agent_people_num)) {
  2848. $agent_people_num=0;
  2849. }
  2850. if (empty($agent_people_vip_num)) {
  2851. $agent_people_vip_num=0;
  2852. }
  2853. $agent_list['agent_money'] =$agent_money_sum ;
  2854. $agent_list['agent_people_num'] = $agent_people_num;
  2855. $agent_list['agent_vip_num'] =$agent_people_vip_num ;
  2856. if (!empty($agent_list)) {
  2857. $data['code'] = '200';
  2858. $data['status'] = '1';
  2859. $data['status'] = 'ok';
  2860. $data['data'] = $agent_list;
  2861. echo json_encode($data);
  2862. }else{
  2863. $data['code'] = '200';
  2864. $data['status'] = '1';
  2865. $data['message'] = 'null';
  2866. $data['data'] = array();
  2867. echo json_encode($data);
  2868. }
  2869. }else{
  2870. echo $this->returnData();
  2871. }
  2872. }
  2873. /**
  2874. * 提现佣金数
  2875. * @param $templateid []
  2876. * @return $type 消息类型
  2877. */
  2878. public function withdrawamount(){
  2879. header('Content-Type:text/json;charset=utf-8');
  2880. header('Access-Control-Allow-Origin:*');
  2881. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2882. header('Access-Control-Allow-Methods:POST');
  2883. header('Access-Control-Expose-Headers:*');
  2884. if (!empty($_POST)){
  2885. $uid = $_POST['uid'];
  2886. }else{
  2887. echo $this->returnData();
  2888. }
  2889. }
  2890. /**
  2891. * 提现支付宝
  2892. * @param $templateid []
  2893. * @return $type 消息类型
  2894. */
  2895. public function seting_withdrawal_alipay(){
  2896. header('Content-Type:text/json;charset=utf-8');
  2897. header('Access-Control-Allow-Origin:*');
  2898. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2899. header('Access-Control-Allow-Methods:POST');
  2900. header('Access-Control-Expose-Headers:*');
  2901. if (!empty($_POST)){
  2902. $uid = $_POST['uid'];
  2903. $realname = $_POST['realname'];
  2904. $alipayuser = $_POST['alipayuser'];
  2905. $save_time = time();
  2906. //15天后
  2907. $cha_time = 3600 * 24 * 15;
  2908. $save_list['uid'] = $uid;
  2909. $save_list['real_name'] =$realname ;
  2910. $save_list['alipay_user'] =$alipayuser ;
  2911. $save_list['save_time'] = $save_time+$cha_time;
  2912. $last_save_time = M("alipay_user")->where("uid=$uid")->getField("save_time");
  2913. if (empty($last_save_time)) {
  2914. //没有数据能添加
  2915. M("alipay_user")->add($save_list);
  2916. $data['code'] = '200';
  2917. $data['status'] = '1';
  2918. $data['message'] = 'save_yes';
  2919. echo json_encode($data);
  2920. }else{
  2921. $now_time = time();
  2922. if ($now_time>$last_save_time) {
  2923. //chao
  2924. $yn_save = M("alipay_user")->where("uid=$uid")->save($save_list);
  2925. if ($yn_save) {
  2926. $data['code'] = '200';
  2927. $data['status'] = '1';
  2928. $data['message'] = 'save_yes';
  2929. echo json_encode($data);
  2930. } else {
  2931. $data['code'] = '200';
  2932. $data['status'] = '2';
  2933. $data['message'] = 'save_no';
  2934. echo json_encode($data);
  2935. }
  2936. }else{
  2937. $userip = $this->get_bb_ip();
  2938. $ttime = time();
  2939. $ddate = date("Y-m-d H:i:s",$ttime);
  2940. $last_login_list['time'] = $ttime;
  2941. $last_login_list['time_date'] = $ddate;
  2942. $last_login_list['uid'] = $uid;
  2943. $last_login_list['ip'] = $userip;
  2944. M("black_box")->add($last_login_list);
  2945. die();
  2946. }
  2947. }
  2948. }else{
  2949. echo $this->returnData();
  2950. }
  2951. }
  2952. /**
  2953. * 判断是否能修改 支付宝账号
  2954. * @param $templateid []
  2955. * @return $type 消息类型
  2956. */
  2957. public function judgmentsavealipay(){
  2958. header('Content-Type:text/json;charset=utf-8');
  2959. header('Access-Control-Allow-Origin:*');
  2960. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  2961. header('Access-Control-Allow-Methods:POST');
  2962. header('Access-Control-Expose-Headers:*');
  2963. if (!empty($_POST)){
  2964. $uid = $_POST['uid'];
  2965. $last_save_time_list = M("alipay_user")->where("uid=$uid")->Field('real_name,alipay_user,save_time')->select();
  2966. $last_save_time = $last_save_time_list[0]['save_time'];
  2967. $r_name = $last_save_time_list[0]['save_time'];
  2968. $r_name = $last_save_time_list[0]['save_time'];
  2969. $today = time();
  2970. if (empty($last_save_time_list)) {
  2971. $last_save_time_list[0]['real_name'] ='';
  2972. $last_save_time_list[0]['alipay_user'] ='';
  2973. $last_save_time_list[0]['save_time'] ='0';
  2974. }
  2975. if (empty($last_save_time)) {
  2976. //没有数据能添加
  2977. $data['message'] = 'okay';
  2978. $data['data'] = $last_save_time_list;
  2979. echo json_encode($data);
  2980. }else{
  2981. $now_time = time();
  2982. if ($now_time>$last_save_time) {
  2983. //chao
  2984. $data['message'] = 'okay';
  2985. $data['data'] = $last_save_time_list;
  2986. echo json_encode($data);
  2987. } else {
  2988. // 计算距离指定时间戳的差值(单位:秒)
  2989. $timeDifference = $last_save_time - $today;
  2990. // 转换为天数
  2991. $daysRemaining = ceil($timeDifference / (60 * 60 * 24));
  2992. $data['message'] = 'no';
  2993. $data['save_day'] = $daysRemaining;
  2994. $data['data'] = $last_save_time_list;
  2995. echo json_encode($data);
  2996. }
  2997. }
  2998. }else{
  2999. echo $this->returnData();
  3000. }
  3001. }
  3002. /**
  3003. * 用户代理佣金数
  3004. * @param $templateid []
  3005. * @return $type 消息类型
  3006. */
  3007. public function show_agent_user_money(){
  3008. header('Content-Type:text/json;charset=utf-8');
  3009. header('Access-Control-Allow-Origin:*');
  3010. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3011. header('Access-Control-Allow-Methods:POST');
  3012. header('Access-Control-Expose-Headers:*');
  3013. if (!empty($_POST)){
  3014. $uid = $_POST['uid'];
  3015. $user_agent_money_list = M("user_info")->where("id=$uid")->field("last_month_agent_money,payable_one,payable_two")->select();
  3016. $user_agent_money = $user_agent_money_list[0]['last_month_agent_money'];
  3017. $button_one = $user_agent_money_list[0]['payable_one'];
  3018. $button_two = $user_agent_money_list[0]['payable_two'];
  3019. // 获取当前月份
  3020. $currentMonth = date('n');
  3021. // 获取下个月的月份
  3022. $nextMonth = date('n', strtotime('+1 month'));
  3023. if ($button_one==1 and $button_two==1) {
  3024. $data['code'] = '200';
  3025. $data['status'] = '4';
  3026. $data['message'] = '已打款';
  3027. $data['data'] = array("$nextMonth", "$user_agent_money");
  3028. echo json_encode($data);
  3029. die();
  3030. }
  3031. if (!empty($user_agent_money)) {
  3032. if ($user_agent_money>=200) {
  3033. //大于等于200则显示
  3034. $data['code'] = '200';
  3035. $data['status'] = '1';
  3036. $data['message'] = 'true';
  3037. $data['data'] = array("$nextMonth", "$user_agent_money");
  3038. echo json_encode($data);
  3039. }else{
  3040. $data['code'] = '200';
  3041. $data['status'] = '2';
  3042. $data['message'] = 'null';
  3043. $data['data'] = $data['data'] = array("$nextMonth", "0");;
  3044. echo json_encode($data);
  3045. }
  3046. } else {
  3047. $data['code'] = '200';
  3048. $data['status'] = '3';
  3049. $data['message'] = 'null';
  3050. $data['data'] = $data['data'] = array("$nextMonth", "0");;
  3051. echo json_encode($data);
  3052. }
  3053. }else{
  3054. echo $this->returnData();
  3055. }
  3056. }
  3057. /**
  3058. * 测试功能
  3059. * @param $templateid []
  3060. * @return $type 消息类型
  3061. */
  3062. public function accumulateandmonth(){
  3063. // 获取本月起始时间戳(零点)
  3064. $firstDayOfMonth = strtotime('first day of this month midnight');
  3065. // 获取下个月起始时间戳(零点),并减去1秒
  3066. $firstDayOfNextMonth = strtotime('first day of next month midnight') - 1;
  3067. // 输出时间戳区间
  3068. echo "本月起始时间戳:" . $firstDayOfMonth . "<br>";
  3069. echo "本月结束时间戳:" . $firstDayOfNextMonth . "<br>";
  3070. // 可以将时间戳转换为日期格式进行查看
  3071. echo "本月起始日期:" . date('Y-m-d H:i:s', $firstDayOfMonth) . "<br>";
  3072. echo "本月结束日期:" . date('Y-m-d H:i:s', $firstDayOfNextMonth) . "<br>";
  3073. }
  3074. /**
  3075. *显示支付宝账号
  3076. * @param $templateid []
  3077. * @return $type 消息类型
  3078. */
  3079. public function show_alipay_user(){
  3080. $data = $this->returnData();
  3081. if (!empty($_POST)){
  3082. $uid = $_POST['uid'];
  3083. }else{
  3084. echo $this->returnData();
  3085. }
  3086. }
  3087. /**
  3088. * 测试功能
  3089. * @param $templateid []
  3090. * @return $type 消息类型
  3091. */
  3092. public function favorite_video_list(){
  3093. header('Content-Type:text/json;charset=utf-8');
  3094. header('Access-Control-Allow-Origin:*');
  3095. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3096. header('Access-Control-Allow-Methods:POST');
  3097. header('Access-Control-Expose-Headers:*');
  3098. if (!empty($_POST)){
  3099. $jintian = M("suiji_num")->where("id=1")->getField("time");
  3100. $page = $_POST['page'];
  3101. $page_one = ($page - 1) * 30;
  3102. //所有视频id
  3103. $favorite_video_list = M("shoucang_two_video")->where("time='$jintian'")->field("v_id")->LIMIT($page_one, 30)->select();
  3104. $favorite_video_amount = M("shoucang_two_video")->where("time='$jintian'")->field("v_id")->select();
  3105. $video_list_count = count($favorite_video_amount);
  3106. foreach ($favorite_video_list as $key1 => $value1) {
  3107. $duifang_id = $value1['v_id'];
  3108. $xianzhi_one = " or id='$duifang_id'";
  3109. $sql_charu .= $xianzhi_one;
  3110. }
  3111. $video_list = M("video_list_test")->where("id=0 $sql_charu")->select();
  3112. //获取广告列表
  3113. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  3114. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  3115. $jia_num = 5;
  3116. $qishi_num = 0;
  3117. $data_list_number = count($video_list);
  3118. $quzheng_num = floor($data_list_number / 5);
  3119. foreach ($adv_list as $key => $value) {
  3120. $charu_array = array($adv_list[$key]);
  3121. array_splice($video_list, $jia_num, 0, $charu_array);
  3122. $jia_num += 6;
  3123. $qishi_num += 1;
  3124. if ($qishi_num >= $quzheng_num) {
  3125. break;
  3126. }
  3127. }
  3128. if (!empty($video_list)) {
  3129. $data['code'] = '200';
  3130. $data['status'] = '1';
  3131. $data['message'] = 'yes';
  3132. $data['data'] = $video_list;
  3133. $data['count'] = $video_list_count;
  3134. echo json_encode($data);
  3135. } else {
  3136. $data['code'] = '200';
  3137. $data['status'] = '1';
  3138. $data['message'] = 'yes';
  3139. $data['data'] = $video_list;
  3140. $data['count'] = 0;
  3141. echo json_encode($data);
  3142. }
  3143. }else{
  3144. echo $this->returnData();
  3145. }
  3146. }
  3147. /**
  3148. *
  3149. * checkbank.php文件
  3150. *
  3151. * User: jackhhy
  3152. * DateTime: 2018/12/1 10:01
  3153. */
  3154. public function bankInfo($card,$bankList)
  3155. {
  3156. header('Content-type:text/html;charset=utf-8');
  3157. $card_8 = substr($card, 0, 8);
  3158. if (isset($bankList[$card_8])) {
  3159. // echo $bankList[$card_8];
  3160. return $bankList[$card_8];
  3161. }
  3162. $card_6 = substr($card, 0, 6);
  3163. if (isset($bankList[$card_6])) {
  3164. // echo $bankList[$card_6];
  3165. return $bankList[$card_6];
  3166. }
  3167. $card_5 = substr($card, 0, 5);
  3168. if (isset($bankList[$card_5])) {
  3169. // echo $bankList[$card_5];
  3170. return $bankList[$card_5];
  3171. }
  3172. $card_4 = substr($card, 0, 4);
  3173. if (isset($bankList[$card_4])) {
  3174. // echo $bankList[$card_4];
  3175. return $bankList[$card_4];
  3176. }
  3177. return '该卡号信息暂未录入';
  3178. }
  3179. /**
  3180. * 判断是否能修改 支付宝账号
  3181. * @param $templateid []
  3182. * @return $type 消息类型
  3183. */
  3184. public function judgmentsave_bank_card(){
  3185. header('Content-Type:text/json;charset=utf-8');
  3186. header('Access-Control-Allow-Origin:*');
  3187. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3188. header('Access-Control-Allow-Methods:POST');
  3189. header('Access-Control-Expose-Headers:*');
  3190. if (!empty($_POST)){
  3191. $uid = $_POST['uid'];
  3192. $last_save_time_list = M("agent_bank_card_info")->where("uid=$uid")->Field('real_name,bank_card_number,bank_name,save_time')->select();
  3193. $last_save_time = $last_save_time_list[0]['save_time'];
  3194. $today = time();
  3195. if (empty($last_save_time_list)) {
  3196. $last_save_time_list[0]['real_name'] ='';
  3197. $last_save_time_list[0]['bank_card_number'] ='';
  3198. $last_save_time_list[0]['bank_name'] ='';
  3199. $last_save_time_list[0]['save_time'] ='0';
  3200. }
  3201. if (empty($last_save_time)) {
  3202. //没有数据能添加
  3203. $data['message'] = 'okay';
  3204. $data['data'] = $last_save_time_list;
  3205. echo json_encode($data);
  3206. }else{
  3207. $now_time = time();
  3208. if ($now_time>$last_save_time) {
  3209. //chao
  3210. $data['message'] = 'okay';
  3211. $data['data'] = $last_save_time_list;
  3212. echo json_encode($data);
  3213. } else {
  3214. // 计算距离指定时间戳的差值(单位:秒)
  3215. $timeDifference = $last_save_time - $today;
  3216. // 转换为天数
  3217. $daysRemaining = floor($timeDifference / (60 * 60 * 24));
  3218. $data['message'] = 'no';
  3219. $data['save_day'] = $daysRemaining;
  3220. $data['data'] = $last_save_time_list;
  3221. echo json_encode($data);
  3222. }
  3223. }
  3224. }else{
  3225. echo $this->returnData();
  3226. }
  3227. }
  3228. /**
  3229. * 提现银行卡
  3230. * @param $templateid []
  3231. * @return $type 消息类型
  3232. */
  3233. public function seting_bank_card(){
  3234. header('Content-Type:text/json;charset=utf-8');
  3235. header('Access-Control-Allow-Origin:*');
  3236. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3237. header('Access-Control-Allow-Methods:POST');
  3238. header('Access-Control-Expose-Headers:*');
  3239. if (!empty($_POST)){
  3240. $uid = $_POST['uid'];
  3241. $realname = $_POST['realname'];
  3242. $bank_card_number = $_POST['bank_card_number'];
  3243. $bank_name = $_POST['bank_name'];
  3244. $save_time = time();
  3245. //15天后
  3246. $cha_time = 3600 * 24 * 15;
  3247. $save_list['uid'] = $uid;
  3248. $save_list['real_name'] =$realname ;
  3249. $save_list['bank_card_number'] =$bank_card_number ;
  3250. $save_list['bank_name'] =$bank_name ;
  3251. $save_list['save_time'] = $save_time+$cha_time;
  3252. $save_list['pay_type'] = 'bank';
  3253. $last_save_time = M("agent_bank_card_info")->where("uid=$uid")->getField("save_time");
  3254. if (empty($last_save_time)) {
  3255. //没有数据能添加
  3256. M("agent_bank_card_info")->add($save_list);
  3257. $data['code'] = '200';
  3258. $data['status'] = '1';
  3259. $data['message'] = 'save_yes';
  3260. echo json_encode($data);
  3261. }else{
  3262. $now_time = time();
  3263. if ($now_time>$last_save_time) {
  3264. //chao
  3265. $yn_save = M("agent_bank_card_info")->where("uid=$uid")->save($save_list);
  3266. if ($yn_save) {
  3267. $data['code'] = '200';
  3268. $data['status'] = '1';
  3269. $data['message'] = 'save_yes';
  3270. echo json_encode($data);
  3271. } else {
  3272. $data['code'] = '200';
  3273. $data['status'] = '2';
  3274. $data['message'] = 'save_no';
  3275. echo json_encode($data);
  3276. }
  3277. }else{
  3278. $userip = $this->get_bb_ip();
  3279. $ttime = time();
  3280. $ddate = date("Y-m-d H:i:s",$ttime);
  3281. $last_login_list['time'] = $ttime;
  3282. $last_login_list['time_date'] = $ddate;
  3283. $last_login_list['uid'] = $uid;
  3284. $last_login_list['ip'] = $userip;
  3285. M("black_box")->add($last_login_list);
  3286. die();
  3287. }
  3288. }
  3289. }else{
  3290. echo $this->returnData();
  3291. }
  3292. }
  3293. /**
  3294. * 测试功能
  3295. * @param $templateid []
  3296. * @return $type 消息类型
  3297. */
  3298. public function get_bank_name(){
  3299. header('Content-type:text/html;charset=utf-8');
  3300. header('Access-Control-Allow-Origin:*');
  3301. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3302. header('Access-Control-Allow-Methods:POST');
  3303. header('Access-Control-Expose-Headers:*');
  3304. include 'bankList.php';
  3305. if (!empty($_POST)){
  3306. $bank_card_number = $_POST['bank_card_number'];
  3307. /** @noinspection PhpUndefinedVariableInspection */
  3308. $wula = $this->bankInfo("{$bank_card_number}", $bankList);
  3309. if ($wula =='该卡号信息暂未录入') {
  3310. $data['code'] = '200';
  3311. $data['status'] = '2';
  3312. $data['data'] = "该卡号信息暂未录入";
  3313. echo json_encode($data);
  3314. die();
  3315. }
  3316. $bank_name_list = explode('-',$wula);
  3317. $bank_name = $bank_name_list[0];
  3318. $data['code'] = '200';
  3319. $data['status'] = 1;
  3320. $data['data'] = "$bank_name";
  3321. echo json_encode($data);
  3322. }else{
  3323. echo $this->returnData();
  3324. }
  3325. }
  3326. /**
  3327. * 海角列表
  3328. * @param $templateid []
  3329. * @return $type 消息类型
  3330. */
  3331. public function haijiao_video_list(){
  3332. header('Content-type:text/html;charset=utf-8');
  3333. header('Access-Control-Allow-Origin:*');
  3334. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3335. header('Access-Control-Allow-Methods:POST');
  3336. header('Access-Control-Expose-Headers:*');
  3337. if (!empty($_POST)){
  3338. }else{
  3339. echo $this->returnData();
  3340. }
  3341. }
  3342. /**
  3343. * 反差列表
  3344. * @param $templateid []
  3345. * @return $type 消息类型
  3346. */
  3347. public function fancha_video_list(){
  3348. header('Content-type:text/html;charset=utf-8');
  3349. header('Access-Control-Allow-Origin:*');
  3350. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3351. header('Access-Control-Allow-Methods:POST');
  3352. header('Access-Control-Expose-Headers:*');
  3353. if (!empty($_POST)){
  3354. }else{
  3355. echo $this->returnData();
  3356. }
  3357. }
  3358. /**
  3359. * 首页视频列表112
  3360. * @param $templateid []
  3361. * @return $type 消息类型
  3362. */
  3363. public function twotwoone_list(){
  3364. header('Content-type:text/html;charset=utf-8');
  3365. header('Access-Control-Allow-Origin:*');
  3366. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3367. header('Access-Control-Allow-Methods:POST');
  3368. header('Access-Control-Expose-Headers:*');
  3369. if (!empty($_POST)){
  3370. $page = $_POST['page'];
  3371. $uid = $_POST['uid'];
  3372. $page_one = ($page - 1) * 42;
  3373. //获取该获取那天的数据
  3374. $jintian = M("suiji_num")->where("id=1")->getField("time");
  3375. //获取今日页数
  3376. // $video_list_suiji_list = M("two_two_one_video_test")->where("time='$jintian'")->LIMIT($page_one, 42)->Field('v_id')->select();
  3377. $video_list_suiji_list = M("two_two_one_video")->where("time='$jintian'")->LIMIT($page_one, 42)->Field('v_id')->select();
  3378. // $video_list_suiji_list = M("two_two_one_video_test")->where("id is not null")->LIMIT($page_one, 30)->Field('v_id')->select();
  3379. // echo PHP_EOL.M("two_two_one_video_test")->_sql();
  3380. $id_list = array_column($video_list_suiji_list, 'v_id');
  3381. $sql_charu = "";
  3382. foreach ($video_list_suiji_list as $key1 => $value1) {
  3383. $duifang_id = $value1['v_id'];;
  3384. $xianzhi_one = " or id='$duifang_id'";
  3385. $sql_charu .= $xianzhi_one;
  3386. }
  3387. $video_list = M("video_list_test")->where("id=0 $sql_charu")->select();
  3388. // echo PHP_EOL.M("video_list_test")->_sql();
  3389. //牛逼
  3390. $wula_lsit = array();
  3391. $num_fc = 0;
  3392. $new_twotwo_list = array();
  3393. // print_r($video_list);
  3394. // echo PHP_EOL.'1991';
  3395. foreach ($video_list as $key => $value) {
  3396. $id = $value['id'];
  3397. $video_site = $value['site'];
  3398. if ($id==''){
  3399. $value= M("video_list_test")->where("id=146145")->select();
  3400. }
  3401. $suozai_num = array_search("$id", $id_list);
  3402. $id_list[$suozai_num] = $value;
  3403. }
  3404. // print_r($id_list);
  3405. // die();
  3406. foreach ($id_list as $keyn => $valuen) {
  3407. $video_site_n = $valuen['site'];
  3408. //被删数据替换
  3409. if (is_string($valuen)){
  3410. $valuen = M("video_list_test")->where("site = 'HL'")->order("rand()")->LIMIT(1)->select()[0];
  3411. }
  3412. // echo PHP_EOL.'-----';
  3413. // echo PHP_EOL.$video_site_n;
  3414. // echo PHP_EOL.$value;
  3415. if ($video_site_n =='FC') {
  3416. $goumai_str_list = M("hj_fc_buy_record")->where("uid=$uid")->field("v_id")->select();
  3417. $goumai_str = ',';
  3418. foreach ($goumai_str_list as $key1 => $value1) {
  3419. $vv_id = $value1['v_id'];
  3420. $goumai_str .= "$vv_id".",";
  3421. }
  3422. $now_vid = $valuen['id'];
  3423. $needle = ",$now_vid,";
  3424. if (strpos($goumai_str, $needle) !== false){
  3425. $valuen['coins'] = "-1";
  3426. }
  3427. $num_fc++;
  3428. array_push($wula_lsit, $valuen);
  3429. if ($num_fc==2) {
  3430. array_push($new_twotwo_list,$wula_lsit);
  3431. $num_fc = 0;
  3432. $wula_lsit = array();
  3433. }
  3434. }else{
  3435. array_push($new_twotwo_list,$valuen);
  3436. }
  3437. }
  3438. $data['all_num'] = 10624;
  3439. $data['code'] = '200';
  3440. //获取广告列表
  3441. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(6)->select();
  3442. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  3443. $jia_num = 6;
  3444. $qishi_num = 0;
  3445. $data_list_number = count($id_list);
  3446. $quzheng_num = floor($data_list_number / 7);
  3447. foreach ($adv_list as $key => $value) {
  3448. $charu_array = array();
  3449. $charu_array = array($adv_list[$key]);
  3450. array_splice($new_twotwo_list, $jia_num, 0, $charu_array);
  3451. $jia_num += 7;
  3452. $qishi_num += 1;
  3453. if ($qishi_num >= $quzheng_num) {
  3454. break;
  3455. }
  3456. }
  3457. $data['data'] = $new_twotwo_list;
  3458. echo json_encode($data);
  3459. }else{
  3460. echo $this->returnData();
  3461. }
  3462. }
  3463. /**
  3464. * 查询判断是否能修改USDT
  3465. * 返回已有
  3466. * @param $templateid []
  3467. * @return $type 消息类型
  3468. */
  3469. public function judgmentsave_usdt(){
  3470. header('Content-Type:text/json;charset=utf-8');
  3471. header('Access-Control-Allow-Origin:*');
  3472. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3473. header('Access-Control-Allow-Methods:POST');
  3474. header('Access-Control-Expose-Headers:*');
  3475. if (!empty($_POST)){
  3476. $uid = $_POST['uid'];
  3477. $last_save_time_list = M("agent_bank_card_info")->where("uid=$uid")->Field('usdt_string,save_time')->select();
  3478. $last_save_time = $last_save_time_list[0]['save_time'];
  3479. $today = time();
  3480. if (empty($last_save_time_list)) {
  3481. $last_save_time_list[0]['usdt_string'] ='';
  3482. $last_save_time_list[0]['save_time'] ='0';
  3483. }
  3484. if (empty($last_save_time)) {
  3485. //没有数据能添加
  3486. $data['message'] = 'okay';
  3487. $data['data'] = $last_save_time_list;
  3488. echo json_encode($data);
  3489. }else{
  3490. $now_time = time();
  3491. if ($now_time>$last_save_time) {
  3492. //chao
  3493. $data['message'] = 'okay';
  3494. $data['data'] = $last_save_time_list;
  3495. echo json_encode($data);
  3496. } else {
  3497. // 计算距离指定时间戳的差值(单位:秒)
  3498. $timeDifference = $last_save_time - $today;
  3499. // 转换为天数
  3500. $daysRemaining = floor($timeDifference / (60 * 60 * 24));
  3501. $data['message'] = 'no';
  3502. $data['save_day'] = $daysRemaining;
  3503. $data['data'] = $last_save_time_list;
  3504. echo json_encode($data);
  3505. }
  3506. }
  3507. }else{
  3508. echo $this->returnData();
  3509. }
  3510. }
  3511. /**
  3512. * 提现银行卡
  3513. * @param $templateid []
  3514. * @return $type 消息类型
  3515. */
  3516. public function seting_usdt(){
  3517. header('Content-Type:text/json;charset=utf-8');
  3518. header('Access-Control-Allow-Origin:*');
  3519. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3520. header('Access-Control-Allow-Methods:POST');
  3521. header('Access-Control-Expose-Headers:*');
  3522. if (!empty($_POST)){
  3523. $uid = $_POST['uid'];
  3524. $usdt_string = $_POST['usdt_string'];
  3525. $save_time = time();
  3526. //15天后
  3527. $cha_time = 3600 * 24 * 15;
  3528. $save_list['uid'] = $uid;
  3529. $save_list['usdt_string'] =$usdt_string ;
  3530. $save_list['save_time'] = $save_time+$cha_time;
  3531. $save_list['pay_type'] = 'usdt';
  3532. $last_save_time = M("agent_bank_card_info")->where("uid=$uid")->getField("save_time");
  3533. if (empty($last_save_time)) {
  3534. //没有数据能添加
  3535. M("agent_bank_card_info")->add($save_list);
  3536. $data['code'] = '200';
  3537. $data['status'] = '1';
  3538. $data['message'] = 'save_yes';
  3539. echo json_encode($data);
  3540. }else{
  3541. $now_time = time();
  3542. if ($now_time>$last_save_time) {
  3543. //chao
  3544. $yn_save = M("agent_bank_card_info")->where("uid=$uid")->save($save_list);
  3545. if ($yn_save) {
  3546. $data['code'] = '200';
  3547. $data['status'] = '1';
  3548. $data['message'] = 'save_yes';
  3549. echo json_encode($data);
  3550. } else {
  3551. $data['code'] = '200';
  3552. $data['status'] = '2';
  3553. $data['message'] = 'save_no';
  3554. echo json_encode($data);
  3555. }
  3556. }else{
  3557. $userip = $this->get_bb_ip();
  3558. $ttime = time();
  3559. $ddate = date("Y-m-d H:i:s",$ttime);
  3560. $last_login_list['time'] = $ttime;
  3561. $last_login_list['time_date'] = $ddate;
  3562. $last_login_list['uid'] = $uid;
  3563. $last_login_list['ip'] = $userip;
  3564. M("black_box")->add($last_login_list);
  3565. die();
  3566. }
  3567. }
  3568. }else{
  3569. echo $this->returnData();
  3570. }
  3571. }
  3572. /**
  3573. * c
  3574. * @param $templateid []
  3575. * @return $type 消息类型
  3576. */
  3577. public function get_user_payment(){
  3578. header('Content-Type:text/json;charset=utf-8');
  3579. header('Access-Control-Allow-Origin:*');
  3580. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3581. header('Access-Control-Allow-Methods:POST');
  3582. header('Access-Control-Expose-Headers:*');
  3583. if (!empty($_POST)){
  3584. $uid = $_POST['uid'];
  3585. $bank_info = M("agent_bank_card_info")->where("uid=$uid")->getField("pay_type");
  3586. if (empty($bank_info)) {
  3587. $data['code'] = '200';
  3588. $data['status'] = '1';
  3589. $data['message'] = 'no_set';
  3590. echo json_encode($data);
  3591. } else{
  3592. $data['code'] = '200';
  3593. $data['status'] = '1';
  3594. $data['message'] = $bank_info;
  3595. echo json_encode($data);
  3596. }
  3597. }else{
  3598. echo $this->returnData();
  3599. }
  3600. }
  3601. /**
  3602. * 测试功能
  3603. * @param $templateid []
  3604. * @return $type 消息类型
  3605. */
  3606. public function get_agent_user(){
  3607. header('Content-Type:text/json;charset=utf-8');
  3608. header('Access-Control-Allow-Origin:*');
  3609. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3610. header('Access-Control-Allow-Methods:POST');
  3611. header('Access-Control-Expose-Headers:*');
  3612. if (!empty($_POST)){
  3613. $uid = $_POST['uid'];
  3614. $agent_user_list = M("agent_money")->where("uid=$uid")->field("get_uid")->order("id asc")->LIMIT(2)->select();
  3615. foreach ($agent_user_list as $key => $value) {
  3616. $get_uid = $value['get_uid'];
  3617. $user_info[$key]['name'] = M("pop_user")->where("get_uid=$get_uid")->getField("get_name");
  3618. }
  3619. if (empty($user_info)) {
  3620. $data['code'] = '200';
  3621. $data['message'] = '0';
  3622. $data['data'] = [];
  3623. echo json_encode($data);
  3624. }else{
  3625. $data['code'] = '200';
  3626. $data['message'] = '1';
  3627. $data['data'] = $user_info;
  3628. echo json_encode($data);
  3629. }
  3630. }else{
  3631. echo $this->returnData();
  3632. }
  3633. }
  3634. /**
  3635. * 代理 统计固定增加
  3636. * @param $templateid []
  3637. * @return $type 消息类型
  3638. */
  3639. public function get_agent_record(){
  3640. header('Content-Type:text/json;charset=utf-8');
  3641. header('Access-Control-Allow-Origin:*');
  3642. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3643. header('Access-Control-Allow-Methods:POST');
  3644. header('Access-Control-Expose-Headers:*');
  3645. $agent_list = M("add_agent_record")->where("id=1")->field('agent_people_number,agent_money_acount')->select();
  3646. $data['code'] = '200';
  3647. $data['message'] = '1';
  3648. $data['data'] = $agent_list;
  3649. echo json_encode($data);
  3650. }
  3651. /**
  3652. * 是否在新注册两小时内
  3653. * @param $templateid []
  3654. * @return $type 消息类型
  3655. */
  3656. public function newusertwoh(){
  3657. header('Content-Type:text/json;charset=utf-8');
  3658. header('Access-Control-Allow-Origin:*');
  3659. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3660. header('Access-Control-Allow-Methods:POST');
  3661. header('Access-Control-Expose-Headers:*');
  3662. if (!empty($_POST)){
  3663. $uid =$_POST['uid'];
  3664. //用户注册时间
  3665. $zhuce_time = M("user_info")->where("id=$uid")->getField("add_time");
  3666. //now time
  3667. $now_time = time();
  3668. $time_cha = $now_time - $zhuce_time;
  3669. $two_h =7200;
  3670. $time_now_cha = $two_h - $time_cha;
  3671. if ($two_h<$time_cha) {
  3672. $data['code'] = '200';
  3673. $data['status'] = '1';
  3674. $data['message'] = 'no';
  3675. $data['data'] = "0";
  3676. echo json_encode($data);
  3677. }else{
  3678. $use_first_pay_type = M("user_first_pay")->where("uid=$uid")->field('thirty,fifty,eighty,one_hundred,two_hundred')->select();
  3679. $wula = array('time'=>$time_now_cha,'pay'=>$use_first_pay_type);
  3680. $data['code'] = '200';
  3681. $data['status'] = '1';
  3682. $data['message'] = 'yes';
  3683. $data['data'] = $wula;
  3684. echo json_encode($data);
  3685. }
  3686. }else{
  3687. echo $this->returnData();
  3688. }
  3689. }
  3690. /**
  3691. * 黑料详情
  3692. * @param $templateid []
  3693. * @return $type 消息类型
  3694. */
  3695. public function heiliao_detail(){
  3696. header('Content-Type:text/json;charset=utf-8');
  3697. header('Access-Control-Allow-Origin:*');
  3698. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3699. header('Access-Control-Allow-Methods:POST');
  3700. header('Access-Control-Expose-Headers:*');
  3701. if (!empty($_POST)){
  3702. $video_id = $_POST['video_id'];
  3703. $uid = $_POST['uid'];
  3704. //判读是否登录
  3705. if ($uid == '0' or $uid == '' or $uid=='undefined') {
  3706. $data['message'] = 'error';
  3707. echo json_encode($data);
  3708. die();
  3709. }
  3710. //内容攒数 观看数
  3711. $now_zan_num_list = M("video_list_test")->where("id=$video_id")->Field("views,thumbs_up,site")->select();
  3712. $video_site = $now_zan_num_list[0]['site'];
  3713. if($video_site =='HL'){
  3714. $heiliao_list = M("heiliao_haijiao_books")->where("id=$video_id")->field("book,site,hj_video_url")->select()[0];
  3715. $heiliao_list['views'] = $now_zan_num_list[0]['views'];
  3716. $heiliao_list['thumbs_up'] = $now_zan_num_list[0]['thumbs_up'];
  3717. $heiliao_list['hj_video_url'] = explode(",", $heiliao_list['hj_video_url']);
  3718. }elseif ($video_site =='WB'){
  3719. $heiliao_list = M("heiliao_haijiao_books")->where("id=$video_id")->field("book,site,hj_video_url")->select()[0];
  3720. $heiliao_list['views'] = $now_zan_num_list[0]['views'];
  3721. $heiliao_list['thumbs_up'] = $now_zan_num_list[0]['thumbs_up'];
  3722. }else{
  3723. $heiliao_list = M("heiliao_haijiao_books")->where("id=$video_id")->field("book,site")->select()[0];
  3724. $heiliao_list['views'] = $now_zan_num_list[0]['views'];
  3725. $heiliao_list['thumbs_up'] = $now_zan_num_list[0]['thumbs_up'];
  3726. }
  3727. if ( $heiliao_list['hj_video_url'][0]=="") {
  3728. $heiliao_list['hj_video_url'] = array();
  3729. }
  3730. if($heiliao_list){
  3731. M('video_list_test')->where("id=$video_id")->setInc('v_really',1);
  3732. $data['code'] = '200';
  3733. $data['status'] = '1';
  3734. $data['message'] = 'ok';
  3735. $data['data'] = $heiliao_list;
  3736. echo json_encode($data);
  3737. }else{
  3738. $data['code'] = '200';
  3739. $data['status'] = '1';
  3740. $data['message'] = '';
  3741. $data['data'] = "";
  3742. echo json_encode($data);
  3743. }
  3744. }else{
  3745. echo $this->returnData();
  3746. }
  3747. }
  3748. /**
  3749. * 用户金币数量
  3750. * @param $templateid []
  3751. * @return $type 消息类型
  3752. */
  3753. public function user_gold_coins_amount(){
  3754. header('Content-Type:text/json;charset=utf-8');
  3755. header('Access-Control-Allow-Origin:*');
  3756. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3757. header('Access-Control-Allow-Methods:POST');
  3758. header('Access-Control-Expose-Headers:*');
  3759. if (!empty($_POST)){
  3760. $uid = $_POST['uid'];
  3761. $user_gold_coins_number = M("user_info")->where("id=$uid")->getField("gold_coins_number");
  3762. if ($user_gold_coins_number) {
  3763. $data['code'] = '200';
  3764. $data['status'] = '1';
  3765. $data['message'] = 'ok';
  3766. $data['data'] = $user_gold_coins_number;
  3767. echo json_encode($data);
  3768. }else{
  3769. $data['code'] = '200';
  3770. $data['status'] = '2';
  3771. $data['message'] = 'ok';
  3772. $data['data'] = 0;
  3773. echo json_encode($data);
  3774. }
  3775. }else{
  3776. echo $this->returnData();
  3777. }
  3778. }
  3779. /**
  3780. * 判断海角详情里是否有视频,反差详情
  3781. * @param $templateid []
  3782. * @return $type 消息类型
  3783. */
  3784. public function haijiao_video_yn(){
  3785. header('Content-Type:text/json;charset=utf-8');
  3786. header('Access-Control-Allow-Origin:*');
  3787. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3788. header('Access-Control-Allow-Methods:POST');
  3789. header('Access-Control-Expose-Headers:*');
  3790. if (!empty($_POST)){
  3791. $video_id = $_POST['video_id'];
  3792. $uid = $_POST['uid'];
  3793. $coins_buy =$_POST['coins'];
  3794. $user_gold_coins_number = M("user_info")->where("id=$uid")->getField("gold_coins_number");
  3795. $yn_video_list =M("heiliao_haijiao_books")->where("id=$video_id")->field("hj_video_url,book_type,book,site,book_str")->select()[0];
  3796. $yn_video = $yn_video_list['hj_video_url'];
  3797. $video_site = $yn_video_list['book_type'];
  3798. if ($yn_video or $video_site=='FC') {
  3799. $now_zan_num_list = M("video_list_test")->where("id=$video_id")->Field("views,thumbs_up,site,coins")->select();
  3800. if ($video_site=='FC') {
  3801. $video_list['book'] =$yn_video_list['book_str'] ;
  3802. $video_list['hj_video_url'] = array();
  3803. $video_list['title'] = $yn_video_list['site'] ;
  3804. $video_list['coins'] = $now_zan_num_list[0]['coins'] ;
  3805. $video_list['views'] = $now_zan_num_list[0]['views'] ;
  3806. $video_list['thumbs_up'] = $now_zan_num_list[0]['thumbs_up'] ;
  3807. }else{
  3808. $video_list['hj_video_url'] =array();
  3809. }
  3810. //查询是否购买
  3811. $yn_buy_hj = M("hj_fc_buy_record")->where("uid=$uid and v_id=$video_id")->getField("id");
  3812. if ($yn_buy_hj or $coins_buy=='0') {
  3813. M('video_list_test')->where("id=$video_id")->setInc('v_really',1);
  3814. $data['code'] = '200';
  3815. $data['status'] = '1';
  3816. $data['message'] = 'yes';
  3817. $data['buy'] = '1';
  3818. $data['user_coins'] = $user_gold_coins_number;
  3819. $data['data'] = $video_list;
  3820. echo json_encode($data);
  3821. }else{
  3822. $data['title'] = $yn_video_list['site'] ;
  3823. $data['code'] = '200';
  3824. $data['status'] = '3';
  3825. $data['message'] = 'yes';
  3826. $data['buy'] = '0';
  3827. $data['user_coins'] = $user_gold_coins_number;
  3828. $data['data'] = array();
  3829. echo json_encode($data);
  3830. }
  3831. }else{
  3832. $data['code'] = '200';
  3833. $data['status'] = '2';
  3834. $data['message'] = 'no';
  3835. $data['buy'] = '0';
  3836. $data['user_coins'] = $user_gold_coins_number;
  3837. $data['data'] = 'yes';
  3838. echo json_encode($data);
  3839. }
  3840. }else{
  3841. echo $this->returnData();
  3842. }
  3843. }
  3844. /**
  3845. * 购买海角视频
  3846. * @param $templateid []
  3847. * @return $type 消息类型
  3848. */
  3849. public function haijiao_video_detail_buy(){
  3850. header('Content-Type:text/json;charset=utf-8');
  3851. header('Access-Control-Allow-Origin:*');
  3852. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3853. header('Access-Control-Allow-Methods:POST');
  3854. header('Access-Control-Expose-Headers:*');
  3855. if (!empty($_POST)){
  3856. $uid = $_POST['uid'];
  3857. $video_id = $_POST['video_id'];
  3858. $user_gold_coins = M("user_info")->where("id=$uid")->getField("gold_coins_number");
  3859. $video_coins = M("video_list_test")->where("id=$video_id")->getField("coins");
  3860. if ($user_gold_coins>=$video_coins){
  3861. //给用户扣费
  3862. $koufei_hj = M("user_info")->where("id=$uid")->setDec('gold_coins_number',$video_coins); // 用户的积分减5
  3863. if ($koufei_hj) {
  3864. $buy_hj_record['uid'] = $uid;
  3865. $buy_hj_record['v_id'] = $video_id;
  3866. $buy_hj_record['time'] = time();
  3867. $buy_hj_record['date'] = date("Y-m-d H:i:s",$buy_hj_record['time']);;
  3868. $buy_hj_record['coins'] =$video_coins;
  3869. $buy_hj_record['type'] ="FC";
  3870. M("hj_fc_buy_record")->add($buy_hj_record);
  3871. $data['code'] = '200';
  3872. $data['status'] = '1';
  3873. $data['message'] = 'success';
  3874. echo json_encode($data);
  3875. }else{
  3876. //没有足够金币
  3877. $data['code'] = '200';
  3878. $data['status'] = '2';
  3879. $data['message'] = 'error';
  3880. echo json_encode($data);
  3881. }
  3882. }else{
  3883. //没有足够金币
  3884. $data['code'] = '200';
  3885. $data['status'] = '3';
  3886. $data['message'] = 'no_coins';
  3887. echo json_encode($data);
  3888. }
  3889. }else{
  3890. echo $this->returnData();
  3891. }
  3892. }
  3893. /**
  3894. * 临时
  3895. * @param $templateid []
  3896. * @return $type 消息类型
  3897. */
  3898. public function save_fancha_str(){
  3899. if (!empty($_POST)){
  3900. $fancha_list = M("heiliao_haijiao_books")->where("book_type='FC'")->field("id,book,book_str")->select();
  3901. echo PHP_EOL.M("heiliao_haijiao_books")->_sql();
  3902. foreach ($fancha_list as $key => $value) {
  3903. $img_str = $value['book'];
  3904. $img_id = $value['id'];
  3905. $topimg_list = explode(',', $img_str);
  3906. echo PHP_EOL.$img_id;
  3907. $book_str = '';
  3908. foreach ($topimg_list as $key1 => $value1) {
  3909. echo PHP_EOL.$value1.'*';
  3910. $book_str .= "<img src='".$value1."' alt=''>" ;
  3911. }
  3912. $fancha_list['book_str'] = $book_str;
  3913. M("heiliao_haijiao_books")->where("id=$img_id")->save($fancha_list);
  3914. }
  3915. }else{
  3916. echo $this->returnData();
  3917. }
  3918. }
  3919. /**
  3920. * 三大类推荐
  3921. * 1个欧美+1个日韩+1个动画+1个黑料专区+1个海角社区+2个反差福利+1个信息流广告——如此循环5次结束
  3922. * @param $templateid []
  3923. * @return $type 消息类型
  3924. */
  3925. public function three_type_tuijian(){
  3926. header('Content-Type:text/json;charset=utf-8');
  3927. header('Access-Control-Allow-Origin:*');
  3928. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  3929. header('Access-Control-Allow-Methods:POST');
  3930. header('Access-Control-Expose-Headers:*');
  3931. if (!empty($_POST)){
  3932. $uid = $_POST['uid'];
  3933. // EUA
  3934. // Asian
  3935. // Anime
  3936. // HL
  3937. // WB
  3938. // FC
  3939. $oumei_list =M("video_list_test")->where("site = 'EUA'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("rand()")->LIMIT(5)->select();
  3940. $yazhou_list =M("video_list_test")->where("site = 'Asian'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("rand()")->LIMIT(5)->select();
  3941. $dongman_list = M("video_list_test")->where("site = 'Anime'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("rand()")->LIMIT(5)->select();
  3942. $heiliao_list = M("video_list_test")->where("site = 'HL'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("rand()")->LIMIT(5)->select();
  3943. $wangbao_list = M("video_list_test")->where("site = 'WB'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("rand()")->LIMIT(5)->select();
  3944. // $fancha_list = M("video_list_test")->where("site = 'FC'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("id asc")->LIMIT(10)->select();
  3945. $fancha_list = M("video_list_test")->where("site = 'FC'")->field("id,title,top_img,views,thumbs_up,favorite,time_chuo,uploader,site,coins")->order("rand()")->LIMIT(10)->select();
  3946. $goumai_str_list = M("hj_fc_buy_record")->where("uid=$uid")->field("v_id")->select();
  3947. $goumai_str = ',';
  3948. foreach ($goumai_str_list as $key1 => $value1) {
  3949. $vv_id = $value1['v_id'];
  3950. $goumai_str .= "$vv_id".",";
  3951. }
  3952. foreach ($fancha_list as $key => $value) {
  3953. $now_vid = $value['id'];
  3954. $needle = ",$now_vid,";
  3955. if (strpos($goumai_str, $needle) !== false){
  3956. $fancha_list[$key]['coins'] = "-1";
  3957. }
  3958. }
  3959. $tuijian_video_list = array($oumei_list[0], $yazhou_list[0], $dongman_list[0], $heiliao_list[0], $wangbao_list[0], array($fancha_list[0],$fancha_list[1]),
  3960. $oumei_list[1], $yazhou_list[1], $dongman_list[1], $heiliao_list[1], $wangbao_list[1], array($fancha_list[2],$fancha_list[3]),
  3961. $oumei_list[2], $yazhou_list[2], $dongman_list[2], $heiliao_list[2], $wangbao_list[2], array($fancha_list[4],$fancha_list[5]),
  3962. $oumei_list[3], $yazhou_list[3], $dongman_list[3], $heiliao_list[3], $wangbao_list[3], array($fancha_list[6],$fancha_list[7]),
  3963. $oumei_list[4], $yazhou_list[4], $dongman_list[4], $heiliao_list[4], $wangbao_list[4], array($fancha_list[8],$fancha_list[9]),);
  3964. if (!empty($tuijian_video_list)) {
  3965. $data['message'] = 'ok';
  3966. //获取广告列表
  3967. $adv_list = M("slgj_advert_list")->where("type='视频列表广告'")->Field("img,jump_link,number")->order("rand()")->LIMIT(12)->select();
  3968. $adv_list = array($adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3],$adv_list[0],$adv_list[1],$adv_list[2],$adv_list[3]);
  3969. $jia_num = 0;
  3970. $qishi_num = 0;
  3971. $data_list_number = count($tuijian_video_list);
  3972. $quzheng_num = floor($data_list_number / 6);
  3973. foreach ($adv_list as $key => $value) {
  3974. $charu_array = array($adv_list[$key]);
  3975. array_splice($tuijian_video_list, $jia_num, 0, $charu_array);
  3976. $jia_num += 7;
  3977. $qishi_num += 1;
  3978. if ($qishi_num >= $quzheng_num) {
  3979. break;
  3980. }
  3981. }
  3982. $data['data'] = $tuijian_video_list;
  3983. echo json_encode($data);
  3984. } else {
  3985. $data['message'] = 'null';
  3986. $data['data'] = [];
  3987. echo json_encode($data);
  3988. }
  3989. }else{
  3990. echo $this->returnData();
  3991. }
  3992. }
  3993. /**
  3994. * 测试功能
  3995. * @param $templateid []
  3996. * @return $type 消息类型
  3997. */
  3998. public function save_idheiliao(){
  3999. $user_list =M("video_list_test")->where("site='WB'")->field("id,title")->select();
  4000. foreach ($user_list as $key => $value) {
  4001. $vid = $value['id'];
  4002. $title = $value['title'];
  4003. echo PHP_EOL.$vid;
  4004. echo PHP_EOL.$title;
  4005. $heiliao_list['id'] =$vid;
  4006. M("heiliao_haijiao_books")->where("site='$title'")->save($heiliao_list);
  4007. }
  4008. }
  4009. }
  4010. ?>