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