Standards and just some more poco slitting

This commit is contained in:
Michael 2017-03-19 21:32:11 +00:00
parent e684fff477
commit 41ee4ec60a
2 changed files with 34 additions and 10 deletions

View File

@ -15,6 +15,7 @@ function discover_poco_run(&$argv, &$argc) {
- 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")) {
@ -30,6 +31,8 @@ function discover_poco_run(&$argv, &$argc) {
$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;
@ -39,7 +42,14 @@ function discover_poco_run(&$argv, &$argc) {
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();

View File

@ -14,8 +14,13 @@ require_once("include/html2bbcode.php");
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
@ -27,12 +32,21 @@ require_once("include/Photo.php");
* 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) {
@ -1739,9 +1753,9 @@ function poco_discover($complete = false) {
$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));