Collect.php 104 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\Cache;
  5. use app\common\util\Pinyin;
  6. use think\Request;
  7. class Collect extends Base {
  8. // 设置数据表(不含前缀)
  9. protected $name = 'collect';
  10. // 定义时间戳字段名
  11. protected $createTime = '';
  12. protected $updateTime = '';
  13. // 自动完成
  14. protected $auto = [];
  15. protected $insert = [];
  16. protected $update = [];
  17. public function listData($where,$order,$page=1,$limit=20,$start=0)
  18. {
  19. $total = $this->where($where)->count();
  20. $list = Db::name('Collect')->where($where)->order($order)->page($page)->limit($limit)->select();
  21. return ['code'=>1,'msg'=>lang('data_list'),'page'=>$page,'pagecount'=>ceil($total/$limit),'limit'=>$limit,'total'=>$total,'list'=>$list];
  22. }
  23. public function infoData($where,$field='*')
  24. {
  25. if(empty($where) || !is_array($where)){
  26. return ['code'=>1001,'msg'=>lang('param_err')];
  27. }
  28. $info = $this->field($field)->where($where)->find();
  29. if(empty($info)){
  30. return ['code'=>1002,'msg'=>lang('obtain_err')];
  31. }
  32. $info = $info->toArray();
  33. return ['code'=>1,'msg'=>lang('obtain_ok'),'info'=>$info];
  34. }
  35. public function saveData($data)
  36. {
  37. $validate = \think\Loader::validate('Collect');
  38. if(!empty($data['collect_id'])){
  39. if(!$validate->scene('edit')->check($data)){
  40. return ['code'=>1001,'msg'=>lang('param_err').':'.$validate->getError() ];
  41. }
  42. $where=[];
  43. $where['collect_id'] = ['eq',$data['collect_id']];
  44. $res = $this->where($where)->update($data);
  45. }
  46. else{
  47. if(!$validate->scene('edit')->check($data)){
  48. return ['code'=>1002,'msg'=>lang('param_err').':'.$validate->getError() ];
  49. }
  50. $res = $this->insert($data);
  51. }
  52. if(false === $res){
  53. return ['code'=>1003,'msg'=>''.$this->getError() ];
  54. }
  55. return ['code'=>1,'msg'=>lang('save_ok')];
  56. }
  57. public function delData($where)
  58. {
  59. $res = $this->where($where)->delete();
  60. if($res===false){
  61. return ['code'=>1001,'msg'=>lang('del_err').':'.$this->getError() ];
  62. }
  63. return ['code'=>1,'msg'=>lang('del_ok')];
  64. }
  65. public function check_flag($param)
  66. {
  67. if($param['cjflag'] != md5($param['cjurl'])){
  68. return ['code'=>9001, 'msg'=>lang('model/collect/flag_err')];
  69. }
  70. return ['code'=>1,'msg'=>'ok'];
  71. }
  72. public function vod($param)
  73. {
  74. if($param['type'] == '1'){
  75. return $this->vod_xml($param);
  76. }
  77. elseif($param['type'] == '2'){
  78. return $this->vod_json($param);
  79. }
  80. else{
  81. $data = $this->vod_json($param);
  82. if($data['code'] == 1){
  83. return $data;
  84. }
  85. else{
  86. return $this->vod_xml($param);
  87. }
  88. }
  89. }
  90. public function art($param)
  91. {
  92. return $this->art_json($param);
  93. }
  94. public function actor($param)
  95. {
  96. return $this->actor_json($param);
  97. }
  98. public function role($param)
  99. {
  100. return $this->role_json($param);
  101. }
  102. public function website($param)
  103. {
  104. return $this->website_json($param);
  105. }
  106. public function vod_xml_replace($url)
  107. {
  108. $array_url = array();
  109. $arr_ji = explode('#',str_replace('||','//',$url));
  110. foreach($arr_ji as $key=>$value){
  111. $urlji = explode('$',$value);
  112. if( count($urlji) > 1 ){
  113. $array_url[$key] = $urlji[0].'$'.trim($urlji[1]);
  114. }else{
  115. $array_url[$key] = trim($urlji[0]);
  116. }
  117. }
  118. return implode('#',$array_url);
  119. }
  120. public function vod_xml($param,$html='')
  121. {
  122. $url_param = [];
  123. $url_param['ac'] = $param['ac'];
  124. $url_param['t'] = $param['t'];
  125. $url_param['pg'] = is_numeric($param['page']) ? $param['page'] : '';
  126. $url_param['h'] = $param['h'];
  127. $url_param['ids'] = $param['ids'];
  128. $url_param['wd'] = $param['wd'];
  129. if(empty($param['h']) && !empty($param['rday'])){
  130. $url_param['h'] = $param['rday'];
  131. }
  132. if($param['ac']!='list'){
  133. $url_param['ac'] = 'videolist';
  134. }
  135. $url = $param['cjurl'];
  136. if(strpos($url,'?')===false){
  137. $url .='?';
  138. }
  139. else{
  140. $url .='&';
  141. }
  142. $url .= http_build_query($url_param). base64_decode($param['param']);
  143. $html = mac_curl_get($url);
  144. if(empty($html)){
  145. return ['code'=>1001, 'msg'=>lang('model/collect/get_html_err')];
  146. }
  147. $html = mac_filter_tags($html);
  148. $xml = @simplexml_load_string($html);
  149. if(empty($xml)){
  150. $labelRule = '<pic>'."(.*?)".'</pic>';
  151. $labelRule = mac_buildregx($labelRule,"is");
  152. preg_match_all($labelRule,$html,$tmparr);
  153. $ec=false;
  154. foreach($tmparr[1] as $tt){
  155. if(strpos($tt,'[CDATA')===false){
  156. $ec=true;
  157. $ne = '<pic>'.'<![CDATA['.$tt .']]>'.'</pic>';
  158. $html = str_replace('<pic>'.$tt.'</pic>',$ne,$html);
  159. }
  160. }
  161. if($ec) {
  162. $xml = @simplexml_load_string($html);
  163. }
  164. if(empty($xml)) {
  165. return ['code' => 1002, 'msg'=>lang('model/collect/xml_err')];
  166. }
  167. }
  168. $array_page = [];
  169. $array_page['page'] = (string)$xml->list->attributes()->page;
  170. $array_page['pagecount'] = (string)$xml->list->attributes()->pagecount;
  171. $array_page['pagesize'] = (string)$xml->list->attributes()->pagesize;
  172. $array_page['recordcount'] = (string)$xml->list->attributes()->recordcount;
  173. $array_page['url'] = $url;
  174. $type_list = model('Type')->getCache('type_list');
  175. $bind_list = config('bind');
  176. $key = 0;
  177. $array_data = [];
  178. foreach($xml->list->video as $video){
  179. $bind_key = $param['cjflag'] .'_'.(string)$video->tid;
  180. if($bind_list[$bind_key] >0){
  181. $array_data[$key]['type_id'] = $bind_list[$bind_key];
  182. }
  183. else{
  184. $array_data[$key]['type_id'] = 0;
  185. }
  186. $array_data[$key]['vod_id'] = (string)$video->id;
  187. //$array_data[$key]['type_id'] = (string)$video->tid;
  188. $array_data[$key]['vod_name'] = mac_filter_xss((string)$video->name);
  189. $array_data[$key]['vod_sub'] = mac_filter_xss((string)$video->subname);
  190. $array_data[$key]['vod_remarks'] = mac_filter_xss((string)$video->note);
  191. $array_data[$key]['type_name'] = mac_filter_xss((string)$video->type);
  192. $array_data[$key]['vod_pic'] = mac_filter_xss((string)$video->pic);
  193. $array_data[$key]['vod_lang'] = mac_filter_xss((string)$video->lang);
  194. $array_data[$key]['vod_area'] = mac_filter_xss((string)$video->area);
  195. $array_data[$key]['vod_year'] = mac_filter_xss((string)$video->year);
  196. $array_data[$key]['vod_serial'] = mac_filter_xss((string)$video->state);
  197. $array_data[$key]['vod_actor'] = mac_filter_xss((string)$video->actor);
  198. $array_data[$key]['vod_director'] = mac_filter_xss((string)$video->director);
  199. $array_data[$key]['vod_content'] = (string)$video->des;
  200. $array_data[$key]['vod_status'] = 1;
  201. $array_data[$key]['vod_type'] = mac_filter_xss($array_data[$key]['list_name']);
  202. $array_data[$key]['vod_time'] = mac_filter_xss((string)$video->last);
  203. $array_data[$key]['vod_total'] = 0;
  204. $array_data[$key]['vod_isend'] = 1;
  205. if($array_data[$key]['vod_serial']){
  206. $array_data[$key]['vod_isend'] = 0;
  207. }
  208. //格式化地址与播放器
  209. $array_from = [];
  210. $array_url = [];
  211. $array_server=[];
  212. $array_note=[];
  213. //videolist|list播放列表不同
  214. if($count=count($video->dl->dd)){
  215. for($i=0; $i<$count; $i++){
  216. $array_from[$i] = (string)$video->dl->dd[$i]['flag'];
  217. $array_url[$i] = $this->vod_xml_replace((string)$video->dl->dd[$i]);
  218. $array_server[$i] = 'no';
  219. $array_note[$i] = '';
  220. }
  221. }else{
  222. $array_from[]=(string)$video->dt;
  223. $array_url[] ='';
  224. $array_server[]='';
  225. $array_note[]='';
  226. }
  227. if(strpos(base64_decode($param['param']),'ct=1')!==false){
  228. $array_data[$key]['vod_down_from'] = implode('$$$', $array_from);
  229. $array_data[$key]['vod_down_url'] = implode('$$$', $array_url);
  230. $array_data[$key]['vod_down_server'] = implode('$$$', $array_server);
  231. $array_data[$key]['vod_down_note'] = implode('$$$', $array_note);
  232. }
  233. else{
  234. $array_data[$key]['vod_play_from'] = implode('$$$', $array_from);
  235. $array_data[$key]['vod_play_url'] = implode('$$$', $array_url);
  236. $array_data[$key]['vod_play_server'] = implode('$$$', $array_server);
  237. $array_data[$key]['vod_play_note'] = implode('$$$', $array_note);
  238. }
  239. $key++;
  240. }
  241. $array_type = [];
  242. $key=0;
  243. //分类列表
  244. if($param['ac'] == 'list'){
  245. foreach($xml->class->ty as $ty){
  246. $array_type[$key]['type_id'] = (string)$ty->attributes()->id;
  247. $array_type[$key]['type_name'] = mac_filter_xss((string)$ty);
  248. $key++;
  249. }
  250. }
  251. $res = ['code'=>1, 'msg'=>'xml', 'page'=>$array_page, 'type'=>$array_type, 'data'=>$array_data ];
  252. return $res;
  253. }
  254. public function vod_json($param)
  255. {
  256. $url_param = [];
  257. $url_param['ac'] = $param['ac'];
  258. $url_param['t'] = $param['t'];
  259. $url_param['pg'] = is_numeric($param['page']) ? $param['page'] : '';
  260. $url_param['h'] = $param['h'];
  261. $url_param['ids'] = $param['ids'];
  262. $url_param['wd'] = $param['wd'];
  263. if($param['ac']!='list'){
  264. $url_param['ac'] = 'videolist';
  265. }
  266. $url = $param['cjurl'];
  267. if(strpos($url,'?')===false){
  268. $url .='?';
  269. }
  270. else{
  271. $url .='&';
  272. }
  273. $url .= http_build_query($url_param). base64_decode($param['param']);
  274. $html = mac_curl_get($url);
  275. if(empty($html)){
  276. return ['code'=>1001, 'msg'=>lang('model/collect/get_html_err')];
  277. }
  278. $html = mac_filter_tags($html);
  279. $json = json_decode($html,true);
  280. if(!$json){
  281. return ['code'=>1002, 'msg'=>lang('model/collect/json_err')];
  282. }
  283. $array_page = [];
  284. $array_page['page'] = $json['page'];
  285. $array_page['pagecount'] = $json['pagecount'];
  286. $array_page['pagesize'] = $json['limit'];
  287. $array_page['recordcount'] = $json['total'];
  288. $array_page['url'] = $url;
  289. $type_list = model('Type')->getCache('type_list');
  290. $bind_list = config('bind');
  291. $key = 0;
  292. $array_data = [];
  293. foreach($json['list'] as $key=>$v){
  294. $array_data[$key] = $v;
  295. $bind_key = $param['cjflag'] .'_'.$v['type_id'];
  296. if($bind_list[$bind_key] >0){
  297. $array_data[$key]['type_id'] = $bind_list[$bind_key];
  298. }
  299. else{
  300. $array_data[$key]['type_id'] = 0;
  301. }
  302. if(!empty($v['dl'])) {
  303. //格式化地址与播放器
  304. $array_from = [];
  305. $array_url = [];
  306. $array_server = [];
  307. $array_note = [];
  308. //videolist|list播放列表不同
  309. foreach ($v['dl'] as $k2 => $v2) {
  310. $array_from[] = $k2;
  311. $array_url[] = $v2;
  312. $array_server[] = 'no';
  313. $array_note[] = '';
  314. }
  315. $array_data[$key]['vod_play_from'] = implode('$$$', $array_from);
  316. $array_data[$key]['vod_play_url'] = implode('$$$', $array_url);
  317. $array_data[$key]['vod_play_server'] = implode('$$$', $array_server);
  318. $array_data[$key]['vod_play_note'] = implode('$$$', $array_note);
  319. }
  320. }
  321. $array_type = [];
  322. $key=0;
  323. //分类列表
  324. if($param['ac'] == 'list'){
  325. foreach($json['class'] as $k=>$v){
  326. $array_type[$key]['type_id'] = $v['type_id'];
  327. $array_type[$key]['type_name'] = mac_filter_xss($v['type_name']);
  328. $key++;
  329. }
  330. }
  331. $res = ['code'=>1, 'msg'=>'json', 'page'=>$array_page, 'type'=>$array_type, 'data'=>$array_data ];
  332. return $res;
  333. }
  334. public function syncImages($pic_status,$pic_url,$flag='vod')
  335. {
  336. if($pic_status == 1){
  337. $img_url = model('Image')->down_load($pic_url, $GLOBALS['config']['upload'], $flag);
  338. if(substr($img_url,0,7)=='upload/'){
  339. $link = MAC_PATH . $img_url;
  340. }
  341. else{
  342. $link = str_replace('mac:', $GLOBALS['config']['upload']['protocol'].':', $img_url);
  343. }
  344. if ($img_url == $pic_url) {
  345. $des = '<a href="' . $pic_url . '" target="_blank">' . $pic_url . '</a><font color=red>'.lang('download_err').'!</font>';
  346. } else {
  347. $pic_url = $img_url;
  348. $des = '<a href="' . $link . '" target="_blank">' . $link . '</a><font color=green>'.lang('download_ok').'!</font>';
  349. }
  350. }
  351. return ['pic'=>$pic_url,'msg'=>$des];
  352. }
  353. public function vod_data($param,$data,$show=1)
  354. {
  355. if($show==1) {
  356. mac_echo('[' . __FUNCTION__ . '] ' . lang('model/collect/data_tip1',[$data['page']['page'],$data['page']['pagecount'],$data['page']['url']]));
  357. }
  358. $config = config('maccms.collect');
  359. $config = $config['vod'];
  360. $players = config('vodplayer');
  361. $downers = config('voddowner');
  362. $type_list = model('Type')->getCache('type_list');
  363. $filter_arr = explode(',',$config['filter']); $filter_arr = array_filter($filter_arr);
  364. $pse_rnd = explode('#',$config['words']); $pse_rnd = array_filter($pse_rnd);
  365. $pse_name = mac_txt_explain($config['namewords']);
  366. $pse_syn = mac_txt_explain($config['thesaurus']);
  367. foreach($data['data'] as $k=>$v){
  368. $color='red';
  369. $des='';
  370. $msg='';
  371. $tmp='';
  372. if($v['type_id'] ==0){
  373. $des = lang('model/collect/type_err');
  374. }
  375. elseif(empty($v['vod_name'])) {
  376. $des = lang('model/collect/name_err');
  377. }
  378. elseif( mac_array_filter($filter_arr,$v['vod_name']) !==false) {
  379. $des = lang('model/collect/name_in_filter_err');
  380. }
  381. else {
  382. unset($v['vod_id']);
  383. foreach($v as $k2=>$v2){
  384. if(strpos($k2,'_content')===false && $k2!=='vod_plot_detail') {
  385. $v[$k2] = strip_tags($v2);
  386. }
  387. }
  388. $v['vod_name'] = mac_filter_xss($v['vod_name']);
  389. $v['type_id_1'] = intval($type_list[$v['type_id']]['type_pid']);
  390. $v['vod_en'] = Pinyin::get($v['vod_name']);
  391. $v['vod_letter'] = strtoupper(substr($v['vod_en'],0,1));
  392. $v['vod_time_add'] = time();
  393. $v['vod_time'] = time();
  394. $v['vod_status'] = intval($config['status']);
  395. $v['vod_lock'] = intval($v['vod_lock']);
  396. if(!empty($v['vod_status'])) {
  397. $v['vod_status'] = intval($v['vod_status']);
  398. }
  399. $v['vod_year'] = intval($v['vod_year']);
  400. $v['vod_level'] = intval($v['vod_level']);
  401. $v['vod_hits'] = intval($v['vod_hits']);
  402. $v['vod_hits_day'] = intval($v['vod_hits_day']);
  403. $v['vod_hits_week'] = intval($v['vod_hits_week']);
  404. $v['vod_hits_month'] = intval($v['vod_hits_month']);
  405. $v['vod_stint_play'] = intval($v['vod_stint_play']);
  406. $v['vod_stint_down'] = intval($v['vod_stint_down']);
  407. $v['vod_total'] = intval($v['vod_total']);
  408. $v['vod_serial'] = intval($v['vod_serial']);
  409. $v['vod_isend'] = intval($v['vod_isend']);
  410. $v['vod_up'] = intval($v['vod_up']);
  411. $v['vod_down'] = intval($v['vod_down']);
  412. $v['vod_score'] = floatval($v['vod_score']);
  413. $v['vod_score_all'] = intval($v['vod_score_all']);
  414. $v['vod_score_num'] = intval($v['vod_score_num']);
  415. $v['vod_class'] = mac_txt_merge($v['vod_class'],$v['type_name']);
  416. $v['vod_actor'] = mac_format_text($v['vod_actor']);
  417. $v['vod_director'] = mac_format_text($v['vod_director']);
  418. $v['vod_class'] = mac_format_text($v['vod_class']);
  419. $v['vod_tag'] = mac_format_text($v['vod_tag']);
  420. $v['vod_plot_name'] = mac_filter_xss((string)$v['vod_plot_name']);
  421. $v['vod_plot_detail'] = mac_filter_xss((string)$v['vod_plot_detail']);
  422. if(!empty($v['vod_plot_name'])){
  423. $v['vod_plot'] = 1;
  424. $v['vod_plot_name'] = trim($v['vod_plot_name'],'$$$');
  425. }
  426. if(!empty($v['vod_plot_detail'])){
  427. $v['vod_plot_detail'] = trim($v['vod_plot_detail'],'$$$');
  428. }
  429. if(empty($v['vod_isend']) && !empty($v['vod_serial'])){
  430. $v['vod_isend'] = 0;
  431. }
  432. if($config['hits_start']>0 && $config['hits_end']>0) {
  433. $v['vod_hits'] = rand($config['hits_start'], $config['hits_end']);
  434. $v['vod_hits_day'] = rand($config['hits_start'], $config['hits_end']);
  435. $v['vod_hits_week'] = rand($config['hits_start'], $config['hits_end']);
  436. $v['vod_hits_month'] = rand($config['hits_start'], $config['hits_end']);
  437. }
  438. if($config['updown_start']>0 && $config['updown_end']){
  439. $v['vod_up'] = rand($config['updown_start'], $config['updown_end']);
  440. $v['vod_down'] = rand($config['updown_start'], $config['updown_end']);
  441. }
  442. if($config['score']==1) {
  443. $v['vod_score_num'] = rand(1, 1000);
  444. $v['vod_score_all'] = $v['vod_score_num'] * rand(1, 10);
  445. $v['vod_score'] = round($v['vod_score_all'] / $v['vod_score_num'], 1);
  446. }
  447. if ($config['psename'] == 1) {
  448. $v['vod_name'] = mac_rep_pse_syn($pse_name, $v['vod_name']);
  449. }
  450. $v['vod_content'] = mac_filter_xss($v['vod_content']);
  451. if ($config['psernd'] == 1) {
  452. $v['vod_content'] = mac_rep_pse_rnd($pse_rnd, $v['vod_content']);
  453. }
  454. if ($config['psesyn'] == 1) {
  455. $v['vod_content'] = mac_rep_pse_syn($pse_syn, $v['vod_content']);
  456. }
  457. if(empty($v['vod_blurb'])){
  458. $v['vod_blurb'] = mac_substring( strip_tags($v['vod_content']) ,100);
  459. }
  460. $where = [];
  461. $where['vod_name'] = $v['vod_name'];
  462. $blend=false;
  463. if (strpos($config['inrule'], 'b')!==false) {
  464. $where['type_id'] = $v['type_id'];
  465. }
  466. if (strpos($config['inrule'], 'c')!==false) {
  467. $where['vod_year'] = $v['vod_year'];
  468. }
  469. if (strpos($config['inrule'], 'd')!==false) {
  470. $where['vod_area'] = $v['vod_area'];
  471. }
  472. if (strpos($config['inrule'], 'e')!==false) {
  473. $where['vod_lang'] = $v['vod_lang'];
  474. }
  475. if (strpos($config['inrule'], 'f')!==false) {
  476. $where['vod_actor'] = ['like', mac_like_arr($v['vod_actor']), 'OR'];
  477. }
  478. if (strpos($config['inrule'], 'g')!==false) {
  479. $where['vod_director'] = $v['vod_director'];
  480. }
  481. if ($config['tag'] == 1) {
  482. $v['vod_tag'] = mac_get_tag($v['vod_name'], $v['vod_content']);
  483. }
  484. if(!empty($where['vod_actor']) && !empty($where['vod_director'])){
  485. $blend = true;
  486. $GLOBALS['blend'] = [
  487. 'vod_actor' => $where['vod_actor'],
  488. 'vod_director' => $where['vod_director']
  489. ];
  490. unset($where['vod_actor'],$where['vod_director']);
  491. }
  492. if(empty($v['vod_play_url'])){
  493. $v['vod_play_url'] = '';
  494. }
  495. if(empty($v['vod_down_url'])){
  496. $v['vod_down_url'] = '';
  497. }
  498. //验证地址
  499. $cj_play_from_arr = explode('$$$',$v['vod_play_from'] );
  500. $cj_play_url_arr = explode('$$$',$v['vod_play_url']);
  501. $cj_play_server_arr = explode('$$$',$v['vod_play_server']);
  502. $cj_play_note_arr = explode('$$$',$v['vod_play_note']);
  503. $cj_down_from_arr = explode('$$$',$v['vod_down_from'] );
  504. $cj_down_url_arr = explode('$$$',$v['vod_down_url']);
  505. $cj_down_server_arr = explode('$$$',$v['vod_down_server']);
  506. $cj_down_note_arr = explode('$$$',$v['vod_down_note']);
  507. $collect_filter=[];
  508. foreach($cj_play_from_arr as $kk=>$vv){
  509. if(empty($vv)){
  510. unset($cj_play_from_arr[$kk]);
  511. unset($cj_play_url_arr[$kk]);
  512. unset($cj_play_server_arr[$kk]);
  513. unset($cj_play_note_arr[$kk]);
  514. continue;
  515. }
  516. if(empty($players[$vv])){
  517. unset($cj_play_from_arr[$kk]);
  518. unset($cj_play_url_arr[$kk]);
  519. unset($cj_play_server_arr[$kk]);
  520. unset($cj_play_note_arr[$kk]);
  521. continue;
  522. }
  523. $cj_play_url_arr[$kk] = rtrim($cj_play_url_arr[$kk],'#');
  524. $cj_play_server_arr[$kk] = $cj_play_server_arr[$kk];
  525. $cj_play_note_arr[$kk] = $cj_play_note_arr[$kk];
  526. if($param['filter'] > 0){
  527. if(strpos(','.$param['filter_from'].',',$vv)!==false) {
  528. $collect_filter['play'][$param['filter']]['cj_play_from_arr'][$kk] = $vv;
  529. $collect_filter['play'][$param['filter']]['cj_play_url_arr'][$kk] = $cj_play_url_arr[$kk];
  530. $collect_filter['play'][$param['filter']]['cj_play_server_arr'][$kk] = $cj_play_server_arr[$kk];
  531. $collect_filter['play'][$param['filter']]['cj_play_note_arr'][$kk] = $cj_play_note_arr[$kk];
  532. }
  533. }
  534. }
  535. foreach($cj_down_from_arr as $kk=>$vv){
  536. if(empty($vv)){
  537. unset($cj_down_from_arr[$kk]);
  538. unset($cj_down_url_arr[$kk]);
  539. unset($cj_down_server_arr[$kk]);
  540. unset($cj_down_note_arr[$kk]);
  541. continue;
  542. }
  543. if(empty($downers[$vv])){
  544. unset($cj_down_from_arr[$kk]);
  545. unset($cj_down_url_arr[$kk]);
  546. unset($cj_down_server_arr[$kk]);
  547. unset($cj_down_note_arr[$kk]);
  548. continue;
  549. }
  550. $cj_down_url_arr[$kk] = rtrim($cj_down_url_arr[$kk]);
  551. $cj_down_server_arr[$kk] = $cj_down_server_arr[$kk];
  552. $cj_down_note_arr[$kk] = $cj_down_note_arr[$kk];
  553. if($param['filter'] > 0){
  554. if(strpos(','.$param['filter_from'].',',$vv)!==false) {
  555. $collect_filter['down'][$param['filter']]['cj_down_from_arr'][$kk] = $vv;
  556. $collect_filter['down'][$param['filter']]['cj_down_url_arr'][$kk] = $cj_down_url_arr[$kk];
  557. $collect_filter['down'][$param['filter']]['cj_down_server_arr'][$kk] = $cj_down_server_arr[$kk];
  558. $collect_filter['down'][$param['filter']]['cj_down_note_arr'][$kk] = $cj_down_note_arr[$kk];
  559. }
  560. }
  561. }
  562. $v['vod_play_from'] = (string)join('$$$',$cj_play_from_arr);
  563. $v['vod_play_url'] = (string)join('$$$',$cj_play_url_arr);
  564. $v['vod_play_server'] = (string)join('$$$',$cj_play_server_arr);
  565. $v['vod_play_note'] = (string)join('$$$',$cj_play_note_arr);
  566. $v['vod_down_from'] = (string)join('$$$',$cj_down_from_arr);
  567. $v['vod_down_url'] = (string)join('$$$',$cj_down_url_arr);
  568. $v['vod_down_server'] = (string)join('$$$',$cj_down_server_arr);
  569. $v['vod_down_note'] = (string)join('$$$',$cj_down_note_arr);
  570. if($blend===false){
  571. $info = model('Vod')->where($where)->find();
  572. }
  573. else{
  574. $info = model('Vod')->where($where)
  575. ->where(function($query){
  576. $query->where('vod_director',$GLOBALS['blend']['vod_director'])
  577. ->whereOr('vod_actor',$GLOBALS['blend']['vod_actor']);
  578. })
  579. ->find();
  580. }
  581. if (!$info) {
  582. if($param['opt'] == 2){
  583. $des= lang('model/collect/not_check_add');
  584. }
  585. else {
  586. if ($param['filter'] == 1 || $param['filter'] == 2) {
  587. $v['vod_play_from'] = (string)join('$$$', $collect_filter['play'][$param['filter']]['cj_play_from_arr']);
  588. $v['vod_play_url'] = (string)join('$$$', $collect_filter['play'][$param['filter']]['cj_play_url_arr']);
  589. $v['vod_play_server'] = (string)join('$$$', $collect_filter['play'][$param['filter']]['cj_play_server_arr']);
  590. $v['vod_play_note'] = (string)join('$$$', $collect_filter['play'][$param['filter']]['cj_play_note_arr']);
  591. $v['vod_down_from'] = (string)join('$$$', $collect_filter['down'][$param['filter']]['cj_down_from_arr']);
  592. $v['vod_down_url'] = (string)join('$$$', $collect_filter['down'][$param['filter']]['cj_down_url_arr']);
  593. $v['vod_down_server'] = (string)join('$$$', $collect_filter['down'][$param['filter']]['cj_down_server_arr']);
  594. $v['vod_down_note'] = (string)join('$$$', $collect_filter['down'][$param['filter']]['cj_down_note_arr']);
  595. }
  596. $tmp = $this->syncImages($config['pic'], $v['vod_pic'], 'vod');
  597. $v['vod_pic'] = mac_filter_xss((string)$tmp['pic']);
  598. $msg = $tmp['msg'];
  599. $res = model('Vod')->insert($v);
  600. if ($res === false) {
  601. }
  602. $color = 'green';
  603. $des = lang('model/collect/add_ok');
  604. }
  605. } else {
  606. if(empty($config['uprule'])){
  607. $des = lang('model/collect/uprule_empty');
  608. }
  609. elseif ($info['vod_lock'] == 1) {
  610. $des = lang('model/collect/data_lock');
  611. }
  612. elseif($param['opt'] == 1){
  613. $des= lang('model/collect/not_check_update');
  614. }
  615. else {
  616. unset($v['vod_time_add']);
  617. $update = [];
  618. $ec=false;
  619. if($param['filter'] ==1 || $param['filter']==3){
  620. $cj_play_from_arr = $collect_filter['play'][$param['filter']]['cj_play_from_arr'];
  621. $cj_play_url_arr = $collect_filter['play'][$param['filter']]['cj_play_url_arr'];
  622. $cj_play_server_arr = $collect_filter['play'][$param['filter']]['cj_play_server_arr'];
  623. $cj_play_note_arr = $collect_filter['play'][$param['filter']]['cj_play_note_arr'];
  624. $cj_down_from_arr = $collect_filter['down'][$param['filter']]['cj_down_from_arr'];
  625. $cj_down_url_arr = $collect_filter['down'][$param['filter']]['cj_down_url_arr'];
  626. $cj_down_server_arr = $collect_filter['down'][$param['filter']]['cj_down_server_arr'];
  627. $cj_down_note_arr = $collect_filter['down'][$param['filter']]['cj_down_note_arr'];
  628. }
  629. if (strpos(',' . $config['uprule'], 'a')!==false && !empty($v['vod_play_from'])) {
  630. $old_play_from = $info['vod_play_from'];
  631. $old_play_url = $info['vod_play_url'];
  632. $old_play_server = $info['vod_play_server'];
  633. $old_play_note = $info['vod_play_note'];
  634. foreach ($cj_play_from_arr as $k2 => $v2) {
  635. $cj_play_from = $v2;
  636. $cj_play_url = $cj_play_url_arr[$k2];
  637. $cj_play_server = $cj_play_server_arr[$k2];
  638. $cj_play_note = $cj_play_note_arr[$k2];
  639. if ($cj_play_url == $info['vod_play_url']) {
  640. $des .= lang('model/collect/playurl_same');
  641. } elseif (empty($cj_play_from)) {
  642. $des .= lang('model/collect/playfrom_empty');
  643. } elseif (strpos('$$$'.$info['vod_play_from'].'$$$', '$$$'.$cj_play_from.'$$$') === false) {
  644. $color = 'green';
  645. $des .= lang('model/collect/playgroup_add_ok',[$cj_play_from]);
  646. if(!empty($old_play_from)){
  647. $old_play_url .="$$$";
  648. $old_play_from .= "$$$" ;
  649. $old_play_server .= "$$$" ;
  650. $old_play_note .= "$$$" ;
  651. }
  652. $old_play_url .= "" . $cj_play_url;
  653. $old_play_from .= "" . $cj_play_from;
  654. $old_play_server .= "" . $cj_play_server;
  655. $old_play_note .= "" . $cj_play_note;
  656. $ec=true;
  657. } elseif (!empty($cj_play_url)) {
  658. $arr1 = explode("$$$", $old_play_url);
  659. $arr2 = explode("$$$", $old_play_from);
  660. $play_key = array_search($cj_play_from, $arr2);
  661. if ($arr1[$play_key] == $cj_play_url) {
  662. $des .= lang('model/collect/playgroup_same',[$cj_play_from]);;
  663. } else {
  664. $color = 'green';
  665. $des .= lang('model/collect/playgroup_update_ok',[$cj_play_from]);
  666. if ($config['urlrole'] == 1) {
  667. $tmp1 = explode('#',$arr1[$play_key]);
  668. $tmp2 = explode('#',$cj_play_url);
  669. $tmp1 = array_merge($tmp1,$tmp2);
  670. $tmp1 = array_unique($tmp1);
  671. $cj_play_url = join('#',$tmp1);
  672. unset($tmp1,$tmp2);
  673. }
  674. $arr1[$play_key] = $cj_play_url;
  675. $ec=true;
  676. }
  677. $old_play_url = join('$$$', $arr1);
  678. }
  679. }
  680. if($ec) {
  681. $update['vod_play_from'] = $old_play_from;
  682. $update['vod_play_url'] = $old_play_url;
  683. $update['vod_play_server'] = $old_play_server;
  684. $update['vod_play_note'] = $old_play_note;
  685. }
  686. }
  687. $ec=false;
  688. if (strpos(',' . $config['uprule'], 'b')!==false && !empty($v['vod_down_from'])) {
  689. $old_down_from = $info['vod_down_from'];
  690. $old_down_url = $info['vod_down_url'];
  691. $old_down_server = $info['vod_down_server'];
  692. $old_down_note = $info['vod_down_note'];
  693. foreach ($cj_down_from_arr as $k2 => $v2) {
  694. $cj_down_from = $v2;
  695. $cj_down_url = $cj_down_url_arr[$k2];
  696. $cj_down_server = $cj_down_server_arr[$k2];
  697. $cj_down_note = $cj_down_note_arr[$k2];
  698. if ($cj_down_url == $info['vod_down_url']) {
  699. $des .= lang('model/collect/downurl_same');
  700. } elseif (empty($cj_down_from)) {
  701. $des .= lang('model/collect/downfrom_empty');
  702. } elseif (strpos('$$$'.$info['vod_down_from'].'$$$', '$$$'.$cj_down_from.'$$$')===false) {
  703. $color = 'green';
  704. $des .= lang('model/collect/downgroup_add_ok',[$cj_down_from]);
  705. if(!empty($old_down_from)){
  706. $old_down_url .="$$$";
  707. $old_down_from .= "$$$" ;
  708. $old_down_server .= "$$$" ;
  709. $old_down_note .= "$$$" ;
  710. }
  711. $old_down_url .= "" .$cj_down_url;
  712. $old_down_from .= "" .$cj_down_from;
  713. $old_down_server .= "" .$cj_down_server;
  714. $old_down_note .= "" .$cj_down_note;
  715. $ec=true;
  716. } elseif (!empty($cj_down_url)) {
  717. $arr1 = explode("$$$", $old_down_url);
  718. $arr2 = explode("$$$", $old_down_from);
  719. $down_key = array_search($cj_down_from, $arr2);
  720. if ($arr1[$down_key] == $cj_down_url) {
  721. $des .= lang('model/collect/downgroup_same',[$cj_down_from]);
  722. } else {
  723. $color = 'green';
  724. $des .= lang('model/collect/downgroup_update_ok',[$cj_down_from]);
  725. $arr1[$down_key] = $cj_down_url;
  726. $ec=true;
  727. }
  728. $old_down_url = join('$$$', $arr1);
  729. }
  730. }
  731. if($ec) {
  732. $update['vod_down_from'] = $old_down_from;
  733. $update['vod_down_url'] = $old_down_url;
  734. $update['vod_down_server'] = $old_down_server;
  735. $update['vod_down_note'] = $old_down_note;
  736. }
  737. }
  738. if (strpos(',' . $config['uprule'], 'c')!==false && !empty($v['vod_serial']) && $v['vod_serial']!=$info['vod_serial']) {
  739. $update['vod_serial'] = $v['vod_serial'];
  740. }
  741. if (strpos(',' . $config['uprule'], 'd')!==false && !empty($v['vod_remarks']) && $v['vod_remarks']!=$info['vod_remarks']) {
  742. $update['vod_remarks'] = $v['vod_remarks'];
  743. }
  744. if (strpos(',' . $config['uprule'], 'e')!==false && !empty($v['vod_director']) && $v['vod_director']!=$info['vod_director']) {
  745. $update['vod_director'] = $v['vod_director'];
  746. }
  747. if (strpos(',' . $config['uprule'], 'f')!==false && !empty($v['vod_actor']) && $v['vod_actor']!=$info['vod_actor']) {
  748. $update['vod_actor'] = $v['vod_actor'];
  749. }
  750. if (strpos(',' . $config['uprule'], 'g')!==false && !empty($v['vod_year']) && $v['vod_year']!=$info['vod_year']) {
  751. $update['vod_year'] = $v['vod_year'];
  752. }
  753. if (strpos(',' . $config['uprule'], 'h')!==false && !empty($v['vod_area']) && $v['vod_area']!=$info['vod_area']) {
  754. $update['vod_area'] = $v['vod_area'];
  755. }
  756. if (strpos(',' . $config['uprule'], 'i')!==false && !empty($v['vod_lang']) && $v['vod_lang']!=$info['vod_lang']) {
  757. $update['vod_lang'] = $v['vod_lang'];
  758. }
  759. if (strpos(',' . $config['uprule'], 'j')!==false && (substr($info["vod_pic"], 0, 4) == "http" || empty($info['vod_pic']) ) && $v['vod_pic']!=$info['vod_pic'] ) {
  760. $tmp = $this->syncImages($config['pic'],$v['vod_pic'],'vod');
  761. $update['vod_pic'] = mac_filter_xss((string)$tmp['pic']);
  762. $msg =$tmp['msg'];
  763. }
  764. if (strpos(',' . $config['uprule'], 'k')!==false && !empty($v['vod_content']) && $v['vod_content']!=$info['vod_content']) {
  765. $update['vod_content'] = $v['vod_content'];
  766. }
  767. if (strpos(',' . $config['uprule'], 'l')!==false && !empty($v['vod_tag']) && $v['vod_tag']!=$info['vod_tag']) {
  768. $update['vod_tag'] = $v['vod_tag'];
  769. }
  770. if (strpos(',' . $config['uprule'], 'm')!==false && !empty($v['vod_sub']) && $v['vod_sub']!=$info['vod_sub']) {
  771. $update['vod_sub'] = $v['vod_sub'];
  772. }
  773. if (strpos(',' . $config['uprule'], 'n')!==false && !empty($v['vod_class']) && $v['vod_class']!=$info['vod_class']) {
  774. $update['vod_class'] = mac_txt_merge($info['vod_class'], $v['vod_class']);
  775. }
  776. if (strpos(',' . $config['uprule'], 'o')!==false && !empty($v['vod_writer']) && $v['vod_writer']!=$info['vod_writer']) {
  777. $update['vod_writer'] = $v['vod_writer'];
  778. }
  779. if (strpos(',' . $config['uprule'], 'p')!==false && !empty($v['vod_version']) && $v['vod_version']!=$info['vod_version']) {
  780. $update['vod_version'] = $v['vod_version'];
  781. }
  782. if (strpos(',' . $config['uprule'], 'q')!==false && !empty($v['vod_state']) && $v['vod_state']!=$info['vod_state']) {
  783. $update['vod_state'] = $v['vod_state'];
  784. }
  785. if (strpos(',' . $config['uprule'], 'r')!==false && !empty($v['vod_blurb']) && $v['vod_blurb']!=$info['vod_blurb']) {
  786. $update['vod_blurb'] = $v['vod_blurb'];
  787. }
  788. if (strpos(',' . $config['uprule'], 's')!==false && !empty($v['vod_tv']) && $v['vod_tv']!=$info['vod_tv']) {
  789. $update['vod_tv'] = $v['vod_tv'];
  790. }
  791. if (strpos(',' . $config['uprule'], 't')!==false && !empty($v['vod_weekday']) && $v['vod_weekday']!=$info['vod_weekday']) {
  792. $update['vod_weekday'] = $v['vod_weekday'];
  793. }
  794. if (strpos(',' . $config['uprule'], 'u')!==false && !empty($v['vod_total']) && $v['vod_total']!=$info['vod_total']) {
  795. $update['vod_total'] = $v['vod_total'];
  796. }
  797. if (strpos(',' . $config['uprule'], 'v')!==false && !empty($v['vod_isend']) && $v['vod_isend']!=$info['vod_isend']) {
  798. $update['vod_isend'] = $v['vod_isend'];
  799. }
  800. if (strpos(',' . $config['uprule'], 'w')!==false && !empty($v['vod_plot_name']) && $v['vod_plot_name']!=$info['vod_plot_name']) {
  801. $update['vod_plot'] = 1;
  802. $update['vod_plot_name'] = $v['vod_plot_name'];
  803. $update['vod_plot_detail'] = $v['vod_plot_detail'];
  804. }
  805. if(count($update)>0){
  806. $update['vod_time'] = time();
  807. $where = [];
  808. $where['vod_id'] = $info['vod_id'];
  809. $res = model('Vod')->where($where)->update($update);
  810. $color = 'green';
  811. if ($res === false) {
  812. }
  813. }
  814. else{
  815. $des = lang('model/collect/not_need_update');
  816. }
  817. }
  818. }
  819. }
  820. if($show==1) {
  821. mac_echo( ($k + 1) .'、'. $v['vod_name'] . "<font color=$color>" .$des .'</font>'. $msg.'' );
  822. }
  823. else{
  824. return ['code'=>($color=='red' ? 1001 : 1),'msg'=>$des ];
  825. }
  826. }
  827. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_vod';
  828. if(ENTRANCE=='api'){
  829. Cache::rm($key);
  830. if ($data['page']['page'] < $data['page']['pagecount']) {
  831. $param['page'] = intval($data['page']['page']) + 1;
  832. $res = $this->vod($param);
  833. if($res['code']>1){
  834. return $this->error($res['msg']);
  835. }
  836. $this->vod_data($param,$res );
  837. }
  838. mac_echo(lang('model/collect/is_over'));
  839. die;
  840. }
  841. if(empty($GLOBALS['config']['app']['collect_timespan'])){
  842. $GLOBALS['config']['app']['collect_timespan'] = 3;
  843. }
  844. if($show==1) {
  845. if ($param['ac'] == 'cjsel') {
  846. Cache::rm($key);
  847. mac_echo(lang('model/collect/is_over'));
  848. unset($param['ids']);
  849. $param['ac'] = 'list';
  850. $url = url('api') . '?' . http_build_query($param);
  851. $ref = $_SERVER["HTTP_REFERER"];
  852. if(!empty($ref)){
  853. $url = $ref;
  854. }
  855. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  856. } else {
  857. if ($data['page']['page'] >= $data['page']['pagecount']) {
  858. Cache::rm($key);
  859. mac_echo(lang('model/collect/is_over'));
  860. unset($param['page'],$param['ids']);
  861. $param['ac'] = 'list';
  862. $url = url('api') . '?' . http_build_query($param);
  863. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  864. } else {
  865. $param['page'] = intval($data['page']['page']) + 1;
  866. $url = url('api') . '?' . http_build_query($param);
  867. mac_jump($url, $GLOBALS['config']['app']['collect_timespan'] );
  868. }
  869. }
  870. }
  871. }
  872. public function art_json($param)
  873. {
  874. $url_param = [];
  875. $url_param['ac'] = $param['ac'];
  876. $url_param['t'] = $param['t'];
  877. $url_param['pg'] = is_numeric($param['page']) ? $param['page'] : '';
  878. $url_param['h'] = $param['h'];
  879. $url_param['ids'] = $param['ids'];
  880. $url_param['wd'] = $param['wd'];
  881. if($param['ac']!='list'){
  882. $url_param['ac'] = 'detail';
  883. }
  884. $url = $param['cjurl'];
  885. if(strpos($url,'?')===false){
  886. $url .='?';
  887. }
  888. else{
  889. $url .='&';
  890. }
  891. $url .= http_build_query($url_param). base64_decode($param['param']);
  892. $html = mac_curl_get($url);
  893. if(empty($html)){
  894. return ['code'=>1001, 'msg'=>lang('model/collect/get_html_err')];
  895. }
  896. $html = mac_filter_tags($html);
  897. $json = json_decode($html,true);
  898. if(!$json){
  899. return ['code'=>1002, 'msg'=>lang('model/collect/json_err')];
  900. }
  901. $array_page = [];
  902. $array_page['page'] = $json['page'];
  903. $array_page['pagecount'] = $json['pagecount'];
  904. $array_page['pagesize'] = $json['limit'];
  905. $array_page['recordcount'] = $json['total'];
  906. $array_page['url'] = $url;
  907. $type_list = model('Type')->getCache('type_list');
  908. $bind_list = config('bind');
  909. $key = 0;
  910. $array_data = [];
  911. foreach($json['list'] as $key=>$v){
  912. $array_data[$key] = $v;
  913. $bind_key = $param['cjflag'] .'_'.$v['type_id'];
  914. if($bind_list[$bind_key] >0){
  915. $array_data[$key]['type_id'] = $bind_list[$bind_key];
  916. }
  917. else{
  918. $array_data[$key]['type_id'] = 0;
  919. }
  920. }
  921. $array_type = [];
  922. $key=0;
  923. //分类列表
  924. if($param['ac'] == 'list'){
  925. foreach($json['class'] as $k=>$v){
  926. $array_type[$key]['type_id'] = $v['type_id'];
  927. $array_type[$key]['type_name'] = mac_filter_xss($v['type_name']);
  928. $key++;
  929. }
  930. }
  931. $res = ['code'=>1, 'msg'=>'ok', 'page'=>$array_page, 'type'=>$array_type, 'data'=>$array_data ];
  932. return $res;
  933. }
  934. public function art_data($param,$data,$show=1)
  935. {
  936. if($show==1) {
  937. mac_echo('[' . __FUNCTION__ . '] ' . lang('model/collect/data_tip1',[$data['page']['page'],$data['page']['pagecount'],$data['page']['url']]));
  938. }
  939. $config = config('maccms.collect');
  940. $config = $config['art'];
  941. $type_list = model('Type')->getCache('type_list');
  942. $filter_arr = explode(',',$config['filter']); $filter_arr = array_filter($filter_arr);
  943. $pse_rnd = explode('#',$config['words']); $pse_rnd = array_filter($pse_rnd);
  944. $pse_syn = mac_txt_explain($config['thesaurus']);
  945. foreach($data['data'] as $k=>$v){
  946. $color='red';
  947. $des='';
  948. $msg='';
  949. $tmp='';
  950. if($v['type_id'] ==0){
  951. $des = lang('model/collect/type_err');
  952. }
  953. elseif(empty($v['art_name'])) {
  954. $des = lang('model/collect/name_err');
  955. }
  956. elseif( mac_array_filter($filter_arr,$v['art_name']) !==false) {
  957. $des = lang('model/collect/name_in_filter_err');
  958. }
  959. else {
  960. unset($v['art_id']);
  961. foreach($v as $k2=>$v2){
  962. if(strpos($k2,'_content')===false) {
  963. $v[$k2] = strip_tags($v2);
  964. }
  965. }
  966. $v['art_name'] = trim($v['art_name']);
  967. $v['type_id_1'] = intval($type_list[$v['type_id']]['type_pid']);
  968. $v['art_en'] = Pinyin::get($v['art_name']);
  969. $v['art_letter'] = strtoupper(substr($v['art_en'],0,1));
  970. $v['art_time_add'] = time();
  971. $v['art_time'] = time();
  972. $v['art_status'] = intval($config['status']);
  973. $v['art_lock'] = intval($v['art_lock']);
  974. if(!empty($v['art_status'])) {
  975. $v['art_status'] = intval($v['art_status']);
  976. }
  977. $v['art_level'] = intval($v['art_level']);
  978. $v['art_hits'] = intval($v['art_hits']);
  979. $v['art_hits_day'] = intval($v['art_hits_day']);
  980. $v['art_hits_week'] = intval($v['art_hits_week']);
  981. $v['art_hits_month'] = intval($v['art_hits_month']);
  982. $v['art_stint'] = intval($v['art_stint']);
  983. $v['art_up'] = intval($v['art_up']);
  984. $v['art_down'] = intval($v['art_down']);
  985. $v['art_score'] = floatval($v['art_score']);
  986. $v['art_score_all'] = intval($v['art_score_all']);
  987. $v['art_score_num'] = intval($v['art_score_num']);
  988. if($config['hits_start']>0 && $config['hits_end']>0) {
  989. $v['art_hits'] = rand($config['hits_start'], $config['hits_end']);
  990. $v['art_hits_day'] = rand($config['hits_start'], $config['hits_end']);
  991. $v['art_hits_week'] = rand($config['hits_start'], $config['hits_end']);
  992. $v['art_hits_month'] = rand($config['hits_start'], $config['hits_end']);
  993. }
  994. if($config['updown_start']>0 && $config['updown_end']){
  995. $v['art_up'] = rand($config['updown_start'], $config['updown_end']);
  996. $v['art_down'] = rand($config['updown_start'], $config['updown_end']);
  997. }
  998. if($config['score']==1) {
  999. $v['art_score_num'] = rand(1, 1000);
  1000. $v['art_score_all'] = $v['art_score_num'] * rand(1, 10);
  1001. $v['art_score'] = round($v['art_score_all'] / $v['art_score_num'], 1);
  1002. }
  1003. if ($config['psernd'] == 1) {
  1004. $v['art_content'] = mac_rep_pse_rnd($pse_rnd, $v['art_content']);
  1005. }
  1006. if ($config['psesyn'] == 1) {
  1007. $v['art_content'] = mac_rep_pse_syn($pse_syn, $v['art_content']);
  1008. }
  1009. if(empty($v['art_blurb'])){
  1010. $v['art_blurb'] = mac_substring( strip_tags( str_replace('$$$','',$v['art_content']) ) ,100);
  1011. }
  1012. $where = [];
  1013. $where['art_name'] = $v['art_name'];
  1014. if (strpos($config['inrule'], 'b')!==false) {
  1015. $where['type_id'] = $v['type_id'];
  1016. }
  1017. //验证地址
  1018. $cj_title_arr = explode('$$$',$v['art_title'] );
  1019. $cj_note_arr = explode('$$$',$v['art_note']);
  1020. $cj_content_arr = explode('$$$',$v['art_content']);
  1021. $tmp_title_arr=[];
  1022. $tmp_note_arr=[];
  1023. $tmp_content_arr=[];
  1024. foreach($cj_content_arr as $kk=>$vv){
  1025. $tmp_content_arr[] = $vv;
  1026. $tmp_title_arr[] = $cj_title_arr[$kk];
  1027. $tmp_note_arr[] = $cj_note_arr[$kk];
  1028. }
  1029. $v['art_title'] = join('$$$',$tmp_title_arr);
  1030. $v['art_note'] = join('$$$',$tmp_note_arr);
  1031. $v['art_content'] = join('$$$',$tmp_content_arr);
  1032. $info = model('Art')->where($where)->find();
  1033. if (!$info) {
  1034. $tmp = $this->syncImages($config['pic'],$v['art_pic'],'art');
  1035. $v['art_pic'] = mac_filter_xss((string)$tmp['pic']);
  1036. $msg = $tmp['msg'];
  1037. $res = model('Art')->insert($v);
  1038. if($res===false){
  1039. }
  1040. $color ='green';
  1041. $des= lang('model/collect/add_ok');
  1042. }
  1043. else {
  1044. if(empty($config['uprule'])){
  1045. $des = lang('model/collect/uprule_empty');
  1046. }
  1047. elseif($info['art_lock'] == 1) {
  1048. $des = lang('model/collect/data_lock');
  1049. }
  1050. else {
  1051. unset($v['art_time_add']);
  1052. $old_art_title = $info['art_title'];
  1053. $old_art_note = $info['art_note'];
  1054. $old_art_content = $info['art_content'];
  1055. $cj_art_title = $v['art_title'];
  1056. $cj_art_note = $v['art_note'];
  1057. $cj_art_content = $v['art_content'];
  1058. $rc=true;
  1059. if($rc){
  1060. $update=[];
  1061. if(strpos(','.$config['uprule'],'a')!==false && !empty($v['art_content']) && $v['art_content']!=$info['art_content']){
  1062. $update['art_content'] = $v['art_content'];
  1063. }
  1064. if(strpos(','.$config['uprule'],'b')!==false && !empty($v['art_author']) && $v['art_author']!=$info['art_author']){
  1065. $update['art_author'] = $v['art_author'];
  1066. }
  1067. if(strpos(','.$config['uprule'],'c')!==false && !empty($v['art_from']) && $v['art_from']!=$info['art_from']){
  1068. $update['art_from'] = $v['art_from'];
  1069. }
  1070. if(strpos(','.$config['uprule'],'d')!==false && (substr($info["art_pic"], 0, 4) == "http" || empty($info['art_pic'])) && $v['art_pic']!=$info['art_pic'] ){
  1071. $tmp = $this->syncImages($config['pic'],$v['art_pic'],'art');
  1072. $update['art_pic'] = mac_filter_xss((string)$tmp['pic']);
  1073. $msg =$tmp['msg'];
  1074. }
  1075. if(strpos(','.$config['uprule'],'e')!==false && !empty($v['art_tag']) && $v['art_tag']!=$info['art_tag']){
  1076. $update['art_tag'] = $v['art_tag'];
  1077. }
  1078. if(strpos(','.$config['uprule'],'f')!==false && !empty($v['art_blurb']) && $v['art_blurb']!=$info['art_blurb']){
  1079. $update['art_blurb'] = $v['art_blurb'];
  1080. }
  1081. if(count($update)>0){
  1082. $update['art_time'] = time();
  1083. $where = [];
  1084. $where['art_id'] = $info['art_id'];
  1085. $res = model('Art')->where($where)->update($update);
  1086. $color = 'green';
  1087. if($res===false){
  1088. }
  1089. }
  1090. else{
  1091. $des = lang('model/collect/not_need_update');
  1092. }
  1093. }
  1094. }
  1095. }
  1096. }
  1097. if($show==1) {
  1098. mac_echo( ($k + 1) . $v['art_name'] . "<font color=$color>" .$des .'</font>'. $msg . '');
  1099. }
  1100. else{
  1101. return ['code'=>($color=='red' ? 1001 : 1),'msg'=> $v['art_name'] .' '.$des ];
  1102. }
  1103. }
  1104. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_art';
  1105. if(ENTRANCE=='api'){
  1106. Cache::rm($key);
  1107. if ($data['page']['page'] < $data['page']['pagecount']) {
  1108. $param['page'] = intval($data['page']['page']) + 1;
  1109. $res = $this->art($param);
  1110. if($res['code']>1){
  1111. return $this->error($res['msg']);
  1112. }
  1113. $this->art_data($param,$res );
  1114. }
  1115. mac_echo(lang('model/collect/is_over'));
  1116. die;
  1117. }
  1118. if(empty($GLOBALS['config']['app']['collect_timespan'])){
  1119. $GLOBALS['config']['app']['collect_timespan'] = 3;
  1120. }
  1121. if($show==1) {
  1122. if ($param['ac'] == 'cjsel') {
  1123. Cache::rm($key);
  1124. mac_echo(lang('model/collect/is_over'));
  1125. unset($param['ids']);
  1126. $param['ac'] = 'list';
  1127. $url = url('api') . '?' . http_build_query($param);
  1128. $ref = $_SERVER["HTTP_REFERER"];
  1129. if(!empty($ref)){
  1130. $url = $ref;
  1131. }
  1132. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1133. } else {
  1134. if ($data['page']['page'] >= $data['page']['pagecount']) {
  1135. Cache::rm($key);
  1136. mac_echo(lang('model/collect/is_over'));
  1137. unset($param['page']);
  1138. $param['ac'] = 'list';
  1139. $url = url('api') . '?' . http_build_query($param);
  1140. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1141. } else {
  1142. $param['page'] = intval($data['page']['page']) + 1;
  1143. $url = url('api') . '?' . http_build_query($param);
  1144. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1145. }
  1146. }
  1147. }
  1148. }
  1149. public function actor_json($param)
  1150. {
  1151. $url_param = [];
  1152. $url_param['ac'] = $param['ac'];
  1153. $url_param['t'] = $param['t'];
  1154. $url_param['pg'] = is_numeric($param['page']) ? $param['page'] : '';
  1155. $url_param['h'] = $param['h'];
  1156. $url_param['ids'] = $param['ids'];
  1157. $url_param['wd'] = $param['wd'];
  1158. if($param['ac']!='list'){
  1159. $url_param['ac'] = 'detail';
  1160. }
  1161. $url = $param['cjurl'];
  1162. if(strpos($url,'?')===false){
  1163. $url .='?';
  1164. }
  1165. else{
  1166. $url .='&';
  1167. }
  1168. $url .= http_build_query($url_param).base64_decode($param['param']);
  1169. $html = mac_curl_get($url);
  1170. if(empty($html)){
  1171. return ['code'=>1001, 'msg'=>lang('model/collect/get_html_err')];
  1172. }
  1173. $html = mac_filter_tags($html);
  1174. $json = json_decode($html,true);
  1175. if(!$json){
  1176. return ['code'=>1002, 'msg'=>lang('model/collect/json_err')];
  1177. }
  1178. $array_page = [];
  1179. $array_page['page'] = $json['page'];
  1180. $array_page['pagecount'] = $json['pagecount'];
  1181. $array_page['pagesize'] = $json['limit'];
  1182. $array_page['recordcount'] = $json['total'];
  1183. $array_page['url'] = $url;
  1184. $type_list = model('Type')->getCache('type_list');
  1185. $bind_list = config('bind');
  1186. $key = 0;
  1187. $array_data = [];
  1188. foreach($json['list'] as $key=>$v){
  1189. $array_data[$key] = $v;
  1190. $bind_key = $param['cjflag'] .'_'.$v['type_id'];
  1191. if($bind_list[$bind_key] >0){
  1192. $array_data[$key]['type_id'] = $bind_list[$bind_key];
  1193. }
  1194. else{
  1195. $array_data[$key]['type_id'] = 0;
  1196. }
  1197. }
  1198. $array_type = [];
  1199. $key=0;
  1200. //分类列表
  1201. if($param['ac'] == 'list'){
  1202. foreach($json['class'] as $k=>$v){
  1203. $array_type[$key]['type_id'] = $v['type_id'];
  1204. $array_type[$key]['type_name'] = mac_filter_xss($v['type_name']);
  1205. $key++;
  1206. }
  1207. }
  1208. $res = ['code'=>1, 'msg'=>'ok', 'page'=>$array_page, 'type'=>$array_type, 'data'=>$array_data ];
  1209. return $res;
  1210. }
  1211. public function actor_data($param,$data,$show=1)
  1212. {
  1213. if($show==1) {
  1214. mac_echo('[' . __FUNCTION__ . '] ' . lang('model/collect/data_tip1',[$data['page']['page'],$data['page']['pagecount'],$data['page']['url']]));
  1215. }
  1216. $config = config('maccms.collect');
  1217. $config = $config['actor'];
  1218. $type_list = model('Type')->getCache('type_list');
  1219. $filter_arr = explode(',',$config['filter']); $filter_arr = array_filter($filter_arr);
  1220. $pse_rnd = explode('#',$config['words']); $pse_rnd = array_filter($pse_rnd);
  1221. $pse_syn = mac_txt_explain($config['thesaurus']);
  1222. foreach($data['data'] as $k=>$v){
  1223. $color='red';
  1224. $des='';
  1225. $msg='';
  1226. $tmp='';
  1227. if($v['type_id'] ==0){
  1228. $des = lang('model/collect/type_err');
  1229. }
  1230. elseif(empty($v['actor_name']) || empty($v['actor_sex'])) {
  1231. $des = lang('odel/collect/actor_data_require');
  1232. }
  1233. elseif( mac_array_filter($filter_arr,$v['actor_name'])!==false) {
  1234. $des = lang('model/collect/name_in_filter_err');
  1235. }
  1236. else {
  1237. unset($v['actor_id']);
  1238. foreach($v as $k2=>$v2){
  1239. if(strpos($k2,'_content')===false) {
  1240. $v[$k2] = strip_tags($v2);
  1241. }
  1242. }
  1243. $v['actor_name'] = trim($v['actor_name']);
  1244. $v['type_id_1'] = intval($type_list[$v['type_id']]['type_pid']);
  1245. $v['actor_en'] = Pinyin::get($v['actor_name']);
  1246. $v['actor_letter'] = strtoupper(substr($v['actor_en'],0,1));
  1247. $v['actor_time_add'] = time();
  1248. $v['actor_time'] = time();
  1249. $v['actor_status'] = intval($config['status']);
  1250. $v['actor_lock'] = intval($v['actor_lock']);
  1251. if(!empty($v['actor_status'])) {
  1252. $v['actor_status'] = intval($v['actor_status']);
  1253. }
  1254. $v['actor_level'] = intval($v['actor_level']);
  1255. $v['actor_hits'] = intval($v['actor_hits']);
  1256. $v['actor_hits_day'] = intval($v['actor_hits_day']);
  1257. $v['actor_hits_week'] = intval($v['actor_hits_week']);
  1258. $v['actor_hits_month'] = intval($v['actor_hits_month']);
  1259. $v['actor_up'] = intval($v['actor_up']);
  1260. $v['actor_down'] = intval($v['actor_down']);
  1261. $v['actor_score'] = floatval($v['actor_score']);
  1262. $v['actor_score_all'] = intval($v['actor_score_all']);
  1263. $v['actor_score_num'] = intval($v['actor_score_num']);
  1264. if($config['hits_start']>0 && $config['hits_end']>0) {
  1265. $v['actor_hits'] = rand($config['hits_start'], $config['hits_end']);
  1266. $v['actor_hits_day'] = rand($config['hits_start'], $config['hits_end']);
  1267. $v['actor_hits_week'] = rand($config['hits_start'], $config['hits_end']);
  1268. $v['actor_hits_month'] = rand($config['hits_start'], $config['hits_end']);
  1269. }
  1270. if($config['updown_start']>0 && $config['updown_end']){
  1271. $v['actor_up'] = rand($config['updown_start'], $config['updown_end']);
  1272. $v['actor_down'] = rand($config['updown_start'], $config['updown_end']);
  1273. }
  1274. if($config['score']==1) {
  1275. $v['actor_score_num'] = rand(1, 1000);
  1276. $v['actor_score_all'] = $v['actor_score_num'] * rand(1, 10);
  1277. $v['actor_score'] = round($v['actor_score_all'] / $v['actor_score_num'], 1);
  1278. }
  1279. if ($config['psernd'] == 1) {
  1280. $v['actor_content'] = mac_rep_pse_rnd($pse_rnd, $v['actor_content']);
  1281. }
  1282. if ($config['psesyn'] == 1) {
  1283. $v['actor_content'] = mac_rep_pse_syn($pse_syn, $v['actor_content']);
  1284. }
  1285. if(empty($v['actor_blurb'])){
  1286. $v['actor_blurb'] = mac_substring( strip_tags($v['actor_content']) ,100);
  1287. }
  1288. $where = [];
  1289. $where['actor_name'] = $v['actor_name'];
  1290. if (strpos($config['inrule'], 'b')!==false) {
  1291. $where['actor_sex'] = $v['actor_sex'];
  1292. }
  1293. if (strpos($config['inrule'], 'c')!==false) {
  1294. $where['type_id'] = $v['type_id'];
  1295. }
  1296. $info = model('Actor')->where($where)->find();
  1297. if (!$info) {
  1298. $tmp = $this->syncImages($config['pic'],$v['actor_pic'],'actor');
  1299. $v['actor_pic'] = $tmp['pic'];
  1300. $msg = $tmp['msg'];
  1301. $res = model('Actor')->insert($v);
  1302. if($res===false){
  1303. }
  1304. $color ='green';
  1305. $des= lang('model/collect/add_ok');
  1306. } else {
  1307. if(empty($config['uprule'])){
  1308. $des = lang('model/collect/uprule_empty');
  1309. }
  1310. elseif ($info['actor_lock'] == 1) {
  1311. $des = lang('model/collect/data_lock');
  1312. }
  1313. else {
  1314. unset($v['actor_time_add']);
  1315. $rc=true;
  1316. if($rc){
  1317. $update=[];
  1318. if(strpos(','.$config['uprule'],'a')!==false && !empty($v['actor_content']) && $v['actor_content']!=$info['actor_content']){
  1319. $update['actor_content'] = $v['actor_content'];
  1320. }
  1321. if(strpos(','.$config['uprule'],'b')!==false && !empty($v['actor_blurb']) && $v['actor_blurb']!=$info['actor_blurb']){
  1322. $update['actor_blurb'] = $v['actor_blurb'];
  1323. }
  1324. if(strpos(','.$config['uprule'],'c')!==false && !empty($v['actor_remarks']) && $v['actor_remarks']!=$info['actor_remarks']){
  1325. $update['actor_remarks'] = $v['actor_remarks'];
  1326. }
  1327. if(strpos(','.$config['uprule'],'d')!==false && !empty($v['actor_works']) && $v['actor_works']!=$info['actor_works']){
  1328. $update['actor_works'] = $v['actor_works'];
  1329. }
  1330. if(strpos(','.$config['uprule'],'e')!==false && (substr($info["actor_pic"], 0, 4) == "http" ||empty($info['actor_pic']) ) && $v['actor_pic']!=$info['actor_pic'] ){
  1331. $tmp = $this->syncImages($config['pic'],$v['actor_pic'],'actor');
  1332. $update['actor_pic'] =$tmp['pic'];
  1333. $msg =$tmp['msg'];
  1334. }
  1335. if(count($update)>0){
  1336. $update['actor_time'] = time();
  1337. $where = [];
  1338. $where['actor_id'] = $info['actor_id'];
  1339. $res = model('Actor')->where($where)->update($update);
  1340. $color = 'green';
  1341. if($res===false){
  1342. }
  1343. }
  1344. else{
  1345. $des = lang('model/collect/not_need_update');
  1346. }
  1347. }
  1348. }
  1349. }
  1350. }
  1351. if($show==1) {
  1352. mac_echo( ($k + 1) . $v['actor_name'] . "<font color=$color>" .$des .'</font>'. $msg . '');
  1353. }
  1354. else{
  1355. return ['code'=>($color=='red' ? 1001 : 1),'msg'=> $v['actor_name'] .' '.$des ];
  1356. }
  1357. }
  1358. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_actor';
  1359. if(ENTRANCE=='api'){
  1360. Cache::rm($key);
  1361. if ($data['page']['page'] < $data['page']['pagecount']) {
  1362. $param['page'] = intval($data['page']['page']) + 1;
  1363. $res = $this->actor($param);
  1364. if($res['code']>1){
  1365. return $this->error($res['msg']);
  1366. }
  1367. $this->actor_data($param,$res );
  1368. }
  1369. mac_echo(lang('model/collect/is_over'));
  1370. die;
  1371. }
  1372. if(empty($GLOBALS['config']['app']['collect_timespan'])){
  1373. $GLOBALS['config']['app']['collect_timespan'] = 3;
  1374. }
  1375. if($show==1) {
  1376. if ($param['ac'] == 'cjsel') {
  1377. Cache::rm($key);
  1378. mac_echo(lang('model/collect/is_over'));
  1379. unset($param['ids']);
  1380. $param['ac'] = 'list';
  1381. $url = url('api') . '?' . http_build_query($param);
  1382. $ref = $_SERVER["HTTP_REFERER"];
  1383. if(!empty($ref)){
  1384. $url = $ref;
  1385. }
  1386. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1387. } else {
  1388. if ($data['page']['page'] >= $data['page']['pagecount']) {
  1389. Cache::rm($key);
  1390. mac_echo(lang('model/collect/is_over'));
  1391. unset($param['page']);
  1392. $param['ac'] = 'list';
  1393. $url = url('api') . '?' . http_build_query($param);
  1394. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1395. } else {
  1396. $param['page'] = intval($data['page']['page']) + 1;
  1397. $url = url('api') . '?' . http_build_query($param);
  1398. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1399. }
  1400. }
  1401. }
  1402. }
  1403. public function role_json($param)
  1404. {
  1405. $url_param = [];
  1406. $url_param['ac'] = $param['ac'];
  1407. $url_param['t'] = $param['t'];
  1408. $url_param['pg'] = is_numeric($param['page']) ? $param['page'] : '';
  1409. $url_param['h'] = $param['h'];
  1410. $url_param['ids'] = $param['ids'];
  1411. $url_param['wd'] = $param['wd'];
  1412. if($param['ac']!='list'){
  1413. $url_param['ac'] = 'detail';
  1414. }
  1415. $url = $param['cjurl'];
  1416. if(strpos($url,'?')===false){
  1417. $url .='?';
  1418. }
  1419. else{
  1420. $url .='&';
  1421. }
  1422. $url .= http_build_query($url_param).base64_decode($param['param']);
  1423. $html = mac_curl_get($url);
  1424. if(empty($html)){
  1425. return ['code'=>1001, 'msg'=>lang('model/collect/get_html_err')];
  1426. }
  1427. $html = mac_filter_tags($html);
  1428. $json = json_decode($html,true);
  1429. if(!$json){
  1430. return ['code'=>1002, 'msg'=>lang('model/collect/json_err')];
  1431. }
  1432. $array_page = [];
  1433. $array_page['page'] = $json['page'];
  1434. $array_page['pagecount'] = $json['pagecount'];
  1435. $array_page['pagesize'] = $json['limit'];
  1436. $array_page['recordcount'] = $json['total'];
  1437. $array_page['url'] = $url;
  1438. $key = 0;
  1439. $array_data = [];
  1440. foreach($json['list'] as $key=>$v){
  1441. $array_data[$key] = $v;
  1442. }
  1443. $res = ['code'=>1, 'msg'=>'ok', 'page'=>$array_page, 'data'=>$array_data ];
  1444. return $res;
  1445. }
  1446. public function role_data($param,$data,$show=1)
  1447. {
  1448. if($show==1) {
  1449. mac_echo('[' . __FUNCTION__ . '] ' . lang('model/collect/data_tip1',[$data['page']['page'],$data['page']['pagecount'],$data['page']['url']]));
  1450. }
  1451. $config = config('maccms.collect');
  1452. $config = $config['role'];
  1453. $filter_arr = explode(',',$config['filter']); $filter_arr = array_filter($filter_arr);
  1454. $pse_rnd = explode('#',$config['words']); $pse_rnd = array_filter($pse_rnd);
  1455. $pse_syn = mac_txt_explain($config['thesaurus']);
  1456. foreach($data['data'] as $k=>$v){
  1457. $color='red';
  1458. $des='';
  1459. $msg='';
  1460. $tmp='';
  1461. if(empty($v['role_name']) || empty($v['role_actor']) || empty($v['vod_name']) ) {
  1462. $des = lang('model/collect/role_data_require');
  1463. }
  1464. elseif( mac_array_filter($filter_arr,$v['role_name']) !==false) {
  1465. $des = lang('model/collect/name_in_filter_err');
  1466. }
  1467. else {
  1468. unset($v['role_id']);
  1469. foreach($v as $k2=>$v2){
  1470. if(strpos($k2,'_content')===false) {
  1471. $v[$k2] = strip_tags($v2);
  1472. }
  1473. }
  1474. $v['role_en'] = Pinyin::get($v['role_name']);
  1475. $v['role_letter'] = strtoupper(substr($v['role_en'],0,1));
  1476. $v['role_time_add'] = time();
  1477. $v['role_time'] = time();
  1478. $v['role_status'] = intval($config['status']);
  1479. $v['role_lock'] = intval($v['role_lock']);
  1480. if(!empty($v['role_status'])) {
  1481. $v['role_status'] = intval($v['role_status']);
  1482. }
  1483. $v['role_level'] = intval($v['role_level']);
  1484. $v['role_hits'] = intval($v['role_hits']);
  1485. $v['role_hits_day'] = intval($v['role_hits_day']);
  1486. $v['role_hits_week'] = intval($v['role_hits_week']);
  1487. $v['role_hits_month'] = intval($v['role_hits_month']);
  1488. $v['role_up'] = intval($v['role_up']);
  1489. $v['role_down'] = intval($v['role_down']);
  1490. $v['role_score'] = floatval($v['role_score']);
  1491. $v['role_score_all'] = intval($v['role_score_all']);
  1492. $v['role_score_num'] = intval($v['role_score_num']);
  1493. if($config['hits_start']>0 && $config['hits_end']>0) {
  1494. $v['role_hits'] = rand($config['hits_start'], $config['hits_end']);
  1495. $v['role_hits_day'] = rand($config['hits_start'], $config['hits_end']);
  1496. $v['role_hits_week'] = rand($config['hits_start'], $config['hits_end']);
  1497. $v['role_hits_month'] = rand($config['hits_start'], $config['hits_end']);
  1498. }
  1499. if($config['updown_start']>0 && $config['updown_end']){
  1500. $v['role_up'] = rand($config['updown_start'], $config['updown_end']);
  1501. $v['role_down'] = rand($config['updown_start'], $config['updown_end']);
  1502. }
  1503. if($config['score']==1) {
  1504. $v['role_score_num'] = rand(1, 1000);
  1505. $v['role_score_all'] = $v['role_score_num'] * rand(1, 10);
  1506. $v['role_score'] = round($v['role_score_all'] / $v['role_score_num'], 1);
  1507. }
  1508. if ($config['psernd'] == 1) {
  1509. $v['role_content'] = mac_rep_pse_rnd($pse_rnd, $v['role_content']);
  1510. }
  1511. if ($config['psesyn'] == 1) {
  1512. $v['role_content'] = mac_rep_pse_syn($pse_syn, $v['role_content']);
  1513. }
  1514. $where = [];
  1515. $where['role_name'] = $v['role_name'];
  1516. $where['role_actor'] = $v['role_actor'];
  1517. $where2 = [];
  1518. $blend = false;
  1519. if(!empty($v['douban_id'])){
  1520. $where2['vod_douban_id'] = ['eq',$v['douban_id']];
  1521. unset($v['douban_id']);
  1522. }
  1523. else{
  1524. $where2['vod_name'] = ['eq',$v['vod_name']];
  1525. }
  1526. if (strpos($config['inrule'], 'c')!==false) {
  1527. $where2['vod_actor'] = ['like', mac_like_arr($v['role_actor']), 'OR'];
  1528. }
  1529. if (strpos($config['inrule'], 'd')!==false) {
  1530. $where2['vod_director'] = ['like', mac_like_arr($v['role_actor']), 'OR'];
  1531. }
  1532. if(!empty($where2['vod_actor']) && !empty($where2['vod_director'])){
  1533. $blend = true;
  1534. $GLOBALS['blend'] = [
  1535. 'vod_actor' => $where2['vod_actor'],
  1536. 'vod_director' => $where2['vod_director']
  1537. ];
  1538. unset($where2['vod_actor'],$where2['vod_director']);
  1539. }
  1540. if($blend===false){
  1541. $vod_info = model('Vod')->where($where2)->find();
  1542. }
  1543. else{
  1544. $vod_info = model('Vod')->where($where2)
  1545. ->where(function($query){
  1546. $query->where('vod_director',$GLOBALS['blend']['vod_director'])
  1547. ->whereOr('vod_actor',$GLOBALS['blend']['vod_actor']);
  1548. })
  1549. ->find();
  1550. }
  1551. if (!$vod_info) {
  1552. $des = lang('model/collect/not_found_rel_vod');
  1553. }
  1554. else {
  1555. $v['role_rid'] = $vod_info['vod_id'];
  1556. $where['role_rid'] = $vod_info['vod_id'];
  1557. $info = model('Role')->where($where)->find();
  1558. if (!$info) {
  1559. $tmp = $this->syncImages($config['pic'], $v['role_pic'], 'role');
  1560. $v['role_pic'] = $tmp['pic'];
  1561. $msg = $tmp['msg'];
  1562. $res = model('Role')->insert($v);
  1563. if ($res === false) {
  1564. }
  1565. $color = 'green';
  1566. $des = lang('model/collect/add_ok');
  1567. } else {
  1568. if(empty($config['uprule'])){
  1569. $des = lang('model/collect/uprule_empty');
  1570. }
  1571. elseif ($info['role_lock'] == 1) {
  1572. $des = lang('model/collect/data_lock');
  1573. }
  1574. else {
  1575. unset($v['role_time_add']);
  1576. $rc = true;
  1577. if ($rc) {
  1578. $update = [];
  1579. if (strpos(',' . $config['uprule'], 'a') !== false && !empty($v['role_content']) && $v['role_content'] != $info['role_content']) {
  1580. $update['role_content'] = $v['role_content'];
  1581. }
  1582. if (strpos(',' . $config['uprule'], 'b') !== false && !empty($v['role_remarks']) && $v['role_remarks'] != $info['role_remarks']) {
  1583. $update['role_remarks'] = $v['role_remarks'];
  1584. }
  1585. if (strpos(',' . $config['uprule'], 'c') !== false && (substr($info["role_pic"], 0, 4) == "http" || empty($info['role_pic'])) && $v['role_pic'] != $info['role_pic']) {
  1586. $tmp = $this->syncImages($config['pic'], $v['role_pic'], 'role');
  1587. $update['role_pic'] = $tmp['pic'];
  1588. $msg = $tmp['msg'];
  1589. }
  1590. if(count($update)>0){
  1591. $update['role_time'] = time();
  1592. $where = [];
  1593. $where['role_id'] = $info['role_id'];
  1594. $res = model('Role')->where($where)->update($update);
  1595. $color = 'green';
  1596. if ($res === false) {
  1597. }
  1598. }
  1599. else{
  1600. $des = lang('model/collect/not_need_update');
  1601. }
  1602. }
  1603. }
  1604. }
  1605. }
  1606. }
  1607. if($show==1) {
  1608. mac_echo( ($k + 1) . $v['role_name'] . "<font color=$color>" .$des .'</font>'. $msg . '');
  1609. }
  1610. else{
  1611. return ['code'=>($color=='red' ? 1001 : 1),'msg'=> $v['role_name'] .' '.$des ];
  1612. }
  1613. }
  1614. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_role';
  1615. if(ENTRANCE=='api'){
  1616. Cache::rm($key);
  1617. if ($data['page']['page'] < $data['page']['pagecount']) {
  1618. $param['page'] = intval($data['page']['page']) + 1;
  1619. $res = $this->role($param);
  1620. if($res['code']>1){
  1621. return $this->error($res['msg']);
  1622. }
  1623. $this->actor_data($param,$res );
  1624. }
  1625. mac_echo(lang('model/collect/is_over'));
  1626. die;
  1627. }
  1628. if(empty($GLOBALS['config']['app']['collect_timespan'])){
  1629. $GLOBALS['config']['app']['collect_timespan'] = 3;
  1630. }
  1631. if($show==1) {
  1632. if ($param['ac'] == 'cjsel') {
  1633. Cache::rm($key);
  1634. mac_echo(lang('model/collect/is_over'));
  1635. unset($param['ids']);
  1636. $param['ac'] = 'list';
  1637. $url = url('api') . '?' . http_build_query($param);
  1638. $ref = $_SERVER["HTTP_REFERER"];
  1639. if(!empty($ref)){
  1640. $url = $ref;
  1641. }
  1642. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1643. } else {
  1644. if ($data['page']['page'] >= $data['page']['pagecount']) {
  1645. Cache::rm($key);
  1646. mac_echo(lang('model/collect/is_over'));
  1647. unset($param['page']);
  1648. $param['ac'] = 'list';
  1649. $url = url('api') . '?' . http_build_query($param);
  1650. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1651. } else {
  1652. $param['page'] = intval($data['page']['page']) + 1;
  1653. $url = url('api') . '?' . http_build_query($param);
  1654. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1655. }
  1656. }
  1657. }
  1658. }
  1659. public function website_json($param)
  1660. {
  1661. $url_param = [];
  1662. $url_param['ac'] = $param['ac'];
  1663. $url_param['t'] = $param['t'];
  1664. $url_param['pg'] = is_numeric($param['page']) ? $param['page'] : '';
  1665. $url_param['h'] = $param['h'];
  1666. $url_param['ids'] = $param['ids'];
  1667. $url_param['wd'] = $param['wd'];
  1668. if($param['ac']!='list'){
  1669. $url_param['ac'] = 'detail';
  1670. }
  1671. $url = $param['cjurl'];
  1672. if(strpos($url,'?')===false){
  1673. $url .='?';
  1674. }
  1675. else{
  1676. $url .='&';
  1677. }
  1678. $url .= http_build_query($url_param).base64_decode($param['param']);
  1679. $html = mac_curl_get($url);
  1680. if(empty($html)){
  1681. return ['code'=>1001, 'msg'=>lang('model/collect/get_html_err')];
  1682. }
  1683. $html = mac_filter_tags($html);
  1684. $json = json_decode($html,true);
  1685. if(!$json){
  1686. return ['code'=>1002, 'msg'=>lang('model/collect/json_err')];
  1687. }
  1688. $array_page = [];
  1689. $array_page['page'] = $json['page'];
  1690. $array_page['pagecount'] = $json['pagecount'];
  1691. $array_page['pagesize'] = $json['limit'];
  1692. $array_page['recordcount'] = $json['total'];
  1693. $array_page['url'] = $url;
  1694. $type_list = model('Type')->getCache('type_list');
  1695. $bind_list = config('bind');
  1696. $key = 0;
  1697. $array_data = [];
  1698. foreach($json['list'] as $key=>$v){
  1699. $array_data[$key] = $v;
  1700. $bind_key = $param['cjflag'] .'_'.$v['type_id'];
  1701. if($bind_list[$bind_key] >0){
  1702. $array_data[$key]['type_id'] = $bind_list[$bind_key];
  1703. }
  1704. else{
  1705. $array_data[$key]['type_id'] = 0;
  1706. }
  1707. }
  1708. $array_type = [];
  1709. $key=0;
  1710. //分类列表
  1711. if($param['ac'] == 'list'){
  1712. foreach($json['class'] as $k=>$v){
  1713. $array_type[$key]['type_id'] = $v['type_id'];
  1714. $array_type[$key]['type_name'] = mac_filter_xss($v['type_name']);
  1715. $key++;
  1716. }
  1717. }
  1718. $res = ['code'=>1, 'msg'=>'ok', 'page'=>$array_page, 'type'=>$array_type, 'data'=>$array_data ];
  1719. return $res;
  1720. }
  1721. public function website_data($param,$data,$show=1)
  1722. {
  1723. if($show==1) {
  1724. mac_echo('[' . __FUNCTION__ . '] ' . lang('model/collect/data_tip1',[$data['page']['page'],$data['page']['pagecount'],$data['page']['url']]));
  1725. }
  1726. $config = config('maccms.collect');
  1727. $config = $config['website'];
  1728. $type_list = model('Type')->getCache('type_list');
  1729. $filter_arr = explode(',',$config['filter']); $filter_arr = array_filter($filter_arr);
  1730. $pse_rnd = explode('#',$config['words']); $pse_rnd = array_filter($pse_rnd);
  1731. $pse_syn = mac_txt_explain($config['thesaurus']);
  1732. foreach($data['data'] as $k=>$v){
  1733. $color='red';
  1734. $des='';
  1735. $msg='';
  1736. $tmp='';
  1737. if($v['type_id'] ==0){
  1738. $des = lang('model/collect/type_err');
  1739. }
  1740. elseif(empty($v['website_name'])) {
  1741. $des = lang('model/collect/name_err');
  1742. }
  1743. elseif( mac_array_filter($filter_arr,$v['website_name'])!==false) {
  1744. $des = lang('model/collect/name_in_filter_err');
  1745. }
  1746. else {
  1747. unset($v['website_id']);
  1748. foreach($v as $k2=>$v2){
  1749. if(strpos($k2,'_content')===false) {
  1750. $v[$k2] = strip_tags($v2);
  1751. }
  1752. }
  1753. $v['website_name'] = trim($v['website_name']);
  1754. $v['type_id_1'] = intval($type_list[$v['type_id']]['type_pid']);
  1755. $v['website_en'] = Pinyin::get($v['website_name']);
  1756. $v['website_letter'] = strtoupper(substr($v['website_en'],0,1));
  1757. $v['website_time_add'] = time();
  1758. $v['website_time'] = time();
  1759. $v['website_status'] = intval($config['status']);
  1760. $v['website_lock'] = intval($v['website_lock']);
  1761. if(!empty($v['website_status'])) {
  1762. $v['website_status'] = intval($v['website_status']);
  1763. }
  1764. $v['website_level'] = intval($v['website_level']);
  1765. $v['website_hits'] = intval($v['website_hits']);
  1766. $v['website_hits_day'] = intval($v['website_hits_day']);
  1767. $v['website_hits_week'] = intval($v['website_hits_week']);
  1768. $v['website_hits_month'] = intval($v['website_hits_month']);
  1769. $v['website_up'] = intval($v['website_up']);
  1770. $v['website_down'] = intval($v['website_down']);
  1771. $v['website_score'] = floatval($v['website_score']);
  1772. $v['website_score_all'] = intval($v['website_score_all']);
  1773. $v['website_score_num'] = intval($v['website_score_num']);
  1774. if($config['hits_start']>0 && $config['hits_end']>0) {
  1775. $v['website_hits'] = rand($config['hits_start'], $config['hits_end']);
  1776. $v['website_hits_day'] = rand($config['hits_start'], $config['hits_end']);
  1777. $v['website_hits_week'] = rand($config['hits_start'], $config['hits_end']);
  1778. $v['website_hits_month'] = rand($config['hits_start'], $config['hits_end']);
  1779. }
  1780. if($config['updown_start']>0 && $config['updown_end']){
  1781. $v['website_up'] = rand($config['updown_start'], $config['updown_end']);
  1782. $v['website_down'] = rand($config['updown_start'], $config['updown_end']);
  1783. }
  1784. if($config['score']==1) {
  1785. $v['website_score_num'] = rand(1, 1000);
  1786. $v['website_score_all'] = $v['website_score_num'] * rand(1, 10);
  1787. $v['website_score'] = round($v['website_score_all'] / $v['website_score_num'], 1);
  1788. }
  1789. if ($config['psernd'] == 1) {
  1790. $v['website_content'] = mac_rep_pse_rnd($pse_rnd, $v['website_content']);
  1791. }
  1792. if ($config['psesyn'] == 1) {
  1793. $v['website_content'] = mac_rep_pse_syn($pse_syn, $v['website_content']);
  1794. }
  1795. if(empty($v['website_blurb'])){
  1796. $v['website_blurb'] = mac_substring( strip_tags($v['website_content']) ,100);
  1797. }
  1798. $where = [];
  1799. $where['website_name'] = $v['website_name'];
  1800. if (strpos($config['inrule'], 'b')!==false) {
  1801. $where['type_id'] = $v['type_id'];
  1802. }
  1803. $info = model('Website')->where($where)->find();
  1804. if (!$info) {
  1805. $tmp = $this->syncImages($config['pic'],$v['website_pic'],'website');
  1806. $v['website_pic'] = $tmp['pic'];
  1807. $msg = $tmp['msg'];
  1808. $res = model('Website')->insert($v);
  1809. if($res===false){
  1810. }
  1811. $color ='green';
  1812. $des= lang('model/collect/add_ok');
  1813. } else {
  1814. if(empty($config['uprule'])){
  1815. $des = lang('model/collect/uprule_empty');
  1816. }
  1817. elseif ($info['website_lock'] == 1) {
  1818. $des = lang('model/collect/data_lock');
  1819. }
  1820. else {
  1821. unset($v['website_time_add']);
  1822. $rc=true;
  1823. if($rc){
  1824. $update=[];
  1825. if(strpos(','.$config['uprule'],'a')!==false && !empty($v['website_content']) && $v['website_content']!=$info['website_content']){
  1826. $update['website_content'] = $v['website_content'];
  1827. }
  1828. if(strpos(','.$config['uprule'],'b')!==false && !empty($v['website_blurb']) && $v['website_blurb']!=$info['website_blurb']){
  1829. $update['website_blurb'] = $v['website_blurb'];
  1830. }
  1831. if(strpos(','.$config['uprule'],'c')!==false && !empty($v['website_remarks']) && $v['website_remarks']!=$info['website_remarks']){
  1832. $update['website_remarks'] = $v['website_remarks'];
  1833. }
  1834. if(strpos(','.$config['uprule'],'d')!==false && !empty($v['website_jumpurl']) && $v['website_jumpurl']!=$info['website_jumpurl']){
  1835. $update['website_jumpurl'] = $v['website_jumpurl'];
  1836. }
  1837. if(strpos(','.$config['uprule'],'e')!==false && (substr($info["website_pic"], 0, 4) == "http" ||empty($info['website_pic']) ) && $v['website_pic']!=$info['website_pic'] ){
  1838. $tmp = $this->syncImages($config['pic'],$v['website_pic'],'website');
  1839. $update['website_pic'] =$tmp['pic'];
  1840. $msg =$tmp['msg'];
  1841. }
  1842. if(count($update)>0){
  1843. $update['website_time'] = time();
  1844. $where = [];
  1845. $where['website_id'] = $info['website_id'];
  1846. $res = model('Website')->where($where)->update($update);
  1847. $color = 'green';
  1848. if($res===false){
  1849. }
  1850. }
  1851. else{
  1852. $des = lang('model/collect/not_need_update');
  1853. }
  1854. }
  1855. }
  1856. }
  1857. }
  1858. if($show==1) {
  1859. mac_echo( ($k + 1) . $v['website_name'] . "<font color=$color>" .$des .'</font>'. $msg . '');
  1860. }
  1861. else{
  1862. return ['code'=>($color=='red' ? 1001 : 1),'msg'=> $v['website_name'] .' '.$des ];
  1863. }
  1864. }
  1865. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_website';
  1866. if(ENTRANCE=='api'){
  1867. Cache::rm($key);
  1868. if ($data['page']['page'] < $data['page']['pagecount']) {
  1869. $param['page'] = intval($data['page']['page']) + 1;
  1870. $res = $this->actor($param);
  1871. if($res['code']>1){
  1872. return $this->error($res['msg']);
  1873. }
  1874. $this->website_data($param,$res );
  1875. }
  1876. mac_echo(lang('model/collect/is_over'));
  1877. die;
  1878. }
  1879. if(empty($GLOBALS['config']['app']['collect_timespan'])){
  1880. $GLOBALS['config']['app']['collect_timespan'] = 3;
  1881. }
  1882. if($show==1) {
  1883. if ($param['ac'] == 'cjsel') {
  1884. Cache::rm($key);
  1885. mac_echo(lang('model/collect/is_over'));
  1886. unset($param['ids']);
  1887. $param['ac'] = 'list';
  1888. $url = url('api') . '?' . http_build_query($param);
  1889. $ref = $_SERVER["HTTP_REFERER"];
  1890. if(!empty($ref)){
  1891. $url = $ref;
  1892. }
  1893. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1894. } else {
  1895. if ($data['page']['page'] >= $data['page']['pagecount']) {
  1896. Cache::rm($key);
  1897. mac_echo(lang('model/collect/is_over'));
  1898. unset($param['page']);
  1899. $param['ac'] = 'list';
  1900. $url = url('api') . '?' . http_build_query($param);
  1901. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1902. } else {
  1903. $param['page'] = intval($data['page']['page']) + 1;
  1904. $url = url('api') . '?' . http_build_query($param);
  1905. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  1906. }
  1907. }
  1908. }
  1909. }
  1910. public function comment_json($param)
  1911. {
  1912. $url_param = [];
  1913. $url_param['ac'] = $param['ac'];
  1914. $url_param['t'] = $param['t'];
  1915. $url_param['pg'] = is_numeric($param['page']) ? $param['page'] : '';
  1916. $url_param['h'] = $param['h'];
  1917. $url_param['ids'] = $param['ids'];
  1918. $url_param['wd'] = $param['wd'];
  1919. if($param['ac']!='list'){
  1920. $url_param['ac'] = 'detail';
  1921. }
  1922. $url = $param['cjurl'];
  1923. if(strpos($url,'?')===false){
  1924. $url .='?';
  1925. }
  1926. else{
  1927. $url .='&';
  1928. }
  1929. $url .= http_build_query($url_param).base64_decode($param['param']);
  1930. $html = mac_curl_get($url);
  1931. if(empty($html)){
  1932. return ['code'=>1001, 'msg'=>lang('model/collect/get_html_err')];
  1933. }
  1934. $html = mac_filter_tags($html);
  1935. $json = json_decode($html,true);
  1936. if(!$json){
  1937. return ['code'=>1002, 'msg'=>lang('model/collect/json_err')];
  1938. }
  1939. $array_page = [];
  1940. $array_page['page'] = $json['page'];
  1941. $array_page['pagecount'] = $json['pagecount'];
  1942. $array_page['pagesize'] = $json['limit'];
  1943. $array_page['recordcount'] = $json['total'];
  1944. $array_page['url'] = $url;
  1945. $key = 0;
  1946. $array_data = [];
  1947. foreach($json['list'] as $key=>$v){
  1948. $array_data[$key] = $v;
  1949. }
  1950. $res = ['code'=>1, 'msg'=>'ok', 'page'=>$array_page, 'data'=>$array_data ];
  1951. return $res;
  1952. }
  1953. public function comment_data($param,$data,$show=1)
  1954. {
  1955. if($show==1) {
  1956. mac_echo('[' . __FUNCTION__ . '] ' . lang('model/collect/data_tip1',[$data['page']['page'],$data['page']['pagecount'],$data['page']['url']]));
  1957. }
  1958. $config = config('maccms.collect');
  1959. $config = $config['comment'];
  1960. $filter_arr = explode(',',$config['filter']); $filter_arr = array_filter($filter_arr);
  1961. $pse_rnd = explode('#',$config['words']); $pse_rnd = array_filter($pse_rnd);
  1962. $pse_syn = mac_txt_explain($config['thesaurus']);
  1963. foreach($data['data'] as $k=>$v){
  1964. $color='red';
  1965. $des='';
  1966. $msg='';
  1967. $tmp='';
  1968. if(empty($v['comment_name']) || empty($v['comment_content']) || empty($v['rel_name']) ) {
  1969. $des = lang('model/collect/comment_data_require');
  1970. }
  1971. elseif( mac_array_filter($filter_arr,$v['comment_content']) !==false) {
  1972. $des = lang('model/collect/name_in_filter_err');
  1973. }
  1974. else {
  1975. unset($v['comment_id']);
  1976. foreach($v as $k2=>$v2){
  1977. if(strpos($k2,'_content')===false) {
  1978. $v[$k2] = strip_tags($v2);
  1979. }
  1980. }
  1981. $v['comment_time'] = time();
  1982. $v['comment_status'] = intval($config['status']);
  1983. $v['comment_up'] = intval($v['comment_up']);
  1984. $v['comment_down'] = intval($v['comment_down']);
  1985. $v['comment_mid'] = intval($v['comment_mid']);
  1986. if(!empty($v['comment_ip']) && !is_numeric($v['comment_ip'])){
  1987. $v['comment_ip'] = mac_get_ip_long($v['comment_ip']);
  1988. }
  1989. if($config['updown_start']>0 && $config['updown_end']){
  1990. $v['comment_up'] = rand($config['updown_start'], $config['updown_end']);
  1991. $v['comment_down'] = rand($config['updown_start'], $config['updown_end']);
  1992. }
  1993. if ($config['psernd'] == 1) {
  1994. $v['comment_content'] = mac_rep_pse_rnd($pse_rnd, $v['comment_content']);
  1995. }
  1996. if ($config['psesyn'] == 1) {
  1997. $v['comment_content'] = mac_rep_pse_syn($pse_syn, $v['comment_content']);
  1998. }
  1999. $where = [];
  2000. $where2 = [];
  2001. $blend = false;
  2002. if (strpos($config['inrule'], 'b')!==false) {
  2003. $where['comment_content'] = ['eq', $v['comment_content']];
  2004. }
  2005. if (strpos($config['inrule'], 'c')!==false) {
  2006. $where['comment_name'] = ['eq', $v['comment_name']];
  2007. }
  2008. if(empty($v['rel_id'])){
  2009. if($v['comment_mid']==1){
  2010. if(!empty($v['douban_id'])){
  2011. $where2['vod_douban_id'] = ['eq',$v['douban_id']];
  2012. unset($v['douban_id']);
  2013. }
  2014. else{
  2015. $where2['vod_name'] = ['eq',$v['rel_name']];
  2016. }
  2017. $rel_info = model('Vod')->where($where2)->find();
  2018. }
  2019. elseif($v['comment_mid']==2){
  2020. $where2['art_name'] = ['eq',$v['rel_name']];
  2021. $rel_info = model('Art')->where($where2)->find();
  2022. }
  2023. elseif($v['comment_mid']==3){
  2024. $where2['topic_name'] = ['eq',$v['rel_name']];
  2025. $rel_info = model('Topic')->where($where2)->find();
  2026. }
  2027. elseif($v['comment_mid']==8){
  2028. $where2['actor_name'] = ['eq',$v['rel_name']];
  2029. $rel_info = model('Actor')->where($where2)->find();
  2030. }
  2031. elseif($v['comment_mid']==9){
  2032. $where2['role_name'] = ['eq',$v['rel_name']];
  2033. $rel_info = model('Role')->where($where2)->find();
  2034. }
  2035. elseif($v['comment_mid']==11){
  2036. $where2['website_name'] = ['eq',$v['rel_name']];
  2037. $rel_info = model('Website')->where($where2)->find();
  2038. }
  2039. $rel_id = $rel_info[mac_get_mid_code($v['comment_mid']).'_id'];
  2040. }
  2041. else{
  2042. $rel_id = $v['rel_id'];
  2043. }
  2044. if(empty($rel_id)){
  2045. $des = lang('model/collect/not_found_rel_data');
  2046. }
  2047. else {
  2048. $v['comment_rid'] = $rel_id;
  2049. $info=false;
  2050. if(!empty($where)) {
  2051. $where['comment_rid'] = $rel_id;
  2052. $info = model('Comment')->where($where)->find();
  2053. }
  2054. if (!$info) {
  2055. $msg = $tmp['msg'];
  2056. $res = model('Comment')->insert($v);
  2057. if ($res === false) {
  2058. }
  2059. $color = 'green';
  2060. $des = lang('model/collect/add_ok');
  2061. } else {
  2062. if(empty($config['uprule'])){
  2063. $des = lang('model/collect/uprule_empty');
  2064. }
  2065. else {
  2066. $rc = true;
  2067. if ($rc) {
  2068. $update = [];
  2069. if (strpos(',' . $config['uprule'], 'a') !== false && !empty($v['comment_time']) && $v['comment_time'] != $info['comment_time']) {
  2070. $update['comment_time'] = $v['comment_time'];
  2071. }
  2072. if(count($update)>0){
  2073. $update['comment_time'] = time();
  2074. $where = [];
  2075. $where['comment_id'] = $info['comment_id'];
  2076. $res = model('Comment')->where($where)->update($update);
  2077. $color = 'green';
  2078. if ($res === false) {
  2079. }
  2080. }
  2081. else{
  2082. $des = lang('model/collect/not_need_update');
  2083. }
  2084. }
  2085. }
  2086. }
  2087. }
  2088. }
  2089. if($show==1) {
  2090. mac_echo( ($k + 1) . $v['comment_content'] . "<font color=$color>" .$des .'</font>'. $msg . '');
  2091. }
  2092. else{
  2093. return ['code'=>($color=='red' ? 1001 : 1),'msg'=> $v['comment_content'] .' '.$des ];
  2094. }
  2095. }
  2096. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_comment';
  2097. if(ENTRANCE=='api'){
  2098. Cache::rm($key);
  2099. if ($data['page']['page'] < $data['page']['pagecount']) {
  2100. $param['page'] = intval($data['page']['page']) + 1;
  2101. $res = $this->role($param);
  2102. if($res['code']>1){
  2103. return $this->error($res['msg']);
  2104. }
  2105. $this->actor_data($param,$res );
  2106. }
  2107. mac_echo(lang('model/collect/is_over'));
  2108. die;
  2109. }
  2110. if(empty($GLOBALS['config']['app']['collect_timespan'])){
  2111. $GLOBALS['config']['app']['collect_timespan'] = 3;
  2112. }
  2113. if($show==1) {
  2114. if ($param['ac'] == 'cjsel') {
  2115. Cache::rm($key);
  2116. mac_echo(lang('model/collect/is_over'));
  2117. unset($param['ids']);
  2118. $param['ac'] = 'list';
  2119. $url = url('api') . '?' . http_build_query($param);
  2120. $ref = $_SERVER["HTTP_REFERER"];
  2121. if(!empty($ref)){
  2122. $url = $ref;
  2123. }
  2124. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  2125. } else {
  2126. if ($data['page']['page'] >= $data['page']['pagecount']) {
  2127. Cache::rm($key);
  2128. mac_echo(lang('model/collect/is_over'));
  2129. unset($param['page']);
  2130. $param['ac'] = 'list';
  2131. $url = url('api') . '?' . http_build_query($param);
  2132. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  2133. } else {
  2134. $param['page'] = intval($data['page']['page']) + 1;
  2135. $url = url('api') . '?' . http_build_query($param);
  2136. mac_jump($url, $GLOBALS['config']['app']['collect_timespan']);
  2137. }
  2138. }
  2139. }
  2140. }
  2141. }