This commit is contained in:
friendica 2013-03-10 18:45:58 -07:00
parent 0d504715c1
commit 952b2ef2ab
18 changed files with 5431 additions and 7056 deletions

View File

@ -992,6 +992,18 @@ function check_config(&$a) {
if(! x($build))
$build = set_config('system','db_version',DB_UPDATE_VERSION);
$saved = get_config('system','urlverify');
if(! $saved)
set_config('system','urlverify',bin2hex(z_root()));
if(($saved) && ($saved != bin2hex(z_root()))) {
// our URL changed. Do something.
$oldurl = hex2bin($saved);
fix_system_urls($oldurl,z_root());
set_config('system','urlverify',bin2hex(z_root()));
}
// $url = get_config('system','baseurl');
// if the url isn't set or the stored url is radically different
@ -1130,6 +1142,53 @@ function check_config(&$a) {
function fix_system_urls($oldurl,$newurl) {
require_once('include/crypto.php');
// Basically a site rename, but this can happen if you change from http to https for instance - even if the site name didn't change
// This should fix URL changes on our site, but other sites will end up with orphan hublocs which they will try to contact and will
// cause wasted communications.
// What we need to do after fixing this up is to send a revocation of the old URL to every other site that we communicate with so
// that they can clean up their hubloc tables (this includes directories).
// It's a very expensive operation so you don't want to have to do it often or after your site gets to be large.
$r = q("select xchan_hash, channel_prvkey from xchan left join channel on channel_hash = xchan_hash where xchan_url = '%s'",
dbesc($oldurl)
);
if($r) {
foreach($r as $rr) {
$channel = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@'));
$parsed = @parse_url($rr['xchan_url']);
if(! $parsed)
continue;
$newhost = $parsed['host'];
$rhs = $newhost . (($parsed['port']) ? ':' . $parsed['port'] : '') . (($parsed['path']) ? $parsed['path'] : '');
$x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s' where xchan_hash = '%s' limit 1",
dbesc($channel . '@' . $rhs),
dbesc($newurl),
dbesc($newurl . '/poco/' . $channel),
dbesc($rr['xchan_hash'])
);
$y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s' limit 1",
dbesc($channel . '@' . $rhs),
dbesc($newurl),
dbesc(base64url_encode(rsa_sign($newurl,$rr['channel_prvkey']))),
dbesc($newhost),
dbesc($newurl . '/post'),
dbesc($rr['xchan_hash']),
dbesc($oldurl)
);
}
}
}
// wrapper for adding a login box. If $register == true provide a registration
// link. This will most always depend on the value of $a->config['system']['register_policy'].
// returns the complete html for inserting into the page

6
bugs Normal file
View File

@ -0,0 +1,6 @@
- send refresh posts to everybody that needs to see it, e.g. when site url changes
- implement xchan refresh on remote sites when site url changes, currently hublocs are fixed but xchans aren't.
- when you clear one type of notification or view the target item, clear the corresponding system notification. Issue: what to do about matrix/network posts where you might not have actually seen it.

View File

@ -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

View File

@ -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);
}}
}

View File

@ -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')) {

View File

@ -107,10 +107,10 @@ You can generally find the location of PHP by executing "which php". If you
have troubles with this section please contact your hosting provider for
assistance. Friendica will not work correctly if you cannot perform this step.
You should also be sure that $a->config['php_path'] is set correctly, it should
You should also be sure that $a->config['system']['php_path'] is set correctly, it should
look like (changing it to the correct PHP location)
$a->config['php_path'] = '/usr/local/php53/bin/php'
$a->config['system']['php_path'] = '/usr/local/php53/bin/php';
Alternative: You may be able to use the 'poormancron' plugin to perform this
step if you are using a recent Friendica release. 'poormancron' may result in
@ -260,7 +260,7 @@ are NOT called with -d suhosin.executor.func.blacklist=none.
So the simple solution is to put the correct parameters into .htconfig.php:
// Location of PHP command line processor
$a->config['php_path'] = '/usr/bin/php -d suhosin.executor.func.blacklist=none
$a->config['system']['php_path'] = '/usr/bin/php -d suhosin.executor.func.blacklist=none
-d suhosin.executor.eval.blacklist=none';

