some poco fixes

This commit is contained in:
friendica 2013-01-22 20:48:03 -08:00
parent d43591fb0f
commit d06c21dc39
3 changed files with 43 additions and 45 deletions

View File

@ -113,16 +113,14 @@ function onepoll_run($argv, $argc){
// set last updated timestamp // set last updated timestamp
$r = null;
if($contact['xchan_connurl']) { if($contact['xchan_connurl']) {
$r = q("SELECT xlink_id from xlink $r = q("SELECT xlink_id from xlink
where xlink_xchan = '%s' and xlink_updated > UTC_TIMESTAMP() - INTERVAL 1 DAY", where xlink_xchan = '%s' and xlink_updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
intval($contact['xchan_hash']) intval($contact['xchan_hash'])
); );
} if($r) {
if($r) { poco_load($contact['xchan_hash'],$contact['xchan_connurl']);
poco_load($contact['xchan_hash'],$contact['xchan_connurl']); }
} }
return; return;

View File

@ -23,12 +23,11 @@ function poco_load($xchan = null,$url = null) {
$a = get_app(); $a = get_app();
if($xchan && ! $url) { if($xchan && ! $url) {
$r = q("select xchan_connurl from xchan where xchan_hash = %d limit 1", $r = q("select xchan_connurl from xchan where xchan_hash = '%s' limit 1",
intval($xchan) dbesc($xchan)
); );
if($r) { if($r) {
$url = $r[0]['xchan_connurl']; $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", if($xchan) {
dbesc($xchan), $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' limit 1",
dbesc($hash)
);
if(! $r) {
q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated ) values ( '%s', '%s', '%s' ) ",
dbesc($xchan), dbesc($xchan),
dbesc($hash), dbesc($hash)
dbesc(datetime_convert())
); );
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'])
);
}
} }
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); logger("poco_load: loaded $total entries",LOGGER_DEBUG);
@ -295,37 +295,38 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
function update_suggestions() { function update_suggestions() {
// FIXME
return;
$a = get_app(); $a = get_app();
$done = array(); $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'))) { // if(strlen(get_config('system','directory_submit_url'))) {
$x = fetch_url('http://dir.friendica.com/pubsites'); // $x = fetch_url('http://dir.friendica.com/pubsites');
if($x) { // if($x) {
$j = json_decode($x); // $j = json_decode($x);
if($j->entries) { // if($j->entries) {
foreach($j->entries as $entry) { // foreach($j->entries as $entry) {
$url = $entry->url . '/poco'; // $url = $entry->url . '/poco';
if(! in_array($url,$done)) // if(! in_array($url,$done))
poco_load(0,0,0,$entry->url . '/poco'); // poco_load(0,0,0,$entry->url . '/poco');
} // }
} // }
} // }
} // }
$r = q("select distinct(poco) as poco from contact where network = '%s'", $r = q("select distinct(xchan_connurl) as poco from xchan where xchan_network = 'zot'");
dbesc(NETWORK_DFRN)
);
if(count($r)) { if($r) {
foreach($r as $rr) { foreach($r as $rr) {
$base = substr($rr['poco'],0,strrpos($rr['poco'],'/')); $base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
if(! in_array($base,$done)) if(! in_array($base,$done))
poco_load(0,0,0,$base); poco_load('',$base);
} }
} }
} }

View File

@ -7,7 +7,6 @@ function poco_init(&$a) {
if(intval(get_config('system','block_public'))) if(intval(get_config('system','block_public')))
http_status_exit(401); http_status_exit(401);
$observer = $a->get_observer(); $observer = $a->get_observer();
if(argc() > 1) { if(argc() > 1) {
@ -15,7 +14,7 @@ function poco_init(&$a) {
} }
if(! x($user)) { if(! x($user)) {
$c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = 1"); $c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = 1");
if(! count($c)) if(! $c)
http_status_exit(401); http_status_exit(401);
$system_mode = true; $system_mode = true;
} }