首页 > 其他分享 >上传代码

上传代码

时间:2022-11-19 18:37:00浏览次数:47  
标签:title db 代码 list api onclick 上传 id

 1 <?php
 2 
 3 //获取用户在搜索框输入的信息
 4 $seek=$api->post('seek');
 5 $b=$api->post('b');
 6 $nowtime=$api->post('nowtime');
 7 $c=b+10;
 8 if($seek===''){
 9     $q[0][title]="输入为空,请重新输入";
10     $result = [
11     'seeklist'=>$q
12     ];
13 // 输出json数据
14 $api->json($result);
15 }
16 //在关键词表查询
17 $list = $api->load('db')->query("select id,truetime from [!db.pre!]ecms_tagram where title='$seek'");
18 
19 //数据超过一个月将更新,24小时:86400
20 if($nowtime-$list[0][truetime]>2592000){
21     $list1 = $api->load('db')->query("select title,id,onclick,fileSize,newstime from [!db.pre!]ecms_fujian where locate('$seek',title)>0 order by onclick desc limit 0,200");
22     $id=$list[0][id];
23     $truetime=$nowtime;
24     $list2 = json_encode($list1,JSON_UNESCAPED_UNICODE);
25     $data = array(
26         'truetime' => $truetime,
27         'RAM' => $list2
28     );
29      $api->load('table')->update('tagram' , $data , $id);
30 };
31 //将未登录账号设置为游客
32 if(!$userid){
33     $userid='';
34     $username='游客';}
35 
36 //在关键词表没有查询到数据后
37 if(!$list[0][id])
38 {   //在附件表查询
39     // $list = $api->load('db')->query("select title,id,onclick,fileSize,newstime,id from [!db.pre!]ecms_fujian where title like '%$seek%' order by onclick desc limit 0,200");
40     $list = $api->load('db')->query("select title,id,onclick,fileSize,newstime,id from [!db.pre!]ecms_fujian where locate('$seek',title)>0 order by onclick desc limit 0,200");
41     //将读取到的信息存放在list1中
42     $list1 = json_encode($list,JSON_UNESCAPED_UNICODE);
43     //将查询到的数据以及对应的关键词存到关键词表中
44     $data = array(
45     'title' => $seek,//搜索的关键词
46     'classid' => 26, //会自动判断当前栏目是否属于news模型
47     'userid' => $userid, //发布者id
48     'username' => $username, //发布者名称
49     'checked' => 1  ,// 0表示发布到待审核 1表示直接审核
50     'RAM' => $list1//关键词的缓存
51     );
52     //存入关键词表
53     $id = $api->load('table')->insert('tagram' , $data);
54 }
55 
56 
57 $list = $api->load('db')->query("select title,id,onclick,RAM from [!db.pre!]ecms_tagram where title='$seek'");
58 
59 //搜索次数增加
60 if($b==='0'){
61     $seekId=$list[0][id];
62     $onclick=$list[0][onclick];
63     $onclick=$onclick+1;
64     $data = array(
65         'onclick' => $onclick
66     );
67     $api->load('table')->update('tagram' , $data , $seekId);
68 };
69 //读取缓存的信息
70 $list1 = $list[0][RAM];
71 $list2 = json_decode($list1);
72 $list3 = array_slice($list2,$b,$c);
73 
74 $result = [
75     'seeklist'=>$list3
76 ];
77 
78 // 输出json数据
79 $api->json($result);

 

标签:title,db,代码,list,api,onclick,上传,id
From: https://www.cnblogs.com/meetlilanglang/p/16906699.html

相关文章