aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Img_filesize.php121
-rw-r--r--Zotlabs/Module/Apps.php5
-rw-r--r--Zotlabs/Module/Connedit.php2
-rw-r--r--Zotlabs/Module/Feed.php9
-rw-r--r--Zotlabs/Module/Network.php18
-rw-r--r--Zotlabs/Module/Ofeed.php9
-rw-r--r--Zotlabs/Module/Profile_photo.php7
-rw-r--r--Zotlabs/Module/Settings/Featured.php24
-rw-r--r--Zotlabs/Storage/Directory.php2
-rw-r--r--Zotlabs/Thumbs/Video.php16
-rw-r--r--Zotlabs/Web/Router.php6
-rw-r--r--Zotlabs/Widget/Affinity.php14
-rw-r--r--Zotlabs/Widget/Notifications.php1
13 files changed, 189 insertions, 45 deletions
diff --git a/Zotlabs/Lib/Img_filesize.php b/Zotlabs/Lib/Img_filesize.php
new file mode 100644
index 000000000..e7bef37e1
--- /dev/null
+++ b/Zotlabs/Lib/Img_filesize.php
@@ -0,0 +1,121 @@
+<?php
+
+namespace Zotlabs\Lib;
+
+class Img_filesize {
+
+ private $url;
+
+ function __construct($url) {
+ $this->url = $url;
+ }
+
+ function getSize() {
+ $size = null;
+
+ if(stripos($this->url,z_root() . '/photo') !== false) {
+ $size = self::getLocalFileSize($this->url);
+ }
+ if(! $size) {
+ $size = getRemoteFileSize($this->url);
+ }
+
+ return $size;
+ }
+
+
+ static function getLocalFileSize($url) {
+
+ $fname = basename($url);
+ $resolution = 0;
+
+ if(strpos($fname,'.') !== false)
+ $fname = substr($fname,0,strpos($fname,'.'));
+
+ if(substr($fname,-2,1) == '-') {
+ $resolution = intval(substr($fname,-1,1));
+ $fname = substr($fname,0,-2);
+ }
+
+ $r = q("SELECT filesize FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
+ dbesc($fname),
+ intval($resolution)
+ );
+ if($r) {
+ return $r[0]['filesize'];
+ }
+ return null;
+ }
+
+}
+
+/**
+ * Try to determine the size of a remote file by making an HTTP request for
+ * a byte range, or look for the content-length header in the response.
+ * The function aborts the transfer as soon as the size is found, or if no
+ * length headers are returned, it aborts the transfer.
+ *
+ * @return int|null null if size could not be determined, or length of content
+ */
+function getRemoteFileSize($url)
+{
+ $ch = curl_init($url);
+
+ $headers = array(
+ 'Range: bytes=0-1',
+ 'Connection: close',
+ );
+
+ $in_headers = true;
+ $size = null;
+
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2450.0 Iron/46.0.2450.0');
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_VERBOSE, 0); // set to 1 to debug
+ curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'r'));
+
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $line) use (&$in_headers, &$size) {
+ $length = strlen($line);
+
+ if (trim($line) == '') {
+ $in_headers = false;
+ }
+
+ list($header, $content) = explode(':', $line, 2);
+ $header = strtolower(trim($header));
+
+ if ($header == 'content-range') {
+ // found a content-range header
+ list($rng, $s) = explode('/', $content, 2);
+ $size = (int)$s;
+ return 0; // aborts transfer
+ } else if ($header == 'content-length' && 206 != curl_getinfo($curl, CURLINFO_HTTP_CODE)) {
+ // found content-length header and this is not a 206 Partial Content response (range response)
+ $size = (int)$content;
+ return 0;
+ } else {
+ // continue
+ return $length;
+ }
+ });
+
+ curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($curl, $data) use ($in_headers) {
+ if (!$in_headers) {
+ // shouldn't be here unless we couldn't determine file size
+ // abort transfer
+ return 0;
+ }
+
+ // write function is also called when reading headers
+ return strlen($data);
+ });
+
+ $result = curl_exec($ch);
+ $info = curl_getinfo($ch);
+
+ return $size;
+} \ No newline at end of file
diff --git a/Zotlabs/Module/Apps.php b/Zotlabs/Module/Apps.php
index 2f61f2932..c672ea467 100644
--- a/Zotlabs/Module/Apps.php
+++ b/Zotlabs/Module/Apps.php
@@ -22,7 +22,8 @@ class Apps extends \Zotlabs\Web\Controller {
if(local_channel()) {
Zlib\Apps::import_system_apps();
$syslist = array();
- $list = Zlib\Apps::app_list(local_channel(), (($mode == 'edit') ? true : false), $_GET['cat']);
+ $cat = ((array_key_exists('cat',$_GET) && $_GET['cat']) ? [ escape_tags($_GET['cat']) ] : '');
+ $list = Zlib\Apps::app_list(local_channel(), (($mode == 'edit') ? true : false), $cat);
if($list) {
foreach($list as $x) {
$syslist[] = Zlib\Apps::app_encode($x);
@@ -43,7 +44,7 @@ class Apps extends \Zotlabs\Web\Controller {
return replace_macros(get_markup_template('myapps.tpl'), array(
'$sitename' => get_config('system','sitename'),
- '$cat' => ((array_key_exists('cat',$_GET) && $_GET['cat']) ? escape_tags($_GET['cat']) : ''),
+ '$cat' => $cat,
'$title' => t('Apps'),
'$apps' => $apps,
'$authed' => ((local_channel()) ? true : false),
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index 23c5282e3..e0511b0d3 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -567,7 +567,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$contact_id = \App::$poi['abook_id'];
$contact = \App::$poi;
- $cn = q("SELECT abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 order by xchan_name",
+ $cn = q("SELECT abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 order by xchan_name",
intval(local_channel())
);
diff --git a/Zotlabs/Module/Feed.php b/Zotlabs/Module/Feed.php
index 06637b6d2..36869abbe 100644
--- a/Zotlabs/Module/Feed.php
+++ b/Zotlabs/Module/Feed.php
@@ -16,12 +16,15 @@ class Feed extends \Zotlabs\Web\Controller {
$params['type'] = ((stristr(argv(0),'json')) ? 'json' : 'xml');
$params['pages'] = ((x($_REQUEST,'pages')) ? intval($_REQUEST['pages']) : 0);
$params['top'] = ((x($_REQUEST,'top')) ? intval($_REQUEST['top']) : 0);
- $params['start'] = ((x($params,'start')) ? intval($params['start']) : 0);
- $params['records'] = ((x($params,'records')) ? intval($params['records']) : 40);
- $params['direction'] = ((x($params,'direction')) ? dbesc($params['direction']) : 'desc');
+ $params['start'] = ((x($_REQUEST,'start')) ? intval($_REQUEST['start']) : 0);
+ $params['records'] = ((x($_REQUEST,'records')) ? intval($_REQUEST['records']) : 40);
+ $params['direction'] = ((x($_REQUEST,'direction')) ? dbesc($_REQUEST['direction']) : 'desc');
$params['cat'] = ((x($_REQUEST,'cat')) ? escape_tags($_REQUEST['cat']) : '');
$params['compat'] = ((x($_REQUEST,'compat')) ? intval($_REQUEST['compat']) : 0);
+ if(! in_array($params['direction'],['asc','desc'])) {
+ $params['direction'] = 'desc';
+ }
if(argc() > 1) {
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 4deb7c9e8..551303984 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -35,9 +35,12 @@ class Network extends \Zotlabs\Web\Controller {
return login(false);
}
- if($load)
+ $o = '';
+
+ if($load) {
$_SESSION['loadtime'] = datetime_convert();
-
+ }
+
$arr = array('query' => \App::$query_string);
call_hooks('network_content_init', $arr);
@@ -104,8 +107,10 @@ class Network extends \Zotlabs\Web\Controller {
$def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
}
- $o = '';
+ $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
+ $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
+
// if no tabs are selected, defaults to comments
@@ -115,8 +120,8 @@ class Network extends \Zotlabs\Web\Controller {
$liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0);
$conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0);
$spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0);
- $cmin = ((x($_GET,'cmin')) ? intval($_GET['cmin']) : 0);
- $cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
+ $cmin = ((array_key_exists('cmin',$_GET)) ? intval($_GET['cmin']) : $default_cmin);
+ $cmax = ((array_key_exists('cmax',$_GET)) ? intval($_GET['cmax']) : $default_cmax);
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
$xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : '');
$net = ((x($_GET,'net')) ? $_GET['net'] : '');
@@ -404,7 +409,6 @@ class Network extends \Zotlabs\Web\Controller {
if($cmax == 99)
$sql_nets .= " OR abook.abook_closeness IS NULL ) ";
-
}
$net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : '');
@@ -473,7 +477,6 @@ class Network extends \Zotlabs\Web\Controller {
if($load) {
// Fetch a page full of parent items for this page
-
$r = q("SELECT distinct item.id AS item_id, $ordering FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
$net_query
@@ -484,7 +487,6 @@ class Network extends \Zotlabs\Web\Controller {
$net_query2
ORDER BY $ordering DESC $pager_sql "
);
-
}
else {
diff --git a/Zotlabs/Module/Ofeed.php b/Zotlabs/Module/Ofeed.php
index 58488d4af..d18a43ae5 100644
--- a/Zotlabs/Module/Ofeed.php
+++ b/Zotlabs/Module/Ofeed.php
@@ -17,12 +17,15 @@ class Ofeed extends \Zotlabs\Web\Controller {
$params['type'] = ((stristr(argv(0),'json')) ? 'json' : 'xml');
$params['pages'] = ((x($_REQUEST,'pages')) ? intval($_REQUEST['pages']) : 0);
$params['top'] = ((x($_REQUEST,'top')) ? intval($_REQUEST['top']) : 0);
- $params['start'] = ((x($params,'start')) ? intval($params['start']) : 0);
- $params['records'] = ((x($params,'records')) ? intval($params['records']) : 10);
- $params['direction'] = ((x($params,'direction')) ? dbesc($params['direction']) : 'desc');
+ $params['start'] = ((x($_REQUEST,'start')) ? intval($_REQUEST['start']) : 0);
+ $params['records'] = ((x($_REQUEST,'records')) ? intval($_REQUEST['records']) : 10);
+ $params['direction'] = ((x($_REQUEST,'direction')) ? dbesc($_REQUEST['direction']) : 'desc');
$params['cat'] = ((x($_REQUEST,'cat')) ? escape_tags($_REQUEST['cat']) : '');
$params['compat'] = ((x($_REQUEST,'compat')) ? intval($_REQUEST['compat']) : 1);
+ if(! in_array($params['direction'],['asc','desc'])) {
+ $params['direction'] = 'desc';
+ }
if(argc() > 1) {
diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php
index 411518c61..45a606d5f 100644
--- a/Zotlabs/Module/Profile_photo.php
+++ b/Zotlabs/Module/Profile_photo.php
@@ -179,7 +179,10 @@ class Profile_photo extends \Zotlabs\Web\Controller {
);
}
- profiles_build_sync(local_channel());
+ // set $send to false in profiles_build_sync() to return the data
+ // so that we only send one sync packet.
+
+ $sync_profiles = profiles_build_sync(local_channel(),false);
// We'll set the updated profile-photo timestamp even if it isn't the default profile,
// so that browsers will do a cache update unconditionally
@@ -201,7 +204,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$base_image['resource_id']);
if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ build_sync_packet($channel['channel_id'],array('file' => array($sync), 'profile' => $sync_profiles));
// Similarly, tell the nav bar to bypass the cache and update the avatar image.
diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php
index ebe2996d3..9c5a7b16c 100644
--- a/Zotlabs/Module/Settings/Featured.php
+++ b/Zotlabs/Module/Settings/Featured.php
@@ -11,15 +11,17 @@ class Featured {
call_hooks('feature_settings_post', $_POST);
if($_POST['affinity_slider-submit']) {
- if(intval($_POST['affinity_cmax'])) {
- set_pconfig(local_channel(),'affinity','cmax',intval($_POST['affinity_cmax']));
- }
- if(intval($_POST['affinity_cmin'])) {
- set_pconfig(local_channel(),'affinity','cmin',intval($_POST['affinity_cmin']));
- }
- if(intval($_POST['affinity_cmax']) || intval($_POST['affinity_cmin'])) {
- info( t('Affinity Slider settings updated.') . EOL);
- }
+ $cmax = intval($_POST['affinity_cmax']);
+ if($cmax < 0 || $cmax > 99)
+ $cmax = 99;
+ $cmin = intval($_POST['affinity_cmin']);
+ if($cmin < 0 || $cmin > 99)
+ $cmin = 0;
+ set_pconfig(local_channel(),'affinity','cmin',$cmin);
+ set_pconfig(local_channel(),'affinity','cmax',$cmax);
+
+ info( t('Affinity Slider settings updated.') . EOL);
+
}
build_sync_packet();
@@ -40,12 +42,12 @@ class Featured {
$cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
$cmax = (($cmax) ? $cmax : 99);
$setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, '')
+ '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
));
$cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
$cmin = (($cmin) ? $cmin : 0);
$setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, '')
+ '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0'))
));
$settings_addons .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php
index 63ff4341c..510d463c1 100644
--- a/Zotlabs/Storage/Directory.php
+++ b/Zotlabs/Storage/Directory.php
@@ -691,7 +691,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
}
$prefix = '';
- $suffix = '';
+ $suffix = ' order by is_dir desc, filename asc ';
$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),
diff --git a/Zotlabs/Thumbs/Video.php b/Zotlabs/Thumbs/Video.php
index 5e09ef9a3..05127355e 100644
--- a/Zotlabs/Thumbs/Video.php
+++ b/Zotlabs/Thumbs/Video.php
@@ -32,12 +32,24 @@ class Video {
fclose($ostream);
}
+ /*
+ * Note: imagick convert may try to call 'ffmpeg' (or other conversion utilities) under
+ * the covers for this particular operation. If this is not installed or not in the path
+ * for the web server user, errors may be reported in the web server logs.
+ */
+
+
+ $ffmpeg = trim(shell_exec('which ffmpeg'));
+ if($ffmpeg) {
+ logger('ffmpeg not found in path. Video thumbnails may fail.');
+ }
+
$imagick_path = get_config('system','imagick_convert_path');
if($imagick_path && @file_exists($imagick_path)) {
$cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -thumbnail ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile);
// logger('imagick thumbnail command: ' . $cmd);
- exec($cmd);
+ @exec($cmd);
if(! file_exists($outfile)) {
logger('imagick scale failed.');
@@ -46,7 +58,7 @@ class Video {
@rename($outfile,$file . '.thumb');
}
}
-
+
@unlink($tmpfile);
}
}
diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php
index 12ef315d4..a6b780cdc 100644
--- a/Zotlabs/Web/Router.php
+++ b/Zotlabs/Web/Router.php
@@ -265,7 +265,7 @@ class Router {
if(! \App::$error) {
$arr = array('content' => \App::$page['content'], 'replace' => false);
call_hooks(\App::$module . '_mod_content', $arr);
- \App::$page['content'] = $arr['content'];
+
if(! $arr['replace']) {
if($this->controller && method_exists($this->controller,'get')) {
$arr = array('content' => $this->controller->get());
@@ -276,8 +276,8 @@ class Router {
}
}
call_hooks(\App::$module . '_mod_aftercontent', $arr);
- \App::$page['content'] .= $arr['content'];
+ \App::$page['content'] = (($arr['replace']) ? $arr['content'] : \App::$page['content'] . $arr['content']);
}
}
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Widget/Affinity.php b/Zotlabs/Widget/Affinity.php
index 439ba1f33..4fb2874ae 100644
--- a/Zotlabs/Widget/Affinity.php
+++ b/Zotlabs/Widget/Affinity.php
@@ -9,15 +9,11 @@ class Affinity {
if(! local_channel())
return '';
- // Get default cmin value from pconfig, but allow GET parameter to override
- $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
- $cmin = (($cmin) ? $cmin : 0);
- $cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : $cmin);
-
- // Get default cmax value from pconfig, but allow GET parameter to override
- $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
- $cmax = (($cmax) ? $cmax : 99);
- $cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : $cmax);
+ $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
+ $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
+
+ $cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : $default_cmin);
+ $cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : $default_cmax);
if(feature_enabled(local_channel(),'affinity')) {
diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php
index a677d84c9..5a0c1f3d5 100644
--- a/Zotlabs/Widget/Notifications.php
+++ b/Zotlabs/Widget/Notifications.php
@@ -144,6 +144,7 @@ class Notifications {
$o = replace_macros(get_markup_template('notifications_widget.tpl'), array(
'$module' => \App::$module,
'$notifications' => $notifications,
+ '$no_notifications' => t('Sorry, you have got no notifications at the moment'),
'$loading' => t('Loading')
));