From cdfb5f9dc740734fbd95363a026ab44ae1dd9d94 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Sep 2013 20:38:24 -0700 Subject: adult channel setting --- include/zot.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index efcc4abaa..ba55880ee 100644 --- a/include/zot.php +++ b/include/zot.php @@ -469,6 +469,11 @@ function import_xchan($arr) { else $new_flags = $r[0]['xchan_flags']; + $adult = (($r[0]['xchan_flags'] & XCHAN_FLAGS_SELFCENSORED) ? true : false); + $adult_changed = ((intval($adult) != intval($arr['adult_content'])) ? true : false); + if($adult_changed) + $new_flags = $new_flags ^ XCHAN_FLAGS_SELFCENSORED; + if(($r[0]['xchan_name_date'] != $arr['name_updated']) || ($r[0]['xchan_connurl'] != $arr['connections_url']) @@ -511,6 +516,8 @@ function import_xchan($arr) { $new_flags = XCHAN_FLAGS_HIDDEN; else $new_flags = 0; + if($arr['adult_content']) + $new_flags |= XCHAN_FLAGS_SELFCENSORED; $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype, xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags) -- cgit v1.2.3 From 00e5ded1c892a94c79a854327b44d8673cc43274 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 24 Sep 2013 20:13:53 -0700 Subject: populate the new fields in the directory updates table --- include/zot.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index ba55880ee..ae470b70b 100644 --- a/include/zot.php +++ b/include/zot.php @@ -411,7 +411,7 @@ function zot_register_hub($arr) { // If the xchan already exists, update the name and photo if these have changed. // -function import_xchan($arr) { +function import_xchan($arr,$ud_flags = 1) { $ret = array('success' => false); $dirmode = intval(get_config('system','directory_mode')); @@ -688,7 +688,7 @@ function import_xchan($arr) { if($dirmode != DIRECTORY_MODE_NORMAL) { if(array_key_exists('profile',$arr) && is_array($arr['profile'])) { - $profile_changed = import_directory_profile($xchan_hash,$arr['profile']); + $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$arr['address'],$ud_flags); if($profile_changed) { $what .= 'profile '; $changed = true; @@ -718,7 +718,7 @@ function import_xchan($arr) { if($changed) { $guid = random_string() . '@' . get_app()->get_hostname(); - update_modtime($xchan_hash,$guid); + update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags); logger('import_xchan: changed: ' . $what,LOGGER_DEBUG); } @@ -1371,7 +1371,12 @@ function process_profile_delivery($sender,$arr,$deliveries) { // deliveries is irrelevant, what to do about birthday notification....? logger('process_profile_delivery', LOGGER_DEBUG); - import_directory_profile($sender['hash'],$arr); + + $r = q("select xchan_addr from xchan where xchan_hash = '%s' limit 1", + dbesc($sender['hash']) + ); + if($r) + import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], 1); } @@ -1382,7 +1387,7 @@ function process_profile_delivery($sender,$arr,$deliveries) { * */ -function import_directory_profile($hash,$profile) { +function import_directory_profile($hash,$profile,$addr,$ud_flags = 1) { logger('import_directory_profile', LOGGER_DEBUG); if(! $hash) @@ -1489,7 +1494,7 @@ function import_directory_profile($hash,$profile) { call_hooks('import_directory_profile', $d); if($d['update']) - update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname()); + update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname(), $addr, $ud_flags); return $d['update']; } @@ -1529,11 +1534,14 @@ function import_directory_keywords($hash,$keywords) { } -function update_modtime($hash,$guid) { - q("insert into updates (ud_hash, ud_guid, ud_date) values ( '%s', '%s', '%s' )", +function update_modtime($hash,$guid,$addr,$flags = 0) { + + q("insert into updates (ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) values ( '%s', '%s', '%s', %d, '%s' )", dbesc($hash), dbesc($guid), - dbesc(datetime_convert()) + dbesc(datetime_convert()), + intval($flags), + dbesc($addr) ); } -- cgit v1.2.3 From 6519433301a571d8e12ffa24b56534bb2e3afe5f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Sep 2013 21:22:36 -0700 Subject: suppress creating the directory update record for profile updates which are part of the normal import_xchan sequence - otherwise we get two for every change. Create it normally if we are called with a profile_update message and don't go through the whole import_xchan thing. --- include/zot.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index ae470b70b..0290bc402 100644 --- a/include/zot.php +++ b/include/zot.php @@ -688,7 +688,7 @@ function import_xchan($arr,$ud_flags = 1) { if($dirmode != DIRECTORY_MODE_NORMAL) { if(array_key_exists('profile',$arr) && is_array($arr['profile'])) { - $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$arr['address'],$ud_flags); + $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$arr['address'],$ud_flags, 1); if($profile_changed) { $what .= 'profile '; $changed = true; @@ -1376,7 +1376,7 @@ function process_profile_delivery($sender,$arr,$deliveries) { dbesc($sender['hash']) ); if($r) - import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], 1); + import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], 1, 0); } @@ -1387,7 +1387,7 @@ function process_profile_delivery($sender,$arr,$deliveries) { * */ -function import_directory_profile($hash,$profile,$addr,$ud_flags = 1) { +function import_directory_profile($hash,$profile,$addr,$ud_flags = 1, $suppress_update = 0) { logger('import_directory_profile', LOGGER_DEBUG); if(! $hash) @@ -1493,7 +1493,7 @@ function import_directory_profile($hash,$profile,$addr,$ud_flags = 1) { $d = array('xprof' => $arr, 'profile' => $profile, 'update' => $update); call_hooks('import_directory_profile', $d); - if($d['update']) + if(($d['update']) && (! $suppress_update)) update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname(), $addr, $ud_flags); return $d['update']; } -- cgit v1.2.3 From edc5566f79c94f7ad994eccc7a8bb0e586961cf4 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Sep 2013 16:25:28 -0700 Subject: structure for channel unions --- include/zot.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index 0290bc402..0658f1738 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1422,9 +1422,10 @@ function import_directory_profile($hash,$profile,$addr,$ud_flags = 1, $suppress_ // Self censored, make it so // These are not translated, so the German "erwachsenen" keyword will not censor the directory profile. Only the English form - "adult". + if(in_arrayi('nsfw',$clean) || in_arrayi('adult',$clean)) { q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' limit 1", - intval(XCHAN_FLAGS_CENSORED), + intval(XCHAN_FLAGS_SELFCENSORED), dbesc($hash) ); } -- cgit v1.2.3 From 0497c441df7feabdbfeea41f2d7b5dca8fd16989 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Mon, 30 Sep 2013 09:59:22 +0200 Subject: ret_secret is not used --- include/zot.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index 0658f1738..1a90481ff 100644 --- a/include/zot.php +++ b/include/zot.php @@ -788,10 +788,6 @@ function zot_fetch($arr) { logger('zot_fetch: no hub: ' . print_r($arr['sender'],true)); return; } - - - $ret_secret = json_encode(array($arr['secret'],'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey'))))); - $data = array( 'type' => 'pickup', @@ -802,7 +798,6 @@ function zot_fetch($arr) { 'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey'))) ); - $datatosend = json_encode(aes_encapsulate(json_encode($data),$ret_hub['hubloc_sitekey'])); $fetch = zot_zot($url,$datatosend); -- cgit v1.2.3 From e992cfeca9a80583b7cde12776fcfe279be02996 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 18:33:27 -0700 Subject: directory sync - this will either work, or it won't work, or it will possibly recurse and blow up the matrix. Hard to say. Do you feel lucky? Well do ya' ... punk? Rule #1 - don't mess with anything unless it's blowing up the matrix. If it doesn't blow up the matrix, but doesn't work, just let it go and let's figure out what it is doing and what it isn't doing. The flow is as follows: Once a day go out to all the directory servers besides yourself and grab a list of updates. This happens in the poller. If we've never seen them before add them to the updates table. The poller also looks to see if we're a directory server and have updates that haven't yet been processed. It calls onedirsync.php to process each one. If we contact the channel to update and don't find anything (we're just doing a basic zot_finger), set a ud_last timestamp. If this is set we will only try once a day for seven days. Then we stop trying to update. This will probably cause a spike the first time through because you haven't seen any updates before, but we spread out the load over your delivery interval. --- include/zot.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index 1a90481ff..33bb60c0f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1532,13 +1532,21 @@ function import_directory_keywords($hash,$keywords) { function update_modtime($hash,$guid,$addr,$flags = 0) { - q("insert into updates (ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) values ( '%s', '%s', '%s', %d, '%s' )", - dbesc($hash), - dbesc($guid), - dbesc(datetime_convert()), - intval($flags), - dbesc($addr) - ); + if($flags) { + q("insert into updates (ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) values ( '%s', '%s', '%s', %d, '%s' )", + dbesc($hash), + dbesc($guid), + dbesc(datetime_convert()), + intval($flags), + dbesc($addr) + ); + } + else { + q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d) ", + intval(UPDATE_FLAGS_UPDATED), + intval(UPDATE_FLAGS_UPDATED) + ); + } } -- cgit v1.2.3