diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/api.php | 2 | ||||
-rw-r--r-- | include/language.php | 30 | ||||
-rw-r--r-- | include/zot.php | 39 |
3 files changed, 56 insertions, 15 deletions
diff --git a/include/api.php b/include/api.php index 1456ec29a..f240b60bf 100644 --- a/include/api.php +++ b/include/api.php @@ -1452,7 +1452,7 @@ require_once('include/security.php'); return api_apply_template('test', $type, array('$ok' => $ok)); } - api_register_func('api/help/test','api_help_test',true); + api_register_func('api/help/test','api_help_test',false); /** * https://dev.twitter.com/docs/api/1/get/statuses/friends diff --git a/include/language.php b/include/language.php index 853b6ebee..24a6a08ca 100644 --- a/include/language.php +++ b/include/language.php @@ -15,8 +15,6 @@ * */ - -if(! function_exists('get_browser_language')) { function get_browser_language() { $langs = array(); @@ -43,7 +41,7 @@ function get_browser_language() { $langs['en'] = 1; return $langs; -}} +} function get_best_language() { @@ -101,15 +99,23 @@ function pop_lang() { // load string translation table for alternate language -if(! function_exists('load_translation_table')) { function load_translation_table($lang) { global $a; + $a->strings = array(); if(file_exists("view/$lang/strings.php")) { include("view/$lang/strings.php"); } - else - $a->strings = array(); + + $plugins = q("SELECT name FROM addon WHERE installed=1;"); + if ($plugins!==false) { + foreach($plugins as $p) { + $name = $p['name']; + if(file_exists("addon/$name/lang/$lang/strings.php")) { + include("addon/$name/lang/$lang/strings.php"); + } + } + } // Allow individual strings to be over-ridden on this site // Either for the default language or for all languages @@ -118,11 +124,10 @@ function load_translation_table($lang) { include("view/local-$lang/strings.php"); } -}} +} // translate string if translation exists -if(! function_exists('t')) { function t($s) { global $a; @@ -132,9 +137,9 @@ function t($s) { return is_array($t)?$t[0]:$t; } return $s; -}} +} + -if(! function_exists('tt')){ function tt($singular, $plural, $count){ $a = get_app(); @@ -152,15 +157,14 @@ function tt($singular, $plural, $count){ } else { return $singular; } -}} +} // provide a fallback which will not collide with // a function defined in any language file -if(! function_exists('string_plural_select_default')) { function string_plural_select_default($n) { return ($n != 1); -}} +} diff --git a/include/zot.php b/include/zot.php index 1cf34170e..e5b6ac56a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -503,7 +503,15 @@ function import_xchan($arr) { ); } + // what we are missing for true hub independence is for any changes in the primary hub to + // get reflected not only in the hublocs, but also to update the URLs and addr in the appropriate xchan + if($arr['locations']) { + + $xisting = q("select hubloc_id, hubloc_url from hubloc where hubloc_hash = '%s'", + dbesc($xchan_hash) + ); + foreach($arr['locations'] as $location) { if(! rsa_verify($location['url'],base64url_decode($location['url_sig']),$arr['key'])) { logger('import_xchan: Unable to verify site signature for ' . $location['url']); @@ -511,12 +519,19 @@ function import_xchan($arr) { continue; } + for($x = 0; $x < count($xisting); $x ++) { + if($xisiting[$x]['hubloc_url'] == $location['url']) { + $xisting[$x]['updated'] = true; + } + } + $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' limit 1", dbesc($xchan_hash), dbesc($location['url']) ); if($r) { - if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) { + if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) + || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) { $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_id = %d limit 1", intval(HUBLOC_FLAGS_PRIMARY), intval($r[0]['hubloc_id']) @@ -525,6 +540,16 @@ function import_xchan($arr) { continue; } + // new hub claiming to be primary. Make it so. + + if(intval($location['primary'])) { + $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_hash = '%s' and (hubloc_flags & %d )", + intval(HUBLOC_FLAGS_PRIMARY), + dbesc($xchan_hash), + intval(HUBLOC_FLAGS_PRIMARY) + ); + } + $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey) values ( '%s','%s','%s','%s', %d ,'%s','%s','%s','%s','%s')", dbesc($arr['guid']), @@ -541,6 +566,18 @@ function import_xchan($arr) { } + // get rid of any hubs we have for this channel which weren't reported. + + if($xisting) { + foreach($xisting as $x) { + if(! array_key_exists('updated',$x)) { + $r = q("delete from hubloc where hubloc_id = %d limit 1", + intval($x['hubloc_id']) + ); + } + } + } + } if(! x($ret,'message')) { |