]> git.mxchange.org Git - friendica.git/blob - mod/repair_ostatus.php
Merge branch 'develop' into rewrites/dbm_is_result
[friendica.git] / mod / repair_ostatus.php
1 <?php
2
3 require_once('include/Scrape.php');
4 require_once('include/follow.php');
5
6 function repair_ostatus_content(App &$a) {
7
8         if (! local_user()) {
9                 notice( t('Permission denied.') . EOL);
10                 goaway($_SESSION['return_url']);
11                 // NOTREACHED
12         }
13
14         $o = "<h2>".t("Resubscribing to OStatus contacts")."</h2>";
15
16         $uid = local_user();
17
18         $a = get_app();
19
20         $counter = intval($_REQUEST['counter']);
21
22         $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE
23                 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
24                 intval($uid),
25                 dbesc(NETWORK_OSTATUS),
26                 intval(CONTACT_IS_FRIEND),
27                 intval(CONTACT_IS_SHARING));
28
29         if (!$r)
30                 return($o.t("Error"));
31
32         $total = $r[0]["total"];
33
34         $r = q("SELECT `url` FROM `contact` WHERE
35                 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)
36                 ORDER BY `url`
37                 LIMIT %d, 1",
38                 intval($uid),
39                 dbesc(NETWORK_OSTATUS),
40                 intval(CONTACT_IS_FRIEND),
41                 intval(CONTACT_IS_SHARING), $counter++);
42
43         if (!$r) {
44                 $o .= t("Done");
45                 return $o;
46         }
47
48         $o .= "<p>".$counter."/".$total.": ".$r[0]["url"]."</p>";
49
50         $o .= "<p>".t("Keep this window open until done.")."</p>";
51
52         $result = new_contact($uid,$r[0]["url"],true);
53
54         $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.App::get_baseurl().'/repair_ostatus?counter='.$counter.'">';
55
56         return $o;
57 }