View File

@ -18,13 +18,14 @@ function editpost_content(&$a) {
return;
}
$itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
$itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d and author_xchan = '%s' LIMIT 1",
intval($post_id),
intval(local_user())
intval(local_user()),
dbesc(get_observer_hash())
);
if(! count($itm)) {
notice( t('Item not found') . EOL);
notice( t('Item is not editable') . EOL);
return;
}

View File

@ -261,6 +261,7 @@ function post_post(&$a) {
}
}
if($msgtype === 'refresh') {
// remote channel info (such as permissions or photo or something)

View File

@ -145,6 +145,12 @@ function zfinger_init(&$a) {
// array of (verified) hubs this channel uses
$ret['locations'] = array();
$x = zot_get_hubloc(array($e['channel_hash']));
if($x && count($x)) {
foreach($x as $hub) {

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +1,81 @@
#!/bin/bash
FULLPATH=$(dirname $(readlink -f "$0"))
cd "$FULLPATH/../view/en/"
ADDONMODE=
ADDONNAME=
if [ "$1" == "--addon" -o "$1" == "-a" ]
then
ADDONMODE=1
if [ -z $2 ]; then echo -e "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
ADDONNAME=$2
if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi
fi
if [ $ADDONMODE ]
then
cd "$FULLPATH/../addon/$ADDONNAME"
mkdir -p "$FULLPATH/../addon/$ADDONNAME/lang/C"
OUTFILE="$FULLPATH/../addon/$ADDONNAME/lang/C/messages.po"
FINDSTARTDIR="."
FINDOPTS=
else
cd "$FULLPATH/../view/en/"
OUTFILE="$FULLPATH/messages.po"
FINDSTARTDIR="../../"
# skip addon folder
FINDOPTS="-wholename */addon -prune -o"
fi
F9KVERSION=$(sed -n "s/.*'FRIENDICA_VERSION'.*'\([0-9.]*\)'.*/\1/p" ../../boot.php);
echo "Friendica version $F9KVERSION"
OPTS=
OUTFILE="$FULLPATH/messages.po"
if [ "" != "$1" ]
then
OUTFILE="$(readlink -f ${FULLPATH}/$1)"
if [ -e "$OUTFILE" ]
then
echo "join extracted strings"
OPTS="-j"
fi
fi
#if [ "" != "$1" ]
#then
# OUTFILE="$(readlink -f ${FULLPATH}/$1)"
# if [ -e "$OUTFILE" ]
# then
# echo "join extracted strings"
# OPTS="-j"
# fi
#fi
KEYWORDS="-k -kt -ktt:1,2"
echo "extract strings to $OUTFILE.."
find ../../ -name "*.php" | xargs xgettext $KEYWORDS $OPTS -o "$OUTFILE" --from-code=UTF-8
echo "extract strings to $OUTFILE.."
rm "$OUTFILE"; touch "$OUTFILE"
for f in $(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f)
do
if [ ! -d "$f" ]
then
xgettext $KEYWORDS $OPTS -j -o "$OUTFILE" --from-code=UTF-8 "$f" > /dev/null 2>&1
fi
done
echo "setup base info.."
sed -i "s/SOME DESCRIPTIVE TITLE./FRIENDICA Distributed Social Network/g" "$OUTFILE"
sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2010, 2011 the Friendica Project/g" "$OUTFILE"
sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Mike Macgirvin, 2010/g" "$OUTFILE"
sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE"
sed -i "s/PACKAGE/Friendica/g" "$OUTFILE"
sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
sed -i "s/^\"Plural-Forms/#\"Plural-Forms/g" "$OUTFILE"
if [ $ADDONMODE ]
then
sed -i "s/SOME DESCRIPTIVE TITLE./ADDON $ADDONNAME/g" "$OUTFILE"
sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER//g" "$OUTFILE"
sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.//g" "$OUTFILE"
sed -i "s/PACKAGE VERSION//g" "$OUTFILE"
sed -i "s/PACKAGE/Friendica $ADDONNAME addon/g" "$OUTFILE"
sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
sed -i "s/^\"Plural-Forms/#\"Plural-Forms/g" "$OUTFILE"
else
sed -i "s/SOME DESCRIPTIVE TITLE./Red Communications Project/g" "$OUTFILE"
sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2013 the Friendica Project/g" "$OUTFILE"
sed -i "s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Mike Macgirvin, 2013/g" "$OUTFILE"
sed -i "s/PACKAGE VERSION/$F9KVERSION/g" "$OUTFILE"
sed -i "s/PACKAGE/Red/g" "$OUTFILE"
sed -i "s/CHARSET/UTF-8/g" "$OUTFILE"
sed -i "s/^\"Plural-Forms/#\"Plural-Forms/g" "$OUTFILE"
fi
echo "done."

View File

@ -38,8 +38,8 @@
}
}
if(x($a->config,'php_path'))
$phpath = $a->config['php_path'];
if(x($a->config,'system') && x($a->config['system'],'php_path'))
$phpath = $a->config['system']['php_path'];
else
$phpath = 'php';

View File

@ -1 +1 @@
2013-03-06.244
2013-03-10.248

View File

@ -2258,36 +2258,10 @@ aside input[type='text'] {
}
#profile-jot-desc {
/*float: left;*/
width: 480px;
color: #FF0000;
margin-top: 10px;
margin-bottom: 10px;
#profile-jot-wrapper {
margin-top: 25px;
}
#character-counter {
float: right;
font-size: 120%;
}
#character-counter.grey {
color: #888888;
}
#character-counter.orange {
color: orange;
}
#character-counter.red {
color: red;
}
#profile-jot-banner-end {
/* clear: both; */
}
#settings-default-perms-menu {
margin-top: 15px;

