aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/attach.php19
-rw-r--r--include/bbcode.php2
-rw-r--r--include/conversation.php9
-rw-r--r--include/help.php5
-rw-r--r--include/import.php3
-rwxr-xr-xinclude/items.php3
-rw-r--r--include/message.php20
-rwxr-xr-xinclude/oembed.php63
-rw-r--r--include/photo/photo_driver.php11
-rw-r--r--include/widgets.php8
-rw-r--r--include/zot.php3
11 files changed, 96 insertions, 50 deletions
diff --git a/include/attach.php b/include/attach.php
index 237b06217..f832427bb 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -709,6 +709,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$os_relpath .= $hash;
+ // not yet used
+ $os_path = '';
+
if($src)
@file_put_contents($os_basepath . $os_relpath,@file_get_contents($src));
@@ -723,7 +726,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$edited = $created;
if($options === 'replace') {
- $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, content = '%s', edited = '%s' where id = %d and uid = %d",
+ $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, content = '%s', edited = '%s', os_path = '%s' where id = %d and uid = %d",
dbesc($filename),
dbesc($mimetype),
dbesc($folder_hash),
@@ -732,13 +735,14 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
intval($is_photo),
dbesc($os_basepath . $os_relpath),
dbesc($created),
+ dbesc($os_path),
intval($existing_id),
intval($channel_id)
);
}
elseif($options === 'revise') {
- $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid, deny_cid, deny_gid )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($x[0]['aid']),
intval($channel_id),
dbesc($x[0]['hash']),
@@ -753,6 +757,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($os_basepath . $os_relpath),
dbesc($created),
dbesc($created),
+ dbesc($os_path),
dbesc($x[0]['allow_cid']),
dbesc($x[0]['allow_gid']),
dbesc($x[0]['deny_cid']),
@@ -760,7 +765,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
elseif($options === 'update') {
- $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', edited = '%s', os_storage = %d, is_photo = %d,
+ $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', edited = '%s', os_storage = %d, is_photo = %d, os_path = '%s',
allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where id = %d and uid = %d",
dbesc((array_key_exists('filename',$arr)) ? $arr['filename'] : $x[0]['filename']),
dbesc((array_key_exists('filetype',$arr)) ? $arr['filetype'] : $x[0]['filetype']),
@@ -768,6 +773,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($created),
dbesc((array_key_exists('os_storage',$arr)) ? $arr['os_storage'] : $x[0]['os_storage']),
dbesc((array_key_exists('is_photo',$arr)) ? $arr['is_photo'] : $x[0]['is_photo']),
+ dbesc((array_key_exists('os_path',$arr)) ? $arr['os_path'] : $x[0]['os_path']),
dbesc((array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $x[0]['allow_cid']),
dbesc((array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $x[0]['allow_gid']),
dbesc((array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $x[0]['deny_cid']),
@@ -778,8 +784,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
else {
- $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, allow_cid, allow_gid,deny_cid, deny_gid )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid,deny_cid, deny_gid )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($channel['channel_account_id']),
intval($channel_id),
dbesc($hash),
@@ -794,6 +800,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($os_basepath . $os_relpath),
dbesc($created),
dbesc($created),
+ dbesc($os_path),
dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $str_contact_allow),
dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $str_group_allow),
dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $str_contact_deny),
diff --git a/include/bbcode.php b/include/bbcode.php
index 70c75e5c4..45dd5ef24 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -15,7 +15,7 @@ function tryoembed($match) {
$o = oembed_fetch_url($url);
- if ($o->type == 'error')
+ if ($o['type'] == 'error')
return $match[0];
$html = oembed_format_object($o);
diff --git a/include/conversation.php b/include/conversation.php
index 62b22e893..287dd4983 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -712,10 +712,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
'forged' => $forged,
'txt_cats' => t('Categories:'),
'txt_folders' => t('Filed under:'),
- 'has_cats' => ((count($categories)) ? 'true' : ''),
- 'has_folders' => ((count($folders)) ? 'true' : ''),
- 'categories' => $categories,
- 'folders' => $folders,
+ 'has_cats' => ((count($body['categories'])) ? 'true' : ''),
+ 'has_folders' => ((count($body['folders'])) ? 'true' : ''),
'text' => strip_tags($body['html']),
'ago' => relative_date($item['created']),
'app' => $item['app'],
@@ -1053,6 +1051,9 @@ function builtin_activity_puller($item, &$conv_responses) {
$conv_responses[$mode][$item['thr_parent']] ++;
$conv_responses[$mode][$item['thr_parent'] . '-l'][] = $url;
+ if(get_observer_hash() && get_observer_hash() === $item['author_xchan']) {
+ $conv_responses[$mode][$item['thr_parent'] . '-m'] = true;
+ }
// there can only be one activity verb per item so if we found anything, we can stop looking
return;
diff --git a/include/help.php b/include/help.php
index 5538fbc1e..3081ae41f 100644
--- a/include/help.php
+++ b/include/help.php
@@ -37,7 +37,10 @@ function get_help_content($tocpath = false) {
$doctype = 'html';
}
}
-
+
+ if(($tocpath) && (! $text))
+ return '';
+
if($tocpath === false) {
if(! $text) {
$text = load_doc_file('doc/Site.md');
diff --git a/include/import.php b/include/import.php
index 3b434c935..1d636bfbd 100644
--- a/include/import.php
+++ b/include/import.php
@@ -1217,6 +1217,9 @@ function sync_files($channel,$files) {
$p['content'] = base64_decode($p['content']);
+ if(!isset($p['display_path']))
+ $p['display_path'] = '';
+
$exists = q("select * from photo where resource_id = '%s' and imgscale = %d and uid = %d limit 1",
dbesc($p['resource_id']),
intval($p['imgscale']),
diff --git a/include/items.php b/include/items.php
index fd9fc05ff..c62d53c3e 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1590,6 +1590,9 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
$arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 );
$arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 );
+ // obsolete, but needed so as not to throw not-null constraints on some database driveres
+ $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 );
+
// only detect language if we have text content, and if the post is private but not yet
// obscured, make it so.
diff --git a/include/message.php b/include/message.php
index 0ba1978f0..0829ebaaa 100644
--- a/include/message.php
+++ b/include/message.php
@@ -299,14 +299,30 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
break;
case 'combined':
- $sql = "SELECT * FROM ( SELECT * FROM mail WHERE channel_id = $local_channel ORDER BY created DESC $limit ) AS temp_table GROUP BY parent_mid ORDER BY created DESC";
+ $parents = q("SELECT parent_mid FROM mail WHERE mid = parent_mid AND channel_id = %d ORDER BY created DESC",
+ dbesc($local_channel)
+ );
+ //FIXME: We need the latest mail of a thread here. This query throws errors in postgres. We now look for the latest in php until somebody can fix this...
+ //$sql = "SELECT * FROM ( SELECT * FROM mail WHERE channel_id = $local_channel ORDER BY created DESC $limit ) AS temp_table GROUP BY parent_mid ORDER BY created DESC";
break;
}
}
- $r = q($sql);
+ if($parents) {
+ foreach($parents as $parent) {
+ $all[] = q("SELECT * FROM mail WHERE parent_mid = '%s' AND channel_id = %d ORDER BY created DESC",
+ dbesc($parent['parent_mid']),
+ dbesc($local_channel)
+ );
+ }
+ foreach($all as $single)
+ $r[] = $single[0];
+ }
+ else {
+ $r = q($sql);
+ }
if(! $r) {
return array();
diff --git a/include/oembed.php b/include/oembed.php
index 085637a00..be2501229 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -105,7 +105,7 @@ function oembed_action($embedurl) {
function oembed_process($url) {
$j = oembed_fetch_url($url);
logger('oembed_process: ' . print_r($j,true));
- if($j && $j->type !== 'error')
+ if($j && $j['type'] !== 'error')
return '[embed]' . $url . '[/embed]';
return false;
}
@@ -215,26 +215,29 @@ function oembed_fetch_url($embedurl){
}
- $j = json_decode($txt);
+ $j = json_decode($txt,true);
+
+ if(! $j)
+ $j = [];
if($action === 'filter') {
- if($j->html) {
- $orig = $j->html;
+ if($j['html']) {
+ $orig = $j['html'];
$allow_position = (($zrl) ? true : false);
- $j->html = purify_html($j->html,$allow_position);
- if($j->html != $orig) {
- logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j->html, LOGGER_DEBUG, LOG_INFO);
+ $j['html'] = purify_html($j['html'],$allow_position);
+ if($j['html'] != $orig) {
+ logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j['html'], LOGGER_DEBUG, LOG_INFO);
}
$orig_len = mb_strlen(preg_replace('/\s+/','',$orig));
- $new_len = mb_strlen(preg_replace('/\s+/','',$j->html));
+ $new_len = mb_strlen(preg_replace('/\s+/','',$j['html']));
if(stripos($orig,'<script') || (! $new_len))
- $j->type = 'error';
+ $j['type'] = 'error';
elseif($orig_len) {
$ratio = $new_len / $orig_len;
if($ratio < 0.5) {
- $j->type = 'error';
+ $j['type'] = 'error';
logger('oembed html truncated: ' . $ratio, LOGGER_DEBUG, LOG_INFO);
}
}
@@ -242,7 +245,7 @@ function oembed_fetch_url($embedurl){
}
}
- $j->embedurl = $embedurl;
+ $j['embedurl'] = $embedurl;
// logger('fetch return: ' . print_r($j,true));
@@ -253,27 +256,27 @@ function oembed_fetch_url($embedurl){
function oembed_format_object($j){
- $embedurl = $j->embedurl;
+ $embedurl = $j['embedurl'];
// logger('format: ' . print_r($j,true));
- $jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null));
+ $jhtml = oembed_iframe($j['embedurl'],(isset($j['width']) ? $j['width'] : null), (isset($j['height']) ? $j['height'] : null));
- $ret="<span class='oembed ".$j->type."'>";
- switch ($j->type) {
+ $ret="<span class='oembed " . $j['type'] . "'>";
+ switch ($j['type']) {
case "video": {
- if (isset($j->thumbnail_url)) {
- $tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
- $th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;
+ if (isset($j['thumbnail_url'])) {
+ $tw = (isset($j['thumbnail_width'])) ? $j['thumbnail_width'] : 200;
+ $th = (isset($j['thumbnail_height'])) ? $j['thumbnail_height'] : 180;
$tr = $tw/$th;
$th=120; $tw = $th*$tr;
$tpl=get_markup_template('oembed_video.tpl');
if(strstr($embedurl,'youtu') && strstr(z_root(),'https:')) {
$embedurl = str_replace('http:','https:',$embedurl);
- $j->thumbnail_url = str_replace('http:','https:', $j->thumbnail_url);
+ $j['thumbnail_url'] = str_replace('http:','https:', $j['thumbnail_url']);
$jhtml = str_replace('http:','https:', $jhtml);
- $j->html = str_replace('http:','https:', $j->html);
+ $j['html'] = str_replace('http:','https:', $j['html']);
}
$ret.=replace_macros($tpl, array(
@@ -282,7 +285,7 @@ function oembed_format_object($j){
'$escapedhtml'=>base64_encode($jhtml),
'$tw'=>$tw,
'$th'=>$th,
- '$turl'=>$j->thumbnail_url,
+ '$turl'=> $j['thumbnail_url'],
));
} else {
@@ -291,19 +294,19 @@ function oembed_format_object($j){
$ret.="<br>";
}; break;
case "photo": {
- $ret.= "<img width='".$j->width."' src='".$j->url."'>";
+ $ret.= "<img width='".$j['width']."' src='".$j['url']."'>";
$ret.="<br>";
}; break;
case "link": {
- if($j->thumbnail_url) {
+ if($j['thumbnail_url']) {
if(is_matrix_url($embedurl)) {
$embedurl = zid($embedurl);
- $j->thumbnail_url = zid($j->thumbnail_url);
+ $j['thumbnail_url'] = zid($j['thumbnail_url']);
}
- $ret = '<a href="' . $embedurl . '" ><img src="' . $j->thumbnail_url . '" alt="thumbnail" /></a><br /><br />';
+ $ret = '<a href="' . $embedurl . '" ><img src="' . $j['thumbnail_url'] . '" alt="thumbnail" /></a><br /><br />';
}
- //$ret = "<a href='".$embedurl."'>".$j->title."</a>";
+ //$ret = "<a href='".$embedurl."'>".$j['title']."</a>";
}; break;
case "rich": {
// not so safe..
@@ -312,12 +315,12 @@ function oembed_format_object($j){
}
// add link to source if not present in "rich" type
- if ( $j->type!='rich' || !strpos($j->html,$embedurl) ){
- $embedlink = (isset($j->title))?$j->title:$embedurl;
+ if ( $j['type'] != 'rich' || !strpos($j['html'],$embedurl) ){
+ $embedlink = (isset($j['title']))?$j['title'] : $embedurl;
$ret .= '<br />' . "<a href='$embedurl' rel='oembed'>$embedlink</a>";
$ret .= "<br />";
- if (isset($j->author_name)) $ret.=" by ".$j->author_name;
- if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
+ if (isset($j['author_name'])) $ret .= t(' by ') . $j['author_name'];
+ if (isset($j['provider_name'])) $ret .= t(' on ') . $j['provider_name'];
} else {
// add <a> for html2bbcode conversion
$ret .= "<br /><a href='$embedurl' rel='oembed'>$embedurl</a>";
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 35cf77707..9b6d38cc1 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -328,6 +328,7 @@ abstract class photo_driver {
$p['photo_usage'] = intval($arr['photo_usage']);
$p['os_storage'] = intval($arr['os_storage']);
$p['os_path'] = $arr['os_path'];
+ $p['display_path'] = (($arr['display_path']) ? $arr['display_path'] : '');
if(! intval($p['imgscale']))
logger('save: ' . print_r($arr,true), LOGGER_DATA);
@@ -359,6 +360,7 @@ abstract class photo_driver {
`title` = '%s',
`description` = '%s',
`os_path` = '%s',
+ `display_path` = '%s',
`allow_cid` = '%s',
`allow_gid` = '%s',
`deny_cid` = '%s',
@@ -384,6 +386,7 @@ abstract class photo_driver {
dbesc($p['title']),
dbesc($p['description']),
dbesc($p['os_path']),
+ dbesc($p['display_path']),
dbesc($p['allow_cid']),
dbesc($p['allow_gid']),
dbesc($p['deny_cid']),
@@ -393,8 +396,8 @@ abstract class photo_driver {
}
else {
$r = q("INSERT INTO `photo`
- ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, mimetype, `album`, `height`, `width`, `content`, `os_storage`, `filesize`, `imgscale`, `photo_usage`, `title`, `description`, `os_path`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
+ ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, mimetype, `album`, `height`, `width`, `content`, `os_storage`, `filesize`, `imgscale`, `photo_usage`, `title`, `description`, `os_path`, `display_path`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($p['aid']),
intval($p['uid']),
dbesc($p['xchan']),
@@ -414,6 +417,7 @@ abstract class photo_driver {
dbesc($p['title']),
dbesc($p['description']),
dbesc($p['os_path']),
+ dbesc($p['display_path']),
dbesc($p['allow_cid']),
dbesc($p['allow_gid']),
dbesc($p['deny_cid']),
@@ -423,6 +427,9 @@ abstract class photo_driver {
return $r;
}
+
+ // should be obsolete now
+
public function store($aid, $uid, $xchan, $rid, $filename, $album, $scale, $usage = PHOTO_NORMAL, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
$x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `imgscale` = %d limit 1",
diff --git a/include/widgets.php b/include/widgets.php
index 9cd15dd59..2e1e58717 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1504,7 +1504,9 @@ function widget_helpindex($arr) {
$o .= '<div class="widget">';
$o .= '<h3>' . t('Documentation') . '</h3>';
- $level_0 = get_help_content('toc');
+ $level_0 = get_help_content('sitetoc');
+ if(! $level_0)
+ $level_0 = get_help_content('toc');
$level_0 = preg_replace('/\<ul(.*?)\>/','<ul class="nav nav-pills nav-stacked">',$level_0);
@@ -1515,7 +1517,9 @@ function widget_helpindex($arr) {
$path = '';
for($x = 1; $x < argc(); $x ++) {
$path .= argv($x) . '/';
- $y = get_help_content($path . 'toc');
+ $y = get_help_content($path . 'sitetoc');
+ if(! $y)
+ $y = get_help_content($path . 'toc');
if($y)
$levels[] = preg_replace('/\<ul(.*?)\>/','<ul class="nav nav-pills nav-stacked">',$y);
}
diff --git a/include/zot.php b/include/zot.php
index 49b66bc62..e0a86abc0 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3643,8 +3643,7 @@ function zot_reply_message_request($data) {
if ($messages) {
$env_recips = null;
- $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0 and hubloc_deleted = 0
- group by hubloc_sitekey",
+ $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0 and hubloc_deleted = 0",
dbesc($sender_hash)
);
if (! $r) {