diff options
-rw-r--r-- | include/onepoll.php | 8 | ||||
-rw-r--r-- | include/socgraph.php | 77 | ||||
-rw-r--r-- | mod/poco.php | 3 |
3 files changed, 43 insertions, 45 deletions
diff --git a/include/onepoll.php b/include/onepoll.php index 4b44ff5b9..019fe8ed3 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -113,16 +113,14 @@ function onepoll_run($argv, $argc){ // set last updated timestamp - $r = null; - if($contact['xchan_connurl']) { $r = q("SELECT xlink_id from xlink where xlink_xchan = '%s' and xlink_updated > UTC_TIMESTAMP() - INTERVAL 1 DAY", intval($contact['xchan_hash']) ); - } - if($r) { - poco_load($contact['xchan_hash'],$contact['xchan_connurl']); + if($r) { + poco_load($contact['xchan_hash'],$contact['xchan_connurl']); + } } return; diff --git a/include/socgraph.php b/include/socgraph.php index aa5a24e89..081927dcc 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -23,12 +23,11 @@ function poco_load($xchan = null,$url = null) { $a = get_app(); if($xchan && ! $url) { - $r = q("select xchan_connurl from xchan where xchan_hash = %d limit 1", - intval($xchan) + $r = q("select xchan_connurl from xchan where xchan_hash = '%s' limit 1", + dbesc($xchan) ); if($r) { $url = $r[0]['xchan_connurl']; - $uid = $r[0]['abook_channel']; } } @@ -109,24 +108,25 @@ function poco_load($xchan = null,$url = null) { } - $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' limit 1", - dbesc($xchan), - dbesc($hash) - ); - if(! $r) { - q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated ) values ( '%s', '%s', '%s' ) ", + if($xchan) { + $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' limit 1", dbesc($xchan), - dbesc($hash), - dbesc(datetime_convert()) - ); - } - else { - q("update xlink set xlink_updated = '%s' where xlink_id = %d limit 1", - dbesc(datetime_convert()), - intval($r[0]['xlink_id']) + dbesc($hash) ); + if(! $r) { + q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated ) values ( '%s', '%s', '%s' ) ", + dbesc($xchan), + dbesc($hash), + dbesc(datetime_convert()) + ); + } + else { + q("update xlink set xlink_updated = '%s' where xlink_id = %d limit 1", + dbesc(datetime_convert()), + intval($r[0]['xlink_id']) + ); + } } - } logger("poco_load: loaded $total entries",LOGGER_DEBUG); @@ -295,37 +295,38 @@ function suggestion_query($uid, $start = 0, $limit = 80) { function update_suggestions() { +// FIXME +return; $a = get_app(); $done = array(); - poco_load(0,0,0,$a->get_baseurl() . '/poco'); + // fix this to get a json list from an upstream directory +// poco_load(0,0,0,$a->get_baseurl() . '/poco'); - $done[] = $a->get_baseurl() . '/poco'; +// $done[] = $a->get_baseurl() . '/poco'; - if(strlen(get_config('system','directory_submit_url'))) { - $x = fetch_url('http://dir.friendica.com/pubsites'); - if($x) { - $j = json_decode($x); - if($j->entries) { - foreach($j->entries as $entry) { - $url = $entry->url . '/poco'; - if(! in_array($url,$done)) - poco_load(0,0,0,$entry->url . '/poco'); - } - } - } - } +// if(strlen(get_config('system','directory_submit_url'))) { +// $x = fetch_url('http://dir.friendica.com/pubsites'); +// if($x) { +// $j = json_decode($x); +// if($j->entries) { +// foreach($j->entries as $entry) { +// $url = $entry->url . '/poco'; +// if(! in_array($url,$done)) +// poco_load(0,0,0,$entry->url . '/poco'); +// } +// } +// } +// } - $r = q("select distinct(poco) as poco from contact where network = '%s'", - dbesc(NETWORK_DFRN) - ); + $r = q("select distinct(xchan_connurl) as poco from xchan where xchan_network = 'zot'"); - if(count($r)) { + if($r) { foreach($r as $rr) { $base = substr($rr['poco'],0,strrpos($rr['poco'],'/')); if(! in_array($base,$done)) - poco_load(0,0,0,$base); + poco_load('',$base); } } } diff --git a/mod/poco.php b/mod/poco.php index c0dc2e133..f87bd8a68 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -7,7 +7,6 @@ function poco_init(&$a) { if(intval(get_config('system','block_public'))) http_status_exit(401); - $observer = $a->get_observer(); if(argc() > 1) { @@ -15,7 +14,7 @@ function poco_init(&$a) { } if(! x($user)) { $c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = 1"); - if(! count($c)) + if(! $c) http_status_exit(401); $system_mode = true; } |