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