redirect('ostatus_repair');
// NOTREACHED
}
$o = "
".L10n::t("Resubscribing to OStatus contacts")."
";
$uid = local_user();
$a = \get_app();
$counter = intval($_REQUEST['counter']);
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE
`uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
intval($uid),
DBA::escape(Protocol::OSTATUS),
intval(Contact::FRIEND),
intval(Contact::SHARING));
if (!DBA::isResult($r)) {
return ($o . L10n::t("Error"));
}
$total = $r[0]["total"];
$r = q("SELECT `url` FROM `contact` WHERE
`uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)
ORDER BY `url`
LIMIT %d, 1",
intval($uid),
DBA::escape(Protocol::OSTATUS),
intval(Contact::FRIEND),
intval(Contact::SHARING), $counter++);
if (!DBA::isResult($r)) {
$o .= L10n::t("Done");
return $o;
}
$o .= "".$counter."/".$total.": ".$r[0]["url"]."
";
$o .= "".L10n::t("Keep this window open until done.")."
";
Contact::createFromProbe($uid, $r[0]["url"], true);
$a->page['htmlhead'] = '';
return $o;
}