aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Import/Importer.php1
-rw-r--r--include/acl_selectors.php73
-rw-r--r--include/attach.php283
-rw-r--r--include/channel.php187
-rw-r--r--include/config.php4
-rw-r--r--include/datetime.php24
-rw-r--r--include/help.php103
-rwxr-xr-xinclude/items.php96
-rw-r--r--include/network.php128
-rw-r--r--include/photos.php96
-rwxr-xr-xinclude/plugin.php46
-rw-r--r--include/security.php84
-rw-r--r--include/text.php563
-rw-r--r--include/widgets.php95
-rw-r--r--include/zot.php183
15 files changed, 1038 insertions, 928 deletions
diff --git a/include/Import/Importer.php b/include/Import/Importer.php
index cddfac7b5..1fa677db0 100644
--- a/include/Import/Importer.php
+++ b/include/Import/Importer.php
@@ -5,7 +5,6 @@ namespace Hubzilla\Import;
/**
* @brief Class Import
*
- * @package Hubzilla\Import
*/
class Import {
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 362776b44..80d1f1216 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -1,17 +1,24 @@
-<?php /** @file */
+<?php
/**
- *
+ * @file include/acl_selectors.php
+ *
+ * @package acl_selectors
*/
/**
- * @package acl_selectors
+ * @brief
+ *
+ * @param string $selname
+ * @param string $selclass
+ * @param mixed $preselected
+ * @param number $size
+ * @return string
*/
-
-function group_select($selname,$selclass,$preselected = false,$size = 4) {
+function group_select($selname, $selclass, $preselected = false, $size = 4) {
$o = '';
- $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
+ $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\">\r\n";
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel())
@@ -34,19 +41,17 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
$o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$trimmed</option>\r\n";
}
-
+
}
$o .= "</select>\r\n";
call_hooks(App::$module . '_post_' . $selname, $o);
-
return $o;
}
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
-
$o = '';
// When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
@@ -54,17 +59,17 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$sql_extra = '';
- $tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : "");
+ $tabindex = ($tabindex > 0 ? 'tabindex="$tabindex"' : '');
if($privmail)
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex >\r\n";
- else
- $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n";
+ else
+ $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex>\r\n";
$r = q("SELECT abook_id, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash
where abook_self = 0 and abook_channel = %d
$sql_extra
- ORDER BY xchan_name ASC ",
+ ORDER BY xchan_name ASC",
intval(local_channel())
);
@@ -78,15 +83,14 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
if($r) {
foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
- $selected = " selected=\"selected\" ";
+ $selected = ' selected="selected" ';
else
$selected = '';
- $trimmed = mb_substr($rr['xchan_name'],0,20);
+ $trimmed = mb_substr($rr['xchan_name'], 0, 20);
$o .= "<option value=\"{$rr['abook_id']}\" $selected title=\"{$rr['xchan_name']}|{$rr['xchan_url']}\" >$trimmed</option>\r\n";
}
-
}
$o .= "</select>\r\n";
@@ -98,13 +102,13 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
function fixacl(&$item) {
- $item = str_replace(array('<','>'),array('',''),$item);
+ $item = str_replace(array('<', '>'), array('', ''), $item);
}
/**
* Builds a modal dialog for editing permissions, using acl_selector.tpl as the template.
*
-* @param array $default Optional access control list for the initial state of the dialog.
+* @param array $defaults Optional access control list for the initial state of the dialog.
* @param boolean $show_jotnets Whether plugins for federated networks should be included in the permissions dialog
* @param PermissionDescription $emptyACL_description - An optional description for the permission implied by selecting an empty ACL. Preferably an instance of PermissionDescription.
* @param string $dialog_description Optional message to include at the top of the dialog. E.g. "Warning: Post permissions cannot be changed once sent".
@@ -118,16 +122,15 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
$allow_cid = $allow_gid = $deny_cid = $deny_gid = false;
$showall_origin = '';
$showall_icon = 'fa-globe';
- $role = get_pconfig(local_channel(),'system','permissions_role');
+ $role = get_pconfig(local_channel(), 'system', 'permissions_role');
if(! $emptyACL_description) {
$showall_caption = t('Visible to your default audience');
- } else if (is_a($emptyACL_description, '\\Zotlabs\\Lib\\PermissionDescription')) {
+ } else if(is_a($emptyACL_description, '\\Zotlabs\\Lib\\PermissionDescription')) {
$showall_caption = $emptyACL_description->get_permission_description();
$showall_origin = (($role === 'custom') ? $emptyACL_description->get_permission_origin_description() : '');
$showall_icon = $emptyACL_description->get_permission_icon();
-
} else {
// For backwards compatibility we still accept a string... for now!
$showall_caption = $emptyACL_description;
@@ -135,7 +138,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
if(is_array($defaults)) {
- $allow_cid = ((strlen($defaults['allow_cid']))
+ $allow_cid = ((strlen($defaults['allow_cid']))
? explode('><', $defaults['allow_cid']) : array() );
$allow_gid = ((strlen($defaults['allow_gid']))
? explode('><', $defaults['allow_gid']) : array() );
@@ -169,9 +172,9 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
'$select_label' => t('Who can see this?'),
'$custom' => t('Custom selection'),
'$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'),
- '$show' => t("Show"),
+ '$show' => t('Show'),
'$hide' => t("Don't show"),
- '$search' => t("Search"),
+ '$search' => t('Search'),
'$allowcid' => json_encode($allow_cid),
'$allowgid' => json_encode($allow_gid),
'$denycid' => json_encode($deny_cid),
@@ -183,20 +186,19 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
));
return $o;
-
}
/**
-* Returns a string that's suitable for passing as the $dialog_description argument to a
-* populate_acl() call for wall posts or network posts.
-*
-* This string is needed in 3 different files, and our .po translation system currently
-* cannot be used as a string table (because the value is always the key in english) so
-* I've centralized the value here (making this function name the "key") until we have a
-* better way.
-*
-* @return string Description to present to user in modal permissions dialog
-*/
+ * Returns a string that's suitable for passing as the $dialog_description argument to a
+ * populate_acl() call for wall posts or network posts.
+ *
+ * This string is needed in 3 different files, and our .po translation system currently
+ * cannot be used as a string table (because the value is always the key in english) so
+ * I've centralized the value here (making this function name the "key") until we have a
+ * better way.
+ *
+ * @return string Description to present to user in modal permissions dialog
+ */
function get_post_aclDialogDescription() {
// I'm trying to make two points in this description text - warn about finality of wall
@@ -212,4 +214,3 @@ function get_post_aclDialogDescription() {
return sprintf($description, $emphasisOpen, $emphasisClose);
}
-
diff --git a/include/attach.php b/include/attach.php
index f7a107fc0..4e8b3c056 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -159,7 +159,6 @@ function attach_count_files($channel_id, $observer, $hash = '', $filename = '',
intval($channel_id)
);
-
$ret['success'] = ((is_array($r)) ? true : false);
$ret['results'] = ((is_array($r)) ? count($r) : false);
@@ -226,7 +225,8 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
* This could exhaust memory so most useful only when immediately sending the data.
*
* @param string $hash
- * @param int $rev Revision
+ * @param string $observer_hash
+ * @param int $rev (optional) Revision default 0
* @return array
*/
function attach_by_hash($hash, $observer_hash, $rev = 0) {
@@ -285,7 +285,7 @@ function attach_by_hash($hash, $observer_hash, $rev = 0) {
function attach_can_view_folder($uid,$ob_hash,$folder_hash) {
$sql_extra = permissions_sql($uid,$ob_hash);
- $hash = $folder_hash;
+ $hash = $folder_hash;
$result = false;
do {
@@ -295,9 +295,10 @@ function attach_can_view_folder($uid,$ob_hash,$folder_hash) {
);
if(! $r)
return false;
+
$hash = $r[0]['folder'];
- }
- while($hash);
+ } while($hash);
+
return true;
}
@@ -308,8 +309,9 @@ function attach_can_view_folder($uid,$ob_hash,$folder_hash) {
* Returns the entire attach structure excluding data.
*
* @see attach_by_hash()
- * @param $hash
- * @param $rev revision default 0
+ * @param string $hash
+ * @param string $observer_hash
+ * @param int $rev (optional) revision default 0
* @return associative array with everything except data
* * \e boolean \b success boolean true or false
* * \e string \b message (optional) only when success is false
@@ -335,12 +337,12 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
return $ret;
}
- if(! perm_is_allowed($r[0]['uid'],$observer_hash,'view_storage')) {
+ if(! perm_is_allowed($r[0]['uid'], $observer_hash, 'view_storage')) {
$ret['message'] = t('Permission denied.');
return $ret;
}
- $sql_extra = permissions_sql($r[0]['uid'],$observer_hash);
+ $sql_extra = permissions_sql($r[0]['uid'], $observer_hash);
// Now we'll see if we can access the attachment
@@ -355,14 +357,13 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
}
if($r[0]['folder']) {
- $x = attach_can_view_folder($r[0]['uid'],$observer_hash,$r[0]['folder']);
+ $x = attach_can_view_folder($r[0]['uid'], $observer_hash, $r[0]['folder']);
if(! $x) {
$ret['message'] = t('Permission denied.');
return $ret;
}
}
-
$ret['success'] = true;
$ret['data'] = $r[0];
@@ -378,25 +379,18 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
* @note Requires an input field \e userfile and does not accept multiple files
* in one request.
*
- * @param array $channel channel array of owner
- * @param string $observer_hash hash of current observer
- * @param string $options (optional) one of update, replace, revision
- * @param array $arr (optional) associative array
- */
-
-/**
- * A lot going on in this function, and some of it is old cruft and some is new cruft
+ * @note A lot going on in this function, and some of it is old cruft and some is new cruft
* and the entire thing probably needs to be refactored. It started out just storing
- * files, before we had DAV. It was made extensible to do extra stuff like edit an
+ * files, before we had DAV. It was made extensible to do extra stuff like edit an
* existing file or optionally store a separate revision using $options to choose between different
* storage models. Along the way we moved from
- * DB data storage to file system storage.
- * Then DAV came along and used different upload methods depending on whether the
- * file was stored as a DAV directory object or updated as a file object. One of these
+ * DB data storage to file system storage.
+ * Then DAV came along and used different upload methods depending on whether the
+ * file was stored as a DAV directory object or updated as a file object. One of these
* is essentially an update and the other is basically an upload, but doesn't use the traditional PHP
- * upload workflow.
+ * upload workflow.
* Then came hubzilla and we tried to merge photo functionality with the file storage. Most of
- * that integration occurs within this function.
+ * that integration occurs within this function.
* This required overlap with the old photo_upload stuff and photo albums were
* completely different concepts from directories which needed to be reconciled somehow.
* The old revision stuff is kind of orphaned currently. There's new revision stuff for photos
@@ -404,13 +398,18 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
* That's where it sits currently. I repeat it needs to be refactored, and this note is here
* for future explorers and those who may be doing that work to understand where it came
* from and got to be the monstrosity of tangled unrelated code that it currently is.
+ *
+ * @param array $channel channel array of owner
+ * @param string $observer_hash hash of current observer
+ * @param string $options (optional) one of update, replace, revision
+ * @param array $arr (optional) associative array
+ * @return void|array
*/
-
function attach_store($channel, $observer_hash, $options = '', $arr = null) {
require_once('include/photos.php');
- call_hooks('photo_upload_begin',$arr);
+ call_hooks('photo_upload_begin', $arr);
$ret = array('success' => false);
$channel_id = $channel['channel_id'];
@@ -441,7 +440,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
return $ret;
}
- $str_group_allow = perms2str($arr['group_allow']);
+ $str_group_allow = perms2str($arr['group_allow']);
$str_contact_allow = perms2str($arr['contact_allow']);
$str_group_deny = perms2str($arr['group_deny']);
$str_contact_deny = perms2str($arr['contact_deny']);
@@ -458,7 +457,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$remove_when_processed = true;
- if($options === 'import') {
+ if($options === 'import') {
$src = $arr['src'];
$filename = $arr['filename'];
$filesize = @filesize($src);
@@ -485,17 +484,15 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
elseif($options !== 'update') {
$f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
- call_hooks('photo_upload_file',$f);
+ call_hooks('photo_upload_file',$f);
call_hooks('attach_upload_file',$f);
- if (x($f,'src') && x($f,'filesize')) {
- $src = $f['src'];
- $filename = $f['filename'];
- $filesize = $f['filesize'];
- $type = $f['type'];
-
- } else {
-
+ if (x($f,'src') && x($f,'filesize')) {
+ $src = $f['src'];
+ $filename = $f['filename'];
+ $filesize = $f['filesize'];
+ $type = $f['type'];
+ } else {
if(! x($_FILES,'userfile')) {
$ret['message'] = t('No source file.');
return $ret;
@@ -543,12 +540,10 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$hash = $x[0]['hash'];
}
-
-
$def_extension = '';
$is_photo = 0;
$gis = @getimagesize($src);
- logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
+ logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
$is_photo = 1;
if($gis[2] === IMAGETYPE_GIF)
@@ -557,7 +552,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$def_extension = '.jpg';
if($gis[2] === IMAGETYPE_PNG)
$def_extension = '.png';
-
}
$pathname = '';
@@ -607,7 +601,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
else {
$folder_hash = ((($arr) && array_key_exists('folder',$arr)) ? $arr['folder'] : '');
- }
+ }
if((! $options) || ($options === 'import')) {
@@ -654,8 +648,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
if($found)
$x++;
- }
- while($found);
+ } while($found);
$filename = $basename . '(' . $x . ')' . $ext;
}
else
@@ -702,7 +695,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($folder_hash) {
$curr = find_folder_hash_by_attach_hash($channel_id,$folder_hash,true);
- if($curr)
+ if($curr)
$os_relpath .= $curr . '/';
$os_relpath .= $folder_hash . '/';
}
@@ -765,7 +758,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, os_path = '%s',
+ $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']),
@@ -783,7 +776,6 @@ 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, 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']),
@@ -869,7 +861,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
return $ret;
}
-
$ret['success'] = true;
$ret['data'] = $r[0];
if(! $is_photo) {
@@ -880,7 +871,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($dosync) {
$sync = attach_export_data($channel,$hash);
- if($sync)
+ if($sync)
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
@@ -998,7 +989,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
intval($channel['channel_id'])
);
if($r) {
- if(array_key_exists('force',$arr) && intval($arr['force'])
+ if(array_key_exists('force',$arr) && intval($arr['force'])
&& (intval($r[0]['is_dir']))) {
$ret['success'] = true;
$r = q("select * from attach where id = %d limit 1",
@@ -1150,7 +1141,7 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
if(! $p)
continue;
$arx = array(
- 'filename' => $p,
+ 'filename' => $p,
'folder' => $current_parent,
'force' => 1
);
@@ -1163,7 +1154,7 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
if(array_key_exists('deny_gid',$arr))
$arx['deny_gid'] = $arr['deny_gid'];
- $x = attach_mkdir($channel, $observer_hash, $arx);
+ $x = attach_mkdir($channel, $observer_hash, $arx);
if($x['success']) {
$current_parent = $x['data']['hash'];
}
@@ -1177,26 +1168,22 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
$ret['data'] = $x['data'];
}
- return $ret;
-
+ return $ret;
}
-
-
-
-
/**
* @brief Changes permissions of a file.
*
- * @param int $channel_id
+ * @param int $channel_id The id of the channel
* @param array $resource
* @param string $allow_cid
* @param string $allow_gid
* @param string $deny_cid
* @param string $deny_gid
* @param boolean $recurse (optional) default false
+ * @param boolean $sync (optional) default false
*/
function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse = false, $sync = false) {
@@ -1248,7 +1235,7 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
if($sync) {
$data = attach_export_data($channel,$resource);
- if($data)
+ if($data)
build_sync_packet($channel['channel_id'],array('file' => array($data)));
}
}
@@ -1263,6 +1250,7 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
* The id of the channel
* @param string $resource
* The hash to delete
+ * @param int $is_photo (optional) default 0
* @return void
*/
function attach_delete($channel_id, $resource, $is_photo = 0) {
@@ -1337,7 +1325,7 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
dbesc($resource)
);
}
-
+
// update the parent folder's lastmodified timestamp
$e = q("UPDATE attach SET edited = '%s' WHERE hash = '%s' AND uid = %d",
dbesc(datetime_convert()),
@@ -1425,6 +1413,7 @@ function get_parent_cloudpath($channel_id, $channel_name, $attachHash) {
$parentFullPath = $parentName . '/' . $parentFullPath;
}
} while ($parentHash);
+
$parentFullPath = z_root() . '/cloud/' . $channel_name . '/' . $parentFullPath;
return $parentFullPath;
@@ -1437,11 +1426,14 @@ function get_parent_cloudpath($channel_id, $channel_name, $attachHash) {
* The id of the channel
* @param string $attachHash
* The hash of the attachment
+ * @param boolean $recurse
+ * (optional) default false
* @return string
*/
function find_folder_hash_by_attach_hash($channel_id, $attachHash, $recurse = false) {
-logger('attach_hash: ' . $attachHash);
+ logger('attach_hash: ' . $attachHash);
+
$r = q("SELECT folder FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1",
intval($channel_id),
dbesc($attachHash)
@@ -1449,10 +1441,11 @@ logger('attach_hash: ' . $attachHash);
$hash = '';
if($r && $r[0]['folder']) {
if($recurse)
- $hash = find_folder_hash_by_attach_hash($channel_id,$r[0]['folder'],true) . '/' . $r[0]['folder'];
+ $hash = find_folder_hash_by_attach_hash($channel_id,$r[0]['folder'],true) . '/' . $r[0]['folder'];
else
$hash = $r[0]['folder'];
}
+
return $hash;
}
@@ -1569,7 +1562,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$arr = array();
$arr['aid'] = get_account_id();
$arr['uid'] = $channel_id;
- $arr['item_wall'] = 1;
+ $arr['item_wall'] = 1;
$arr['item_origin'] = 1;
$arr['item_unseen'] = 1;
$arr['author_xchan'] = $poster['xchan_hash'];
@@ -1732,11 +1725,11 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) {
/**
* @brief Returns array of channels which have recursive permission for a file
*
- * @param $arr_allow_cid
- * @param $arr_allow_gid
- * @param $arr_deny_cid
- * @param $arr_deny_gid
- * @param $folder_hash
+ * @param array $arr_allow_cid
+ * @param array $arr_allow_gid
+ * @param array $arr_deny_cid
+ * @param array $arr_deny_gid
+ * @param string $folder_hash
*/
function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash) {
@@ -1931,50 +1924,53 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
}
return $ret;
-
}
-/* strip off 'store/nickname/' from the provided path */
-
+/**
+ * @brief Strip off 'store/nickname/' from the provided path
+ *
+ * @param string $s
+ * @return string
+ */
function get_attach_binname($s) {
$p = $s;
- if(strpos($s,'store/') === 0) {
- $p = substr($s,6);
- $p = substr($p,strpos($p,'/')+1);
+ if(strpos($s, 'store/') === 0) {
+ $p = substr($s, 6);
+ $p = substr($p, strpos($p, '/')+1);
}
+
return $p;
}
function get_dirpath_by_cloudpath($channel, $path) {
-
- $path = notags(trim($path));
+ $path = notags(trim($path));
$h = @parse_url($path);
if(! $h || !x($h, 'path')) {
return null;
}
- if(substr($h['path'],-1,1) === '/') {
- $h['path'] = substr($h['path'],0,-1);
+ if(substr($h['path'], -1, 1) === '/') {
+ $h['path'] = substr($h['path'], 0, -1);
}
if(substr($h['path'],0,1) === '/') {
- $h['path'] = substr($h['path'],1);
+ $h['path'] = substr($h['path'], 1);
}
$folders = explode('/', $h['path']);
$f = array_shift($folders);
-
+
$nick = $channel['channel_address'];
//check to see if the absolute path was provided (/cloud/channelname/path/to/folder)
- if($f === 'cloud' ) {
+ if($f === 'cloud' ) {
$g = array_shift($folders);
if( $g !== $nick) {
// if nick does not follow "cloud", then the top level folder must be called "cloud"
- // and the given path must be relative to "/cloud/channelname/".
+ // and the given path must be relative to "/cloud/channelname/".
$folders = array_unshift(array_unshift($folders, $g), $f);
- }
+ }
} else {
array_unshift($folders, $f);
}
@@ -1998,8 +1994,6 @@ function get_dirpath_by_cloudpath($channel, $path) {
} else {
return $clouddir . $subdir;
}
-
-
}
function get_filename_by_cloudname($cloudname, $channel, $storepath) {
@@ -2013,66 +2007,74 @@ function get_filename_by_cloudname($cloudname, $channel, $storepath) {
return null;
}
-
-// recursively copy a directory into cloud files
-function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpath)
-{
- if (!is_dir($srcpath) || !is_readable($srcpath)) {
- logger('Error reading source path: ' . $srcpath, LOGGER_NORMAL);
+/**
+ * @brief recursively copy a directory into cloud files
+ *
+ * @param array $channel
+ * @param string $observer_hash
+ * @param string $srcpath
+ * @param string $cloudpath
+ * @return boolean
+ */
+function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpath) {
+ if (!is_dir($srcpath) || !is_readable($srcpath)) {
+ logger('Error reading source path: ' . $srcpath, LOGGER_NORMAL);
+ return false;
+ }
+ $nodes = array_diff(scandir($srcpath), array('.', '..'));
+ foreach ($nodes as $node) {
+ $clouddir = $cloudpath . '/' . $node; // Sub-folder in cloud files destination
+ $nodepath = $srcpath . '/' . $node; // Sub-folder in source path
+ if(is_dir($nodepath)) {
+ $x = attach_mkdirp($channel, $observer_hash, array('pathname' => $clouddir));
+ if(!$x['success']) {
+ logger('Error creating cloud path: ' . $clouddir, LOGGER_NORMAL);
return false;
+ }
+ // Recursively call this function where the source and destination are the subfolders
+ $success = copy_folder_to_cloudfiles($channel, $observer_hash, $nodepath, $clouddir);
+ if(!$success) {
+ logger('Error copying contents of folder: ' . $nodepath, LOGGER_NORMAL);
+ return false;
+ }
+ } elseif(is_file($nodepath) && is_readable($nodepath)) {
+ $x = attach_store($channel, $observer_hash, 'import', array(
+ 'directory' => $cloudpath,
+ 'src' => $nodepath,
+ 'filename' => $node,
+ 'filesize' => @filesize($nodepath),
+ 'preserve_original' => true
+ ));
+ if(!$x['success']) {
+ logger('Error copying file: ' . $nodepath, LOGGER_NORMAL);
+ logger('Return value: ' . json_encode($x), LOGGER_NORMAL);
+ return false;
+ }
+ } else {
+ logger('Error scanning source path', LOGGER_NORMAL);
+ return false;
}
- $nodes = array_diff(scandir($srcpath), array('.', '..'));
- foreach ($nodes as $node) {
- $clouddir = $cloudpath . '/' . $node; // Sub-folder in cloud files destination
- $nodepath = $srcpath . '/' . $node; // Sub-folder in source path
- if(is_dir($nodepath)) {
- $x = attach_mkdirp($channel, $observer_hash, array('pathname' => $clouddir));
- if(!$x['success']) {
- logger('Error creating cloud path: ' . $clouddir, LOGGER_NORMAL);
- return false;
- }
- // Recursively call this function where the source and destination are the subfolders
- $success = copy_folder_to_cloudfiles($channel, $observer_hash, $nodepath, $clouddir);
- if(!$success) {
- logger('Error copying contents of folder: ' . $nodepath, LOGGER_NORMAL);
- return false;
- }
- } elseif (is_file($nodepath) && is_readable($nodepath)) {
- $x = attach_store($channel, $observer_hash, 'import',
- array(
- 'directory' => $cloudpath,
- 'src' => $nodepath,
- 'filename' => $node,
- 'filesize' => @filesize($nodepath),
- 'preserve_original' => true)
- );
- if(!$x['success']) {
- logger('Error copying file: ' . $nodepath , LOGGER_NORMAL);
- logger('Return value: ' . json_encode($x), LOGGER_NORMAL);
- return false;
- }
- } else {
- logger('Error scanning source path', LOGGER_NORMAL);
- return false;
- }
- }
+ }
- return true;
+ return true;
}
/**
- * attach_move()
* This function performs an in place directory-to-directory move of a stored attachment or photo.
* The data is physically moved in the store/nickname storage location and the paths adjusted
* in the attach structure (and if applicable the photo table). The new 'album name' is recorded
* for photos and will show up immediately there.
* This takes a channel_id, attach.hash of the file to move (this is the same as a photo resource_id), and
* the attach.hash of the new parent folder, which must already exist. If $new_folder_hash is blank or empty,
- * the file is relocated to the root of the channel's storage area.
+ * the file is relocated to the root of the channel's storage area.
*
* @fixme: this operation is currently not synced to clones !!
+ *
+ * @param int $channel_id
+ * @param int $resource_id
+ * @param string $new_folder_hash
+ * @return void|boolean
*/
-
-function attach_move($channel_id,$resource_id,$new_folder_hash) {
+function attach_move($channel_id, $resource_id, $new_folder_hash) {
$c = channelx_by_n($channel_id);
if(! $c)
@@ -2086,7 +2088,7 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
return false;
$oldstorepath = $r[0]['content'];
-
+
if($new_folder_hash) {
$n = q("select * from attach where hash = '%s' and uid = %d limit 1",
dbesc($new_folder_hash),
@@ -2094,6 +2096,7 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
);
if(! $n)
return;
+
$newdirname = $n[0]['filename'];
$newstorepath = $n[0]['content'] . '/' . $resource_id;
}
@@ -2115,7 +2118,7 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
if($s) {
$overwrite = get_pconfig($channel_id,'system','overwrite_dup_files');
if($overwrite) {
- // @fixme
+ /// @fixme
return;
}
else {
@@ -2147,7 +2150,7 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
}
if($found)
$x++;
- }
+ }
while($found);
$filename = $basename . '(' . $x . ')' . $ext;
}
@@ -2179,7 +2182,6 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
}
return true;
-
}
@@ -2191,7 +2193,7 @@ function attach_folder_select_list($channel_id) {
$out = [];
$out[''] = '/';
-
+
if($r) {
foreach($r as $rv) {
$x = attach_folder_rpaths($r,$rv);
@@ -2199,6 +2201,7 @@ function attach_folder_select_list($channel_id) {
$out[$x[0]] = $x[1];
}
}
+
return $out;
}
@@ -2223,11 +2226,11 @@ function attach_folder_rpaths($all_folders,$that_folder) {
break;
}
}
- if(! $found)
+ if(! $found)
$error = true;
}
while((! $found) && (! $error) && ($parent_hash != ''));
}
- return (($error) ? false : [ $current_hash , $path ]);
+ return (($error) ? false : [ $current_hash , $path ]);
} \ No newline at end of file
diff --git a/include/channel.php b/include/channel.php
index 4dd356785..39ffef2d2 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -182,7 +182,7 @@ function create_identity($arr) {
return $ret;
}
$ret = identity_check_service_class($arr['account_id']);
- if (!$ret['success']) {
+ if (!$ret['success']) {
return $ret;
}
// save this for auto_friending
@@ -236,13 +236,13 @@ function create_identity($arr) {
$publish = intval($role_permissions['directory_publish']);
$primary = true;
-
+
if(array_key_exists('primary', $arr))
$primary = intval($arr['primary']);
$expire = 0;
- $r = q("insert into channel ( channel_account_id, channel_primary,
+ $r = q("insert into channel ( channel_account_id, channel_primary,
channel_name, channel_address, channel_guid, channel_guid_sig,
channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_system, channel_expire_days, channel_timezone )
values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' ) ",
@@ -262,7 +262,7 @@ function create_identity($arr) {
dbesc(App::$timezone)
);
- $r = q("select * from channel where channel_account_id = %d
+ $r = q("select * from channel where channel_account_id = %d
and channel_guid = '%s' limit 1",
intval($arr['account_id']),
dbesc($guid)
@@ -291,7 +291,7 @@ function create_identity($arr) {
// Create a verified hub location pointing to this site.
- $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary,
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary,
hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_network )
values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
dbesc($guid),
@@ -392,11 +392,11 @@ function create_identity($arr) {
intval($newuid)
);
}
- }
+ }
}
- // Create a group with yourself as a member. This allows somebody to use it
- // right away as a default group for new contacts.
+ // Create a group with yourself as a member. This allows somebody to use it
+ // right away as a default group for new contacts.
require_once('include/group.php');
group_add($newuid, t('Friends'));
@@ -422,7 +422,7 @@ function create_identity($arr) {
set_pconfig($ret['channel']['channel_id'],'system','photo_path', '%Y-%m');
set_pconfig($ret['channel']['channel_id'],'system','attach_path','%Y-%m');
}
-
+
// auto-follow any of the hub's pre-configured channel choices.
// Only do this if it's the first channel for this account;
// otherwise it could get annoying. Don't make this list too big
@@ -494,7 +494,7 @@ function identity_basic_export($channel_id, $items = false) {
$ret = array();
- // use constants here as otherwise we will have no idea if we can import from a site
+ // use constants here as otherwise we will have no idea if we can import from a site
// with a non-standard platform and version.
$ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => STD_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => Zotlabs\Lib\System::get_server_role());
@@ -503,7 +503,7 @@ function identity_basic_export($channel_id, $items = false) {
);
if($r) {
translate_channel_perms_outbound($r[0]);
- $ret['channel'] = $r[0];
+ $ret['channel'] = $r[0];
$ret['relocate'] = [ 'channel_address' => $r[0]['channel_address'], 'url' => z_root()];
}
@@ -526,7 +526,7 @@ function identity_basic_export($channel_id, $items = false) {
if($abconfig)
$ret['abook'][$x]['abconfig'] = $abconfig;
translate_abook_perms_outbound($ret['abook'][$x]);
- }
+ }
stringify_array_elms($xchans);
}
@@ -534,7 +534,7 @@ function identity_basic_export($channel_id, $items = false) {
$r = q("select * from xchan where xchan_hash in ( " . implode(',',$xchans) . " ) ");
if($r)
$ret['xchan'] = $r;
-
+
$r = q("select * from hubloc where hubloc_hash in ( " . implode(',',$xchans) . " ) ");
if($r)
$ret['hubloc'] = $r;
@@ -578,7 +578,6 @@ function identity_basic_export($channel_id, $items = false) {
if($r)
$ret['term'] = $r;
-
// add psuedo-column obj_baseurl to aid in relocations
$r = q("select obj.*, '%s' as obj_baseurl from obj where obj_channel = %d",
@@ -608,7 +607,6 @@ function identity_basic_export($channel_id, $items = false) {
if($r)
$ret['chatroom'] = $r;
-
$r = q("select * from event where uid = %d",
intval($channel_id)
);
@@ -625,7 +623,7 @@ function identity_basic_export($channel_id, $items = false) {
foreach($r as $rr)
$ret['event_item'][] = encode_item($rr,true);
}
-
+
$x = menu_list($channel_id);
if($x) {
$ret['menu'] = array();
@@ -636,12 +634,10 @@ function identity_basic_export($channel_id, $items = false) {
}
}
-
$addon = array('channel_id' => $channel_id,'data' => $ret);
call_hooks('identity_basic_export',$addon);
$ret = $addon['data'];
-
if(! $items)
return $ret;
@@ -659,11 +655,10 @@ function identity_basic_export($channel_id, $items = false) {
if($r) {
for($x = 0; $x < count($r); $x ++) {
$r[$x]['subject'] = base64url_decode(str_rot47($r[$x]['subject']));
- }
+ }
$ret['conv'] = $r;
}
-
$r = q("select * from mail where mail.uid = %d",
intval($channel_id)
);
@@ -680,15 +675,15 @@ function identity_basic_export($channel_id, $items = false) {
/** @warning this may run into memory limits on smaller systems */
- /** export three months of posts. If you want to export and import all posts you have to start with
- * the first year and export/import them in ascending order.
+ /** export three months of posts. If you want to export and import all posts you have to start with
+ * the first year and export/import them in ascending order.
*
* Don't export linked resource items. we'll have to pull those out separately.
*/
$r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d and created > %s - INTERVAL %s and resource_type = '' order by created",
intval($channel_id),
- db_utcnow(),
+ db_utcnow(),
db_quoteinterval('3 MONTH')
);
if($r) {
@@ -730,7 +725,7 @@ function identity_export_year($channel_id,$year,$month = 0) {
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created",
intval(ITEM_TYPE_POST),
intval($channel_id),
- dbesc($mindate),
+ dbesc($mindate),
dbesc($maxdate)
);
@@ -745,16 +740,24 @@ function identity_export_year($channel_id,$year,$month = 0) {
return $ret;
}
-// export items within an arbitrary date range. Date/time is in UTC.
-
-function channel_export_items($channel_id,$start,$finish) {
+/**
+ * @brief Export items within an arbitrary date range.
+ *
+ * Date/time is in UTC.
+ *
+ * @param int $channel_id The channel ID
+ * @param string $start
+ * @param string $finish
+ * @return array
+ */
+function channel_export_items($channel_id, $start, $finish) {
if(! $start)
return array();
else
- $start = datetime_convert('UTC','UTC',$start);
+ $start = datetime_convert('UTC', 'UTC', $start);
- $finish = datetime_convert('UTC','UTC',(($finish) ? $finish : 'now'));
+ $finish = datetime_convert('UTC', 'UTC', (($finish) ? $finish : 'now'));
if($finish < $start)
return array();
@@ -768,16 +771,16 @@ function channel_export_items($channel_id,$start,$finish) {
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created",
intval(ITEM_TYPE_POST),
intval($channel_id),
- dbesc($start),
+ dbesc($start),
dbesc($finish)
);
if($r) {
$ret['item'] = array();
xchan_query($r);
- $r = fetch_post_tags($r,true);
+ $r = fetch_post_tags($r, true);
foreach($r as $rr)
- $ret['item'][] = encode_item($rr,true);
+ $ret['item'][] = encode_item($rr, true);
}
return $ret;
@@ -792,7 +795,7 @@ function channel_export_items($channel_id,$start,$finish) {
*
* Permissions of the current observer are checked. If a restricted profile is available
* to the current observer, that will be loaded instead of the channel default profile.
- *
+ *
* The channel owner can set $profile to a valid profile_guid to preview that profile.
*
* The channel default theme is also selected for use, unless over-riden elsewhere.
@@ -866,7 +869,6 @@ function profile_load($nickname, $profile = '') {
intval($p[0]['profile_uid'])
);
if($q) {
-
$extra_fields = array();
require_once('include/channel.php');
@@ -985,7 +987,6 @@ function profile_edit_menu($uid) {
}
return $ret;
-
}
/**
@@ -997,6 +998,7 @@ function profile_edit_menu($uid) {
* @param array $profile
* @param int $block
* @param boolean $show_connect
+ * @param mixed $zcard
*
* @return HTML string suitable for sidebar inclusion
* Exceptions: Returns empty string if passed $profile is wrong type or not populated
@@ -1032,7 +1034,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa
$connect_url = rconnect_url($profile['uid'],get_observer_hash());
$connect = (($connect_url) ? t('Connect') : '');
- if($connect_url)
+ if($connect_url)
$connect_url = sprintf($connect_url,urlencode(channel_reddress($profile)));
// premium channel - over-ride
@@ -1163,7 +1165,6 @@ function advanced_profile(&$a) {
}
-
$tpl = get_markup_template('profile_advanced.tpl');
$profile = array();
@@ -1198,12 +1199,12 @@ function advanced_profile(&$a) {
if((substr(App::$profile['dob'],5,2) === '00') || (substr(App::$profile['dob'],8,2) === '00'))
$val = substr(App::$profile['dob'],0,4);
-
+
$year_bd_format = t('j F, Y');
$short_bd_format = t('j F');
if(! $val) {
- $val = ((intval(App::$profile['dob']))
+ $val = ((intval(App::$profile['dob']))
? day_translate(datetime_convert('UTC','UTC',App::$profile['dob'] . ' 00:00 +00:00',$year_bd_format))
: day_translate(datetime_convert('UTC','UTC','2001-' . substr(App::$profile['dob'],5) . ' 00:00 +00:00',$short_bd_format)));
}
@@ -1248,7 +1249,7 @@ function advanced_profile(&$a) {
if($txt = prepare_text(App::$profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt);
if($txt = prepare_text(App::$profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt);
-
+
if($txt = prepare_text(App::$profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt);
if($txt = prepare_text(App::$profile['tv'])) $profile['tv'] = array( t('Television:'), $txt);
@@ -1256,7 +1257,7 @@ function advanced_profile(&$a) {
if($txt = prepare_text(App::$profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt);
if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt);
-
+
if($txt = prepare_text(App::$profile['employment'])) $profile['employment'] = array( t('Work/employment:'), $txt);
if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
@@ -1275,7 +1276,7 @@ function advanced_profile(&$a) {
$things = get_things(App::$profile['profile_guid'],App::$profile['profile_uid']);
-// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
+// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
return replace_macros($tpl, array(
'$title' => t('Profile'),
@@ -1403,7 +1404,8 @@ function zid($s,$address = '') {
$mine = get_my_url();
$myaddr = (($address) ? $address : get_my_address());
- /** @FIXME checking against our own channel url is no longer reliable. We may have a lot
+ /**
+ * @FIXME checking against our own channel url is no longer reliable. We may have a lot
* of urls attached to out channel. Should probably match against our site, since we
* will not need to remote authenticate on our own site anyway.
*/
@@ -1426,8 +1428,8 @@ function zid($s,$address = '') {
// Used from within PCSS themes to set theme parameters. If there's a
// puid request variable, that is the "page owner" and normally their theme
-// settings take precedence; unless a local user sets the "always_my_theme"
-// system pconfig, which means they don't want to see anybody else's theme
+// settings take precedence; unless a local user sets the "always_my_theme"
+// system pconfig, which means they don't want to see anybody else's theme
// settings except their own while on this site.
function get_theme_uid() {
@@ -1619,7 +1621,7 @@ function get_profile_fields_advanced($filter = 0) {
* The channel to disable notifications for
* @returns int
* Current notification flag value. Send this to notifications_on() to restore the channel settings when finished
- * with the activity requiring notifications_off();
+ * with the activity requiring notifications_off();
*/
function notifications_off($channel_id) {
$r = q("select channel_notifyflags from channel where channel_id = %d limit 1",
@@ -1633,18 +1635,18 @@ function notifications_off($channel_id) {
}
-function notifications_on($channel_id,$value) {
+function notifications_on($channel_id, $value) {
$x = q("update channel set channel_notifyflags = %d where channel_id = %d",
intval($value),
intval($channel_id)
);
+
return $x;
}
function get_channel_default_perms($uid) {
-
$ret = [];
$r = q("select abook_xchan from abook where abook_channel = %d and abook_self = 1 limit 1",
@@ -1666,7 +1668,6 @@ function get_channel_default_perms($uid) {
function profiles_build_sync($channel_id) {
-
$r = q("select * from profile where uid = %d",
intval($channel_id)
);
@@ -1713,7 +1714,6 @@ function auto_channel_create($account_id) {
$arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999)));
return create_identity($arr);
-
}
function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) {
@@ -1748,18 +1748,24 @@ function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_
break;
}
- return $output;
-
+ return $output;
}
-function get_zcard($channel,$observer_hash = '',$args = array()) {
+/**
+ * @brief
+ *
+ * @param array $channel
+ * @param string $observer_hash
+ * @param array $args
+ * @return string
+ */
+function get_zcard($channel, $observer_hash = '', $args = array()) {
logger('get_zcard');
$maxwidth = (($args['width']) ? intval($args['width']) : 0);
$maxheight = (($args['height']) ? intval($args['height']) : 0);
-
if(($maxwidth > 1200) || ($maxwidth < 1))
$maxwidth = 1200;
@@ -1767,25 +1773,22 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
$width = 425;
$size = 'hz_small';
$cover_size = PHOTO_RES_COVER_425;
- $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
- }
- elseif($maxwidth <= 900) {
+ $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
+ } elseif($maxwidth <= 900) {
$width = 900;
$size = 'hz_medium';
$cover_size = PHOTO_RES_COVER_850;
- $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
- }
- elseif($maxwidth <= 1200) {
+ $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
+ } elseif($maxwidth <= 1200) {
$width = 1200;
$size = 'hz_large';
$cover_size = PHOTO_RES_COVER_1200;
- $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
+ $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
}
// $scale = (float) $maxwidth / $width;
// $translate = intval(($scale / 1.0) * 100);
-
$channel['channel_addr'] = channel_reddress($channel);
$zcard = array('chan' => $channel);
@@ -1798,12 +1801,11 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
if($r) {
$cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
- }
- else {
+ } else {
$cover = $pphoto;
}
-
- $o .= replace_macros(get_markup_template('zcard.tpl'),array(
+
+ $o .= replace_macros(get_markup_template('zcard.tpl'), array(
'$maxwidth' => $maxwidth,
'$scale' => $scale,
'$translate' => $translate,
@@ -1811,21 +1813,19 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
'$cover' => $cover,
'$pphoto' => $pphoto,
'$zcard' => $zcard
- ));
-
+ ));
+
return $o;
-
}
-function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
+function get_zcard_embed($channel, $observer_hash = '', $args = array()) {
logger('get_zcard_embed');
$maxwidth = (($args['width']) ? intval($args['width']) : 0);
$maxheight = (($args['height']) ? intval($args['height']) : 0);
-
if(($maxwidth > 1200) || ($maxwidth < 1))
$maxwidth = 1200;
@@ -1860,11 +1860,10 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
if($r) {
$cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
- }
- else {
+ } else {
$cover = $pphoto;
}
-
+
$o .= replace_macros(get_markup_template('zcard_embed.tpl'),array(
'$maxwidth' => $maxwidth,
'$scale' => $scale,
@@ -1873,36 +1872,62 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
'$cover' => $cover,
'$pphoto' => $pphoto,
'$zcard' => $zcard
- ));
-
+ ));
+
return $o;
-
}
-
+/**
+ * @brief
+ *
+ * @param string $nick
+ * @return mixed
+ */
function channelx_by_nick($nick) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1",
dbesc($nick)
);
+
return(($r) ? $r[0] : false);
}
+/**
+ * @brief
+ *
+ * @param string $hash
+ * @return mixed
+ */
function channelx_by_hash($hash) {
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1",
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1",
dbesc($hash)
);
+
return(($r) ? $r[0] : false);
}
+/**
+ * @brief
+ *
+ * @param int $id
+ * @return mixed
+ */
function channelx_by_n($id) {
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and channel_removed = 0 LIMIT 1",
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and channel_removed = 0 LIMIT 1",
dbesc($id)
);
+
return(($r) ? $r[0] : false);
}
+/**
+ * @brief
+ *
+ * @param string $channel
+ * @return string
+ */
function channel_reddress($channel) {
- if(! ($channel && array_key_exists('channel_address',$channel)))
+ if(! ($channel && array_key_exists('channel_address', $channel)))
return '';
+
return strtolower($channel['channel_address'] . '@' . App::get_hostname());
} \ No newline at end of file
diff --git a/include/config.php b/include/config.php
index 8c0469392..44ef29614 100644
--- a/include/config.php
+++ b/include/config.php
@@ -1,5 +1,4 @@
<?php
-
/**
* @file include/config.php
* @brief Arbitrary configuration storage.
@@ -7,7 +6,6 @@
* Arrays get stored as serialized strings.
* Booleans are stored as integer 0/1.
*
-
* - <b>config</b> is used for hub specific configurations. It overrides the
* configurations from .htconfig file. The storage is of size TEXT.
* - <b>pconfig</b> is used for channel specific configurations and takes a
@@ -26,7 +24,7 @@
* - get_config() and set_config() can also be done through the command line tool
* @ref util/config.md "util/config"
* - get_pconfig() and set_pconfig() can also be done through the command line tool
- * @ref util/pconfig.md "util/pconfig" and takes a channel_id as first argument.
+ * @ref util/pconfig.md "util/pconfig" and takes a channel_id as first argument.
*
*/
diff --git a/include/datetime.php b/include/datetime.php
index cd08ab367..85e87848b 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -92,8 +92,8 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
// otherwise we end up with -0001-11-30 ...
- // add 32 days so that we at least get year 00, and then hack around the fact that
- // months and days always start with 1.
+ // add 32 days so that we at least get year 00, and then hack around the fact that
+ // months and days always start with 1.
// if(substr($s,0,10) == '0000-00-00') {
// $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
@@ -195,7 +195,7 @@ function timesel($format, $h, $m, $id='timepicker') {
/**
* @brief Returns a datetime selector.
*
- * @param $format
+ * @param string $format
* format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param $min
* unix timestamp of minimum date
@@ -203,6 +203,7 @@ function timesel($format, $h, $m, $id='timepicker') {
* unix timestap of maximum date
* @param $default
* unix timestamp of default date
+ * @param string $label
* @param string $id
* id and name of datetimepicker (defaults to "datetimepicker")
* @param boolean $pickdate
@@ -214,8 +215,9 @@ function timesel($format, $h, $m, $id='timepicker') {
* @param $maxfrom
* set maximum date from picker with id $maxfrom (none by default)
* @param boolean $required default false
+ * @param int $first_day (optional) default 0
* @return string Parsed HTML output.
- *
+ *
* @todo Once browser support is better this could probably be replaced with
* native HTML5 date picker.
*/
@@ -239,10 +241,10 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
if(!$picktime) $pickers .= ',timepicker: false, closeOnDateSelect:true';
$extra_js = '';
- if($minfrom != '')
+ if($minfrom != '')
$extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
- if($maxfrom != '')
+ if($maxfrom != '')
$extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
$readable_format = $dateformat;
@@ -276,7 +278,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
*/
function relative_date($posted_date, $format = null) {
- $localtime = datetime_convert('UTC', date_default_timezone_get(), $posted_date);
+ $localtime = datetime_convert('UTC', date_default_timezone_get(), $posted_date);
$abs = strtotime($localtime);
@@ -340,7 +342,7 @@ function plural_dates($k,$n) {
return;
}
}
-
+
@@ -512,7 +514,7 @@ function cal($y = 0, $m = 0, $links = false, $class='') {
/**
* @brief Return the next birthday, converted from the owner's timezone to UTC.
- *
+ *
* This makes it globally portable.
* If the provided birthday lacks a month and or day, return an empty string.
* A missing year is acceptable.
@@ -554,7 +556,7 @@ function update_birthdays() {
require_once('include/event.php');
require_once('include/permissions.php');
- $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
+ $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_dob > %s + interval %s and abook_dob < %s + interval %s",
db_utcnow(), db_quoteinterval('7 day'),
db_utcnow(), db_quoteinterval('14 day')
@@ -572,7 +574,7 @@ function update_birthdays() {
$ev['dtend'] = datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day ');
$ev['adjust'] = intval(feature_enabled($rr['abook_channel'],'smart_birthdays'));
$ev['summary'] = sprintf( t('%1$s\'s birthday'), $rr['xchan_name']);
- $ev['description'] = sprintf( t('Happy Birthday %1$s'),
+ $ev['description'] = sprintf( t('Happy Birthday %1$s'),
'[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]') ;
$ev['etype'] = 'birthday';
diff --git a/include/help.php b/include/help.php
index 3081ae41f..f7fffc4d4 100644
--- a/include/help.php
+++ b/include/help.php
@@ -1,11 +1,17 @@
<?php
+/**
+ * @brief
+ *
+ * @param string $tocpath
+ * @return string|unknown
+ */
function get_help_content($tocpath = false) {
-
+
global $lang;
-
+
$doctype = 'markdown';
-
+
$text = '';
$path = (($tocpath !== false) ? $tocpath : '');
@@ -25,7 +31,7 @@ function get_help_content($tocpath = false) {
\App::$page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title)));
$text = load_doc_file('doc/' . $path . '.md');
-
+
if(! $text) {
$text = load_doc_file('doc/' . $path . '.bb');
if($text)
@@ -51,16 +57,16 @@ function get_help_content($tocpath = false) {
$text = load_doc_file('doc/main.bb');
\App::$page['title'] = t('Help');
}
-
+
if(! $text) {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
$tpl = get_markup_template("404.tpl");
return replace_macros($tpl, array(
- '$message' => t('Page not found.' )
+ '$message' => t('Page not found.')
));
}
}
-
+
if($doctype === 'html')
$content = $text;
if($doctype === 'markdown') {
@@ -74,30 +80,30 @@ function get_help_content($tocpath = false) {
require_once('include/bbcode.php');
$content = bbcode($text);
// bbcode retargets external content to new windows. This content is internal.
- $content = str_replace(' target="_blank"','',$content);
- }
-
+ $content = str_replace(' target="_blank"', '', $content);
+ }
+
$content = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $content);
+
return translate_projectname($content);
-
}
function preg_callback_help_include($matches) {
-
+
if($matches[1]) {
$include = str_replace($matches[0],load_doc_file($matches[1]),$matches[0]);
if(preg_match('/\.bb$/', $matches[1]) || preg_match('/\.txt$/', $matches[1])) {
require_once('include/bbcode.php');
$include = bbcode($include);
- $include = str_replace(' target="_blank"','',$include);
- }
+ $include = str_replace(' target="_blank"','',$include);
+ }
elseif(preg_match('/\.md$/', $matches[1])) {
require_once('library/markdown.php');
$include = Markdown($include);
}
return $include;
}
-
+
}
@@ -110,10 +116,10 @@ function load_doc_file($s) {
$d = dirname($s);
$c = find_doc_file("$d/$lang/$b");
- if($c)
+ if($c)
return $c;
$c = find_doc_file($s);
- if($c)
+ if($c)
return $c;
return '';
}
@@ -125,6 +131,12 @@ function find_doc_file($s) {
return '';
}
+/**
+ * @brief
+ *
+ * @param string $s
+ * @return number|mixed|unknown|boolean
+ */
function search_doc_files($s) {
$itemspage = get_pconfig(local_channel(),'system','itemspage');
@@ -133,21 +145,21 @@ function search_doc_files($s) {
$regexop = db_getfunc('REGEXP');
- $r = q("select iconfig.v, item.* from item left join iconfig on item.id = iconfig.iid
+ $r = q("select iconfig.v, item.* from item left join iconfig on item.id = iconfig.iid
where iconfig.cat = 'system' and iconfig.k = 'docfile' and
body $regexop '%s' and item_type = %d $pager_sql",
dbesc($s),
intval(ITEM_TYPE_DOC)
);
-
- $r = fetch_post_tags($r,true);
+
+ $r = fetch_post_tags($r, true);
for($x = 0; $x < count($r); $x ++) {
$position = stripos($r[$x]['body'], $s);
$dislen = 300;
$start = $position-floor($dislen/2);
if ( $start < 0) {
- $start = 0;
+ $start = 0;
}
$r[$x]['text'] = substr($r[$x]['body'], $start, $dislen);
@@ -159,43 +171,50 @@ function search_doc_files($s) {
}
}
}
- if(stristr($r[$x]['v'],$s))
+ if(stristr($r[$x]['v'], $s))
$r[$x]['rank'] ++;
- $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']),strtolower($s));
+ $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s));
// bias the results to the observer's native language
if($r[$x]['lang'] === \App::$language)
$r[$x]['rank'] = $r[$x]['rank'] + 10;
}
usort($r,'doc_rank_sort');
+
return $r;
}
-function doc_rank_sort($s1,$s2) {
+function doc_rank_sort($s1, $s2) {
if($s1['rank'] == $s2['rank'])
return 0;
+
return (($s1['rank'] < $s2['rank']) ? 1 : (-1));
}
-
+/**
+ * @brief
+ *
+ * @return string
+ */
function load_context_help() {
-
+
$path = App::$cmd;
$args = App::$argv;
$lang = App::$language;
-
+
if(! isset($lang) || !is_dir('doc/context/' . $lang . '/')) {
- $lang = 'en';
- }
+ $lang = 'en';
+ }
while($path) {
$context_help = load_doc_file('doc/context/' . $lang . '/' . $path . '/help.html');
- if(!$context_help) {
- // Fallback to English if the translation is absent
- $context_help = load_doc_file('doc/context/en/' . $path . '/help.html');
- }
+ if(!$context_help) {
+ // Fallback to English if the translation is absent
+ $context_help = load_doc_file('doc/context/en/' . $path . '/help.html');
+ }
if($context_help)
break;
+
array_pop($args);
$path = implode($args,'/');
}
@@ -203,7 +222,12 @@ function load_context_help() {
return $context_help;
}
-
+/**
+ * @brief
+ *
+ * @param string $s
+ * @return void|boolean[]|number[]|string[]|unknown[]
+ */
function store_doc_file($s) {
if(is_dir($s))
@@ -215,10 +239,9 @@ function store_doc_file($s) {
$item['aid'] = 0;
$item['uid'] = $sys['channel_id'];
-
- if(strpos($s,'.md'))
+ if(strpos($s, '.md'))
$mimetype = 'text/markdown';
- elseif(strpos($s,'.html'))
+ elseif(strpos($s, '.html'))
$mimetype = 'text/html';
else
$mimetype = 'text/bbcode';
@@ -227,12 +250,12 @@ function store_doc_file($s) {
$item['body'] = html2plain(prepare_text(file_get_contents($s),$mimetype, true));
$item['mimetype'] = 'text/plain';
-
+
$item['plink'] = z_root() . '/' . str_replace('doc','help',$s);
$item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash'];
$item['item_type'] = ITEM_TYPE_DOC;
- $r = q("select item.* from item left join iconfig on item.id = iconfig.iid
+ $r = q("select item.* from item left join iconfig on item.id = iconfig.iid
where iconfig.cat = 'system' and iconfig.k = 'docfile' and
iconfig.v = '%s' and item_type = %d limit 1",
dbesc($s),
@@ -252,6 +275,4 @@ function store_doc_file($s) {
}
return $x;
-
}
-
diff --git a/include/items.php b/include/items.php
index aaa51fc8b..4c40d9430 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3,9 +3,6 @@
* @file include/items.php
*/
-// uncertain if this line is needed and why
-use Sabre\HTTP\URLUtil;
-
use Zotlabs\Lib as Zlib;
require_once('include/bbcode.php');
@@ -66,6 +63,7 @@ function collect_recipients($item, &$private_envelope) {
if($recipients && $deny)
$recipients = array_diff($recipients,$deny);
+
$private_envelope = true;
}
else {
@@ -116,7 +114,7 @@ function collect_recipients($item, &$private_envelope) {
// Add the authors of any posts in this thread, if they are known to us.
// This is specifically designed to forward wall-to-wall posts to the original author,
- // in case they aren't a connection but have permission to write on our wall.
+ // in case they aren't a connection but have permission to write on our wall.
// This is important for issue tracker channels. It should be a no-op for most channels.
// Whether or not they will accept the delivery is not determined here, but should
// be taken into account by zot:process_delivery()
@@ -131,7 +129,6 @@ function collect_recipients($item, &$private_envelope) {
}
}
}
-
}
@@ -173,19 +170,19 @@ function comments_are_now_closed($item) {
}
function item_normal() {
- return " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0
- and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
+ return " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0
+ and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
}
/**
* @brief
- *
- * This is a compatibility function primarily for plugins, because
+ *
+ * This is a compatibility function primarily for plugins, because
* in earlier DB schemas this was a much simpler single integer compare
*
+ * @param array $item
*/
-
function is_item_normal($item) {
if(intval($item['item_hidden']) || intval($item['item_type']) || intval($item['item_deleted'])
@@ -193,8 +190,7 @@ function is_item_normal($item) {
|| intval($item['item_blocked']))
return false;
- return true;
-
+ return true;
}
/**
@@ -236,7 +232,7 @@ function can_comment_on_post($observer_xchan, $item) {
case 'public':
// We don't really allow or support public comments yet, but anonymous
// folks won't ever reach this point (as $observer_xchan will be empty).
- // This means the viewer has an xchan and we can identify them.
+ // This means the viewer has an xchan and we can identify them.
return true;
break;
case 'any connections':
@@ -481,7 +477,7 @@ function validate_item_elements($message,$arr) {
if(! array_key_exists('created',$arr))
$result['message'] = 'missing created, possible author/owner lookup failure';
- if((! $arr['mid']) || (! $arr['parent_mid']))
+ if((! $arr['mid']) || (! $arr['parent_mid']))
$result['message'] = 'missing message-id or parent message-id';
if(array_key_exists('flags',$message) && in_array('relay',$message['flags']) && $arr['mid'] === $arr['parent_mid'])
@@ -495,10 +491,6 @@ function validate_item_elements($message,$arr) {
}
-
-
-
-
/**
* @brief Limit lenght on imported system messages.
*
@@ -652,7 +644,6 @@ function get_item_elements($x,$allow_code = false) {
if(mb_strlen($arr['title']) > 255)
$arr['title'] = mb_substr($arr['title'],0,255);
-
$arr['app'] = (($x['app']) ? htmlspecialchars($x['app'], ENT_COMPAT,'UTF-8',false) : '');
$arr['route'] = (($x['route']) ? htmlspecialchars($x['route'], ENT_COMPAT,'UTF-8',false) : '');
$arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
@@ -714,7 +705,7 @@ function get_item_elements($x,$allow_code = false) {
// hub and verify that they are legit - or else we're going to toss the post. We only need to do this
// once, and after that your hub knows them. Sure some info is in the post, but it's only a transit identifier
// and not enough info to be able to look you up from your hash - which is the only thing stored with the post.
-
+
$xchan_hash = import_author_xchan($x['author']);
if($xchan_hash)
$arr['author_xchan'] = $xchan_hash;
@@ -1057,7 +1048,6 @@ function encode_item($item,$mirror = false) {
$x['item_blocked'] = $item['item_blocked'];
}
-
$x['message_id'] = $item['mid'];
$x['message_top'] = $item['parent_mid'];
$x['message_parent'] = $item['thr_parent'];
@@ -1078,9 +1068,9 @@ function encode_item($item,$mirror = false) {
$x['longlat'] = $item['coord'];
$x['signature'] = $item['sig'];
$x['route'] = $item['route'];
-
$x['owner'] = encode_item_xchan($item['owner']);
$x['author'] = encode_item_xchan($item['author']);
+
if($item['obj'])
$x['object'] = json_decode($item['obj'],true);
if($item['target'])
@@ -1237,7 +1227,7 @@ function decode_item_meta($meta) {
$ret[] = array('cat' => escape_tags($m['family']),'k' => escape_tags($m['key']),'v' => $m['value'],'sharing' => $m['sharing']);
}
}
- return $ret;
+ return $ret;
}
/**
@@ -1530,6 +1520,8 @@ function get_profile_elements($x) {
*
* @param array $arr
* @param boolean $allow_exec (optional) default false
+ * @param boolean $deliver (optional) default true
+ *
* @return array
* * \e boolean \b success
* * \e int \b item_id
@@ -1662,7 +1654,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
// otherwise, just preserve the original timestamp.
$arr['received'] = ((x($arr,'received') !== false) ? datetime_convert('UTC','UTC',$arr['received']) : datetime_convert());
- $arr['changed'] = ((x($arr,'changed') !== false) ? datetime_convert('UTC','UTC',$arr['changed']) : datetime_convert());
+ $arr['changed'] = ((x($arr,'changed') !== false) ? datetime_convert('UTC','UTC',$arr['changed']) : datetime_convert());
}
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : '');
@@ -1681,7 +1673,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
$arr['public_policy'] = ((x($arr,'public_policy')) ? notags(trim($arr['public_policy'])) : '' );
$arr['comment_policy'] = ((x($arr,'comment_policy')) ? notags(trim($arr['comment_policy'])) : 'contacts' );
-
+
if(! array_key_exists('item_unseen',$arr))
$arr['item_unseen'] = 1;
@@ -2334,10 +2326,10 @@ function send_status_notifications($post_id,$item) {
// check for an unfollow thread activity - we should probably decode the obj and check the id
// but it will be extremely rare for this to be wrong.
- if(($xx['verb'] === ACTIVITY_UNFOLLOW)
- && ($xx['obj_type'] === ACTIVITY_OBJ_NOTE || $xx['obj_type'] === ACTIVITY_OBJ_PHOTO)
+ if(($xx['verb'] === ACTIVITY_UNFOLLOW)
+ && ($xx['obj_type'] === ACTIVITY_OBJ_NOTE || $xx['obj_type'] === ACTIVITY_OBJ_PHOTO)
&& ($xx['parent'] != $xx['id']))
- $unfollowed = true;
+ $unfollowed = true;
}
if($xx['id'] == $xx['parent']) {
$parent = $xx['parent'];
@@ -2560,7 +2552,7 @@ function tag_deliver($uid, $item_id) {
if($mention) {
logger('tag_deliver: mention found for ' . $u[0]['channel_name']);
-
+
$r = q("update item set item_mentionsme = 1 where id = %d",
intval($item_id)
);
@@ -2849,7 +2841,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
$title = $item['title'];
$body = $item['body'];
- $r = q("update item set item_uplink = %d, item_nocomment = %d, item_obscured = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
+ $r = q("update item set item_uplink = %d, item_nocomment = %d, item_obscured = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s', item_wall = %d, item_origin = %d where id = %d",
intval($item_uplink),
intval($item_nocomment),
@@ -3344,7 +3336,7 @@ function item_expire($uid,$days) {
AND item_starred = 0
$sql_extra $item_normal LIMIT $expire_limit ",
intval($uid),
- db_utcnow(),
+ db_utcnow(),
db_quoteinterval(intval($days).' DAY')
);
@@ -3737,7 +3729,7 @@ function fetch_post_tags($items,$link = false) {
);
$imeta = q("select * from iconfig where iid in ( %s )",
dbesc($tag_finder_str)
- );
+ );
}
@@ -3870,7 +3862,7 @@ function zot_feed($uid,$observer_hash,$arr) {
unset($r[$x]);
}
}
-
+
$parents_str = ids_to_querystr($r,'parent');
$sys_query = ((is_sys_channel($uid)) ? $sql_extra : '');
$item_normal = item_normal();
@@ -3934,9 +3926,9 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
if($arr['mid'])
$sql_options .= " and parent_mid = '" . dbesc($arr['mid']) . "' ";
-
+
$sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options $item_normal ) ";
-
+
if($arr['since_id'])
$sql_extra .= " and item.id > " . $since_id . " ";
@@ -4188,7 +4180,7 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
if(! $post_id)
return;
-
+
if($webpage == ITEM_TYPE_WEBPAGE)
$page_type = 'WEBPAGE';
elseif($webpage == ITEM_TYPE_BLOCK)
@@ -4339,7 +4331,7 @@ function send_profile_photo_activity($channel,$photo,$profile) {
$ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('profile photo') . '[/zrl]';
- $ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg=150x150]' . z_root() . '/photo/' . $photo['resource_id'] . '-4[/zmg][/zrl]';
+ $ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg=150x150]' . z_root() . '/photo/' . $photo['resource_id'] . '-4[/zmg][/zrl]';
$arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext;
@@ -4381,11 +4373,11 @@ function sync_an_item($channel_id,$item_id) {
function fix_attached_photo_permissions($uid,$xchan_hash,$body,
$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny) {
-
+
if(get_pconfig($uid,'system','force_public_uploads')) {
$str_contact_allow = $str_group_allow = $str_contact_deny = $str_group_deny = '';
}
-
+
$match = null;
// match img and zmg image links
if(preg_match_all("/\[[zi]mg(.*?)\](.*?)\[\/[zi]mg\]/",$body,$match)) {
@@ -4402,7 +4394,7 @@ function fix_attached_photo_permissions($uid,$xchan_hash,$body,
if(! strlen($image_uri))
continue;
$srch = '<' . $xchan_hash . '>';
-
+
$r = q("select folder from attach where hash = '%s' and uid = %d limit 1",
dbesc($image_uri),
intval($uid)
@@ -4419,15 +4411,15 @@ function fix_attached_photo_permissions($uid,$xchan_hash,$body,
$str_group_deny = $f[0]['deny_gid'];
}
}
-
- $r = q("SELECT id FROM photo
+
+ $r = q("SELECT id FROM photo
WHERE allow_cid = '%s' AND allow_gid = '' AND deny_cid = '' AND deny_gid = ''
AND resource_id = '%s' AND uid = %d LIMIT 1",
dbesc($srch),
dbesc($image_uri),
intval($uid)
);
-
+
if($r) {
$r = q("UPDATE photo SET allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s'
WHERE resource_id = '%s' AND uid = %d ",
@@ -4438,9 +4430,9 @@ function fix_attached_photo_permissions($uid,$xchan_hash,$body,
dbesc($image_uri),
intval($uid)
);
-
+
// also update the linked item (which is probably invisible)
-
+
$r = q("select id from item
WHERE allow_cid = '%s' AND allow_gid = '' AND deny_cid = '' AND deny_gid = ''
AND resource_id = '%s' and resource_type = 'photo' AND uid = %d LIMIT 1",
@@ -4450,7 +4442,7 @@ function fix_attached_photo_permissions($uid,$xchan_hash,$body,
);
if($r) {
$private = (($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny) ? true : false);
-
+
$r = q("UPDATE item SET allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d
WHERE id = %d AND uid = %d",
dbesc($str_contact_allow),
@@ -4476,23 +4468,23 @@ function fix_attached_photo_permissions($uid,$xchan_hash,$body,
intval($r[0]['id']),
intval($uid)
);
- }
+ }
}
}
}
}
}
-
-
+
+
function fix_attached_file_permissions($channel,$observer_hash,$body,
$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny) {
-
+
if(get_pconfig($channel['channel_id'],'system','force_public_uploads')) {
$str_contact_allow = $str_group_allow = $str_contact_deny = $str_group_deny = '';
}
-
+
$match = false;
-
+
if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
$attaches = $match[1];
if($attaches) {
diff --git a/include/network.php b/include/network.php
index 53bb583fa..6411d6ddf 100644
--- a/include/network.php
+++ b/include/network.php
@@ -30,12 +30,12 @@ function get_capath() {
* * \b filep => stream resource to write body to. header and body are not returned when using this option.
* * \b custom => custom request method: e.g. 'PUT', 'DELETE'
* * \b cookiejar => cookie file (write)
- * * \B cookiefile => cookie file (read)
+ * * \b cookiefile => cookie file (read)
*
* @return array an associative array with:
* * \e int \b return_code => HTTP return code or 0 if timeout or failure
* * \e boolean \b success => boolean true (if HTTP 2xx result) or false
- * * \e string \b header => HTTP headers
+ * * \e string \b header => HTTP headers
* * \e string \b body => fetched content
*/
function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@@ -43,7 +43,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
$ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => "");
$ch = @curl_init($url);
- if(($redirects > 8) || (! $ch))
+ if(($redirects > 8) || (! $ch))
return $ret;
@curl_setopt($ch, CURLOPT_HEADER, true);
@@ -64,7 +64,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
if(x($opts,'upload'))
@curl_setopt($ch, CURLOPT_UPLOAD, $opts['upload']);
-
+
if(x($opts,'infile'))
@curl_setopt($ch, CURLOPT_INFILE, $opts['infile']);
@@ -104,7 +104,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
if(x($opts,'cookie'))
@curl_setopt($ch, CURLOPT_COOKIE, $opts['cookie']);
- @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
+ @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));
$prx = get_config('system','proxy');
@@ -179,10 +179,10 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
* @param string $url
* URL to post
* @param mixed $params
- * The full data to post in a HTTP "POST" operation. This parameter can
- * either be passed as a urlencoded string like 'para1=val1&para2=val2&...'
- * or as an array with the field name as key and field data as value. If value
- * is an array, the Content-Type header will be set to multipart/form-data.
+ * The full data to post in a HTTP "POST" operation. This parameter can
+ * either be passed as a urlencoded string like 'para1=val1&para2=val2&...'
+ * or as an array with the field name as key and field data as value. If value
+ * is an array, the Content-Type header will be set to multipart/form-data.
* @param int $redirects = 0
* internal use, recursion counter
* @param array $opts (optional parameters)
@@ -209,7 +209,7 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => "");
$ch = curl_init($url);
- if(($redirects > 8) || (! $ch))
+ if(($redirects > 8) || (! $ch))
return $ret;
@curl_setopt($ch, CURLOPT_HEADER, true);
@@ -232,7 +232,7 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
if(x($opts,'headers')) {
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
}
-
+
if(x($opts,'nobody'))
@curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
@@ -265,7 +265,7 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
if(x($opts,'cookie'))
@curl_setopt($ch, CURLOPT_COOKIE, $opts['cookie']);
- @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
+ @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));
$prx = get_config('system','proxy');
@@ -379,8 +379,8 @@ function json_return_and_die($x, $content_type = 'application/json') {
// Generic XML return
-// Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
-// of $st and an optional text <message> of $message and terminates the current process.
+// Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
+// of $st and an optional text <message> of $message and terminates the current process.
function xml_status($st, $message = '') {
@@ -399,7 +399,7 @@ function xml_status($st, $message = '') {
/**
- * @brief Send HTTP status header
+ * @brief Send HTTP status header
*
* @param int $val
* integer HTTP status result value
@@ -413,7 +413,7 @@ function http_status($val, $msg = '') {
if ($val >= 200 && $val < 300)
$msg = (($msg) ? $msg : 'OK');
- logger('http_status_exit ' . $val . ' ' . $msg);
+ logger('http_status_exit ' . $val . ' ' . $msg);
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $val . ' ' . $msg);
}
@@ -486,14 +486,14 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {
function validate_url(&$url) {
-
+
// no naked subdomains (allow localhost for tests)
if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
return false;
if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
$h = @parse_url($url);
-
+
if(($h) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
return true;
}
@@ -552,7 +552,7 @@ function allowed_url($url) {
foreach($allowed as $a) {
$pat = strtolower(trim($a));
if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
- $found = true;
+ $found = true;
break;
}
}
@@ -575,14 +575,14 @@ function allowed_email($email) {
$str_allowed = get_config('system','allowed_email');
$str_not_allowed = get_config('system','not_allowed_email');
-
+
if(! $str_allowed && ! $str_not_allowed)
return true;
$return = false;
- $found_allowed = false;
+ $found_allowed = false;
$found_not_allowed = false;
-
+
$fnmatch = function_exists('fnmatch');
$allowed = explode(',',$str_allowed);
@@ -591,7 +591,7 @@ function allowed_email($email) {
foreach($allowed as $a) {
$pat = strtolower(trim($a));
if(($fnmatch && fnmatch($pat,$email)) || ($pat == $domain)) {
- $found_allowed = true;
+ $found_allowed = true;
break;
}
}
@@ -603,16 +603,16 @@ function allowed_email($email) {
foreach($not_allowed as $na) {
$pat = strtolower(trim($na));
if(($fnmatch && fnmatch($pat,$email)) || ($pat == $domain)) {
- $found_not_allowed = true;
+ $found_not_allowed = true;
break;
}
}
- }
-
+ }
+
if ($found_allowed) {
- $return = true;
+ $return = true;
} elseif (!$str_allowed && !$found_not_allowed) {
- $return = true;
+ $return = true;
}
return $return;
}
@@ -652,7 +652,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
foreach($matches as $mtch) {
logger('scale_external_image: ' . $mtch[2] . ' ' . $mtch[3]);
-
+
if(substr($mtch[1],0,1) == '=') {
$owidth = intval(substr($mtch[2],1));
if(intval($owidth) > 0 && intval($owidth) < 1024)
@@ -686,7 +686,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$type = guess_image_type($mtch[3],$i['header']);
if(strpos($type,'image') === false)
continue;
-
+
if($i['success']) {
$ph = photo_factory($i['body'], $type);
if($ph->is_valid()) {
@@ -700,7 +700,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$new_height = $ph->getHeight();
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
$s = str_replace($mtch[0],'[' . $tag . '=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/' . $tag . ']'
- . "\n" . (($include_link)
+ . "\n" . (($include_link)
? '[zrl=' . $mtch[2] . ']' . t('view full size') . '[/zrl]' . "\n"
: ''),$s);
logger('scale_external_images: new string: ' . $s, LOGGER_DEBUG);
@@ -728,7 +728,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
* Examples: $array = xml2array(file_get_contents('feed.xml'));
* $array = xml2array(file_get_contents('feed.xml', true, 1, 'attribute'));
- */
+ */
function xml2array($contents, $namespaces = true, $get_attributes=1, $priority = 'attribute') {
if(!$contents) return array();
@@ -752,7 +752,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
return array();
}
- xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
// http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
@@ -786,7 +786,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
$result = array();
$attributes_data = array();
-
+
if(isset($value)) {
if($priority == 'tag') $result = $value;
else $result['value'] = $value; // Put the value in a assoc array if we are in the 'Attribute' mode
@@ -802,7 +802,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
// See tag status and do the needed.
if($namespaces && strpos($tag,':')) {
- $namespc = substr($tag,0,strrpos($tag,':'));
+ $namespc = substr($tag,0,strrpos($tag,':'));
$tag = strtolower(substr($tag,strlen($namespc)+1));
$result['@namespace'] = $namespc;
}
@@ -825,7 +825,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
} else { // This section will make the value an array if multiple tags with the same name appear together
$current[$tag] = array($current[$tag],$result); // This will combine the existing item and the new item together to make an array
$repeated_tag_index[$tag.'_'.$level] = 2;
-
+
if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
@@ -848,7 +848,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
// ...push the new element into that array.
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
-
+
if($priority == 'tag' and $get_attributes and $attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
@@ -859,11 +859,11 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
$repeated_tag_index[$tag.'_'.$level] = 1;
if($priority == 'tag' and $get_attributes) {
if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
-
+
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
}
-
+
if($attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
@@ -876,9 +876,9 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
$current = &$parent[$level-1];
}
}
-
+
return($xml_array);
-}
+}
function email_header_encode($in_str, $charset = 'UTF-8') {
@@ -1128,7 +1128,7 @@ function discover_by_webbie($webbie) {
$diaspora = false;
$gnusoc = false;
$dfrn = false;
-
+
$has_salmon = false;
$salmon_key = false;
$atom_feed = false;
@@ -1144,7 +1144,7 @@ function discover_by_webbie($webbie) {
if(array_key_exists('rel',$link)) {
// If we discover zot - don't search further; grab the info and get out of
- // here.
+ // here.
if($link['rel'] === PROTOCOL_ZOT) {
logger('discover_by_webbie: zot found for ' . $webbie, LOGGER_DEBUG);
@@ -1204,11 +1204,11 @@ function discover_by_webbie($webbie) {
$pubkey = '';
if(is_array($x)) {
- if(array_key_exists('address',$x))
+ if(array_key_exists('address',$x))
$address = $x['address'];
- if(array_key_exists('location',$x))
+ if(array_key_exists('location',$x))
$location = $x['location'];
- if(array_key_exists('nickname',$x))
+ if(array_key_exists('nickname',$x))
$nickname = $x['nickname'];
}
@@ -1216,16 +1216,16 @@ function discover_by_webbie($webbie) {
$probe_old = true;
- if((! $dfrn) && (! $has_salmon))
+ if((! $dfrn) && (! $has_salmon))
$probe_old = true;
if($probe_old) {
- $y = old_webfinger($webbie);
+ $y = old_webfinger($webbie);
if($y) {
logger('old_webfinger: ' . print_r($x,true));
foreach($y as $link) {
if($link['@attributes']['rel'] === NAMESPACE_DFRN)
- $dfrn = unamp($link['@attributes']['href']);
+ $dfrn = unamp($link['@attributes']['href']);
if($link['@attributes']['rel'] === 'salmon')
$notify = unamp($link['@attributes']['href']);
if($link['@attributes']['rel'] === NAMESPACE_FEED)
@@ -1344,7 +1344,7 @@ function discover_by_webbie($webbie) {
if($vcard['fn'])
$fullname = $vcard['fn'];
if($vcard['photo'] && (strpos($vcard['photo'],'http') !== 0))
- $vcard['photo'] = $diaspora_base . '/' . $vcard['photo'];
+ $vcard['photo'] = $diaspora_base . '/' . $vcard['photo'];
if(($vcard['public_key']) && (! $pubkey)) {
$diaspora_key = $vcard['public_key'];
if(strstr($diaspora_key,'RSA '))
@@ -1358,7 +1358,7 @@ function discover_by_webbie($webbie) {
if(($vcard['uid']) && (! $diaspora_guid))
$diaspora_guid = $vcard['uid'];
if(($vcard['url']) && (! $diaspora_base))
- $diaspora_base = $vcard['url'];
+ $diaspora_base = $vcard['url'];
@@ -1372,7 +1372,7 @@ function discover_by_webbie($webbie) {
if(($profile) && (! $location))
$location = $profile;
- if($location) {
+ if($location) {
$m = parse_url($location);
$base = $m['scheme'] . '://' . $m['host'];
$host = $m['host'];
@@ -1407,7 +1407,7 @@ function discover_by_webbie($webbie) {
// if we have everything we need, let's create the records
- if($network && $address && $fullname && $pubkey && $location) {
+ if($network && $address && $fullname && $pubkey && $location) {
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($address)
);
@@ -1493,7 +1493,7 @@ function webfinger_rfc7033($webbie,$zot = false) {
// We could have a number of URL aliases and webbies
// make an executive decision about the most likely "best" of each
// by comparing against some examples from known networks we're likely to encounter.
- // Otherwise we have to store every alias that we may ever encounter and
+ // Otherwise we have to store every alias that we may ever encounter and
// validate every URL we ever find against every possible alias
// @fixme pump.io is going to be a real bugger since it doesn't return subject or aliases
@@ -1564,7 +1564,7 @@ function match_webfinger_location($s,$h) {
return $s;
return '';
}
-
+
@@ -1935,7 +1935,7 @@ function format_and_send_email($sender,$xchan,$item) {
));
$sender_name = t('Administrator');
-
+
$hostname = App::get_hostname();
if(strpos($hostname,':'))
$hostname = substr($hostname,0,strpos($hostname,':'));
@@ -1964,7 +1964,7 @@ function do_delivery($deliveries) {
if(! (is_array($deliveries) && count($deliveries)))
return;
- $interval = ((get_config('system','delivery_interval') !== false)
+ $interval = ((get_config('system','delivery_interval') !== false)
? intval(get_config('system','delivery_interval')) : 2 );
$deliveries_per_process = intval(get_config('system','delivery_batch_count'));
@@ -1993,7 +1993,7 @@ function do_delivery($deliveries) {
if($deliver)
Zotlabs\Daemon\Master::Summon(array('Deliver',$deliver));
-
+
}
@@ -2002,7 +2002,7 @@ function get_site_info() {
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
$directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_PRIMARY', 'DIRECTORY_MODE_SECONDARY', 256 => 'DIRECTORY_MODE_STANDALONE');
-
+
$sql_extra = '';
$r = q("select * from channel left join account on account_id = channel_account_id where ( account_roles & 4096 )>0 and account_default_channel = channel_id");
@@ -2053,7 +2053,7 @@ function get_site_info() {
else {
$version = $commit = '';
}
-
+
//Statistics
$channels_total_stat = intval(get_config('system','channels_total_stat'));
$channels_active_halfyear_stat = intval(get_config('system','channels_active_halfyear_stat'));
@@ -2073,7 +2073,7 @@ function get_site_info() {
}
-
+
$data = Array(
'version' => $version,
'version_tag' => $tag,
@@ -2190,7 +2190,7 @@ function deliverable_singleton($channel_id,$xchan) {
function get_repository_version($branch = 'master') {
$path = "https://raw.githubusercontent.com/redmatrix/hubzilla/$branch/boot.php";
-
+
$x = z_fetch_url($path);
if($x['success']) {
$y = preg_match('/define(.*?)STD_VERSION(.*?)([0-9.].*)\'/',$x['body'],$matches);
@@ -2199,7 +2199,7 @@ function get_repository_version($branch = 'master') {
}
return '?.?';
-}
+}
function network_to_name($s) {
@@ -2270,7 +2270,7 @@ function z_mail($params) {
return $params['result'];
}
- $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
+ $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
$messageHeader =
diff --git a/include/photos.php b/include/photos.php
index a3018816c..e8f46048c 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -45,7 +45,7 @@ function photo_upload($channel, $observer, $args) {
if(array_key_exists('deliver',$args))
$deliver = intval($args['deliver']);
- // Set to default channel permissions. If the parent directory (album) has permissions set,
+ // Set to default channel permissions. If the parent directory (album) has permissions set,
// use those instead. If we have specific permissions supplied, they take precedence over
// all other settings. 'allow_cid' being passed from an external source takes priority over channel settings.
// ...messy... needs re-factoring once the photos/files integration stabilises
@@ -55,9 +55,9 @@ function photo_upload($channel, $observer, $args) {
$acl->set($args['directory']);
if(array_key_exists('allow_cid',$args))
$acl->set($args);
- if( (array_key_exists('group_allow',$args))
- || (array_key_exists('contact_allow',$args))
- || (array_key_exists('group_deny',$args))
+ 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))) {
$acl->set_from_array($args);
}
@@ -103,7 +103,7 @@ function photo_upload($channel, $observer, $args) {
$type = $_FILES['userfile']['type'];
}
- if (! $type)
+ if (! $type)
$type=guess_image_type($filename);
logger('photo_upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
@@ -176,7 +176,7 @@ function photo_upload($channel, $observer, $args) {
$errors = false;
$p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash,
- 'filename' => $filename, 'album' => $album, 'imgscale' => 0, 'photo_usage' => PHOTO_NORMAL,
+ 'filename' => $filename, 'album' => $album, 'imgscale' => 0, 'photo_usage' => PHOTO_NORMAL,
'allow_cid' => $ac['allow_cid'], 'allow_gid' => $ac['allow_gid'],
'deny_cid' => $ac['deny_cid'], 'deny_gid' => $ac['deny_gid'],
'os_storage' => $os_storage, 'os_path' => $args['os_path']
@@ -220,8 +220,8 @@ function photo_upload($channel, $observer, $args) {
);
if(! $r1)
$errors = true;
-
- if(($width > 640 || $height > 640) && (! $errors))
+
+ if(($width > 640 || $height > 640) && (! $errors))
$ph->scaleImage(640);
$p['imgscale'] = 2;
@@ -236,7 +236,7 @@ function photo_upload($channel, $observer, $args) {
if(! $r2)
$errors = true;
- if(($width > 320 || $height > 320) && (! $errors))
+ if(($width > 320 || $height > 320) && (! $errors))
$ph->scaleImage(320);
$p['imgscale'] = 3;
@@ -304,8 +304,8 @@ function photo_upload($channel, $observer, $args) {
$summary = (($args['body']) ? $args['body'] : '') . '[footer]' . $activity_format . '[/footer]';
- $obj_body = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
- . $tag . z_root() . "/photo/{$photo_hash}-{$scale}." . $ph->getExt() . '[/zmg]'
+ $obj_body = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
+ . $tag . z_root() . "/photo/{$photo_hash}-{$scale}." . $ph->getExt() . '[/zmg]'
. '[/zrl]';
// Create item object
@@ -361,7 +361,7 @@ function photo_upload($channel, $observer, $args) {
$item['uid'] = $channel['channel_id'];
item_store_update($item,false,$deliver);
continue;
- }
+ }
}
else {
$item['aid'] = $channel['channel_account_id'];
@@ -381,7 +381,7 @@ function photo_upload($channel, $observer, $args) {
$arr['aid'] = $account_id;
$arr['uid'] = $channel_id;
$arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
+ $arr['parent_mid'] = $mid;
$arr['item_hidden'] = $item_hidden;
$arr['resource_type'] = 'photo';
$arr['resource_id'] = $photo_hash;
@@ -407,10 +407,10 @@ function photo_upload($channel, $observer, $args) {
// this one is tricky because the item and the photo have the same permissions, those of the photo.
// Use the channel read_stream permissions to get the correct public_policy for the item and recalculate the
- // private flag accordingly. This may cause subtle bugs due to custom permissions roles. We want to use
+ // private flag accordingly. This may cause subtle bugs due to custom permissions roles. We want to use
// public policy when federating items to other sites, but should probably ignore them when accessing the item
// in the photos pages - using the photos permissions instead. We need the public policy to keep the photo
- // linked item from leaking into the feed when somebody has a channel with read_stream restrictions.
+ // linked item from leaking into the feed when somebody has a channel with read_stream restrictions.
$arr['public_policy'] = map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_stream'),true);
if($arr['public_policy'])
@@ -421,7 +421,7 @@ function photo_upload($channel, $observer, $args) {
$result = item_store($arr,false,$deliver);
$item_id = $result['item_id'];
- if($visible && $deliver)
+ if($visible && $deliver)
Zotlabs\Daemon\Master::Summon(array('Notifier', 'wall-new', $item_id));
}
@@ -443,9 +443,12 @@ function photo_upload($channel, $observer, $args) {
*
* @param array $channel
* @param array $observer
+ * @param array $sort_key (optional) default album
+ * @param array $direction (optional) default asc
+ *
* @return bool|array false if no view_storage permission or an array
- * * success (bool)
- * * albums (array)
+ * * \e boolean \b success
+ * * \e array \b albums
*/
function photos_albums_list($channel, $observer, $sort_key = 'album', $direction = 'asc') {
@@ -455,14 +458,11 @@ function photos_albums_list($channel, $observer, $sort_key = 'album', $direction
if(! perm_is_allowed($channel_id, $observer_xchan, 'view_storage'))
return false;
-
$sql_extra = permissions_sql($channel_id,$observer_xchan);
$sort_key = dbesc($sort_key);
$direction = dbesc($direction);
-
-
$albums = q("SELECT count( distinct resource_id ) as total, album from photo where uid = %d and photo_usage IN ( %d, %d ) $sql_extra group by album order by $sort_key $direction",
intval($channel_id),
intval(PHOTO_NORMAL),
@@ -479,8 +479,8 @@ function photos_albums_list($channel, $observer, $sort_key = 'album', $direction
foreach($albums as $k => $album) {
$entry = array(
'text' => (($album['album']) ? $album['album'] : '/'),
- 'total' => $album['total'],
- 'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']),
+ 'total' => $album['total'],
+ 'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']),
'urlencode' => urlencode($album['album']),
'bin2hex' => bin2hex($album['album'])
);
@@ -506,7 +506,7 @@ function photos_album_widget($channelx,$observer,$sortkey = 'album',$direction =
'$title' => t('Photo Albums'),
'$albums' => $albums['albums'],
'$baseurl' => z_root(),
- '$upload' => ((perm_is_allowed($channelx['channel_id'],(($observer) ? $observer['xchan_hash'] : ''),'write_storage'))
+ '$upload' => ((perm_is_allowed($channelx['channel_id'],(($observer) ? $observer['xchan_hash'] : ''),'write_storage'))
? t('Upload New Photos') : '')
));
}
@@ -533,7 +533,7 @@ function photos_list_photos($channel, $observer, $album = '') {
$sql_extra = permissions_sql($channel_id);
if($album)
- $sql_extra .= " and album = '" . protect_sprintf(dbesc($album)) . "' ";
+ $sql_extra .= " and album = '" . protect_sprintf(dbesc($album)) . "' ";
$ret = array('success' => false);
@@ -647,7 +647,7 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
$arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id'];
$arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
+ $arr['parent_mid'] = $mid;
$arr['item_wall'] = 1;
$arr['item_origin'] = 1;
$arr['item_thread_top'] = 1;
@@ -663,9 +663,9 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
$arr['deny_gid'] = $photo['deny_gid'];
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
-
- $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']'
- . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['imgscale'] . '[/zmg]'
+
+ $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']'
+ . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['imgscale'] . '[/zmg]'
. '[/zrl]';
$result = item_store($arr);
@@ -710,39 +710,39 @@ function gps2Num($coordPart) {
}
function profile_photo_set_profile_perms($uid, $profileid = 0) {
-
+
$allowcid = '';
if($profileid) {
$r = q("SELECT photo, profile_guid, id, is_default, uid
- FROM profile WHERE uid = %d and ( profile.id = %d OR profile.profile_guid = '%s') LIMIT 1",
+ FROM profile WHERE uid = %d and ( profile.id = %d OR profile.profile_guid = '%s') LIMIT 1",
intval($uid),
- intval($profileid),
+ intval($profileid),
dbesc($profileid)
);
- }
+ }
else {
logger('Resetting permissions on default-profile-photo for user'.local_channel());
- $r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile
- WHERE profile.uid = %d AND is_default = 1 LIMIT 1",
- intval($uid)
+ $r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile
+ WHERE profile.uid = %d AND is_default = 1 LIMIT 1",
+ intval($uid)
); //If no profile is given, we update the default profile
}
if(! $r)
return;
-
+
$profile = $r[0];
- if($profile['id'] && $profile['photo']) {
+ if($profile['id'] && $profile['photo']) {
preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id);
$resource_id = $resource_id[0];
-
+
if (! intval($profile['is_default'])) {
- $r0 = q("SELECT channel_hash FROM channel WHERE channel_id = %d LIMIT 1",
- intval($uid)
+ $r0 = q("SELECT channel_hash FROM channel WHERE channel_id = %d LIMIT 1",
+ intval($uid)
);
//Should not be needed in future. Catches old int-profile-ids.
- $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%d' ",
+ $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%d' ",
intval($profile['id'])
);
$r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'",
@@ -750,27 +750,27 @@ function profile_photo_set_profile_perms($uid, $profileid = 0) {
);
$allowcid = "<" . $r0[0]['channel_hash'] . ">";
foreach ($r1 as $entry) {
- $allowcid .= "<" . $entry['abook_xchan'] . ">";
+ $allowcid .= "<" . $entry['abook_xchan'] . ">";
}
foreach ($r2 as $entry) {
$allowcid .= "<" . $entry['abook_xchan'] . ">";
}
-
+
q("UPDATE photo SET allow_cid = '%s' WHERE resource_id = '%s' AND uid = %d",
dbesc($allowcid),
dbesc($resource_id),
intval($uid)
);
-
- }
+
+ }
else {
//Reset permissions on default profile picture to public
q("UPDATE photo SET allow_cid = '' WHERE photo_usage = %d AND uid = %d",
intval(PHOTO_PROFILE),
intval($uid)
- );
+ );
}
}
-
+
return;
}
diff --git a/include/plugin.php b/include/plugin.php
index f9eb174bc..e4a854c18 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -143,7 +143,7 @@ function reload_plugins() {
if(file_exists($fname)) {
$t = @filemtime($fname);
foreach($installed as $i) {
- if(($i['aname'] == $pl) && ($i['tstamp'] != $t)) {
+ if(($i['aname'] == $pl) && ($i['tstamp'] != $t)) {
logger('Reloading plugin: ' . $i['aname']);
@include_once($fname);
@@ -205,7 +205,7 @@ function register_hook($hook, $file, $function, $priority = 0) {
/**
* @brief unregisters a hook.
- *
+ *
* @param string $hook the name of the hook
* @param string $file the name of the file that hooks into
* @param string $function the name of the function that the hook called
@@ -224,7 +224,7 @@ function unregister_hook($hook, $file, $function) {
//
// It might not be obvious but themes can manually add hooks to the App::$hooks
-// array in their theme_init() and use this to customise the app behaviour.
+// array in their theme_init() and use this to customise the app behaviour.
// UPDATE: use insert_hook($hookname,$function_name) to do this
//
@@ -248,20 +248,22 @@ function load_hooks() {
/**
* @brief Inserts a hook into a page request.
*
- * Insert a short-lived hook into the running page request.
- * Hooks are normally persistent so that they can be called
+ * Insert a short-lived hook into the running page request.
+ * Hooks are normally persistent so that they can be called
* across asynchronous processes such as delivery and poll
* processes.
*
* insert_hook lets you attach a hook callback immediately
* which will not persist beyond the life of this page request
- * or the current process.
+ * or the current process.
*
* @param string $hook
* name of hook to attach callback
* @param string $fn
* function name of callback handler
- */
+ * @param int $version (optional) default 0
+ * @param int $priority (optional) default 0
+ */
function insert_hook($hook, $fn, $version = 0, $priority = 0) {
if(! is_array(App::$hooks))
@@ -293,7 +295,7 @@ function call_hooks($name, &$data = null) {
$hook[1] = unserialize($hook[1]);
}
elseif(strpos($hook[1],'::')) {
- // We shouldn't need to do this, but it appears that PHP
+ // We shouldn't need to do this, but it appears that PHP
// isn't able to directly execute a string variable with a class
// method in the manner we are attempting it, so we'll
// turn it into an array.
@@ -306,10 +308,10 @@ function call_hooks($name, &$data = null) {
$func($data);
else
$func($a, $data);
- }
+ }
else {
- // Don't do any DB write calls if we're currently logging a possibly failed DB call.
+ // Don't do any DB write calls if we're currently logging a possibly failed DB call.
if(! DBA::$logging) {
// The hook should be removed so we don't process it.
q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND fn = '%s'",
@@ -370,7 +372,7 @@ function get_plugin_info($plugin){
} else {
$info[$k][] = array('name' => $v);
}
- }
+ }
else {
$info[$k] = $v;
}
@@ -407,8 +409,8 @@ function check_plugin_versions($info) {
if(array_key_exists('serverroles',$info)) {
$role = \Zotlabs\Lib\System::get_server_role();
if(! (
- stristr($info['serverroles'],'*')
- || stristr($info['serverroles'],'any')
+ stristr($info['serverroles'],'*')
+ || stristr($info['serverroles'],'any')
|| stristr($info['serverroles'],$role))) {
logger('serverrole limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING);
return false;
@@ -426,7 +428,7 @@ function check_plugin_versions($info) {
if(! $test)
continue;
if(! in_array($test,App::$plugins))
- $found = false;
+ $found = false;
}
}
if(! $found)
@@ -583,11 +585,11 @@ function format_css_if_exists($source) {
/*
* This basically calculates the baseurl. We have other functions to do that, but
- * there was an issue with script paths and mixed-content whose details are arcane
- * and perhaps lost in the message archives. The short answer is that we're ignoring
- * the URL which we are "supposed" to use, and generating script paths relative to
+ * there was an issue with script paths and mixed-content whose details are arcane
+ * and perhaps lost in the message archives. The short answer is that we're ignoring
+ * the URL which we are "supposed" to use, and generating script paths relative to
* the URL which we are currently using; in order to ensure they are found and aren't
- * blocked due to mixed content issues.
+ * blocked due to mixed content issues.
*/
function script_path() {
@@ -599,7 +601,7 @@ function script_path() {
$scheme = 'https';
else
$scheme = 'http';
-
+
// Some proxy setups may require using http_host
if(intval(App::$config['system']['script_path_use_http_host']))
@@ -631,7 +633,7 @@ function head_remove_js($src, $priority = 0) {
}
// We should probably try to register main.js with a high priority, but currently we handle it
-// separately and put it at the end of the html head block in case any other javascript is
+// separately and put it at the end of the html head block in case any other javascript is
// added outside the head_add_js construct.
function head_get_js() {
@@ -640,7 +642,7 @@ function head_get_js() {
if(App::$js_sources) {
ksort(App::$js_sources,SORT_NUMERIC);
foreach(App::$js_sources as $sources) {
- if(count($sources)) {
+ if(count($sources)) {
foreach($sources as $source) {
if($src === 'main.js')
continue;
@@ -655,7 +657,7 @@ function head_get_js() {
function head_get_main_js() {
$str = '';
$sources = array('main.js');
- if(count($sources))
+ if(count($sources))
foreach($sources as $source)
$str .= format_js_if_exists($source,true);
return $str;
diff --git a/include/security.php b/include/security.php
index 5ffa48d9e..2f5de54c7 100644
--- a/include/security.php
+++ b/include/security.php
@@ -2,11 +2,12 @@
/**
* @file include/security.php
*
- * Some security related functions.
+ * @brief Some security related functions.
*/
/**
* @param int $user_record The account_id
+ * @param array $channel
* @param bool $login_initial default false
* @param bool $interactive default false
* @param bool $return
@@ -27,8 +28,8 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa
$uid_to_load = $channel['channel_id'];
if(! $uid_to_load) {
- $uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid'])))
- ? intval($_SESSION['uid'])
+ $uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid'])))
+ ? intval($_SESSION['uid'])
: intval(App::$account['account_default_channel'])
);
}
@@ -89,21 +90,28 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa
function atoken_login($atoken) {
if(! $atoken)
return false;
+
$_SESSION['authenticated'] = 1;
$_SESSION['visitor_id'] = $atoken['xchan_hash'];
$_SESSION['atoken'] = $atoken['atoken_id'];
\App::set_observer($atoken);
+
return true;
}
-
+/**
+ * @brief
+ *
+ * @param array $atoken
+ * @return array|null
+ */
function atoken_xchan($atoken) {
$c = channelx_by_n($atoken['atoken_uid']);
if($c) {
return [
- 'atoken_id' => $atoken['atoken_id'],
+ 'atoken_id' => $atoken['atoken_id'],
'xchan_hash' => substr($c['channel_hash'],0,16) . '.' . $atoken['atoken_name'],
'xchan_name' => $atoken['atoken_name'],
'xchan_addr' => t('guest:') . $atoken['atoken_name'] . '@' . \App::get_hostname(),
@@ -114,9 +122,9 @@ function atoken_xchan($atoken) {
'xchan_photo_l' => get_default_profile_photo(300),
'xchan_photo_m' => get_default_profile_photo(80),
'xchan_photo_s' => get_default_profile_photo(48)
-
];
}
+
return null;
}
@@ -133,7 +141,7 @@ function atoken_delete($atoken_id) {
);
if(! $c)
return;
-
+
$atoken_xchan = substr($c[0]['channel_hash'],0,16) . '.' . $r[0]['atoken_name'];
q("delete from atoken where atoken_id = %d",
@@ -145,12 +153,16 @@ function atoken_delete($atoken_id) {
);
}
-
-
-// in order for atoken logins to create content (such as posts) they need a stored xchan.
-// we'll create one on the first atoken_login; it can't really ever go away but perhaps
-// @fixme we should set xchan_deleted if it's expired or removed
-
+/**
+ * @brief
+ *
+ * In order for atoken logins to create content (such as posts) they need a stored xchan.
+ * we'll create one on the first atoken_login; it can't really ever go away but perhaps
+ * @fixme we should set xchan_deleted if it's expired or removed
+ *
+ * @param array $xchan
+ * @return void|boolean
+ */
function atoken_create_xchan($xchan) {
$r = q("select xchan_hash from xchan where xchan_hash = '%s'",
@@ -159,7 +171,7 @@ function atoken_create_xchan($xchan) {
if($r)
return;
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_mimetype, xchan_photo_l, xchan_photo_m, xchan_photo_s )
+ $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_mimetype, xchan_photo_l, xchan_photo_m, xchan_photo_s )
values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
dbesc($xchan['xchan_hash']),
dbesc($xchan['xchan_hash']),
@@ -202,12 +214,11 @@ function atoken_abook($uid,$xchan_hash) {
}
return false;
-
}
function pseudo_abook($xchan) {
- if(! $xchan)
+ if(! $xchan)
return false;
// set abook_pseudo to flag that we aren't really connected.
@@ -216,8 +227,8 @@ function pseudo_abook($xchan) {
$xchan['abook_blocked'] = 0;
$xchan['abook_ignored'] = 0;
$xchan['abook_pending'] = 0;
+
return $xchan;
-
}
@@ -228,7 +239,6 @@ function pseudo_abook($xchan) {
*
* @return bool|array false or channel record of the new channel
*/
-
function change_channel($change_channel) {
$ret = false;
@@ -260,7 +270,7 @@ function change_channel($change_channel) {
date_default_timezone_set($r[0]['channel_timezone']);
$ret = $r[0];
}
- $x = q("select * from xchan where xchan_hash = '%s' limit 1",
+ $x = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($hash)
);
if($x) {
@@ -275,7 +285,6 @@ function change_channel($change_channel) {
$arr = [ 'channel_id' => $change_channel, 'chanx' => $ret ];
call_hooks('change_channel', $arr);
-
}
return $ret;
@@ -285,11 +294,11 @@ function change_channel($change_channel) {
* @brief Creates an additional SQL where statement to check permissions.
*
* @param int $owner_id
- * @param bool $remote_observer - if unset use current observer
+ * @param bool $remote_observer (optional) use current observer if unset
+ * @param $table (optional)
*
* @return string additional SQL where statement
*/
-
function permissions_sql($owner_id, $remote_observer = null, $table = '') {
$local_channel = local_channel();
@@ -303,11 +312,10 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') {
if($table)
$table .= '.';
-
- $sql = " AND {$table}allow_cid = ''
- AND {$table}allow_gid = ''
- AND {$table}deny_cid = ''
- AND {$table}deny_gid = ''
+ $sql = " AND {$table}allow_cid = ''
+ AND {$table}allow_gid = ''
+ AND {$table}deny_cid = ''
+ AND {$table}deny_gid = ''
";
/**
@@ -319,7 +327,7 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') {
}
/**
- * Authenticated visitor. Unless pre-verified,
+ * Authenticated visitor. Unless pre-verified,
* check that the contact belongs to this $owner_id
* and load the groups the visitor belongs to.
* If pre-verified, the caller is expected to have already
@@ -358,7 +366,7 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') {
* @brief Creates an addiontal SQL where statement to check permissions for an item.
*
* @param int $owner_id
- * @param bool $remote_observer, use current observer if unset
+ * @param bool $remote_observer (optional) use current observer if unset
*
* @return string additional SQL where statement
*/
@@ -379,7 +387,7 @@ function item_permissions_sql($owner_id, $remote_observer = null) {
*/
if(($local_channel) && ($local_channel == $owner_id)) {
- $sql = '';
+ $sql = '';
}
/**
@@ -425,7 +433,7 @@ function item_permissions_sql($owner_id, $remote_observer = null) {
/**
* Remote visitors also need to be checked against the public_scope parameter if item_private is set.
* This function checks the various permutations of that field for any which apply to this observer.
- *
+ *
*/
@@ -448,9 +456,9 @@ function scopes_sql($uid,$observer) {
$str .= " or public_policy = 'contacts' ) ";
return $str;
}
-
-
-
+
+
+
@@ -500,7 +508,7 @@ function public_permissions_sql($observer_hash) {
* If the new page contains by any chance external elements, then the used security token is exposed by the referrer.
* Actually, important actions should not be triggered by Links / GET-Requests at all, but somethimes they still are,
* so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types).
- */
+ */
function get_form_security_token($typename = '') {
$timestamp = time();
@@ -561,13 +569,13 @@ function init_groups_visitor($contact_id) {
-// This is used to determine which uid have posts which are visible to the logged in user (from the API) for the
+// This is used to determine which uid have posts which are visible to the logged in user (from the API) for the
// public_timeline, and we can use this in a community page by making
-// $perms = (PERMS_NETWORK|PERMS_PUBLIC) unless logged in.
+// $perms = (PERMS_NETWORK|PERMS_PUBLIC) unless logged in.
// Collect uids of everybody on this site who has opened their posts to everybody on this site (or greater visibility)
// We always include yourself if logged in because you can always see your own posts
// resolving granular permissions for the observer against every person and every post on the site
-// will likely be too expensive.
+// will likely be too expensive.
// Returns a string list of comma separated channel_ids suitable for direct inclusion in a SQL query
function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) {
diff --git a/include/text.php b/include/text.php
index fcd5dbc0c..03044c78f 100644
--- a/include/text.php
+++ b/include/text.php
@@ -17,6 +17,7 @@ define('RANDOM_STRING_TEXT', 0x01 );
* @param string|SmartyEngine $s the string requiring macro substitution,
* or an instance of SmartyEngine
* @param array $r key value pairs (search => replace)
+ *
* @return string substituted string
*/
function replace_macros($s, $r) {
@@ -35,6 +36,7 @@ function replace_macros($s, $r) {
*
* @param number $size
* @param int $type
+ *
* @return string
*/
function random_string($size = 64, $type = RANDOM_STRING_HEX) {
@@ -52,14 +54,15 @@ function random_string($size = 64, $type = RANDOM_STRING_HEX) {
* that had an XSS attack vector due to stripping the high-bit on an 8-bit character
* after cleansing, and angle chars with the high bit set could get through as markup.
*
- * This is now disabled because it was interfering with some legitimate unicode sequences
- * and hopefully there aren't a lot of those browsers left.
+ * This is now disabled because it was interfering with some legitimate unicode sequences
+ * and hopefully there aren't a lot of those browsers left.
*
* Use this on any text input where angle chars are not valid or permitted
* They will be replaced with safer brackets. This may be filtered further
* if these are not allowed either.
*
* @param string $string Input string
+ *
* @return string Filtered string
*/
function notags($string) {
@@ -74,13 +77,13 @@ function notags($string) {
/**
* use this on "body" or "content" input where angle chars shouldn't be removed,
* and allow them to be safely displayed.
+ *
* @param string $string
+ *
* @return string
*/
function escape_tags($string) {
-
return(htmlspecialchars($string, ENT_COMPAT, 'UTF-8', false));
-
}
@@ -182,7 +185,7 @@ function purify_html($s, $allow_position = false) {
// f6 plugins
- //abide - the use is pointless since we can't do anything with forms
+ //abide - the use is pointless since we can't do anything with forms
//equalizer
$def->info_global_attr['data-equalizer'] = new HTMLPurifier_AttrDef_Text;
@@ -272,14 +275,12 @@ function purify_html($s, $allow_position = false) {
}
-
$purifier = new HTMLPurifier($config);
return $purifier->purify($s);
}
-
/**
* @brief generate a string that's random, but usually pronounceable.
*
@@ -293,7 +294,7 @@ function autoname($len) {
if ($len <= 0)
return '';
- $vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u');
+ $vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u');
if (mt_rand(0, 5) == 4)
$vowels[] = 'y';
@@ -370,13 +371,12 @@ function xmlify($str) {
if(is_array($str)) {
- // allow to fall through so we ge a PHP error, as the log statement will
- // probably get lost in the noise unless we're specifically looking for it.
+ // allow to fall through so we ge a PHP error, as the log statement will
+ // probably get lost in the noise unless we're specifically looking for it.
btlogger('xmlify called with array: ' . print_r($str,true), LOGGER_NORMAL, LOG_WARNING);
}
-
$len = mb_strlen($str);
for($x = 0; $x < $len; $x ++) {
$char = mb_substr($str,$x,1);
@@ -412,27 +412,36 @@ function xmlify($str) {
return($buffer);
}
-// undo an xmlify
-// pass xml escaped text ($s), returns unescaped text
-
-
+/**
+ * @brief Undo an xmlify.
+ *
+ * Pass xml escaped text ($s), returns unescaped text.
+ *
+ * @param string $s
+ *
+ * @return string
+ */
function unxmlify($s) {
- $ret = str_replace('&amp;','&', $s);
- $ret = str_replace(array('&lt;','&gt;','&quot;','&apos;'),array('<','>','"',"'"),$ret);
+ $ret = str_replace('&amp;', '&', $s);
+ $ret = str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $ret);
+
return $ret;
}
-// Automatic pagination.
-// To use, get the count of total items.
-// Then call App::set_pager_total($number_items);
-// Optionally call App::set_pager_itemspage($n) to the number of items to display on each page
-// Then call paginate($a) after the end of the display loop to insert the pager block on the page
-// (assuming there are enough items to paginate).
-// When using with SQL, the setting LIMIT %d, %d => App::$pager['start'],App::$pager['itemspage']
-// will limit the results to the correct items for the current page.
-// The actual page handling is then accomplished at the application layer.
-
-
+/**
+ * @brief Automatic pagination.
+ *
+ * To use, get the count of total items.
+ * Then call App::set_pager_total($number_items);
+ * Optionally call App::set_pager_itemspage($n) to the number of items to display on each page
+ * Then call paginate($a) after the end of the display loop to insert the pager block on the page
+ * (assuming there are enough items to paginate).
+ * When using with SQL, the setting LIMIT %d, %d => App::$pager['start'],App::$pager['itemspage']
+ * will limit the results to the correct items for the current page.
+ * The actual page handling is then accomplished at the application layer.
+ *
+ * @param App &$a
+ */
function paginate(&$a) {
$o = '';
$stripped = preg_replace('/(&page=[0-9]*)/','',App::$query_string);
@@ -451,15 +460,15 @@ function paginate(&$a) {
$o .= "<span class=\"pager_first\"><a href=\"$url"."&page=1\">" . t('first') . "</a></span> ";
- $numpages = App::$pager['total'] / App::$pager['itemspage'];
+ $numpages = App::$pager['total'] / App::$pager['itemspage'];
- $numstart = 1;
- $numstop = $numpages;
+ $numstart = 1;
+ $numstop = $numpages;
- if($numpages > 14) {
- $numstart = (($pagenum > 7) ? ($pagenum - 7) : 1);
- $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14));
- }
+ if($numpages > 14) {
+ $numstart = (($pagenum > 7) ? ($pagenum - 7) : 1);
+ $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14));
+ }
for($i = $numstart; $i <= $numstop; $i++){
if($i == App::$pager['page'])
@@ -484,6 +493,7 @@ function paginate(&$a) {
$o .= '<span class="pager_next">'."<a href=\"$url"."&page=".(App::$pager['page'] + 1).'">' . t('next') . '</a></span>';
$o .= '</div>'."\r\n";
}
+
return $o;
}
@@ -514,7 +524,6 @@ function alt_pager(&$a, $i, $more = '', $less = '') {
}
-
/**
* @brief Generate a guaranteed unique (for this domain) item ID for ATOM.
*
@@ -558,17 +567,23 @@ function photo_new_resource() {
return $resource;
}
-
-
-// for html,xml parsing - let's say you've got
-// an attribute foobar="class1 class2 class3"
-// and you want to find out if it contains 'class3'.
-// you can't use a normal sub string search because you
-// might match 'notclass3' and a regex to do the job is
-// possible but a bit complicated.
-// pass the attribute string as $attr and the attribute you
-// are looking for as $s - returns true if found, otherwise false
-
+/**
+ * @brief
+ *
+ * for html,xml parsing - let's say you've got
+ * an attribute foobar="class1 class2 class3"
+ * and you want to find out if it contains 'class3'.
+ * you can't use a normal sub string search because you
+ * might match 'notclass3' and a regex to do the job is
+ * possible but a bit complicated.
+ *
+ * pass the attribute string as $attr and the attribute you
+ * are looking for as $s - returns true if found, otherwise false
+ *
+ * @param string $attr attribute string
+ * @param string $s attribute you are looking for
+ * @return boolean true if found
+ */
function attribute_contains($attr, $s) {
$a = explode(' ', $attr);
if(count($a) && in_array($s, $a))
@@ -591,10 +606,9 @@ function attribute_contains($attr, $s) {
* was called, so no need to add it to the message anymore.
*
* @param string $msg Message to log
- * @param int $level A log level.
+ * @param int $level A log level
* @param int $priority - compatible with syslog
*/
-
function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
if(App::$module == 'setup' && is_writable('install.log')) {
@@ -612,7 +626,7 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
return;
$where = '';
-
+
// We require > 5.4 but leave the version check so that install issues (including version) can be logged
if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
@@ -630,19 +644,23 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
@file_put_contents($pluginfo['filename'], $pluginfo['message'], FILE_APPEND);
}
-// like logger() but with a function backtrace to pinpoint certain classes
-// of problems which show up deep in the calling stack
-
-
+/**
+ * @brief like logger() but with a function backtrace to pinpoint certain classes
+ * of problems which show up deep in the calling stack.
+ *
+ * @param string $msg Message to log
+ * @param int $level A log level
+ * @param int $priority - compatible with syslog
+ */
function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
logger($msg, $level, $priority);
if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
- $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+ $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
if($stack) {
for($x = 1; $x < count($stack); $x ++) {
logger('stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()',$level, $priority);
- }
+ }
}
}
}
@@ -718,15 +736,17 @@ function activity_match($haystack,$needle) {
return false;
}
-
-// Pull out all #hashtags and @person tags from $s;
-// We also get @person@domain.com - which would make
-// the regex quite complicated as tags can also
-// end a sentence. So we'll run through our results
-// and strip the period from any tags which end with one.
-// Returns array of tags found, or empty array.
-
-
+/**
+ * @brief Pull out all #hashtags and @person tags from $s.
+ *
+ * We also get @person@domain.com - which would make
+ * the regex quite complicated as tags can also
+ * end a sentence. So we'll run through our results
+ * and strip the period from any tags which end with one.
+ *
+ * @param string $s
+ * @return Returns array of tags found, or empty array.
+ */
function get_tags($s) {
$ret = array();
$match = array();
@@ -797,9 +817,9 @@ function get_tags($s) {
// make sure the longer tags are returned first so that if two or more have common substrings
// we'll replace the longest ones first. Otherwise the common substring would be found in
- // both strings and the string replacement would link both to the shorter strings and
+ // both strings and the string replacement would link both to the shorter strings and
// fail to link the longer string. Hubzilla github issue #378
-
+
usort($ret,'tag_sort_length');
// logger('get_tags: ' . print_r($ret,true));
@@ -824,13 +844,15 @@ function strip_zats($s) {
return preg_replace('/[\?&]zat=(.*?)(&|$)/ism','$2',$s);
}
-
-// quick and dirty quoted_printable encoding
-
-
+/**
+ * @brief Quick and dirty quoted_printable encoding.
+ *
+ * @param string $s
+ * @return string
+ */
function qp($s) {
- return str_replace ("%","=",rawurlencode($s));
-}
+ return str_replace ("%", "=", rawurlencode($s));
+}
function get_mentions($item,$tags) {
@@ -889,9 +911,9 @@ function contact_block() {
$contacts = t('No connections');
$micropro = null;
} else {
-
+
$randfunc = db_getfunc('RAND');
-
+
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d $abook_flags and abook_archived = 0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d",
intval(App::$profile['uid']),
intval($shown)
@@ -936,8 +958,8 @@ function chanlink_cid($d) {
}
function magiclink_url($observer,$myaddr,$url) {
- return (($observer)
- ? z_root() . '/magic?f=&dest=' . $url . '&addr=' . $myaddr
+ return (($observer)
+ ? z_root() . '/magic?f=&dest=' . $url . '&addr=' . $myaddr
: $url
);
}
@@ -1034,8 +1056,8 @@ function sslify($s) {
// Complain to your browser maker
$allow = get_config('system','sslify_everything');
-
- $pattern = (($allow) ? "/\<(.*?)src=\"(http\:.*?)\"(.*?)\>/" : "/\<img(.*?)src=\"(http\:.*?)\"(.*?)\>/" );
+
+ $pattern = (($allow) ? "/\<(.*?)src=\"(http\:.*?)\"(.*?)\>/" : "/\<img(.*?)src=\"(http\:.*?)\"(.*?)\>/" );
$matches = null;
$cnt = preg_match_all($pattern,$s,$matches,PREG_SET_ORDER);
@@ -1105,40 +1127,43 @@ function get_mood_verbs() {
return $arr;
}
-// Function to list all smilies, both internal and from addons
-// Returns array with keys 'texts' and 'icons'
+/**
+ * @brief Function to list all smilies, both internal and from addons.
+ *
+ * @return Returns array with keys 'texts' and 'icons'
+ */
function list_smilies() {
- $texts = array(
- '&lt;3',
- '&lt;/3',
- '&lt;\\3',
- ':-)',
- ';-)',
- ':-(',
- ':-P',
- ':-p',
- ':-"',
- ':-&quot;',
- ':-x',
- ':-X',
- ':-D',
- '8-|',
- '8-O',
- ':-O',
- '\\o/',
- 'o.O',
- 'O.o',
- 'o_O',
- 'O_o',
- ":'(",
- ":-!",
- ":-/",
- ":-[",
+ $texts = array(
+ '&lt;3',
+ '&lt;/3',
+ '&lt;\\3',
+ ':-)',
+ ';-)',
+ ':-(',
+ ':-P',
+ ':-p',
+ ':-"',
+ ':-&quot;',
+ ':-x',
+ ':-X',
+ ':-D',
+ '8-|',
+ '8-O',
+ ':-O',
+ '\\o/',
+ 'o.O',
+ 'O.o',
+ 'o_O',
+ 'O_o',
+ ":'(",
+ ":-!",
+ ":-/",
+ ":-[",
"8-)",
- ':beer',
- ':homebrew',
- ':coffee',
+ ':beer',
+ ':homebrew',
+ ':coffee',
':facepalm',
':like',
':dislike',
@@ -1161,7 +1186,7 @@ function list_smilies() {
'<img class="smiley" src="' . z_root() . '/images/smiley-laughing.gif" alt=":-D" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-|" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-O" />',
- '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt=":-O" />',
+ '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt=":-O" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-thumbsup.gif" alt="\\o/" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="o.O" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="O.o" />',
@@ -1208,7 +1233,7 @@ function list_smilies() {
* We will escape text between HTML pre and code blocks, and HTML attributes
* (such as urls) from being processed.
*
- * At a higher level, the bbcode [nosmile] tag can be used to prevent this
+ * At a higher level, the bbcode [nosmile] tag can be used to prevent this
* function from being executed by the prepare_text() routine when preparing
* bbcode source for HTML display.
*
@@ -1218,7 +1243,7 @@ function list_smilies() {
*/
function smilies($s, $sample = false) {
- if(intval(get_config('system', 'no_smilies'))
+ if(intval(get_config('system', 'no_smilies'))
|| (local_channel() && intval(get_pconfig(local_channel(), 'system', 'no_smilies'))))
return $s;
@@ -1255,8 +1280,8 @@ function smile_shield($m) {
return '<!--base64:' . base64special_encode($m[0]) . '-->';
}
-function smile_unshield($m) {
- return base64special_decode($m[1]);
+function smile_unshield($m) {
+ return base64special_decode($m[1]);
}
/**
@@ -1364,11 +1389,11 @@ function theme_attachments(&$item) {
$icon = getIconFromType($r['type']);
$label = (($r['title']) ? urldecode(htmlspecialchars($r['title'], ENT_COMPAT, 'UTF-8')) : t('Unknown Attachment'));
-
+
//some feeds provide an attachment where title an empty space
if($label == ' ')
$label = t('Unknown Attachment');
-
+
$title = t('Size') . ' ' . (($r['length']) ? userReadableSize($r['length']) : t('unknown'));
require_once('include/channel.php');
@@ -1508,7 +1533,7 @@ function generate_named_map($location) {
function prepare_body(&$item,$attach = false) {
- call_hooks('prepare_body_init', $item);
+ call_hooks('prepare_body_init', $item);
$s = '';
$photo = '';
@@ -1602,7 +1627,9 @@ function prepare_body(&$item,$attach = false) {
* @brief Given a text string, convert from bbcode to html and add smilie icons.
*
* @param string $text
- * @param sting $content_type
+ * @param sting $content_type (optional) default text/bbcode
+ * @param boolean $cache (optional) default false
+ *
* @return string
*/
function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
@@ -1621,19 +1648,18 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
$s = Markdown($text);
break;
-
case 'application/x-pdl';
$s = escape_tags($text);
break;
-
- // No security checking is done here at display time - so we need to verify
- // that the author is allowed to use PHP before storing. We also cannot allow
- // importation of PHP text bodies from other sites. Therefore this content
+
+ // No security checking is done here at display time - so we need to verify
+ // that the author is allowed to use PHP before storing. We also cannot allow
+ // importation of PHP text bodies from other sites. Therefore this content
// type is only valid for web pages (and profile details).
- // It may be possible to provide a PHP message body which is evaluated on the
- // sender's site before sending it elsewhere. In that case we will have a
- // different content-type here.
+ // It may be possible to provide a PHP message body which is evaluated on the
+ // sender's site before sending it elsewhere. In that case we will have a
+ // different content-type here.
case 'application/x-php':
ob_start();
@@ -1687,7 +1713,7 @@ function create_export_photo_body(&$item) {
*/
function zidify_callback($match) {
$is_zid = ((feature_enabled(local_channel(),'sendzid')) || (strpos($match[1],'zrl')) ? true : false);
- $replace = '<a' . $match[1] . ' href="' . (($is_zid) ? zid($match[2]) : $match[2]) . '"';
+ $replace = '<a' . $match[1] . ' href="' . (($is_zid) ? zid($match[2]) : $match[2]) . '"';
$x = str_replace($match[0],$replace,$match[0]);
return $x;
@@ -1735,16 +1761,20 @@ function feed_hublinks() {
return $hubxml;
}
-/* return atom link elements for salmon endpoints */
-
+/**
+ * @brief Return atom link elements for salmon endpoints
+ *
+ * @param string $nick
+ * @return string
+ */
function feed_salmonlinks($nick) {
$salmon = '<link rel="salmon" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
- // old style links that status.net still needed as of 12/2010
+ // old style links that status.net still needed as of 12/2010
- $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-replies" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
- $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-mention" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
+ $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-replies" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
+ $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-mention" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
return $salmon;
}
@@ -1773,7 +1803,7 @@ function unamp($s) {
}
function layout_select($channel_id, $current = '') {
- $r = q("select mid, v from item left join iconfig on iconfig.iid = item.id
+ $r = q("select mid, v from item left join iconfig on iconfig.iid = item.id
where iconfig.cat = 'system' and iconfig.k = 'PDL' and item.uid = %d and item_type = %d ",
intval($channel_id),
intval(ITEM_TYPE_PDL)
@@ -1817,12 +1847,12 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
);
if($r) {
- if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
+ if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
if(local_channel() && get_account_id() == $r[0]['account_id']) {
$x[] = 'application/x-php';
}
}
- }
+ }
}
foreach($x as $y) {
@@ -1886,9 +1916,8 @@ function base64special_decode($s) {
return base64_decode(strtr($s,',.','+/'));
}
-
/**
- * @ Return a div to clear floats.
+ * @brief Return a div to clear floats.
*
* @return string
*/
@@ -2087,11 +2116,18 @@ function ids_to_querystr($arr,$idx = 'id') {
return(implode(',', $t));
}
-// Fetches xchan and hubloc data for an array of items with only an
-// author_xchan and owner_xchan. If $abook is true also include the abook info.
-// This is needed in the API to save extra per item lookups there.
-
-function xchan_query(&$items,$abook = true,$effective_uid = 0) {
+/**
+ * @brief Fetches xchan and hubloc data for an array of items with only an
+ * author_xchan and owner_xchan.
+ *
+ * If $abook is true also include the abook info. This is needed in the API to
+ * save extra per item lookups there.
+ *
+ * @param array[in,out] &$items
+ * @param boolean $abook If true also include the abook info
+ * @param number $effective_uid
+ */
+function xchan_query(&$items, $abook = true, $effective_uid = 0) {
$arr = array();
if($items && count($items)) {
@@ -2124,7 +2160,7 @@ function xchan_query(&$items,$abook = true,$effective_uid = 0) {
if(! $chans)
$chans = $xchans;
else
- $chans = array_merge($xchans,$chans);
+ $chans = array_merge($xchans,$chans);
}
if($items && count($items) && $chans && count($chans)) {
for($x = 0; $x < count($items); $x ++) {
@@ -2182,15 +2218,19 @@ function magic_link($s) {
return $s;
}
-// if $escape is true, dbesc() each element before adding quotes
-
-function stringify_array_elms(&$arr,$escape = false) {
+/**
+ * if $escape is true, dbesc() each element before adding quotes
+ *
+ * @param array[in,out] &$arr
+ * @param boolean $escape default false
+ */
+function stringify_array_elms(&$arr, $escape = false) {
for($x = 0; $x < count($arr); $x ++)
$arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'";
}
/**
- * Indents a flat JSON string to make it more human-readable.
+ * @brief Indents a flat JSON string to make it more human-readable.
*
* @param string $json The original JSON string to process.
*
@@ -2214,7 +2254,7 @@ function jindent($json) {
if ($char == '"' && $prevChar != '\\') {
$outOfQuotes = !$outOfQuotes;
- // If this character is the end of an element,
+ // If this character is the end of an element,
// output a new line and indent the next line.
} else if(($char == '}' || $char == ']') && $outOfQuotes) {
$result .= $newLine;
@@ -2227,7 +2267,7 @@ function jindent($json) {
// Add the character to the result string.
$result .= $char;
- // If the last character was the beginning of an element,
+ // If the last character was the beginning of an element,
// output a new line and indent the next line.
if (($char == ',' || $char == '{' || $char == '[') && $outOfQuotes) {
$result .= $newLine;
@@ -2239,7 +2279,7 @@ function jindent($json) {
$result .= $indentStr;
}
}
-
+
$prevChar = $char;
}
@@ -2249,9 +2289,8 @@ function jindent($json) {
/**
* @brief Creates navigation menu for webpage, layout, blocks, menu sites.
*
- * @return string
+ * @return string with parsed HTML
*/
-
function design_tools() {
$channel = App::get_channel();
@@ -2300,7 +2339,7 @@ function website_portation_tools() {
'$file_import_text' => t('Import from cloud files:'),
'$desc' => t('/cloud/channel/path/to/folder'),
'$hint' => t('Enter path to website files'),
- '$select' => t('Select folder'),
+ '$select' => t('Select folder'),
'$export_label' => t('Export website...'),
'$file_download_text' => t('Export to a zip file'),
'$filename_desc' => t('website.zip'),
@@ -2308,12 +2347,17 @@ function website_portation_tools() {
'$cloud_export_text' => t('Export to cloud files'),
'$cloud_export_desc' => t('/path/to/export/folder'),
'$cloud_export_hint' => t('Enter a path to a cloud files destination.'),
- '$cloud_export_select' => t('Specify folder'),
+ '$cloud_export_select' => t('Specify folder'),
));
}
-/* case insensitive in_array() */
-
+/**
+ * @brief case insensitive in_array()
+ *
+ * @param string $needle
+ * @param array $haystack
+ * @return boolean
+ */
function in_arrayi($needle, $haystack) {
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
@@ -2322,10 +2366,13 @@ function normalise_openid($s) {
return trim(str_replace(array('http://','https://'),array('',''),$s),'/');
}
-// used in ajax endless scroll request to find out all the args that the master page was viewing.
-// This was using $_REQUEST, but $_REQUEST also contains all your cookies. So we're restricting it
-// to $_GET and $_POST.
-
+/**
+ * Used in ajax endless scroll request to find out all the args that the master page was viewing.
+ * This was using $_REQUEST, but $_REQUEST also contains all your cookies. So we're restricting it
+ * to $_GET and $_POST.
+ *
+ * @return string with additional URL parameters
+ */
function extra_query_args() {
$s = '';
if(count($_GET)) {
@@ -2344,6 +2391,7 @@ function extra_query_args() {
}
}
}
+
return $s;
}
@@ -2370,7 +2418,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
$termtype = ((strpos($tag,'@') === 0) ? TERM_MENTION : $termtype);
$termtype = ((strpos($tag,'#^[') === 0) ? TERM_BOOKMARK : $termtype);
- //is it a hash tag?
+ //is it a hash tag?
if(strpos($tag,'#') === 0) {
if(strpos($tag,'#^[') === 0) {
if(preg_match('/#\^\[(url|zrl)(.*?)\](.*?)\[\/(url|zrl)\]/',$tag,$match)) {
@@ -2385,7 +2433,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
return $replaced;
}
if($tag == '#getzot') {
- $basetag = 'getzot';
+ $basetag = 'getzot';
$url = 'http://hubzilla.org';
$newtag = '#[zrl=' . $url . ']' . $basetag . '[/zrl]';
$body = str_replace($tag,$newtag,$body);
@@ -2421,15 +2469,15 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
$str_tags .= $newtag;
}
return [
- 'replaced' => $replaced,
- 'termtype' => $termtype,
- 'term' => $basetag,
- 'url' => $url,
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $basetag,
+ 'url' => $url,
'contact' => $r[0]
- ];
+ ];
}
- //is it a person tag?
+ //is it a person tag?
if(strpos($tag,'@') === 0) {
@@ -2443,7 +2491,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
//get the person's name
$name = substr($tag,(($exclusive) ? 2 : 1)); // The name or name fragment we are going to replace
- $newname = $name; // a copy that we can mess with
+ $newname = $name; // a copy that we can mess with
$tagcid = 0;
$r = null;
@@ -2489,14 +2537,14 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
if($abook_id) { // if there was an id
// select channel with that id from the logged in user's address book
- $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
+ $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
intval($abook_id),
intval($profile_uid)
);
}
else {
- $r = q("SELECT * FROM xchan
+ $r = q("SELECT * FROM xchan
WHERE xchan_hash like '%s%%' LIMIT 1",
dbesc($tagcid)
);
@@ -2525,7 +2573,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
}
//select someone from this user's contacts by name
- $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
+ $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
WHERE xchan_name = '%s' AND abook_channel = %d LIMIT 1",
dbesc($newname),
intval($profile_uid)
@@ -2533,7 +2581,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
if(! $r) {
//select someone by attag or nick and the name passed in
- $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
+ $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
WHERE xchan_addr like ('%s') AND abook_channel = %d LIMIT 1",
dbesc(((strpos($newname,'@')) ? $newname : $newname . '@%')),
intval($profile_uid)
@@ -2544,7 +2592,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
// it's possible somebody has a name ending with '+', which we stripped off as a forum indicator
// This is very rare but we want to get it right.
- $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
+ $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
WHERE xchan_name = '%s' AND abook_channel = %d LIMIT 1",
dbesc($newname . '+'),
intval($profile_uid)
@@ -2568,12 +2616,12 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
}
else {
- // check for a group/collection exclusion tag
+ // check for a group/collection exclusion tag
// note that we aren't setting $replaced even though we're replacing text.
// This tag isn't going to get a term attached to it. It's only used for
// access control. The link points to out own channel just so it doesn't look
- // weird - as all the other tags are linked to something.
+ // weird - as all the other tags are linked to something.
if(local_channel() && local_channel() == $profile_uid) {
require_once('include/group.php');
@@ -2618,10 +2666,10 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d
}
return [
- 'replaced' => $replaced,
- 'termtype' => $termtype,
- 'term' => $newname,
- 'url' => $url,
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $newname,
+ 'url' => $url,
'contact' => $r[0]
];
}
@@ -2650,7 +2698,7 @@ function linkify_tags($a, &$body, $uid, $diaspora = false) {
if($fullnametagged)
continue;
- $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : App::$profile_uid , $tag, $diaspora);
+ $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : App::$profile_uid , $tag, $diaspora);
$results[] = array('success' => $success, 'access_tag' => $access_tag);
if($success['replaced']) $tagged[] = $tag;
}
@@ -2771,10 +2819,10 @@ function json_url_replace($old,$new,&$s) {
$s = $x;
return $replaced;
}
-
+
function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
-
+
if($item['attach']) {
json_url_replace($old,$new,$item['attach']);
if($oldnick)
@@ -2795,7 +2843,7 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
$item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey']));
$item['item_verified'] = 1;
}
-
+
$item['plink'] = str_replace($old,$new,$item['plink']);
if($oldnick)
$item['plink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['plink']);
@@ -2803,7 +2851,7 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
$item['llink'] = str_replace($old,$new,$item['llink']);
if($oldnick)
$item['llink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['llink']);
-
+
}
@@ -2841,7 +2889,6 @@ function perms2str($p) {
return $ret;
}
-
/**
* @brief Turn user/group ACLs stored as angle bracketed text into arrays.
*
@@ -2869,35 +2916,41 @@ function expand_acl($s) {
function acl2json($s) {
$s = expand_acl($s);
$s = json_encode($s);
+
return $s;
}
-
-// When editing a webpage - a dropdown is needed to select a page layout
-// On submit, the pdl_select value (which is the mid of an item with item_type = ITEM_TYPE_PDL) is stored in
-// the webpage's resource_id, with resource_type 'pdl'.
-
-// Then when displaying a webpage, we can see if it has a pdl attached. If not we'll
-// use the default site/page layout.
-
-// If it has a pdl we'll load it as we know the mid and pass the body through comanche_parser() which will generate the
-// page layout from the given description
-
-// @FIXME - there is apparently a very similar function called layout_select; this one should probably take precedence
-// and the other should be checked for compatibility and removed
-
-function pdl_selector($uid, $current="") {
+/**
+ * @brief When editing a webpage - a dropdown is needed to select a page layout
+ *
+ * On submit, the pdl_select value (which is the mid of an item with item_type = ITEM_TYPE_PDL)
+ * is stored in the webpage's resource_id, with resource_type 'pdl'.
+ *
+ * Then when displaying a webpage, we can see if it has a pdl attached. If not we'll
+ * use the default site/page layout.
+ *
+ * If it has a pdl we'll load it as we know the mid and pass the body through comanche_parser() which will generate the
+ * page layout from the given description
+ *
+ * @FIXME - there is apparently a very similar function called layout_select; this one should probably take precedence
+ * and the other should be checked for compatibility and removed
+ *
+ * @param int $uid
+ * @param string $current
+ * @return string HTML code for dropdown
+ */
+function pdl_selector($uid, $current='') {
$o = '';
$sql_extra = item_permissions_sql($uid);
- $r = q("select iconfig.*, mid from item_id left join item on iconfig.iid = item.id
+ $r = q("select iconfig.*, mid from item_id left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' $sql_extra order by v asc",
intval($uid)
);
$arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r);
- call_hooks('pdl_selector',$arr);
+ call_hooks('pdl_selector', $arr);
$entries = $arr['entries'];
$current = $arr['current'];
@@ -2913,16 +2966,17 @@ function pdl_selector($uid, $current="") {
return $o;
}
-/*
- * array flatten_array_recursive(array);
- * returns a one-dimensional array from a multi-dimensional array
+/**
+ * @brief returns a one-dimensional array from a multi-dimensional array
* empty values are discarded
+ *
* example: print_r(flatten_array_recursive(array('foo','bar',array('baz','blip',array('zob','glob')),'','grip')));
*
- * Array ( [0] => foo [1] => bar [2] => baz [3] => blip [4] => zob [5] => glob [6] => grip )
+ * Array ( [0] => foo [1] => bar [2] => baz [3] => blip [4] => zob [5] => glob [6] => grip )
*
+ * @param array $arr multi-dimensional array
+ * @return one-dimensional array
*/
-
function flatten_array_recursive($arr) {
$ret = array();
@@ -2933,64 +2987,71 @@ function flatten_array_recursive($arr) {
if(is_array($a)) {
$tmp = flatten_array_recursive($a);
if($tmp) {
- $ret = array_merge($ret,$tmp);
+ $ret = array_merge($ret, $tmp);
}
}
elseif($a) {
$ret[] = $a;
}
}
+
return($ret);
-}
+}
-function text_highlight($s,$lang) {
+/**
+ * @brief Highlight Text.
+ *
+ * @param string $s Text to highlight
+ * @param string $lang Which language should be highlighted
+ * @return string
+ */
+function text_highlight($s, $lang) {
if($lang === 'js')
$lang = 'javascript';
if($lang === 'json') {
$lang = 'javascript';
- if(! strpos(trim($s),"\n"))
+ if(! strpos(trim($s), "\n"))
$s = jindent($s);
}
- if(! strpos('Text_Highlighter',get_include_path())) {
+ if(! strpos('Text_Highlighter', get_include_path())) {
set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter');
}
require_once('library/Text_Highlighter/Text/Highlighter.php');
- require_once('library/Text_Highlighter/Text/Highlighter/Renderer/Html.php');
- $options = array(
- 'numbers' => HL_NUMBERS_LI,
- 'tabsize' => 4,
- );
+ require_once('library/Text_Highlighter/Text/Highlighter/Renderer/Html.php');
+ $options = array(
+ 'numbers' => HL_NUMBERS_LI,
+ 'tabsize' => 4,
+ );
$tag_added = false;
- $s = trim(html_entity_decode($s,ENT_COMPAT));
- $s = str_replace(" ","\t",$s);
+ $s = trim(html_entity_decode($s, ENT_COMPAT));
+ $s = str_replace(" ", "\t", $s);
- // The highlighter library insists on an opening php tag for php code blocks. If
+ // The highlighter library insists on an opening php tag for php code blocks. If
// it isn't present, nothing is highlighted. So we're going to see if it's present.
- // If not, we'll add it, and then quietly remove it after we get the processed output back.
+ // If not, we'll add it, and then quietly remove it after we get the processed output back.
if($lang === 'php') {
- if(strpos('<?php',$s) !== 0) {
+ if(strpos('<?php', $s) !== 0) {
$s = '<?php' . "\n" . $s;
- $tag_added = true;
+ $tag_added = true;
}
-
- }
- $renderer = new Text_Highlighter_Renderer_HTML($options);
- $hl = Text_Highlighter::factory($lang);
- $hl->setRenderer($renderer);
+ }
+ $renderer = new Text_Highlighter_Renderer_HTML($options);
+ $hl = Text_Highlighter::factory($lang);
+ $hl->setRenderer($renderer);
$o = $hl->highlight($s);
- $o = str_replace([" ","\n"],["&nbsp;&nbsp;&nbsp;&nbsp;",''],$o);
+ $o = str_replace([" ", "\n"], ["&nbsp;&nbsp;&nbsp;&nbsp;", ''], $o);
if($tag_added) {
- $b = substr($o,0,strpos($o,'<li>'));
- $e = substr($o,strpos($o,'</li>'));
+ $b = substr($o, 0, strpos($o, '<li>'));
+ $e = substr($o, strpos($o, '</li>'));
$o = $b . $e;
}
- return('<code>' . $o . '</code>');
+ return('<code>' . $o . '</code>');
}
// function to convert multi-dimensional array to xml
@@ -3007,30 +3068,26 @@ function text_highlight($s,$lang) {
function arrtoxml($root_elem,$arr) {
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><' . $root_elem . '></' . $root_elem . '>', null, false);
array2XML($xml,$arr);
+
return $xml->asXML();
}
-function array2XML($obj, $array)
-{
- foreach ($array as $key => $value)
- {
- if(is_numeric($key))
- $key = 'item' . $key;
+function array2XML($obj, $array) {
+ foreach ($array as $key => $value) {
+ if(is_numeric($key))
+ $key = 'item' . $key;
- if (is_array($value))
- {
- $node = $obj->addChild($key);
- array2XML($node, $value);
- }
- else
- {
- $obj->addChild($key, htmlspecialchars($value));
- }
- }
+ if(is_array($value)) {
+ $node = $obj->addChild($key);
+ array2XML($node, $value);
+ } else {
+ $obj->addChild($key, htmlspecialchars($value));
+ }
+ }
}
-function create_table_from_array($table,$arr) {
+function create_table_from_array($table, $arr) {
if(! ($arr && $table))
return false;
@@ -3040,9 +3097,9 @@ function create_table_from_array($table,$arr) {
. implode(TQUOT . ', ' . TQUOT, array_keys($arr))
. TQUOT . ") VALUES ('"
. implode("', '", array_values($arr))
- . "')"
+ . "')"
);
}
- return $r;
+ return $r;
} \ No newline at end of file
diff --git a/include/widgets.php b/include/widgets.php
index 3396a92a5..cc0b20a72 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -126,7 +126,7 @@ function widget_suggestions($arr) {
// Get two random entries from the top 20 returned.
// We'll grab the first one and the one immediately following.
- // This will throw some entropy intot he situation so you won't
+ // This will throw some entropy intot he situation so you won't
// be looking at the same two mug shots every time the widget runs
$index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0);
@@ -169,7 +169,7 @@ function widget_follow($args) {
intval($uid)
);
if($r)
- $total_channels = $r[0]['total'];
+ $total_channels = $r[0]['total'];
$limit = service_class_fetch($uid,'total_channels');
if($limit !== false) {
$abook_usage_message = sprintf( t("You have %1$.0f of %2$.0f allowed connections."), $total_channels, $limit);
@@ -212,7 +212,7 @@ function widget_savedsearch($arr) {
$search = ((x($_GET,'netsearch')) ? $_GET['netsearch'] : '');
if(! $search)
$search = ((x($_GET,'search')) ? $_GET['search'] : '');
-
+
if(x($_GET,'searchsave') && $search) {
$r = q("select * from term where uid = %d and ttype = %d and term = '%s' limit 1",
intval(local_channel()),
@@ -252,7 +252,7 @@ function widget_savedsearch($arr) {
$hasamp = ((strpos($srchurl,'&') !== false) ? true : false);
if(($hasamp) && (! $hasq))
- $srchurl = substr($srchurl,0,strpos($srchurl,'&')) . '?f=&' . substr($srchurl,strpos($srchurl,'&')+1);
+ $srchurl = substr($srchurl,0,strpos($srchurl,'&')) . '?f=&' . substr($srchurl,strpos($srchurl,'&')+1);
$o = '';
@@ -292,7 +292,7 @@ function widget_savedsearch($arr) {
function widget_sitesearch($arr) {
$search = ((x($_GET,'search')) ? $_GET['search'] : '');
-
+
$srchurl = App::$query_string;
$srchurl = rtrim(preg_replace('/search\=[^\&].*?(\&|$)/is','',$srchurl),'&');
@@ -304,7 +304,7 @@ function widget_sitesearch($arr) {
$hasamp = ((strpos($srchurl,'&') !== false) ? true : false);
if(($hasamp) && (! $hasq))
- $srchurl = substr($srchurl,0,strpos($srchurl,'&')) . '?f=&' . substr($srchurl,strpos($srchurl,'&')+1);
+ $srchurl = substr($srchurl,0,strpos($srchurl,'&')) . '?f=&' . substr($srchurl,strpos($srchurl,'&')+1);
$o = '';
@@ -554,7 +554,7 @@ function widget_affinity($arr) {
));
$arr = array('html' => $x);
call_hooks('main_slider',$arr);
- return $arr['html'];
+ return $arr['html'];
}
return '';
@@ -802,10 +802,10 @@ function widget_design_tools($arr) {
// mod menu doesn't load a profile. For any modules which load a profile, check it.
// otherwise local_channel() is sufficient for permissions.
- if(App::$profile['profile_uid'])
+ if(App::$profile['profile_uid'])
if((App::$profile['profile_uid'] != local_channel()) && (! App::$is_sys))
return '';
-
+
if(! local_channel())
return '';
@@ -817,10 +817,10 @@ function widget_website_portation_tools($arr) {
// mod menu doesn't load a profile. For any modules which load a profile, check it.
// otherwise local_channel() is sufficient for permissions.
- if(App::$profile['profile_uid'])
+ if(App::$profile['profile_uid'])
if((App::$profile['profile_uid'] != local_channel()) && (! App::$is_sys))
return '';
-
+
if(! local_channel())
return '';
@@ -841,7 +841,7 @@ function widget_photo_albums($arr) {
return '';
require_once('include/photos.php');
$sortkey = ((array_key_exists('sortkey',$arr)) ? $arr['sortkey'] : 'album');
- $direction = ((array_key_exists('direction',$arr)) ? $arr['direction'] : 'asc');
+ $direction = ((array_key_exists('direction',$arr)) ? $arr['direction'] : 'asc');
return photos_album_widget($channelx, App::get_observer(),$sortkey,$direction);
}
@@ -901,7 +901,7 @@ function widget_wiki_list($arr) {
require_once("include/wiki.php");
$channel = null;
- if (argc() < 2 && local_channel()) {
+ if (argc() < 2 && local_channel()) {
// This should not occur because /wiki should redirect to /wiki/channel ...
$channel = \App::get_channel();
} else {
@@ -996,9 +996,9 @@ function widget_suggestedchats($arr) {
if(! feature_enabled(App::$profile['profile_uid'],'ajaxchat'))
return '';
- // There are reports that this tool does not ever remove chatrooms on dead sites,
+ // There are reports that this tool does not ever remove chatrooms on dead sites,
// and also will happily link to private chats which you cannot enter.
- // For those reasons, it will be disabled until somebody decides it's worth
+ // For those reasons, it will be disabled until somebody decides it's worth
// fixing and comes up with a plan for doing so.
return '';
@@ -1044,7 +1044,7 @@ function widget_item($arr) {
if($arr['title']) {
$r = q("select item.* from item left join iconfig on item.id = iconfig.iid
- where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s'
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s'
and iconfig.k = 'WEBPAGE' and item_type = %d $sql_options $revision limit 1",
intval($channel_id),
dbesc($arr['title']),
@@ -1108,7 +1108,7 @@ function showtime(){
// timeValue += ((seconds < 10) ? ":0" : ":") + seconds
if(! military)
timeValue += (hours >= 12) ? " P.M." : " A.M."
- $('.clockface').html(timeValue)
+ $('.clockface').html(timeValue)
timerID = setTimeout("showtime()",1000)
timerRunning = true
}
@@ -1124,17 +1124,16 @@ return $o;
}
-
/**
- * @function widget_photo($arr)
- * widget to display a single photo.
- * @param array $arr;
- * 'src' => URL of photo
- * 'zrl' => true or false, use zid in url
- * 'style' => CSS string
- * URL must be an http or https URL
+ * @brief Widget to display a single photo.
+ *
+ * @param array $arr associative array with
+ * * \e string \b src URL of photo; URL must be an http or https URL
+ * * \e boolean \b zrl use zid in URL
+ * * \e string \b style CSS string
+ *
+ * @return string with parsed HTML
*/
-
function widget_photo($arr) {
$style = $zrl = false;
@@ -1142,7 +1141,7 @@ function widget_photo($arr) {
if(array_key_exists('src', $arr) && isset($arr['src']))
$url = $arr['src'];
- if(strpos($url,'http') !== 0)
+ if(strpos($url, 'http') !== 0)
return '';
if(array_key_exists('style', $arr) && isset($arr['style']))
@@ -1150,7 +1149,7 @@ function widget_photo($arr) {
// ensure they can't sneak in an eval(js) function
- if(strpbrk($style,'(\'"<>') !== false)
+ if(strpbrk($style, '(\'"<>') !== false)
$style = '';
if(array_key_exists('zrl', $arr) && isset($arr['zrl']))
@@ -1161,8 +1160,8 @@ function widget_photo($arr) {
$o = '<div class="widget">';
- $o .= '<img ' . (($zrl) ? ' class="zrl" ' : '')
- . (($style) ? ' style="' . $style . '"' : '')
+ $o .= '<img ' . (($zrl) ? ' class="zrl" ' : '')
+ . (($style) ? ' style="' . $style . '"' : '')
. ' src="' . $url . '" alt="' . t('photo/image') . '">';
$o .= '</div>';
@@ -1175,7 +1174,7 @@ function widget_cover_photo($arr) {
require_once('include/channel.php');
$o = '';
-
+
if(App::$module == 'channel' && $_REQUEST['mid'])
return '';
@@ -1191,7 +1190,7 @@ function widget_cover_photo($arr) {
if(array_key_exists('style', $arr) && isset($arr['style']))
$style = $arr['style'];
- else
+ else
$style = 'width:100%; height: auto;';
// ensure they can't sneak in an eval(js) function
@@ -1273,8 +1272,8 @@ function widget_photo_rand($arr) {
$o = '<div class="widget">';
- $o .= '<img class="zrl" '
- . (($style) ? ' style="' . $style . '"' : '')
+ $o .= '<img class="zrl" '
+ . (($style) ? ' style="' . $style . '"' : '')
. ' src="' . $url . '" alt="' . t('photo/image') . '">';
$o .= '</div>';
@@ -1304,7 +1303,7 @@ function widget_random_block($arr) {
$randfunc = db_getfunc('RAND');
$r = q("select item.* from item left join iconfig on item.id = iconfig.iid
- where item.uid = %d and iconfig.cat = 'system' and iconfig.v like '%s' and iconfig.k = 'BUILDBLOCK' and
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.v like '%s' and iconfig.k = 'BUILDBLOCK' and
item_type = %d $sql_options order by $randfunc limit 1",
intval($channel_id),
dbesc('%' . $contains . '%'),
@@ -1413,7 +1412,7 @@ function widget_forums($arr) {
/**
* We used to try and find public forums with custom permissions by checking to see if
- * send_stream was false and tag_deliver was true. However with the newer extensible
+ * send_stream was false and tag_deliver was true. However with the newer extensible
* permissions infrastructure this makes for a very complicated query. Now we're only
* checking channels that report themselves specifically as pubforums
*/
@@ -1440,11 +1439,11 @@ function widget_forums($arr) {
/**
* @FIXME
* This SQL makes the counts correct when you get forum posts arriving from different routes/sources
- * (like personal channels). However the network query for these posts doesn't yet include this
- * correction and it makes the SQL for that query pretty hairy so this is left as a future exercise.
+ * (like personal channels). However the network query for these posts doesn't yet include this
+ * correction and it makes the SQL for that query pretty hairy so this is left as a future exercise.
* It may make more sense in that query to look for the mention in the body rather than another join,
* but that makes it very inefficient.
- *
+ *
$r = q("select sum(item_unseen) as unseen from item left join term on oid = id where otype = %d and owner_xchan != '%s' and item.uid = %d and url = '%s' and ttype = %d $perms_sql ",
intval(TERM_OBJ_POST),
dbesc($r1[$x]['xchan_hash']),
@@ -1457,7 +1456,7 @@ function widget_forums($arr) {
*
* end @FIXME
*/
-
+
}
if($r1) {
@@ -1471,7 +1470,7 @@ function widget_forums($arr) {
}
$o .= '</ul></div>';
}
- return $o;
+ return $o;
}
@@ -1489,7 +1488,7 @@ function widget_tasklist($arr) {
$(".tasklist-tasks").html(data.html);
});
}
- </script>';
+ </script>';
$o .= '<div class="widget">' . '<h3>' . t('Tasks') . '</h3><div class="tasklist-tasks">';
$o .= '</div><form id="tasklist-new-form" action="" ><input id="tasklist-new-summary" type="text" name="summary" value="" /></form>';
@@ -1516,7 +1515,7 @@ function widget_helpindex($arr) {
if(argc() > 2) {
$path = '';
for($x = 1; $x < argc(); $x ++) {
- $path .= argv($x) . '/';
+ $path .= argv($x) . '/';
$y = get_help_content($path . 'sitetoc');
if(! $y)
$y = get_help_content($path . 'toc');
@@ -1590,7 +1589,7 @@ function widget_admin($arr) {
call_hooks('admin_aside',$arr);
$o .= replace_macros(get_markup_template('admin_aside.tpl'), array(
- '$admin' => $aside,
+ '$admin' => $aside,
'$admtxt' => t('Admin'),
'$plugadmtxt' => t('Plugin Features'),
'$plugins' => $plugins,
@@ -1620,7 +1619,7 @@ function widget_album($args) {
if($args['title'])
$title = $args['title'];
- /**
+ /**
* This may return incorrect permissions if you have multiple directories of the same name.
* It is a limitation of the photo table using a name for a photo album instead of a folder hash
*/
@@ -1640,7 +1639,7 @@ function widget_album($args) {
$order = 'DESC';
$r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN
- (SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
+ (SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)
ORDER BY created $order ",
intval($owner_uid),
@@ -1648,7 +1647,7 @@ function widget_album($args) {
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
);
-
+
//edit album name
$album_edit = null;
@@ -1661,7 +1660,7 @@ function widget_album($args) {
$twist = 'rotleft';
else
$twist = 'rotright';
-
+
$ext = $phototypes[$rr['mimetype']];
$imgalt_e = $rr['filename'];
diff --git a/include/zot.php b/include/zot.php
index f6d6fe362..838ac44c6 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -176,7 +176,7 @@ function zot_zot($url, $data) {
* @param boolean $autofallback
* fallback/failover to http if https connection cannot be established. Default is true.
*
- * @return array see z_post_url() and \ref mod/zfinger.php
+ * @return array see z_post_url() and \ref Zotlabs::Zot::Finger "\\Zotlabs\\Zot\\Finger"
*/
function zot_finger($webbie, $channel = null, $autofallback = true) {
@@ -303,7 +303,7 @@ function zot_refresh($them, $channel = null, $force = false) {
// if they re-installed the server we could end up with the wrong record - pointing to the old install.
// We'll order by reverse id to try and pick off the newest one first and hopefully end up with the
- // correct hubloc. If this doesn't work we may have to re-write this section to try them all.
+ // correct hubloc. If this doesn't work we may have to re-write this section to try them all.
if(array_key_exists('xchan_addr',$them) && $them['xchan_addr']) {
$r = q("select hubloc_url, hubloc_primary from hubloc where hubloc_addr = '%s' order by hubloc_id desc",
@@ -526,7 +526,7 @@ function zot_refresh($them, $channel = null, $force = false) {
'to_xchan' => $channel['channel_hash'],
'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'],
));
-
+
if(intval($permissions['view_stream'])) {
if(intval(get_pconfig($channel['channel_id'],'perm_limits','send_stream') & PERMS_PENDING)
|| (! intval($new_connection[0]['abook_pending'])))
@@ -539,7 +539,7 @@ function zot_refresh($them, $channel = null, $force = false) {
if($default_group) {
require_once('include/group.php');
$g = group_rec_byhash($channel['channel_id'],$default_group);
- if($g)
+ if($g)
group_add_member($channel['channel_id'],'',$x['hash'],$g['id']);
}
@@ -575,11 +575,12 @@ function zot_refresh($them, $channel = null, $force = false) {
* * \e string \b guid_sig => guid signed with conversant's private key
* * \e string \b url => URL of the origination hub of this communication
* * \e string \b url_sig => URL signed with conversant's private key
+ * @param boolean $multiple (optional) default false
*
* @returns array|null null if site is blacklisted or not found, otherwise an
* array with an hubloc record
*/
-function zot_gethub($arr,$multiple = false) {
+function zot_gethub($arr, $multiple = false) {
if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
@@ -590,7 +591,7 @@ function zot_gethub($arr,$multiple = false) {
$limit = (($multiple) ? '' : ' limit 1 ');
$sitekey = ((array_key_exists('sitekey',$arr) && $arr['sitekey']) ? " and hubloc_sitekey = '" . protect_sprintf($arr['sitekey']) . "' " : '');
-
+
$r = q("select * from hubloc
where hubloc_guid = '%s' and hubloc_guid_sig = '%s'
and hubloc_url = '%s' and hubloc_url_sig = '%s'
@@ -758,15 +759,15 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
if(intval($r[0]['xchan_pubforum']) != intval($arr['public_forum']))
$pubforum_changed = 1;
- if(($r[0]['xchan_name_date'] != $arr['name_updated'])
- || ($r[0]['xchan_connurl'] != $arr['connections_url'])
+ if(($r[0]['xchan_name_date'] != $arr['name_updated'])
+ || ($r[0]['xchan_connurl'] != $arr['connections_url'])
|| ($r[0]['xchan_addr'] != $arr['address'])
|| ($r[0]['xchan_follow'] != $arr['follow_url'])
- || ($r[0]['xchan_connpage'] != $arr['connect_url'])
+ || ($r[0]['xchan_connpage'] != $arr['connect_url'])
|| ($r[0]['xchan_url'] != $arr['url'])
|| $hidden_changed || $adult_changed || $deleted_changed || $pubforum_changed ) {
- $rup = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s',
- xchan_connpage = '%s', xchan_hidden = %d, xchan_selfcensored = %d, xchan_deleted = %d, xchan_pubforum = %d,
+ $rup = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s',
+ xchan_connpage = '%s', xchan_hidden = %d, xchan_selfcensored = %d, xchan_deleted = %d, xchan_pubforum = %d,
xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s'",
dbesc(($arr['name']) ? $arr['name'] : '-'),
dbesc($arr['name_updated']),
@@ -1026,12 +1027,12 @@ function zot_process_response($hub, $arr, $outq) {
}
}
- // we have a more descriptive delivery report, so discard the per hub 'queued' report.
+ // we have a more descriptive delivery report, so discard the per hub 'queued' report.
q("delete from dreport where dreport_queue = '%s' ",
dbesc($outq['outq_hash'])
);
-
+
// update the timestamp for this site
q("update site set site_dead = 0, site_update = '%s' where site_url = '%s'",
@@ -1072,7 +1073,7 @@ function zot_fetch($arr) {
// set $multiple param on zot_gethub() to return all matching hubs
// This allows us to recover from re-installs when a redundant (but invalid) hubloc for
- // this identity is widely dispersed throughout the network.
+ // this identity is widely dispersed throughout the network.
$ret_hubs = zot_gethub($arr['sender'],true);
if(! $ret_hubs) {
@@ -1084,7 +1085,7 @@ function zot_fetch($arr) {
$data = array(
'type' => 'pickup',
'url' => z_root(),
- 'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post',get_config('system','prvkey'))),
+ 'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post',get_config('system','prvkey'))),
'callback' => z_root() . '/post',
'secret' => $arr['secret'],
'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey')))
@@ -1095,7 +1096,7 @@ function zot_fetch($arr) {
$fetch = zot_zot($url,$datatosend);
$result = zot_import($fetch, $arr['sender']['url']);
-
+
if($result)
return $result;
}
@@ -1199,7 +1200,7 @@ function zot_import($arr, $sender_url) {
if($recip_arr) {
stringify_array_elms($recip_arr);
$recips = implode(',',$recip_arr);
- $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " )
+ $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " )
and channel_removed = 0 ");
}
@@ -1407,7 +1408,7 @@ function public_recips($msg) {
$perm = 'post_mail';
$r = array();
-
+
$c = q("select channel_id, channel_hash from channel where channel_removed = 0");
if($c) {
foreach($c as $cc) {
@@ -1436,7 +1437,7 @@ function public_recips($msg) {
if(($tag['type'] === 'mention') && (strpos($tag['url'],z_root()) !== false)) {
$address = basename($tag['url']);
if($address) {
- $z = q("select channel_hash as hash from channel where channel_address = '%s'
+ $z = q("select channel_hash as hash from channel where channel_address = '%s'
and channel_removed = 0 limit 1",
dbesc($address)
);
@@ -1609,12 +1610,12 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
/**
* @FIXME: Somehow we need to block normal message delivery from our clones, as the delivered
- * message doesn't have ACL information in it as the cloned copy does. That copy
- * will normally arrive first via sync delivery, but this isn't guaranteed.
+ * message doesn't have ACL information in it as the cloned copy does. That copy
+ * will normally arrive first via sync delivery, but this isn't guaranteed.
* There's a chance the current delivery could take place before the cloned copy arrives
* hence the item could have the wrong ACL and *could* be used in subsequent deliveries or
* access checks. So far all attempts at identifying this situation precisely
- * have caused issues with delivery of relayed comments.
+ * have caused issues with delivery of relayed comments.
*/
// if(($d['hash'] === $sender['hash']) && ($sender['url'] !== z_root()) && (! $relay)) {
@@ -1747,7 +1748,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
intval($channel['channel_id']),
dbesc($arr['owner_xchan'])
);
- $abook = (($ab) ? $ab[0] : null);
+ $abook = (($ab) ? $ab[0] : null);
if(intval($arr['item_deleted'])) {
@@ -1761,7 +1762,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
$arr['uid'] = $channel['channel_id'];
$item_id = delete_imported_item($sender,$arr,$channel['channel_id'],$relay);
- $DR->update(($item_id) ? 'deleted' : 'delete_failed');
+ $DR->update(($item_id) ? 'deleted' : 'delete_failed');
$result[] = $DR->get();
if($relay && $item_id) {
@@ -1783,7 +1784,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
$item_id = $r[0]['id'];
if(intval($r[0]['item_deleted'])) {
- // It was deleted locally.
+ // It was deleted locally.
$DR->update('update ignored');
$result[] = $DR->get();
@@ -1810,8 +1811,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
$result[] = $DR->get();
- // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit),
- // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful.
+ // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit),
+ // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful.
if(! intval($r[0]['item_origin']))
continue;
}
@@ -1825,7 +1826,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
if(check_item_source($arr['uid'], $arr))
call_hooks('post_local', $arr);
-
+
$item_id = 0;
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
@@ -1938,9 +1939,11 @@ function remove_community_tag($sender, $arr, $uid) {
* @brief Just calls item_store_update() and logs result.
*
* @see item_store_update()
+ *
* @param array $sender (unused)
* @param array $item
- * @param int $uid (unused)
+ * @param array $orig
+ * @param int $uid
*/
function update_imported_item($sender, $item, $orig, $uid) {
@@ -1961,7 +1964,7 @@ function update_imported_item($sender, $item, $orig, $uid) {
// because event_addtocal will parse the body to get the 'new' event details
if($orig['resource_type'] === 'event') {
- $res = event_addtocal($orig['id'],$uid);
+ $res = event_addtocal($orig['id'], $uid);
if(! $res)
logger('update event: failed');
}
@@ -2236,15 +2239,15 @@ function process_location_delivery($sender,$arr,$deliveries) {
/**
* @brief checks for a moved UNO channel and sets the channel_moved flag
- *
+ *
* Currently the effect of this flag is to turn the channel into 'read-only' mode.
- * New content will not be processed (there was still an issue with blocking the
+ * New content will not be processed (there was still an issue with blocking the
* ability to post comments as of 10-Mar-2016).
- * We do not physically remove the channel at this time. The hub admin may choose
+ * We do not physically remove the channel at this time. The hub admin may choose
* to do so, but is encouraged to allow a grace period of several days in case there
* are any issues migrating content. This packet will generally be received by the
* original site when the basic channel import has been processed.
- *
+ *
* This will only be executed on the UNO system which is the old location
* if a new location is reported and there is only one location record.
* The rest of the hubloc syncronisation will be handled within
@@ -2256,7 +2259,7 @@ function process_location_delivery($sender,$arr,$deliveries) {
function check_location_move($sender_hash,$locations) {
if(! $locations)
- return;
+ return;
if(get_config('system','server_role') !== 'basic')
return;
@@ -2279,13 +2282,13 @@ function check_location_move($sender_hash,$locations) {
dbesc($sender_hash)
);
- // federation plugins may wish to notify connections
+ // federation plugins may wish to notify connections
// of the move on singleton networks
$arr = array('channel' => $r[0],'locations' => $locations);
call_hooks('location_move',$arr);
- }
+ }
}
@@ -2540,7 +2543,7 @@ function zot_encode_locations($channel) {
foreach($x as $hub) {
// if this is a local channel that has been deleted, the hubloc is no good - make sure it is marked deleted
- // so that nobody tries to use it.
+ // so that nobody tries to use it.
if(intval($channel['channel_removed']) && $hub['hubloc_url'] === z_root())
$hub['hubloc_deleted'] = 1;
@@ -3094,7 +3097,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
require_once('include/import.php');
- /** @FIXME this will sync red structures (channel, pconfig and abook).
+ /** @FIXME this will sync red structures (channel, pconfig and abook).
Eventually we need to make this application agnostic. */
$result = array();
@@ -3185,15 +3188,15 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
$arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] - 0x1000;
}
-
- $disallowed = [
- 'channel_id', 'channel_account_id', 'channel_primary', 'channel_prvkey',
- 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_deleted',
- 'channel_system', 'channel_r_stream', 'channel_r_profile', 'channel_r_abook',
- 'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall',
- 'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall',
- 'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish',
- 'channel_a_delegate'
+
+ $disallowed = [
+ 'channel_id', 'channel_account_id', 'channel_primary', 'channel_prvkey',
+ 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_deleted',
+ 'channel_system', 'channel_r_stream', 'channel_r_profile', 'channel_r_abook',
+ 'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall',
+ 'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall',
+ 'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish',
+ 'channel_a_delegate'
];
$clean = array();
@@ -3230,7 +3233,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
foreach($arr['abook'] as $abook) {
-
+
$abconfig = null;
@@ -3507,7 +3510,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
foreach($profile as $k => $v) {
if(in_array($k,$disallowed))
continue;
-
+
if($k === 'name')
$clean['fullname'] = $v;
elseif($k === 'with')
@@ -3518,7 +3521,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
$clean[$k] = $v;
/**
- * @TODO
+ * @TODO
* We also need to import local photos if a custom photo is selected
*/
}
@@ -3720,18 +3723,18 @@ function zotinfo($arr) {
}
}
- $ztarget_hash = (($ztarget && $zsig) ? make_xchan_hash($ztarget,$zsig) : '' );
+ $ztarget_hash = (($ztarget && $zsig) ? make_xchan_hash($ztarget,$zsig) : '' );
$r = null;
if(strlen($zhash)) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
where channel_hash = '%s' limit 1",
dbesc($zhash)
);
}
elseif(strlen($zguid) && strlen($zguid_sig)) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
dbesc($zguid),
dbesc($zguid_sig)
@@ -3750,7 +3753,7 @@ function zotinfo($arr) {
/**
* The special address '[system]' will return a system channel if one has been defined,
- * Or the first valid channel we find if there are no system channels.
+ * Or the first valid channel we find if there are no system channels.
*
* This is used by magic-auth if we have no prior communications with this site - and
* returns an identity on this site which we can use to create a valid hub record so that
@@ -3765,7 +3768,7 @@ function zotinfo($arr) {
$r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
where channel_removed = 0 order by channel_id limit 1");
}
- }
+ }
}
else {
$ret['message'] = 'Invalid request';
@@ -3790,7 +3793,7 @@ function zotinfo($arr) {
if($deleted || $censored || $sys_channel)
$searchable = false;
-
+
$public_forum = false;
$role = get_pconfig($e['channel_id'],'system','permissions_role');
@@ -3823,14 +3826,14 @@ function zotinfo($arr) {
if($p) {
if(! intval($p[0]['publish']))
- $searchable = false;
+ $searchable = false;
$profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob'];
if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],$e['channel_timezone'])) !== ''))
$profile['next_birthday'] = $bd;
- if($age = age($p[0]['dob'],$e['channel_timezone'],''))
+ if($age = age($p[0]['dob'],$e['channel_timezone'],''))
$profile['age'] = $age;
$profile['gender'] = $p[0]['gender'];
$profile['marital'] = $p[0]['marital'];
@@ -3883,14 +3886,14 @@ function zotinfo($arr) {
$ret['adult_content'] = $adult_channel;
$ret['public_forum'] = $public_forum;
if($deleted)
- $ret['deleted'] = $deleted;
+ $ret['deleted'] = $deleted;
if(intval($e['channel_removed']))
$ret['deleted_locally'] = true;
// premium or other channel desiring some contact with potential followers before connecting.
// This is a template - %s will be replaced with the follow_url we discover for the return channel.
- if($special_channel)
+ if($special_channel)
$ret['connect_url'] = z_root() . '/connect/' . $e['channel_address'];
// This is a template for our follow url, %s will be replaced with a webbie
@@ -3966,7 +3969,7 @@ function zotinfo($arr) {
$ret['site']['access_policy'] = 'tiered';
$ret['site']['accounts'] = account_total();
-
+
require_once('include/channel.php');
$ret['site']['channels'] = channel_total();
@@ -4007,7 +4010,7 @@ function check_zotinfo($channel,$locations,&$ret) {
// This function will likely expand as we find more things to detect and fix.
// 1. Because magic-auth is reliant on it, ensure that the system channel has a valid hubloc
- // Force this to be the case if anything is found to be wrong with it.
+ // Force this to be the case if anything is found to be wrong with it.
// @FIXME ensure that the system channel exists in the first place and has an xchan
@@ -4027,9 +4030,9 @@ function check_zotinfo($channel,$locations,&$ret) {
logger('System channel locations are not valid. Attempting repair.');
- // Don't trust any existing records. Just get rid of them, but only do this
+ // Don't trust any existing records. Just get rid of them, but only do this
// for the sys channel as normal channels will be trickier.
-
+
q("delete from hubloc where hubloc_hash = '%s'",
dbesc($channel['channel_hash'])
);
@@ -4086,7 +4089,7 @@ function delivery_report_is_storable($dr) {
return false;
- // is the recipient one of our connections, or do we want to store every report?
+ // is the recipient one of our connections, or do we want to store every report?
$r = explode(' ', $dr['recipient']);
$rxchan = $r[0];
@@ -4097,15 +4100,15 @@ function delivery_report_is_storable($dr) {
// We always add ourself as a recipient to private and relayed posts
// So if a remote site says they can't find us, that's no big surprise
// and just creates a lot of extra report noise
-
+
if(($dr['location'] !== z_root()) && ($dr['sender'] === $rxchan) && ($dr['status'] === 'recipient_not_found'))
return false;
// If you have a private post with a recipient list, every single site is going to report
- // back a failed delivery for anybody on that list that isn't local to them. We're only
+ // back a failed delivery for anybody on that list that isn't local to them. We're only
// concerned about this if we have a local hubloc record which says we expected them to
// have a channel on that site.
-
+
$r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_url = '%s'",
dbesc($rxchan),
dbesc($dr['location'])
@@ -4135,7 +4138,7 @@ function update_hub_connected($hub,$sitekey = '') {
* Any hub with the same URL and a different sitekey cannot be valid.
* Get rid of them (mark them deleted). There's a good chance they were re-installs.
*/
-
+
q("update hubloc set hubloc_deleted = 1, hubloc_error = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ",
dbesc($hub['hubloc_url']),
dbesc($sitekey)
@@ -4146,7 +4149,7 @@ function update_hub_connected($hub,$sitekey = '') {
$sitekey = $hub['sitekey'];
}
- // $sender['sitekey'] is a new addition to the protocol to distinguish
+ // $sender['sitekey'] is a new addition to the protocol to distinguish
// hublocs coming from re-installed sites. Older sites will not provide
// this field and we have to still mark them valid, since we can't tell
// if this hubloc has the same sitekey as the packet we received.
@@ -4169,7 +4172,7 @@ function update_hub_connected($hub,$sitekey = '') {
if(intval($hub['hubloc_error'])) {
q("update hubloc set hubloc_error = 0 where hubloc_id = %d and hubloc_sitekey = '%s' ",
intval($hub['hubloc_id']),
- dbesc($sitekey)
+ dbesc($sitekey)
);
if(intval($r[0]['hubloc_orphancheck'])) {
q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d and hubloc_sitekey = '%s' ",
@@ -4181,7 +4184,7 @@ function update_hub_connected($hub,$sitekey = '') {
dbesc($hub['hubloc_hash'])
);
}
-
+
return $hub['hubloc_url'];
}
@@ -4194,7 +4197,7 @@ function zot_reply_ping() {
// This will let us know if any important communication details
// that we may have stored are no longer valid, regardless of xchan details.
logger('POST: got ping send pong now back: ' . z_root() , LOGGER_DEBUG );
-
+
$ret['success'] = true;
$ret['site'] = array();
$ret['site']['url'] = z_root();
@@ -4268,7 +4271,7 @@ function zot_reply_pickup($data) {
/*
* If we made it to here, the signatures verify, but we still don't know if the tracking ID is valid.
* It wouldn't be an error if the tracking ID isn't found, because we may have sent this particular
- * queue item with another pickup (after the tracking ID for the other pickup was verified).
+ * queue item with another pickup (after the tracking ID for the other pickup was verified).
*/
$r = q("select outq_posturl from outq where outq_hash = '%s' and outq_posturl = '%s' limit 1",
@@ -4308,7 +4311,7 @@ function zot_reply_pickup($data) {
}
else
$ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => $x);
-
+
remove_queue_item($rr['outq_hash']);
}
}
@@ -4330,7 +4333,7 @@ function zot_reply_auth_check($data,$encrypted_packet) {
* Requestor visits /magic/?dest=somewhere on their own site with a browser
* magic redirects them to $destsite/post [with auth args....]
* $destsite sends an auth_check packet to originator site
- * The auth_check packet is handled here by the originator's site
+ * The auth_check packet is handled here by the originator's site
* - the browser session is still waiting
* inside $destsite/post for everything to verify
* If everything checks out we'll return a token to $destsite
@@ -4352,9 +4355,9 @@ function zot_reply_auth_check($data,$encrypted_packet) {
// garbage collect any old unused notifications
- // This was and should be 10 minutes but my hosting provider has time lag between the DB and
- // the web server. We should probably convert this to webserver time rather than DB time so
- // that the different clocks won't affect it and allow us to keep the time short.
+ // This was and should be 10 minutes but my hosting provider has time lag between the DB and
+ // the web server. We should probably convert this to webserver time rather than DB time so
+ // that the different clocks won't affect it and allow us to keep the time short.
Zotlabs\Zot\Verify::purge('auth','30 MINUTE');
@@ -4365,7 +4368,7 @@ function zot_reply_auth_check($data,$encrypted_packet) {
// We created a unique hash in mod/magic.php when we invoked remote auth, and stored it in
// the verify table. It is now coming back to us as 'secret' and is signed by a channel at the other end.
// First verify their signature. We will have obtained a zot-info packet from them as part of the sender
- // verification.
+ // verification.
if ((! $y) || (! rsa_verify($data['secret'], base64url_decode($data['secret_sig']),$y[0]['xchan_pubkey']))) {
logger('mod_zot: auth_check: sender not found or secret_sig invalid.');
@@ -4438,7 +4441,7 @@ function zot_reply_purge($sender,$recipients) {
if ($recipients) {
// basically this means "unfriend"
foreach ($recipients as $recip) {
- $r = q("select channel.*,xchan.* from channel
+ $r = q("select channel.*,xchan.* from channel
left join xchan on channel_hash = xchan_hash
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
dbesc($recip['guid']),
@@ -4455,13 +4458,13 @@ function zot_reply_purge($sender,$recipients) {
}
}
$ret['success'] = true;
- }
+ }
else {
// Unfriend everybody - basically this means the channel has committed suicide
$arr = $sender;
$sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']);
- remove_all_xchan_resources($sender_hash);
+ remove_all_xchan_resources($sender_hash);
$ret['success'] = true;
}
@@ -4476,7 +4479,7 @@ function zot_reply_refresh($sender,$recipients) {
// remote channel info (such as permissions or photo or something)
// has been updated. Grab a fresh copy and sync it.
- // The difference between refresh and force_refresh is that
+ // The difference between refresh and force_refresh is that
// force_refresh unconditionally creates a directory update record,
// even if no changes were detected upon processing.
@@ -4485,7 +4488,7 @@ function zot_reply_refresh($sender,$recipients) {
// This would be a permissions update, typically for one connection
foreach ($recipients as $recip) {
- $r = q("select channel.*,xchan.* from channel
+ $r = q("select channel.*,xchan.* from channel
left join xchan on channel_hash = xchan_hash
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
dbesc($recip['guid']),
@@ -4493,17 +4496,17 @@ function zot_reply_refresh($sender,$recipients) {
);
$x = zot_refresh(array(
- 'xchan_guid' => $sender['guid'],
+ 'xchan_guid' => $sender['guid'],
'xchan_guid_sig' => $sender['guid_sig'],
'hubloc_url' => $sender['url']
), $r[0], (($msgtype === 'force_refresh') ? true : false));
}
- }
+ }
else {
// system wide refresh
$x = zot_refresh(array(
- 'xchan_guid' => $sender['guid'],
+ 'xchan_guid' => $sender['guid'],
'xchan_guid_sig' => $sender['guid_sig'],
'hubloc_url' => $sender['url']
), null, (($msgtype === 'force_refresh') ? true : false));
@@ -4526,7 +4529,7 @@ function zot_reply_notify($data) {
if($async) {
// add to receive queue
// qreceive_add($data);
- }
+ }
else {
$x = zot_fetch($data);
$ret['delivery_report'] = $x;