]> git.mxchange.org Git - friendica.git/blob - include/gprobe.php
Merge remote branch 'upstream/master'
[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                 return;
41
42         $arr = probe_url($url);
43
44         if(count($arr) && x($arr,'network') && $arr['network'] === NETWORK_DFRN) {
45                 q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)
46                         values ( '%s', '%s', '%s', '%s') ",
47                         dbesc($arr['name']),
48                         dbesc($arr['url']),
49                         dbesc(normalise_link($arr['url'])),
50                         dbesc($arr['photo'])
51                 );
52         }
53
54         return;
55 }
56
57 if (array_search(__file__,get_included_files())===0){
58   gprobe_run($argv,$argc);
59   killme();
60 }