Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.5 KiB

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