]> git.mxchange.org Git - friendica.git/blob - include/gprobe.php
link socgraph to zrls
[friendica.git] / include / gprobe.php
1 <?php
2
3 require_once("boot.php");
4 require_once('include/Scrape.php');
5
6 function gprobe_run($argv, $argc){
7         global $a, $db;
8
9         if(is_null($a)) {
10                 $a = new App;
11         }
12   
13         if(is_null($db)) {
14             @include(".htconfig.php");
15         require_once("dba.php");
16             $db = new dba($db_host, $db_user, $db_pass, $db_data);
17         unset($db_host, $db_user, $db_pass, $db_data);
18         };
19
20         require_once('include/session.php');
21         require_once('include/datetime.php');
22
23         load_config('config');
24         load_config('system');
25
26         $a->set_baseurl(get_config('system','url'));
27
28         load_hooks();
29
30         if($argc != 2)
31                 return;
32
33         $url = hex2bin($argv[1]);
34
35         $r = q("select * from gcontact where nurl = '%s' limit 1",
36                 dbesc(normalise_link($url))
37         );
38
39         if(! count($r)) {
40
41                 $arr = probe_url($url);
42                 if(count($arr) && x($arr,'network') && $arr['network'] === NETWORK_DFRN) {
43                         q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)
44                                 values ( '%s', '%s', '%s', '%s') ",
45                                 dbesc($arr['name']),
46                                 dbesc($arr['url']),
47                                 dbesc(normalise_link($arr['url'])),
48                                 dbesc($arr['photo'])
49                         );
50                 }
51                 $r = q("select * from gcontact where nurl = '%s' limit 1",
52                         dbesc(normalise_link($url))
53                 );
54         }
55         if(count($r))
56                 poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
57                 
58         return;
59 }
60
61 if (array_search(__file__,get_included_files())===0){
62   gprobe_run($argv,$argc);
63   killme();
64 }