]> git.mxchange.org Git - friendica.git/blob - include/gprobe.php
Added an option to configure the hostname manually. And there was a problem when...
[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         if ($hostname =  get_config('system', 'hostname'))
28                 $a->set_hostname($hostname);
29
30         $a->set_baseurl(get_config('system','url'));
31
32         load_hooks();
33
34         if($argc != 2)
35                 return;
36
37         $url = hex2bin($argv[1]);
38
39         $r = q("select * from gcontact where nurl = '%s' limit 1",
40                 dbesc(normalise_link($url))
41         );
42
43         if(! count($r)) {
44
45                 $arr = probe_url($url);
46                 if(count($arr) && x($arr,'network') && $arr['network'] === NETWORK_DFRN) {
47                         q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)
48                                 values ( '%s', '%s', '%s', '%s') ",
49                                 dbesc($arr['name']),
50                                 dbesc($arr['url']),
51                                 dbesc(normalise_link($arr['url'])),
52                                 dbesc($arr['photo'])
53                         );
54                 }
55                 $r = q("select * from gcontact where nurl = '%s' limit 1",
56                         dbesc(normalise_link($url))
57                 );
58         }
59         if(count($r))
60                 poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
61                 
62         return;
63 }
64
65 if (array_search(__file__,get_included_files())===0){
66   gprobe_run($argv,$argc);
67   killme();
68 }