-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetdatedemo5.php
420 lines (349 loc) · 10.7 KB
/
getdatedemo5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<?php
require_once(dirname(__FILE__)."/include/lib_splitword_full.php");
class getdatedemo{
public function newsinfo($keyword){
$this->dbsql();
$krows=array();
$keywordssql=mysql_query("select `aid`,`pipei` from `dede_addonweixin10` where `pipei` !=''");
while($krow=mysql_fetch_array($keywordssql))
{
if($krow)
{
$krows[]=$krow;
}
}
foreach($krows as $a)
{
$pipei=trim($a['pipei']);
$pipeiarray=explode(",",$pipei);
if($pipeiarray)
{
foreach($pipeiarray as $b)
{
if($keyword===$b)
$ids[]=$a['aid'];
}
}
}
$ids= array_unique($ids);
if($ids)
{
$idstring=implode(",",$ids);
$sql=mysql_query("SELECT title,weixinpic,zhaiyao,weixinurl,pipei,shuxing FROM `dede_addonweixin10` arc where arc.aid in ($idstring) order by arc.aid desc limit 4");
while($row2 = mysql_fetch_array($sql))
{
if($row2)
{
$row2['title']=trim($row2['title']);
$row2['description']=trim($row2['zhaiyao']);
$row2['picurl']="http://weixin.kuqin.com".$row2['weixinpic'];
$row2['url']=$row2['weixinurl'];
$rows2[]=$row2;
}
}
if($rows2)
{
$numberlist2=count($ids);
$rows2['numberlist']=$numberlist2;
$rows2['type']='news';
}
}
return $rows2;
exit(0);
}
public function keysinfo($keyword){
$this->dbsql();
$keyword = strip_tags($keyword);
if($keyword == ""){
exit(0);
}
$keyword = iconv("UTF-8","GBK", $keyword);
echo $keyword;
exit;
if(strlen($keyword)>7)
{
$sp = new SplitWord();
$keywords=$sp->SplitRMM($keyword);
$sp->Clear();
}
else
{
$keywords = $keyword;
}
if($keywords)
{
$addsql=$this->GetKeywordSql($keywords);
}
else
{
$addsql='1';
}
$sql5=mysql_query("SELECT aid,title,weixinpic,zhaiyao,weixinurl,pipei,shuxing FROM `dede_addonweixin10` arc where $addsql order by arc.aid desc limit 4");
while($row3=mysql_fetch_array($sql5))
{
if($row3)
{
$row3['title']=trim($row3['title']);
$row3['description']=trim($row3['zhaiyao']);
$row3['picurl']="http://weixin.kuqin.com".$row3['weixinpic'];
$row3['url']=$row3['weixinurl'];
$rows3[]=$row3;
}
}
if($rows3)
{
$numberlist3=count($rows3);
$rows3['numberlist']=$numberlist3;
$rows3['type']='news';
}
return $rows3;
exit(0);
}
function GetKeywordSql($Keywords)
{
$ks = explode(' ',$Keywords);
$kwsql = '';
$kwsqls = array();
foreach($ks as $k)
{
$k = trim($k);
if(strlen($k)<1)
{
continue;
}
if(ord($k[0])>0x80 && strlen($k)<2)
{
continue;
}
$k = addslashes($k);
$kwsqls[] = " arc.title LIKE '%$k%' ";
}
if(!isset($kwsqls[0]))
{
return '';
}
else
{
$kwsql = join(' And ',$kwsqls);
return $kwsql;
}
}
public function validnum($keyword){
//回复内容的数据类型:text,
$msgType = "text";
$this->dbsql();
$keyword = strip_tags($keyword);
if($keyword == ""){
exit(0);
}
if($keyword)
{
$bynow=time();
$insql= mysql_query("insert into `dede_addonweixin_norecord`(keyword,addtime) values('$keyword','$bynow');");
$recodesql = mysql_query("select `id` from `dede_addonweixin_norecord` order by id desc limit 0,1");
$recode = mysql_fetch_array($recodesql);
$fkeyword=$this->cut_str($keyword,4);
if($fkeyword=="1024")
{
$lkeyword= str_replace("1024", "", $keyword);
if($lkeyword !="")
{
$select = mysql_query("SELECT * FROM `dede_addonweixin_keywords` arc where arc.keyword LIKE '%$lkeyword%' order by arc.id desc limit 1");
$group = mysql_fetch_array($select);
if(!$group)
{
$upinsql=mysql_query("update `dede_addonweixin_norecord` set `reply`=4 where `id`='$recode[id]'");
$title="";
}
else
{
$title=$this->find2($lkeyword,$recode['id']);
}
return $title;
exit(0);
}
}
else
{
$select = mysql_query("SELECT * FROM `dede_addonweixin_keywords` arc where arc.keyword LIKE '%$keyword%' order by arc.id desc limit 1");
$group = mysql_fetch_array($select);
if(!$group)
{
$title="";
}
else
{
$title=$this->find($keyword,$recode['id']);
}
return $title;
exit(0);
}
}
}
public function dbsql()
{
require_once( dirname(__FILE__).'/weixindemoAdmin2013/topic/config/config.inc.php');
$conn=mysql_connect($config['dbhost'],$config['dbuser'],$config['dbpass']);
$flag=mysql_select_db($config['dbname'],$conn);
mysql_query("set names utf8");
}
public function cut_str($string,$sublen,$start=0,$code='UTF-8'){
if($code == 'UTF-8' OR $code == 'utf-8'){
$pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/";
preg_match_all($pa, $string, $t_string);
if(count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen)).""; return join('', array_slice($t_string[0], $start, $sublen));
}else{
$start = $start*2;
$sublen = $sublen*2;
$strlen = strlen($string);
$tmpstr = '';
for($i=0; $i< $strlen; $i++){
if($i>=$start && $i< ($start+$sublen)){
if(ord(substr($string, $i, 1))>129){
$tmpstr.= substr($string, $i, 2);
}else{
$tmpstr.= substr($string, $i, 1);
}
}
if(ord(substr($string, $i, 1))>129) $i++;
}
return $tmpstr;
}
}
public function wqmatch($keyword)
{
$searchsql = mysql_query("SELECT * FROM `dede_addonweixin_keywords` where keyword like '$keyword' limit 0,1");
$getone = mysql_fetch_array($searchsql);
if(!$getone)
{
$searchsql = mysql_query("SELECT * FROM `dede_addonweixin_keywords` where keyword like '%$keyword%' limit 0,1");
$getone = mysql_fetch_array($searchsql);
}
if($getone)
{
$sqlinfo = mysql_query("SELECT * FROM `dede_addonweixin` where aid=".$getone['aid']);
$info = mysql_fetch_array($sqlinfo);
$sql = mysql_query("SELECT * FROM `dede_arctype` where id=".$getone['typeid']);
$typename = mysql_fetch_array($sql);
$grouptitle = htmlspecialchars_decode($info['title']);
$title_top ="您查询的结果为:";
$title_top .="\n";
$title_cen ="【".$typename['typename'].":".$grouptitle."】";
$title_cen.="\n";
$title = $info['zhaiyao'];
$title = strip_tags($title);
$title = preg_replace('/^\s+\r?\n/m',"\n", $title);
$title = htmlspecialchars_decode($title);
$title = str_replace(" ","",$title);
$title = $this->cut_str($title,150);
$srcurl="http://m.kuqin.com/detail.php?id=".$info[aid];
$view1 = '【<a href="';
$view2 = '">查看详情</a>】';
$title =$title_top.$title_cen.$title.$view1.$srcurl.$view2."\n\n";
}
else
{
$title = "";
}
return $title;
}
public function listmatch($keyword)
{
$addsql = "";
$searchsql = mysql_query("SELECT * FROM `dede_addonweixin_keywords` where keyword like '$keyword' limit 0,1");
$getone = mysql_fetch_array($searchsql);
if($getone)
{
$getid = $getone['aid'];
$addsql = " arc.aid !='$getid' and ";
}
else
{
$searchsql2 = mysql_query("SELECT * FROM `dede_addonweixin_keywords` where keyword like '%$keyword%' limit 0,1");
$getone2 = mysql_fetch_array($searchsql2);
if($getone2)
{
$getid = $getone2['aid'];
$addsql = " arc.aid !='$getid' and ";
}
}
$title_top = "";
$title_cen1 = "";
$title = "";
$title1 = "";
$select = mysql_query("SELECT DISTINCT aid FROM `dede_addonweixin_keywords` arc where $addsql arc.keyword LIKE '%$keyword%' order by arc.id desc limit 0,10 ");
while ($row = mysql_fetch_array($select, MYSQL_BOTH)) {
if($row)
{
$select1 = mysql_query("SELECT * FROM `dede_addonweixin` arc where arc.aid=".$row['aid']);
$group1 = mysql_fetch_array($select1);
if($group1['aid']!="")
{
$i++;
$sql = mysql_query("SELECT * FROM `dede_arctype` where id=".$group1['typeid']);
$typename = mysql_fetch_array($sql);
$group1title=trim($group1['title']);
$grouptitle1 = htmlspecialchars_decode($group1title);
$srcurl1="http://m.kuqin.com/detail.php?id=".$group1['aid'];
$view2 = "<a href='";
$view3 = "'>".$grouptitle1."</a>";
$grouptitle2 = $view2.$srcurl1.$view3;
$title_cen1 ="【".$i.".".$typename['typename'].":".str_replace("'",'"',$grouptitle2)."】";
$title_top = "其他查询结果为:\n";
$title .=$title_cen1."\n\n";
}
}
}
$title1 = $title_top.$title;
return $title1;
}
public function nofind($keyword,$recodeid)
{
$upinsql=mysql_query("update `dede_addonweixin_norecord` set `reply`=2 where `id`='$recodeid'");
$sql = mysql_query("SELECT * FROM `tb_reply_news` arc where arc.id=1");
$nofind = mysql_fetch_array($sql);
$title=$nofind['nofind'];
$title = str_replace(" ","",$title);
$title = str_replace("<p>","",$title);
$title = str_replace("</p>","",$title);
$title = preg_replace('/^\s+\r?\n/m',"\n", $title);
$title = htmlspecialchars_decode($title);
return $title;
}
public function find($keyword,$recodeid)
{
$upinsql=mysql_query("update `dede_addonweixin_norecord` set `reply`=1 where `id`='$recodeid'");
$info = $this->wqmatch($keyword);
$listinfo = $this->listmatch($keyword);
$sql = mysql_query("SELECT * FROM `tb_reply_news` arc where arc.id=1");
$find = mysql_fetch_array($sql);
$stringfind=$find['find'];
$stringfind = str_replace(" ","",$stringfind);
$stringfind = str_replace("<p>","",$stringfind);
$stringfind = str_replace("</p>","",$stringfind);
$stringfind = preg_replace('/^\s+\r?\n/m',"\n", $stringfind);
$stringfind = htmlspecialchars_decode($stringfind);
$title =$info.$listinfo.$stringfind;
return $title;
}
public function find2($s1,$recodeid)
{
$upinsql= mysql_query("update `dede_addonweixin_norecord` set `reply`=1 where `id`='$recodeid'");
$info = $this->wqmatch($s1);
$listinfo = $this->listmatch($s1);
$sql = mysql_query("SELECT * FROM `tb_reply_news` arc where arc.id=1");
$find = mysql_fetch_array($sql);
$stringfind=$find['find'];
$stringfind = str_replace(" ","",$stringfind);
$stringfind = str_replace("<p>","",$stringfind);
$stringfind = str_replace("</p>","",$stringfind);
$stringfind = preg_replace('/^\s+\r?\n/m',"\n", $stringfind);
$stringfind = htmlspecialchars_decode($stringfind);
$title =$info.$listinfo.$stringfind;
return $title;
}
}
$r=new getdatedemo();
$list=$r->keysinfo('喜欢阅读');
print_r($list);
?>