4 function dfrn_poll_init(&$a) {
7 $dfrn_id = $a->config['dfrn_poll_dfrn_id'] = $_GET['dfrn_id'];
9 $type = $a->config['dfrn_poll_type'] = $_GET['type'];
10 if(x($_GET,'last_update'))
11 $last_update = $a->config['dfrn_poll_last_update'] = $_GET['last_update'];
19 if((x($type)) && ($type == 'profile')) {
21 $r = q("SELECT `contact`.*, `user`.`nickname`
22 FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
23 WHERE `issued-id` = '%s' LIMIT 1",
26 $s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&type=profile-check');
28 $xml = simplexml_load_string($s);
29 if((int) $xml->status == 1) {
30 $_SESSION['authenticated'] = 1;
31 $_SESSION['visitor_id'] = $r[0]['id'];
32 $_SESSION['sysmsg'] .= "Hi {$r[0]['name']}" . EOL;
33 // Visitors get 1 day session.
34 $session_id = session_id();
35 $expire = time() + 86400;
36 q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s' LIMIT 1",
41 $profile = ((strlen($r[0]['nickname'])) ? $r[0]['nickname'] : $r[0]['uid']);
42 goaway($a->get_baseurl() . "/profile/$profile/visit");
44 goaway($a->get_baseurl());
47 if((x($type)) && ($type == 'profile-check')) {
49 q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
50 $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",