Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Haakon Meland Eriksen 2015-08-03 21:53:01 +02:00
commit 5adb41a0ed
19 changed files with 209 additions and 3273 deletions

View File

@ -49,7 +49,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1144 );
define ( 'DB_UPDATE_VERSION', 1145 );
/**
* @brief Constant with a HTML line break.

View File

@ -50,7 +50,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
*/
public function __construct($ext_path, &$auth_plugin) {
// $ext_path = urldecode($ext_path);
//logger('directory ' . $ext_path, LOGGER_DATA);
logger('directory ' . $ext_path, LOGGER_DATA);
$this->ext_path = $ext_path;
// remove "/cloud" from the beginning of the path
$modulename = get_app()->module;
@ -80,7 +80,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @return array \Sabre\DAV\INode[]
*/
public function getChildren() {
//logger('children for ' . $this->ext_path, LOGGER_DATA);
logger('children for ' . $this->ext_path, LOGGER_DATA);
$this->log();
if (get_config('system', 'block_public') && (! $this->auth->channel_id) && (! $this->auth->observer)) {
@ -370,15 +370,14 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @return void
*/
function getDir() {
//logger($this->ext_path, LOGGER_DEBUG);
logger('GetDir: ' . $this->ext_path, LOGGER_DEBUG);
$this->auth->log();
$modulename = get_app()->module;
$file = $this->ext_path;
$x = strpos($file, '/' . $modulename);
if ($x === false)
return;
if ($x === 0) {
$file = substr($file, strlen($modulename) + 1);
}
@ -414,14 +413,12 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$os_path = '';
for ($x = 1; $x < count($path_arr); $x++) {
$r = q("select id, hash, filename, flags from attach where folder = '%s' and filename = '%s' and uid = %d and (flags & %d)>0",
$r = q("select id, hash, filename, flags, is_dir from attach where folder = '%s' and filename = '%s' and uid = %d and is_dir != 0",
dbesc($folder),
dbesc($path_arr[$x]),
intval($channel_id),
intval(ATTACH_FLAG_DIR)
intval($channel_id)
);
if ($r && ( $r[0]['flags'] & ATTACH_FLAG_DIR)) {
if ($r && intval($r[0]['is_dir'])) {
$folder = $r[0]['hash'];
if (strlen($os_path))
$os_path .= '/';

View File

@ -49,7 +49,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
$this->data = $data;
$this->auth = $auth;
//logger(print_r($this->data, true), LOGGER_DATA);
logger(print_r($this->data, true), LOGGER_DATA);
}
/**
@ -165,6 +165,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
);
if($is_photo) {
require_once('include/photos.php');
$args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_path' => $f, 'filename' => $r[0]['filename'], 'getimagesize' => $gis );
$p = photo_upload($c[0],$this->auth->observer,$args);
}
@ -207,6 +208,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
*/
public function get() {
logger('get file ' . basename($this->name), LOGGER_DEBUG);
logger('os_path: ' . $this->os_path, LOGGER_DATA);
$r = q("SELECT data, flags, os_storage, filename, filetype FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
dbesc($this->data['hash']),
@ -300,7 +302,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
}
if ($this->auth->owner_id !== $this->auth->channel_id) {
if (($this->auth->observer !== $this->data['creator']) || ($this->data['flags'] & ATTACH_FLAG_DIR)) {
if (($this->auth->observer !== $this->data['creator']) || intval($this->data['is_dir'])) {
throw new DAV\Exception\Forbidden('Permission denied.');
}
}

View File

@ -203,7 +203,7 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
// Retrieve all columns except 'data'
$r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, os_storage, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra $orderby $limit",
$r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, os_storage, is_dir, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra $orderby $limit",
intval($channel_id)
);
@ -339,7 +339,7 @@ function attach_by_hash_nodata($hash, $rev = 0) {
// Now we'll see if we can access the attachment
$r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1",
$r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_photo, is_dir, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1",
intval($r[0]['uid']),
dbesc($hash)
);
@ -733,10 +733,9 @@ function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
if(count($paths) > 1) {
$curpath = array_shift($paths);
$r = q("select hash, id from attach where uid = %d and filename = '%s' and (flags & %d )>0 " . permissions_sql($channel_id) . " limit 1",
$r = q("select hash, id, is_dir from attach where uid = %d and filename = '%s' and is_dir != 0 " . permissions_sql($channel_id) . " limit 1",
intval($channel_id),
dbesc($curpath),
intval(ATTACH_FLAG_DIR)
dbesc($curpath)
);
if(! $r) {
$ret['message'] = t('Path not available.');
@ -749,11 +748,10 @@ function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
else
$paths = array($pathname);
$r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and folder = '%s' and filename = '%s' and (flags & %d )>0 " . permissions_sql($channel_id),
$r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, is_photo, is_dir, os_storage, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and folder = '%s' and filename = '%s' and is_dir != 0 " . permissions_sql($channel_id),
intval($channel_id),
dbesc($parent_hash),
dbesc($paths[0]),
intval(ATTACH_FLAG_DIR)
dbesc($paths[0])
);
if(! $r) {
$ret['message'] = t('Path not available.');
@ -839,11 +837,10 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
$sql_options = permissions_sql($channel['channel_id']);
do {
$r = q("select filename, hash, flags, folder from attach where uid = %d and hash = '%s' and ( flags & %d )>0
$r = q("select filename, hash, flags, is_dir, folder from attach where uid = %d and hash = '%s' and is_dir != 0
$sql_options limit 1",
intval($channel['channel_id']),
dbesc($lfile),
intval(ATTACH_FLAG_DIR)
dbesc($lfile)
);
if(! $r) {
@ -854,7 +851,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
if($lfile)
$lpath = $r[0]['hash'] . '/' . $lpath;
$lfile = $r[0]['folder'];
} while ( ($r[0]['folder']) && ($r[0]['flags'] & ATTACH_FLAG_DIR)) ;
} while ( ($r[0]['folder']) && intval($r[0]['is_dir'])) ;
$path = $basepath . '/' . $lpath;
}
else
@ -864,7 +861,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
$created = datetime_convert();
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, flags, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($channel['channel_account_id']),
intval($channel_id),
@ -876,7 +873,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
intval(0),
dbesc($arr['folder']),
intval(1),
intval(ATTACH_FLAG_DIR),
intval(1),
dbesc($path),
dbesc($created),
dbesc($created),
@ -1012,7 +1009,7 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
*/
function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse = false) {
$r = q("select hash, flags from attach where hash = '%s' and uid = %d limit 1",
$r = q("select hash, flags, is_dir from attach where hash = '%s' and uid = %d limit 1",
dbesc($resource),
intval($channel_id)
);
@ -1020,9 +1017,9 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
if(! $r)
return;
if($r[0]['flags'] & ATTACH_FLAG_DIR) {
if(intval($r[0]['is_dir'])) {
if($recurse) {
$r = q("select hash, flags from attach where folder = '%s' and uid = %d",
$r = q("select hash, flags, is_dir from attach where folder = '%s' and uid = %d",
dbesc($resource),
intval($channel_id)
);
@ -1065,7 +1062,7 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
$channel_address = (($c) ? $c[0]['channel_address'] : 'notfound');
$photo_sql = (($is_photo) ? " and is_photo = 1 " : '');
$r = q("SELECT hash, flags, folder FROM attach WHERE hash = '%s' AND uid = %d $photo_sql limit 1",
$r = q("SELECT hash, flags, is_dir, folder FROM attach WHERE hash = '%s' AND uid = %d $photo_sql limit 1",
dbesc($resource),
intval($channel_id)
);
@ -1077,8 +1074,8 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
$object = get_file_activity_object($channel_id, $resource, $cloudpath);
// If resource is a directory delete everything in the directory recursive
if($r[0]['flags'] & ATTACH_FLAG_DIR) {
$x = q("SELECT hash, os_storage, flags FROM attach WHERE folder = '%s' AND uid = %d",
if(intval($r[0]['is_dir'])) {
$x = q("SELECT hash, os_storage, is_dir, flags FROM attach WHERE folder = '%s' AND uid = %d",
dbesc($resource),
intval($channel_id)
);
@ -1152,11 +1149,10 @@ function get_cloudpath($arr) {
$lfile = $arr['folder'];
do {
$r = q("select filename, hash, flags, folder from attach where uid = %d and hash = '%s' and ( flags & %d )>0
$r = q("select filename, hash, flags, is_dir, folder from attach where uid = %d and hash = '%s' and is_dir != 0
limit 1",
intval($arr['uid']),
dbesc($lfile),
intval(ATTACH_FLAG_DIR)
dbesc($lfile)
);
if(! $r)
@ -1166,7 +1162,7 @@ function get_cloudpath($arr) {
$lpath = $r[0]['filename'] . '/' . $lpath;
$lfile = $r[0]['folder'];
} while ( ($r[0]['folder']) && ($r[0]['flags'] & ATTACH_FLAG_DIR));
} while ( ($r[0]['folder']) && intval($r[0]['is_dir']));
$path .= $lpath;
}
@ -1295,7 +1291,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
//filter out receivers which do not have permission to view filestorage
$arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage');
$is_dir = (($object['flags'] & ATTACH_FLAG_DIR) ? true : false);
$is_dir = (intval($object['is_dir']) ? true : false);
//do not send activity for folders for now
if($is_dir)
@ -1451,7 +1447,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
*/
function get_file_activity_object($channel_id, $hash, $cloudpath) {
$x = q("SELECT creator, filename, filetype, filesize, revision, folder, os_storage, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1",
$x = q("SELECT creator, filename, filetype, filesize, revision, folder, os_storage, is_photo, is_dir, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1",
intval($channel_id),
dbesc($hash)
);
@ -1479,8 +1475,9 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) {
'revision' => $x[0]['revision'],
'folder' => $x[0]['folder'],
'flags' => $x[0]['flags'],
'flags' => $x[0]['os_storage'],
'os_storage' => $x[0]['os_storage'],
'is_photo' => $x[0]['is_photo'],
'is_dir' => $x[0]['is_dir'],
'created' => $x[0]['created'],
'edited' => $x[0]['edited'],
'allow_cid' => $x[0]['allow_cid'],

View File

@ -950,14 +950,21 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
// start which is always required). Allow desc with a missing summary for compatibility.
if ((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
$sub = format_event_html($ev);
$sub = str_replace('$',"\0",$sub);
$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text);
$Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text);
$Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text);
$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text);
$Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text);
$Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text);
$Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text);
$Text = str_replace("\0",'$',$Text);
}
// Unhide all [noparse] contained bbtags unspacefying them

View File

@ -588,7 +588,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
if($arr_blocked) {
$blocked = false;
foreach($arr_blocked as $b) {
if(($b) && ($item['author_xchan'] == $b)) {
if(($b) && (($item['author_xchan'] == $b) || ($item['owner_xchan'] == $b))) {
$blocked = true;
break;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
<?php
use Sabre\VObject;
/**
* @file include/event.php
*/
@ -16,6 +18,7 @@ function format_event_html($ev) {
if(! ((is_array($ev)) && count($ev)))
return '';
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM
$o = '<div class="vevent">' . "\r\n";
@ -163,7 +166,18 @@ function bbtoevent($s) {
$match = '';
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
$ev['adjust'] = $match[1];
$ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0);
if(array_key_exists('start',$ev)) {
if(array_key_exists('finish',$ev)) {
if($ev['finish'] === $ev['start'])
$ev['nofinish'] = 1;
elseif($ev['finish'])
$ev['nofinish'] = 0;
else
$ev['nofinish'] = 1;
}
else
$ev['nofinish'] = 1;
}
return $ev;
}
@ -281,7 +295,7 @@ function event_store_event($arr) {
if(array_key_exists('external_id',$arr))
$hash = $arr['external_id'];
else
$hash = random_string();
$hash = random_string() . '@' . get_app()->get_hostname();
$r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type,
adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid)
@ -371,18 +385,30 @@ function event_addtocal($item_id, $uid) {
function parse_ical_file($f,$uid) {
require_once('library/ical.php');
$ical = new ICal($f);
require_once('vendor/autoload.php');
$s = @file_get_contents($f);
// Change the current timezone to something besides UTC.
// Doesn't matter what it is, as long as it isn't UTC.
// Save the current timezone so we can reset it when we're done processing.
$saved_timezone = date_default_timezone_get();
date_default_timezone_set('Australia/Sydney');
$ical = VObject\Reader::read($s);
if($ical) {
$events = $ical->events();
if($events) {
foreach($events as $ev) {
logger('event parsed: ' . print_r($ev,true), LOGGER_ALL);
event_import_ical($ev,$uid);
}
foreach($ical->VEVENT as $event) {
event_import_ical($event,$uid);
}
return true;
}
date_default_timezone_set($saved_timezone);
if($ical)
return true;
return false;
}
@ -400,40 +426,74 @@ function event_import_ical($ical, $uid) {
$channel = $c[0];
$ev = array();
if($ical['CREATED'])
$ev['created'] = datetime_convert('UTC','UTC',$ical['CREATED']);
if($ical['LAST-MODIFIED'])
$ev['edited'] = datetime_convert('UTC','UTC',$ical['LAST-MODIFIED']);
if($ical['LOCATION'])
$ev['location'] = $ical['LOCATION'];
if($ical['DESCRIPTION'])
$ev['description'] = $ical['DESCRIPTION'];
if($ical['SUMMARY'])
$ev['summary'] = $ical['SUMMARY'];
if($ical['DTEND'])
$ev['finish'] = datetime_convert('UTC','UTC', $ical['DTEND']);
if(! isset($ical->DTSTART)) {
logger('no event start');
return false;
}
$dtstart = $ical->DTSTART->getDateTime();
// logger('dtstart: ' . var_export($dtstart,true));
if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) {
$ev['adjust'] = 1;
}
else {
$ev['adjust'] = 0;
}
$ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
$dtstart->format(\DateTime::W3C));
if(isset($ical->DTEND)) {
$dtend = $ical->DTEND->getDateTime();
$ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
$dtend->format(\DateTime::W3C));
}
else
$ev['nofinish'] = 1;
$ev['start'] = datetime_convert('UTC','UTC',$ical['DTSTART']);
if(substr($ical['DTSTART'],-1) === 'Z')
$ev['adjust'] = 1;
if($ical['UID']) {
if($ev['start'] === $ev['finish'])
$ev['nofinish'] = 1;
if(isset($ical->CREATED)) {
$created = $ical->CREATED->getDateTime();
$ev['created'] = datetime_convert('UTC','UTC',$created->format(\DateTime::W3C));
}
if(isset($ical->{'LAST-MODIFIED'})) {
$edited = $ical->{'LAST-MODIFIED'}->getDateTime();
$ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C));
}
if(isset($ical->LOCATION))
$ev['location'] = (string) $ical->LOCATION;
if(isset($ical->DESCRIPTION))
$ev['description'] = (string) $ical->DESCRIPTION;
if(isset($ical->SUMMARY))
$ev['summary'] = (string) $ical->SUMMARY;
if(isset($ical->UID)) {
$evuid = (string) $ical->UID;
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
dbesc($ical['UID']),
intval($arr['uid'])
dbesc($evuid),
intval($uid)
);
if($r)
$ev['event_hash'] = $ical['UID'];
$ev['event_hash'] = $evuid;
else
$ev['external_id'] = $ical['UID'];
$ev['external_id'] = $evuid;
}
if($ical['SUMMARY'] && $ical['DTSTART']) {
if($ev['summary'] && $ev['start']) {
$ev['event_xchan'] = $channel['channel_hash'];
$ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id'];
$ev['private'] = 1;
$ev['allow_cid'] = '<' . $channel['channel_hash'] . '>';
logger('storing event: ' . print_r($ev,true), LOGGER_ALL);
$event = event_store_event($ev);

View File

@ -866,7 +866,7 @@ function get_item_elements($x) {
$arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : '');
$arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode($x['diaspora_signature']) : '');
$arr['diaspora_meta'] = (($x['diaspora_signature']) ? $x['diaspora_signature'] : '');
$arr['object'] = activity_sanitise($x['object']);
$arr['target'] = activity_sanitise($x['target']);
@ -3765,10 +3765,9 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$author['owner_avatar'] = $contact['thumb'];
}
if(! is_importable($datarray,$contact))
if(! post_is_importable($datarray,$contact))
continue;
logger('consume_feed: author ' . print_r($author,true),LOGGER_DEBUG);
logger('consume_feed: ' . print_r($datarray,true),LOGGER_DATA);

View File

@ -113,11 +113,9 @@ function notifier_run($argv, $argc){
intval($r[0]['abook_channel'])
);
if($s) {
if($r[0]['hubloc_network'] === 'diaspora' || $r[0]['hubloc_network'] === 'friendica-over-diaspora') {
require_once('include/diaspora.php');
diaspora_share($s[0],$r[0]);
}
else {
$perm_update = array('sender' => $s[0], 'recipient' => $r[0], 'success' => false);
call_hooks('permissions_update',$perm_update);
if(! $perm_update['success']) {
// send a refresh message to each hub they have registered here
$h = q("select * from hubloc where hubloc_hash = '%s'
and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0",
@ -606,18 +604,9 @@ function notifier_run($argv, $argc){
foreach($dhubs as $hub) {
if($hub['hubloc_network'] === 'diaspora' || $hub['hubloc_network'] === 'friendica-over-diaspora') {
if(! get_config('system','diaspora_enabled'))
continue;
if($hub['hubloc_network'] !== 'zot') {
// allow this to be set per message
if(strpos($target_item['postopts'],'nodspr') !== false)
continue;
require_once('include/diaspora.php');
diaspora_process_outbound(array(
$narr = array(
'channel' => $channel,
'env_recips' => $env_recips,
'recipients' => $recipients,
@ -638,13 +627,14 @@ function notifier_run($argv, $argc){
'normal_mode' => $normal_mode,
'packet_type' => $packet_type,
'walltowall' => $walltowall
));
);
call_hooks('notifier_hub',$narr);
continue;
}
// default: zot protocol

View File

@ -55,6 +55,17 @@ function photo_upload($channel, $observer, $args) {
$str_group_deny = perms2str(((is_array($args['group_deny'])) ? $args['group_deny'] : explode(',',$args['group_deny'])));
$str_contact_deny = perms2str(((is_array($args['contact_deny'])) ? $args['contact_deny'] : explode(',',$args['contact_deny'])));
if( (! array_key_exists('group_allow',$args))
&& (! array_key_exists('contact_allow',$args))
&& (! array_key_exists('group_deny',$args))
&& (! array_key_exists('contact_deny',$args))) {
$str_group_allow = $channel['channel_allow_gid'];
$str_contact_allow = $channel['channel_allow_cid'];
$str_group_deny = $channel['channel_deny_gid'];
$str_contact_deny = $channel['channel_deny_cid'];
}
$os_storage = 0;
if($args['os_path'] && $args['getimagesize']) {

View File

@ -114,20 +114,18 @@ function RedCollectionData($file, &$auth) {
$permission_error = false;
for ($x = 1; $x < count($path_arr); $x++) {
$r = q("SELECT id, hash, filename, flags FROM attach WHERE folder = '%s' AND filename = '%s' AND uid = %d AND (flags & %d)>0 $perms LIMIT 1",
$r = q("SELECT id, hash, filename, flags, is_dir FROM attach WHERE folder = '%s' AND filename = '%s' AND uid = %d AND is_dir != 0 $perms LIMIT 1",
dbesc($folder),
dbesc($path_arr[$x]),
intval($channel_id),
intval(ATTACH_FLAG_DIR)
intval($channel_id)
);
if (! $r) {
// path wasn't found. Try without permissions to see if it was the result of permissions.
$errors = true;
$r = q("select id, hash, filename, flags from attach where folder = '%s' and filename = '%s' and uid = %d and (flags & %d)>0 limit 1",
$r = q("select id, hash, filename, flags, is_dir from attach where folder = '%s' and filename = '%s' and uid = %d and is_dir != 0 limit 1",
dbesc($folder),
basename($path_arr[$x]),
intval($channel_id),
intval(ATTACH_FLAG_DIR)
intval($channel_id)
);
if ($r) {
$permission_error = true;
@ -135,7 +133,7 @@ function RedCollectionData($file, &$auth) {
break;
}
if ($r && ($r[0]['flags'] & ATTACH_FLAG_DIR)) {
if ($r && intval($r[0]['is_dir'])) {
$folder = $r[0]['hash'];
$path = $path . '/' . $r[0]['filename'];
}
@ -161,18 +159,17 @@ function RedCollectionData($file, &$auth) {
$prefix = '';
$suffix = 'GROUP BY filename';
}
$r = q("select $prefix id, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited from attach where folder = '%s' and uid = %d $perms $suffix",
$r = q("select $prefix id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, created, edited from attach where folder = '%s' and uid = %d $perms $suffix",
dbesc($folder),
intval($channel_id)
);
foreach ($r as $rr) {
//logger('filename: ' . $rr['filename'], LOGGER_DEBUG);
if ($rr['flags'] & ATTACH_FLAG_DIR) {
// @todo can't we drop '/cloud'? it gets stripped off anyway in RedDirectory
$ret[] = new RedDAV\RedDirectory('/cloud' . $path . '/' . $rr['filename'], $auth);
if (intval($rr['is_dir'])) {
$ret[] = new RedDAV\RedDirectory($path . '/' . $rr['filename'], $auth);
} else {
$ret[] = new RedDAV\RedFile('/cloud' . $path . '/' . $rr['filename'], $rr, $auth);
$ret[] = new RedDAV\RedFile($path . '/' . $rr['filename'], $rr, $auth);
}
}
@ -199,6 +196,12 @@ function RedFileData($file, &$auth, $test = false) {
if ($x === 0) {
$file = substr($file, 6);
}
else {
$x = strpos($file,'/dav');
if($x === 0)
$file = substr($file,4);
}
if ((! $file) || ($file === '/')) {
return new RedDAV\RedDirectory('/', $auth);
@ -236,19 +239,18 @@ function RedFileData($file, &$auth, $test = false) {
$errors = false;
for ($x = 1; $x < count($path_arr); $x++) {
$r = q("select id, hash, filename, flags from attach where folder = '%s' and filename = '%s' and uid = %d and (flags & %d)>0 $perms",
$r = q("select id, hash, filename, flags, is_dir from attach where folder = '%s' and filename = '%s' and uid = %d and is_dir != 0 $perms",
dbesc($folder),
dbesc($path_arr[$x]),
intval($channel_id),
intval(ATTACH_FLAG_DIR)
intval($channel_id)
);
if ($r && ( $r[0]['flags'] & ATTACH_FLAG_DIR)) {
if ($r && intval($r[0]['is_dir'])) {
$folder = $r[0]['hash'];
$path = $path . '/' . $r[0]['filename'];
}
if (! $r) {
$r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited from attach
$r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
where folder = '%s' and filename = '%s' and uid = %d $perms order by filename limit 1",
dbesc($folder),
dbesc(basename($file)),
@ -257,7 +259,7 @@ function RedFileData($file, &$auth, $test = false) {
}
if (! $r) {
$errors = true;
$r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited from attach
$r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, is_dir, os_storage, created, edited from attach
where folder = '%s' and filename = '%s' and uid = %d order by filename limit 1",
dbesc($folder),
dbesc(basename($file)),
@ -272,7 +274,7 @@ function RedFileData($file, &$auth, $test = false) {
if ($test)
return true;
// final component was a directory.
return new RedDAV\RedDirectory('/cloud/' . $file, $auth);
return new RedDAV\RedDirectory($file, $auth);
}
if ($errors) {
@ -290,11 +292,10 @@ function RedFileData($file, &$auth, $test = false) {
if ($test)
return true;
if ($r[0]['flags'] & ATTACH_FLAG_DIR) {
// @todo can't we drop '/cloud'? it gets stripped off anyway in RedDirectory
return new RedDAV\RedDirectory('/cloud' . $path . '/' . $r[0]['filename'], $auth);
if (intval($r[0]['is_dir'])) {
return new RedDAV\RedDirectory($path . '/' . $r[0]['filename'], $auth);
} else {
return new RedDAV\RedFile('/cloud' . $path . '/' . $r[0]['filename'], $r[0], $auth);
return new RedDAV\RedFile($path . '/' . $r[0]['filename'], $r[0], $auth);
}
}
return false;

View File

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1144 );
define( 'UPDATE_VERSION' , 1145 );
/**
*
@ -1666,4 +1666,24 @@ function update_r1143() {
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
function update_r1144() {
$r = q("select flags, id from attach where flags != 0");
if($r) {
foreach($r as $rr) {
if($rr['flags'] & 1) {
q("update attach set is_dir = 1 where id = %d",
intval($rr['id'])
);
}
if($rr['flags'] & 2) {
q("update attach set os_storage = 1 where id = %d",
intval($rr['id'])
);
}
}
}
return UPDATE_SUCCESS;
}

View File

@ -491,7 +491,7 @@ function events_content(&$a) {
'$export' => array($a->get_baseurl()."/events/$y/$m/export",t('Export'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
'$upload' => t('Upload'),
'$upload' => t('Import'),
'$submit' => t('Submit')
));

View File

@ -117,7 +117,7 @@ function filestorage_content(&$a) {
}
$file = intval(argv(2));
$r = q("select id, uid, folder, filename, revision, flags, hash, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and uid = %d limit 1",
$r = q("select id, uid, folder, filename, revision, flags, is_dir, os_storage, hash, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and uid = %d limit 1",
intval($file),
intval($owner)
);
@ -125,11 +125,11 @@ function filestorage_content(&$a) {
$f = $r[0];
$channel = $a->get_channel();
$cloudpath = get_cloudpath($f) . (($f['flags'] & ATTACH_FLAG_DIR) ? '?f=&davguest=1' : '');
$cloudpath = get_cloudpath($f) . (intval($f['is_dir']) ? '?f=&davguest=1' : '');
$parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']);
$aclselect_e = populate_acl($f, false);
$is_a_dir = (($f['flags'] & ATTACH_FLAG_DIR) ? true : false);
$is_a_dir = (intval($f['is_dir']) ? true : false);
$lockstate = (($f['allow_cid'] || $f['allow_gid'] || $f['deny_cid'] || $f['deny_gid']) ? 'lock' : 'unlock');

View File

@ -1,51 +0,0 @@
<?php /** @file */
require_once('include/bb2diaspora.php');
// used in Diaspora communications to provide a server copy of a sent post in XML format.
function p_init(&$a) {
if(argc() < 2)
http_status_exit(401);
$mid = str_replace('.xml','',argv(1));
$r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1",
dbesc($mid)
);
if((! $r) || (! perm_is_allowed($r[0]['uid'],'','view_stream')))
http_status_exit(404);
$c = q("select * from channel where channel_id = %d limit 1",
intval($r[0]['uid'])
);
if(! $c)
http_status_exit(404);
$myaddr = $c[0]['channel_address'] . '@' . $a->get_hostname();
$item = $r[0];
$title = $item['title'];
$body = bb2diaspora_itembody($item);
$created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
$tpl = get_markup_template('diaspora_post.tpl');
$msg = replace_macros($tpl, array(
'$body' => xmlify($body),
'$guid' => $item['mid'],
'$handle' => xmlify($myaddr),
'$public' => 'true',
'$created' => $created,
'$provider' => (($item['app']) ? $item['app'] : t('$projectname'))
));
header('Content-type: text/xml');
echo $msg;
killme();
}

View File

@ -1,76 +0,0 @@
<?php
/**
* Diaspora endpoint
*/
require_once('include/crypto.php');
require_once('include/diaspora.php');
function receive_post(&$a) {
$enabled = intval(get_config('system','diaspora_enabled'));
if(! $enabled) {
logger('mod-diaspora: disabled');
http_status_exit(500);
}
$public = false;
if((argc() == 2) && (argv(1) === 'public')) {
$public = true;
}
else {
if(argc() != 3 || argv(1) !== 'users')
http_status_exit(500);
$guid = argv(2);
// Diaspora sites *may* provide a truncated guid.
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND channel_removed = 0 LIMIT 1",
dbesc($guid . '%')
);
if(! $r)
http_status_exit(500);
$importer = $r[0];
}
// It is an application/x-www-form-urlencoded that has been urlencoded twice.
logger('mod-diaspora: receiving post', LOGGER_DEBUG);
$xml = urldecode($_POST['xml']);
logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
if(! $xml)
http_status_exit(500);
logger('mod-diaspora: message is okay', LOGGER_DEBUG);
$msg = diaspora_decode($importer,$xml);
logger('mod-diaspora: decoded', LOGGER_DEBUG);
logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
if(! is_array($msg))
http_status_exit(500);
logger('mod-diaspora: dispatching', LOGGER_DEBUG);
$ret = 0;
if($public)
diaspora_dispatch_public($msg);
else
$ret = diaspora_dispatch($importer,$msg);
http_status_exit(($ret) ? $ret : 200);
// NOTREACHED
}

View File

@ -1 +1 @@
2015-07-27.1106
2015-08-02.1112

View File

@ -3,7 +3,7 @@
<h2>{{$title}}</h2>
<div class="pull-right">
<button class="btn btn-xs" onclick="window.location.href='{{$new_event.0}}'; return false;" >{{$new_event.1}}</button>&nbsp;<button class="btn btn-xs" onclick="exportDate(); return false;" >{{$export.1}}</button>&nbsp;<button class="btn btn-xs btn-success" onclick="openClose('event-upload-form');"><i class="icon-upload"></i>&nbsp;{{$upload}}</button>
<button class="btn btn-xs" onclick="window.location.href='{{$new_event.0}}'; return false;" >{{$new_event.1}}</button>&nbsp;<button class="btn btn-xs" onclick="exportDate(); return false;" ><i class="icon-download"></i>&nbsp;{{$export.1}}</button>&nbsp;<button class="btn btn-xs" onclick="openClose('event-upload-form');"><i class="icon-upload"></i>&nbsp;{{$upload}}</button>
</div>
<div id="event-upload-form" style="display:none;">