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