View File

@ -74,24 +74,6 @@ function initEditor(cb){
$('#profile-jot-desc').html('&nbsp;');
}
//Character count
if(textlen <= 140) {
$('#character-counter').removeClass('red');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('grey');
}
if((textlen > 140) && (textlen <= 420)) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('red');
$('#character-counter').addClass('orange');
}
if(textlen > 420) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('red');
}
$('#character-counter').text(textlen);
});
ed.onInit.add(function(ed) {

View File

@ -1,10 +1,5 @@
<div id="profile-jot-wrapper" >
<div id="profile-jot-banner-wrapper">
<div id="profile-jot-desc" >&nbsp;</div>
<div id="character-counter" class="grey"></div>
</div>
<div id="profile-jot-banner-end"></div>
<form id="profile-jot-form" action="$action" method="post" >
<input type="hidden" name="type" value="$ptyp" />

View File

@ -79,24 +79,6 @@ function initEditor(cb){
$('#profile-jot-desc').html('&nbsp;');
}
//Character count
if(textlen <= 140) {
$('#character-counter').removeClass('red');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('grey');
}
if((textlen > 140) && (textlen <= 420)) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('red');
$('#character-counter').addClass('orange');
}
if(textlen > 420) {
$('#character-counter').removeClass('grey');
$('#character-counter').removeClass('orange');
$('#character-counter').addClass('red');
}
$('#character-counter').text(textlen);
});
ed.onInit.add(function(ed) {

View File

@ -5,11 +5,6 @@
*}}
<div id="profile-jot-wrapper" >
<div id="profile-jot-banner-wrapper">
<div id="profile-jot-desc" >&nbsp;</div>
<div id="character-counter" class="grey"></div>
</div>
<div id="profile-jot-banner-end"></div>
<form id="profile-jot-form" action="{{$action}}" method="post" >
<input type="hidden" name="type" value="{{$ptyp}}" />