aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-11-12 20:59:18 -0800
committerfriendica <info@friendica.com>2012-11-12 20:59:18 -0800
commit5bf3ddfcf66ece4b50d5fccfd90c49005ce768ce (patch)
tree79bfeb6df83e881816aeb8bc7271dae4f7e14582
parentb4c603cdace281f79e1738d2e006851b00af511e (diff)
downloadvolse-hubzilla-5bf3ddfcf66ece4b50d5fccfd90c49005ce768ce.tar.gz
volse-hubzilla-5bf3ddfcf66ece4b50d5fccfd90c49005ce768ce.tar.bz2
volse-hubzilla-5bf3ddfcf66ece4b50d5fccfd90c49005ce768ce.zip
got zot
-rw-r--r--boot.php2
-rw-r--r--include/notifier.php67
-rw-r--r--include/permissions.php4
-rw-r--r--include/zot.php18
-rw-r--r--mod/post.php3
5 files changed, 66 insertions, 28 deletions
diff --git a/boot.php b/boot.php
index 707545155..68bdadc95 100644
--- a/boot.php
+++ b/boot.php
@@ -1604,7 +1604,7 @@ if(! function_exists('proc_run')) {
return;
if(count($args) && $args[0] === 'php')
- $args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
+ $args[0] = ((x($a->config,'system')) && (x($a->config['system'],'php_path')) && (strlen($a->config['system']['php_path'])) ? $a->config['system']['php_path'] : 'php');
for($x = 0; $x < count($args); $x ++)
$args[$x] = escapeshellarg($args[$x]);
diff --git a/include/notifier.php b/include/notifier.php
index dd56750c8..1878c2a98 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -40,42 +40,75 @@ require_once('include/html2plain.php');
* wall-new (in photos.php, item.php)
*
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
+ *
+ * ZOT
+ * permission_updated abook_id
+ *
*/
+require_once('include/cli_startup.php');
+require_once('include/zot.php');
+
function notifier_run($argv, $argc){
- global $a, $db;
- if(is_null($a)){
- $a = new App;
- }
-
- if(is_null($db)) {
- @include(".htconfig.php");
- require_once("dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
- }
+ cli_startup();
+
+ $a = get_app();
require_once("session.php");
require_once("datetime.php");
require_once('include/items.php');
require_once('include/bbcode.php');
- load_config('config');
- load_config('system');
-
- load_hooks();
-
if($argc < 3)
return;
- $a->set_baseurl(get_config('system','url'));
logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
$cmd = $argv[1];
+ $item_id = $argv[2];
+
+ $extra = (($argc > 3) ? $argv[3] : null);
+
+ if($cmd == 'permission_update') {
+ // Get the recipient
+ $r = q("select abook.*, hubloc.* from abook
+ left join hubloc on hubloc_hash = abook_xchan
+ where abook_id = %d limit 1",
+ intval($item_id)
+ );
+ if($r) {
+ // Get the sender
+ $s = q("select * from channel where channel_id = %d limit 1",
+ intval($r[0]['abook_channel'])
+ );
+ if($s) {
+
+ // send a refresh message to each hub they have registered here
+ $h = q("select * from hubloc where hubloc_hash = '%s'",
+ dbesc($r[0]['hubloc_hash'])
+ );
+ if($h) {
+ foreach($h as $hh) {
+ $result = zot_notify($s[0],$hh['hubloc_callback'],'refresh',array(array(
+ 'guid' => $hh['hubloc_guid'],
+ 'guid_sig' => $hh['hubloc_guid_sig'],
+ 'url' => $hh['hubloc_url'])
+ ));
+ // should probably queue these
+ }
+ }
+ }
+ }
+ }
+
+return;
+
+
+
switch($cmd) {
case 'mail':
default:
diff --git a/include/permissions.php b/include/permissions.php
index ca44ac4ad..0502d7e2e 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -135,7 +135,7 @@ function get_all_perms($uid,$observer,$internal_use = true) {
// Check if this is a write permission and they are being ignored
// This flag is only visible internally.
- if(($internal_use) && (! $global_perms[$permission][2]) && ($x[0]['abook_flags'] & ABOOK_FLAG_IGNORED)) {
+ if(($internal_use) && (! $global_perms[$perm_name][2]) && ($x[0]['abook_flags'] & ABOOK_FLAG_IGNORED)) {
$ret[$perm_name] = false;
continue;
}
@@ -149,7 +149,7 @@ function get_all_perms($uid,$observer,$internal_use = true) {
// Permission granted to certain channels. Let's see if the observer is one of them
if(($r) && ($r[0][$channel_perm] & PERMS_SPECIFIC)) {
- if(($x) && ($x[0]['abook_my_perms'] & $global_perms[$permission][1])) {
+ if(($x) && ($x[0]['abook_my_perms'] & $global_perms[$perm_name][1])) {
$ret[$perm_name] = true;
continue;
}
diff --git a/include/zot.php b/include/zot.php
index 63508b749..b11961861 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1,5 +1,6 @@
<?php
+require_once('include/crypto.php');
/**
*
* @function zot_new_uid($channel_nick)
@@ -65,9 +66,9 @@ function zot_notify($channel,$url,$type = 'notify',$recipients = null, $remote_k
'type' => $type,
'sender' => json_encode(array(
'guid' => $channel['channel_guid'],
- 'guid_sig' => base64url_encode($guid,$channel['prvkey']),
- 'hub' => z_root(),
- 'hub_sig' => base64url_encode(z_root,$channel['prvkey'])
+ 'guid_sig' => base64url_encode(rsa_sign($channel['channel_guid'],$channel['channel_prvkey'])),
+ 'url' => z_root(),
+ 'url_sig' => base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))
)),
'callback' => '/post',
'version' => ZOT_REVISION
@@ -82,7 +83,7 @@ function zot_notify($channel,$url,$type = 'notify',$recipients = null, $remote_k
$params = aes_encapsulate($params,$remote_key);
}
- $x = z_post_url($url,$prams);
+ $x = z_post_url($url,$params);
return($x);
}
@@ -211,7 +212,7 @@ function zot_refresh($them,$channel = null) {
}
}
- $r = q("update abook set their_perms = %d
+ $r = q("update abook set abook_their_perms = %d
where abook_xchan = '%s' and abook_channel = %d limit 1",
intval($their_perms),
dbesc($channel['channel_hash']),
@@ -229,15 +230,16 @@ function zot_refresh($them,$channel = null) {
function zot_gethub($jarr) {
- if($jarr->guid && $jarr->guid_sig && $jarr->hub && $jarr->hub_sig) {
+
+ if($jarr->guid && $jarr->guid_sig && $jarr->url && $jarr->url_sig) {
$r = q("select * from hubloc
where hubloc_guid = '%s' and hubloc_guid_sig = '%s'
and hubloc_url = '%s' and hubloc_url_sig = '%s'
limit 1",
dbesc($jarr->guid),
dbesc($jarr->guid_sig),
- dbesc($jarr->hub),
- dbesc($jarr->hub_sig)
+ dbesc($jarr->url),
+ dbesc($jarr->url_sig)
);
if($r && count($r))
return $r[0];
diff --git a/mod/post.php b/mod/post.php
index 82ffb5817..f84b641ca 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -9,6 +9,8 @@ require_once('include/zot.php');
function post_post(&$a) {
+ logger('mod_zot: ' . print_r($_REQUEST,true), LOGGER_DEBUG);
+
$ret = array('result' => false);
if(array_key_exists('iv',$_REQUEST)) {
@@ -31,6 +33,7 @@ function post_post(&$a) {
$result = zot_register_hub($j_sender);
if((! $result['success']) || (! zot_gethub($j_sender))) {
$ret['message'] = 'Hub not available.';
+ logger('mod_zot: no hub');
json_return_and_die($ret);
}
}