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