aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php21
-rw-r--r--include/contact_widgets.php11
-rw-r--r--include/notifier.php5
-rw-r--r--include/zot.php55
-rw-r--r--install/database.sql4
-rw-r--r--install/update.php9
-rw-r--r--mod/chanman.php29
-rw-r--r--mod/filestorage.php70
-rw-r--r--mod/import.php4
-rw-r--r--version.inc2
-rw-r--r--view/tpl/filestorage.tpl22
11 files changed, 193 insertions, 39 deletions
diff --git a/boot.php b/boot.php
index 483e98bba..b3c8701fd 100755
--- a/boot.php
+++ b/boot.php
@@ -43,7 +43,7 @@ require_once('include/taxonomy.php');
define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1067 );
+define ( 'DB_UPDATE_VERSION', 1068 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
@@ -346,6 +346,17 @@ define ( 'XCHAN_FLAGS_HIDDEN', 0x0001);
define ( 'XCHAN_FLAGS_ORPHAN', 0x0002);
+/*
+ * Traficlights for Administration of HubLoc
+ * to detect problems in inter server communication
+ */
+define ('HUBLOC_NOTUSED', 0x0000);
+define ('HUBLOC_SEND_ERROR', 0x0001);
+define ('HUBLOC_RECEIVE_ERROR', 0x0002);
+define ('HUBLOC_WORKS', 0x0004);
+define ('HUBLOC_OFFLINE', 0x0008);
+
+
/**
* Tag/term types
*/
@@ -1228,16 +1239,16 @@ function check_config(&$a) {
$email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
- '$sitename' => $a->config['sitename'],
+ '$sitename' => $a->config['system']['sitename'],
'$siteurl' => $a->get_baseurl(),
'$update' => $x,
'$error' => sprintf( t('Update %s failed. See error logs.'), $x)
));
- $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
+ $subject = email_header_encode(sprintf(t('Update Error at %s'), $a->get_baseurl()));
- mail($a->config['admin_email'], $subject, $email_msg,
- 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
+ mail($a->config['system']['admin_email'], $subject, $email_msg,
+ 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
//try the logger
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index cc7d92508..bc7faebc3 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -91,9 +91,16 @@ function categories_widget($baseurl,$selected = '') {
return '';
$terms = array();
- $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc",
+ $r = q("select distinct(term.term)
+ from term join item on term.oid = item.id
+ where item.uid = %d
+ and term.uid = item.uid
+ and term.type = %d
+ and item.author_xchan = '%s'
+ order by term.term asc",
intval($a->profile['profile_uid']),
- intval(TERM_CATEGORY)
+ intval(TERM_CATEGORY),
+ dbesc($a->profile['channel_hash'])
);
if($r && count($r)) {
foreach($r as $rr)
diff --git a/include/notifier.php b/include/notifier.php
index 5dcd7b58c..e813f7951 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -208,9 +208,8 @@ function notifier_run($argv, $argc){
$channel = $s[0];
$uid = $item_id;
$recipients = array();
- $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d)",
- intval($item_id),
- intval(ABOOK_FLAG_SELF)
+ $r = q("select abook_xchan from abook where abook_channel = %d",
+ intval($item_id)
);
if($r) {
foreach($r as $rr) {
diff --git a/include/zot.php b/include/zot.php
index 33522b485..e9084496c 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -493,7 +493,6 @@ function import_xchan($arr) {
logger('import_xchan: existing: ' . print_r($r[0],true), LOGGER_DATA);
logger('import_xchan: new: ' . print_r($arr,true), LOGGER_DATA);
- update_modtime($xchan_hash);
$changed = true;
}
}
@@ -532,7 +531,7 @@ function import_xchan($arr) {
dbesc($arr['name_updated']),
intval($new_flags)
);
- update_modtime($xchan_hash);
+
$changed = true;
}
@@ -553,7 +552,7 @@ function import_xchan($arr) {
dbesc($xchan_hash)
);
- update_modtime($xchan_hash);
+
$changed = true;
}
@@ -601,7 +600,7 @@ function import_xchan($arr) {
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
- update_modtime($xchan_hash);
+
$changed = true;
}
continue;
@@ -641,7 +640,7 @@ function import_xchan($arr) {
dbesc(datetime_convert()),
dbesc(datetime_convert())
);
- update_modtime($xchan_hash);
+
$changed = true;
}
@@ -653,7 +652,7 @@ function import_xchan($arr) {
$r = q("delete from hubloc where hubloc_id = %d limit 1",
intval($x['hubloc_id'])
);
- update_modtime($xchan_hash);
+
$changed = true;
}
}
@@ -667,7 +666,7 @@ function import_xchan($arr) {
if(array_key_exists('profile',$arr) && is_array($arr['profile'])) {
$profile_changed = import_directory_profile($xchan_hash,$arr['profile']);
if($profile_changed) {
- update_modtime($xchan_hash);
+
$changed = true;
}
}
@@ -686,7 +685,6 @@ function import_xchan($arr) {
if(array_key_exists('site',$arr) && is_array($arr['site'])) {
$profile_changed = import_site($arr['site'],$arr['key']);
if($profile_changed) {
- update_modtime($xchan_hash);
$changed = true;
}
}
@@ -694,9 +692,8 @@ function import_xchan($arr) {
if($changed) {
- // send out a directory mirror update packet if we're a directory server or some kind
-
-
+ $guid = random_string() . '@' . get_app()->get_hostname();
+ update_modtime($xchan_hash,$guid);
}
if(! x($ret,'message')) {
@@ -1431,7 +1428,7 @@ function import_directory_profile($hash,$profile) {
call_hooks('import_directory_profile', $d);
if($d['update'])
- update_modtime($arr['xprof_hash']);
+ update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname());
return $d['update'];
}
@@ -1470,20 +1467,12 @@ function import_directory_keywords($hash,$keywords) {
}
-function update_modtime($hash) {
- $r = q("select * from updates where ud_hash = '%s' limit 1",
- dbesc($hash)
+function update_modtime($hash,$guid) {
+ q("insert into updates (ud_hash, ud_guid, ud_date) values ( '%s', '%s', '%s' )",
+ dbesc($hash),
+ dbesc($guid),
+ dbesc(datetime_convert())
);
- if($r)
- q("update updates set ud_date = '%s' where ud_hash = '%s' limit 1",
- dbesc(datetime_convert()),
- dbesc($hash)
- );
- else
- q("insert into updates (ud_hash, ud_date) values ( '%s', '%s' )",
- dbesc($hash),
- dbesc(datetime_convert())
- );
}
@@ -1549,7 +1538,7 @@ function import_site($arr,$pubkey) {
}
}
else {
- $r = q("insert into site ( site_url, site_acccess, site_flags, site_update, site_directory, site_register )
+ $r = q("insert into site ( site_url, site_access, site_flags, site_update, site_directory, site_register )
values ( '%s', %d, %d, '%s', '%s', %d )",
dbesc(htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false)),
intval($site_directory),
@@ -1745,6 +1734,20 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
if(! array_key_exists('abook_xchan',$clean))
continue;
+ $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
+ dbesc($clean['abook_xchan']),
+ intval($channel['channel_id'])
+ );
+
+ // make sure we have an abook entry for this xchan on this system
+
+ if(! $r) {
+ q("insert into abook ( abook_xchan, abook_channel ) values ('%s', %d ) ",
+ dbesc($clean['abook_xchan']),
+ intval($channel['channel_id'])
+ );
+ }
+
if(count($clean)) {
foreach($clean as $k => $v) {
$r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v)
diff --git a/install/database.sql b/install/database.sql
index ce46149c4..9b1b6cad2 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -883,10 +883,12 @@ CREATE TABLE IF NOT EXISTS `tokens` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `updates` (
+ `ud_id` int(10) unsigned NOT NULL AUTO INCREMENT,
`ud_hash` char(128) NOT NULL,
`ud_guid` char(255) NOT NULL DEFAULT '',
`ud_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
- PRIMARY KEY (`ud_hash`),
+ PRIMARY KEY (`ud_id`),
+ KEY `ud_hash` (`ud_hash`),
KEY `ud_guid` (`ud_guid`),
KEY `ud_date` (`ud_date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/install/update.php b/install/update.php
index 36a85afec..1b6a2218e 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1067 );
+define( 'UPDATE_VERSION' , 1068 );
/**
*
@@ -775,3 +775,10 @@ ADD INDEX ( `site_access` )");
return UPDATE_FAILED;
}
+function update_r1067() {
+ $r = q("ALTER TABLE `updates` DROP PRIMARY KEY , ADD `ud_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST, ADD INDEX ( `ud_hash` ) ");
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
+
diff --git a/mod/chanman.php b/mod/chanman.php
new file mode 100644
index 000000000..2657e7be9
--- /dev/null
+++ b/mod/chanman.php
@@ -0,0 +1,29 @@
+<?php /** @file */
+
+
+/**
+ Placeholder file at present. This is going to involve a bit of work.
+
+ This file will deal with the deletion of channels and management of hublocs.
+
+ We need to provide the following functionality:
+
+ - Delete my account and all channels from the entire network
+
+ - Delete my account and all channels from this server
+
+ - Delete a channel from the entire network
+
+ - Delete a channel from this server
+
+ - List all hub locations for this channel
+
+ - Remove this/some hub location from this channel
+
+ - promote this/some hub location to primary
+
+ - Remove hub location 'xyz' from this channel, (this should possibly only be allowed if that hub has been down for a period of time)
+
+ - Some of these actions should probably require email verification
+
+*/
diff --git a/mod/filestorage.php b/mod/filestorage.php
new file mode 100644
index 000000000..41055f98e
--- /dev/null
+++ b/mod/filestorage.php
@@ -0,0 +1,70 @@
+<?php
+
+function filestorage_content(&$a) {
+
+ if(argc() > 1)
+ $which = argv(1);
+ else {
+ notice( t('Requested profile is not available.') . EOL );
+ $a->error = 404;
+ return;
+ }
+
+ $r = q("select channel_id from channel where channel_address = '%s'",
+ dbesc($which)
+ );
+ if($r) {
+ $owner = intval($r[0]['channel_id']);
+ }
+
+ $is_owner = (((local_user()) && ($owner == local_user())) ? true : false);
+ if (! $is_owner) {
+ info( t('Permission Denied.') . EOL );
+ return;
+ }
+ if ((argc() > 3 && argv(3) === 'delete') ? true : false);{
+ $file = argv(2);
+ $r = q("delete from attach where id = '%s' and uid = '%s' limit 1",
+ dbesc($file),
+ intval($owner)
+ );
+
+
+ }
+
+
+$r = q("select * from attach where uid = %d order by filename asc",
+ intval($owner)
+);
+
+ $files = null;
+
+ if($r) {
+ $files = array();
+ foreach($r as $rr) {
+ $files[$rr['id']][] = array('id' => $rr['id'],'download' => $rr['hash'], 'title' => $rr['filename'], 'size' => $rr['filesize']);
+ }
+ }
+
+
+ $limit = service_class_fetch ($owner,'attach_upload_limit');
+ $r = q("select sum(filesize) as total from attach where uid = %d ",
+ intval($owner)
+ );
+ $used = $r[0]['total'];
+
+ $url = z_root() . "/filestorage/" . $which;
+ return $o . replace_macros(get_markup_template("filestorage.tpl"), array(
+ '$baseurl' => $url,
+ '$download' => t('Download'),
+ '$files' => $files,
+ '$channel' => $which,
+ '$delete' => t('Delete'),
+ '$used' => $used,
+ '$usedlabel' => t('Used: '),
+ '$limit' => $limit,
+ '$limitlabel' => t('Limit: '),
+ ));
+
+
+}
diff --git a/mod/import.php b/mod/import.php
index 08311013a..e2e54c0cd 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -347,6 +347,10 @@ function import_post(&$a) {
}
+ // This will indirectly perform a refresh_all *and* update the directory
+
+ proc_run('php', 'include/directory.php', $channel['channel_id']);
+
// send out refresh requests
notice( t('Import completed.') . EOL);
diff --git a/version.inc b/version.inc
index 5912f3e76..409e919d6 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2013-09-07.429
+2013-09-09.431
diff --git a/view/tpl/filestorage.tpl b/view/tpl/filestorage.tpl
new file mode 100644
index 000000000..995b52cc8
--- /dev/null
+++ b/view/tpl/filestorage.tpl
@@ -0,0 +1,22 @@
+{{if $files}}
+
+ <div class="generic-content-wrapper">
+ {{if $limit}}{{$limitlabel}}{{$limit}}{{/if}} {{if $used}} {{$usedlabel}}{{$used}}{{/if}}
+
+
+ {{foreach $files as $key => $items}}
+ {{foreach $items as $item}}
+ <div class="files-list-item">
+ <a href="attach/{{$item.download}}">{{$download}}</a> |
+ <a href="{{$baseurl}}/{{$item.id}}/delete">{{$delete}}
+ <a href="page/{{$channel}}/{{$item.title}}">{{$title}}</a> {{$item.title}} |
+ {{$item.size}} bytes
+
+</div>
+ {{/foreach}}
+ {{/foreach}}
+ </div>
+
+ <div class="clear"></div>
+
+{{/if}}