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