- server <poco url>: Searches for the poco server list. "poco url" is base64 encoded.
- update_server: Frequently check the first 250 servers for vitality.
- update_server_directory: Discover the given server id for their contacts
+ - poco_load: Load POCO data from a given POCO address
*/
if (($argc > 2) && ($argv[1] == "dirsearch")) {
$mode = 5;
} elseif (($argc == 3) && ($argv[1] == "update_server_directory")) {
$mode = 6;
+ } elseif (($argc > 5) && ($argv[1] == "poco_load")) {
+ $mode = 7;
} elseif ($argc == 1) {
$search = "";
$mode = 0;
logger('start '.$search);
- if ($mode == 6) {
+ if ($mode == 7) {
+ if ($argc == 6) {
+ $url = base64_decode($argv[5]);
+ } else {
+ $url = '';
+ }
+ poco_load_worker(intval($argv[2]), intval($argv[3]), intval($argv[4]), $url);
+ } elseif ($mode == 6) {
poco_discover_single_server(intval($argv[2]));
} elseif ($mode == 5) {
update_server();
require_once("include/Contact.php");
require_once("include/Photo.php");
-/*
- * poco_load
+/**
+ * @brief Fetch POCO data
+ *
+ * @param integer $cid Contact ID
+ * @param integer $uid User ID
+ * @param integer $zcid Global Contact ID
+ * @param integer $url POCO address that should be polled
*
* Given a contact-id (minimum), load the PortableContacts friend list for that contact,
* and add the entries to the gcontact (Global Contact) table, or update existing entries
* pointing to the same global contact id.
*
*/
+function poco_load($cid, $uid = 0, $zcid = 0, $url = null) {
+ // Call the function "poco_load_worker" via the worker
+ proc_run(PRIORITY_LOW, "include/discover_poco.php", "poco_load", $cid, $uid, $zcid, base64_encode($url));
+}
-
-
-
-function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
-
+/**
+ * @brief Fetch POCO data from the worker
+ *
+ * @param integer $cid Contact ID
+ * @param integer $uid User ID
+ * @param integer $zcid Global Contact ID
+ * @param integer $url POCO address that should be polled
+ *
+ */
+function poco_load_worker($cid, $uid, $zcid, $url) {
$a = get_app();
if($cid) {
$requery_days = intval(get_config("system", "poco_requery_days"));
- if ($requery_days == 0)
+ if ($requery_days == 0) {
$requery_days = 7;
-
+ }
$last_update = date("c", time() - (60 * 60 * 24 * $requery_days));
$r = q("SELECT `id`, `url`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update));