]> git.mxchange.org Git - friendica.git/blob - mod/match.php
58c81a0cdd4b43238f31b25426d1bcbff2e2120a
[friendica.git] / mod / match.php
1 <?php
2
3
4 function match_content(&$a) {
5
6         if(! local_user())
7                 return;
8
9         $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
10                 intval(local_user())
11         );
12         if(! count($r))
13                 return; 
14         if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
15                 notice('No keywords to match. Please add keywords to your default profile.');
16                 return;
17
18         }
19
20         $params = array();
21         $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
22         if($tags) {
23                 $params['s'] = $tags;
24
25
26                 $x = post_url('http://dir.friendika.com/msearch', $params);
27
28                 $j = json_decode($x);
29
30                 if(count($j)) {
31                         foreach($j as $jj) {
32
33                                 $o .= '<a href="' . $jj->url . '">' . '<img src="' . $jj->photo . '" alt="' . $jj->name . '" />' . $jj->name . '</a>';
34                         }
35                 }
36                 else {
37                         notice( t('No matches') . EOL);
38                 }               
39
40         }
41         return $o;
42 }