aboutsummaryrefslogtreecommitdiffstats
path: root/include/dir_fns.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-02-05 19:38:43 -0800
committerfriendica <info@friendica.com>2015-02-05 19:38:43 -0800
commit4b348d248975ba07ba9cea62f51eb52d6afb5645 (patch)
treefc60c2d05958c2a458ac72b03e1e7ddffce0c41b /include/dir_fns.php
parentaafed50a0ea8a8d7091572473dcb8e4fb8cd4602 (diff)
parentb948fbaeda84f4358722222b4a2d5555ef10b82e (diff)
downloadvolse-hubzilla-4b348d248975ba07ba9cea62f51eb52d6afb5645.tar.gz
volse-hubzilla-4b348d248975ba07ba9cea62f51eb52d6afb5645.tar.bz2
volse-hubzilla-4b348d248975ba07ba9cea62f51eb52d6afb5645.zip
Merge branch 'master' into tres
Conflicts: view/css/mod_events.css view/theme/redbasic/css/style.css
Diffstat (limited to 'include/dir_fns.php')
-rw-r--r--include/dir_fns.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 86be8662c..b5ba296cf 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -216,6 +216,49 @@ function sync_directories($dirmode) {
);
}
}
+ if(count($j['ratings'])) {
+ foreach($j['ratings'] as $rr) {
+ $x = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1",
+ dbesc($rr['channel']),
+ dbesc($rr['target'])
+ );
+ if($x && $x[0]['xlink_updated'] >= $rr['edited'])
+ continue;
+ $y = q("select xchan_pubkey from xchan where xchan_hash = '%s' limit 1",
+ dbesc($rr['channel'])
+ );
+ if(! $y) {
+ logger('key unavailable on this site for ' . $rr['channel']);
+ continue;
+ }
+ if(! rsa_verify($rr['target'] . '.' . $rr['rating'] . '.' . $rr['rating_text'], base64url_decode($rr['signature']),$y[0]['xchan_pubkey'])) {
+ logger('failed to verify rating');
+ continue;
+ }
+
+ if($x) {
+ $z = q("update xlink set xlink_rating = %d, xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' where xlink_id = %d",
+ intval($rr['rating']),
+ dbesc($rr['rating_text']),
+ dbesc($rr['signature']),
+ dbesc(datetime_convert()),
+ intval($x[0]['xlink_id'])
+ );
+ logger('rating updated');
+ }
+ else {
+ $z = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values( '%s', '%s', %d, '%s', '%s', 1 ) ",
+ dbesc($rr['channel']),
+ dbesc($rr['target']),
+ intval($rr['rating']),
+ dbesc($rr['rating_text']),
+ dbesc($rr['signature']),
+ dbesc(datetime_convert())
+ );
+ logger('rating created');
+ }
+ }
+ }
}
}