mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 01:55:13 +00:00
code cleanup
This commit is contained in:
parent
41055b60a7
commit
864e6f19fa
15 changed files with 90 additions and 192 deletions
|
@ -3969,7 +3969,7 @@ class Activity
|
|||
intval($x['item_id'])
|
||||
);
|
||||
if ($r) {
|
||||
send_status_notifications($x['item_id'], $r[0]);
|
||||
send_status_notifications($r[0]);
|
||||
}
|
||||
sync_an_item($channel['channel_id'], $x['item_id']);
|
||||
}
|
||||
|
|
|
@ -272,13 +272,13 @@ class Libzotdir
|
|||
$arr = [];
|
||||
|
||||
$arr['xprof_hash'] = $hash;
|
||||
|
||||
|
||||
$arr['xprof_dob'] = '0000-00-00';
|
||||
if (isset($profile['birthday'])) {
|
||||
$arr['xprof_dob'] = (($profile['birthday'] === '0000-00-00')
|
||||
? $profile['birthday']
|
||||
: datetime_convert('', '', $profile['birthday'], 'Y-m-d')); // !!!! check this for 0000 year
|
||||
}
|
||||
if (isset($profile['birthday'])) {
|
||||
$arr['xprof_dob'] = (($profile['birthday'] === '0000-00-00')
|
||||
? $profile['birthday']
|
||||
: datetime_convert('', '', $profile['birthday'], 'Y-m-d')); // !!!! check this for 0000 year
|
||||
}
|
||||
$arr['xprof_age'] = (isset($profile['age']) ? intval($profile['age']) : 0);
|
||||
$arr['xprof_desc'] = ((isset($profile['description']) && $profile['description']) ? htmlspecialchars($profile['description'], ENT_COMPAT, 'UTF-8', false) : '');
|
||||
$arr['xprof_gender'] = ((isset($profile['gender']) && $profile['gender']) ? htmlspecialchars($profile['gender'], ENT_COMPAT, 'UTF-8', false) : '');
|
||||
|
|
|
@ -53,7 +53,7 @@ class Ca extends Controller
|
|||
}
|
||||
|
||||
if ($_GET['url']) {
|
||||
goaway($url);
|
||||
goaway($_GET['url']);
|
||||
}
|
||||
}
|
||||
http_status_exit(404, 'Not found');
|
||||
|
|
|
@ -189,6 +189,7 @@ class Channel extends Controller
|
|||
{
|
||||
|
||||
$noscript_content = get_config('system', 'noscript_content', '1');
|
||||
$sql_extra2 = '';
|
||||
|
||||
$category = $datequery = $datequery2 = '';
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Code\Module;
|
|||
use App;
|
||||
use Code\Web\Controller;
|
||||
use Code\Lib\Libzot;
|
||||
use Code\Lib\Zotfinger;
|
||||
use Code\Lib\Webfinger;
|
||||
use Code\Lib\ActivityStreams;
|
||||
use Code\Lib\Activity;
|
||||
|
@ -77,7 +78,7 @@ class Chanview extends Controller
|
|||
$r = null;
|
||||
|
||||
if ($_REQUEST['address']) {
|
||||
$href = Webfinger::zot_url(punify($url));
|
||||
$href = Webfinger::zot_url(punify($_REQUEST['address']));
|
||||
if ($href) {
|
||||
$zf = Zotfinger::exec($href, $channel);
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ use Sabre\DAV as SDAV;
|
|||
use Sabre\DAV\Exception\Forbidden;
|
||||
use Sabre\DAV\Exception\NotFound;
|
||||
use Sabre\DAV\Exception\NotImplemented;
|
||||
use Code\Storage;
|
||||
use Code\Lib\Libprofile;
|
||||
use Code\Storage\Stdio;
|
||||
use Code\Storage\Browser;
|
||||
use Code\Web\Controller;
|
||||
use Code\Storage\BasicAuth;
|
||||
|
@ -40,7 +40,7 @@ class Cloud extends Controller
|
|||
{
|
||||
|
||||
if (!is_dir('store')) {
|
||||
os_mkdir('store', STORAGE_DEFAULT_PERMISSIONS, false);
|
||||
Stdio::mkdir('store', STORAGE_DEFAULT_PERMISSIONS, false);
|
||||
}
|
||||
|
||||
$which = null;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Code\Storage;
|
||||
|
||||
use App;
|
||||
use Sabre\;
|
||||
use Sabre;
|
||||
use Sabre\DAV;
|
||||
use Sabre\DAV\Browser\Plugin;
|
||||
use Sabre\HTTP\Auth\Basic;
|
||||
|
@ -16,7 +16,7 @@ use Sabre\HTTP\ResponseInterface;
|
|||
* This class also contains some data which is not necessary for authentication
|
||||
* like timezone settings.
|
||||
*
|
||||
* @extends \DAV\\Auth\\Backend\\AbstractBasic
|
||||
* @extends Sabre\DAV\Auth\Backend\AbstractBasic
|
||||
*
|
||||
* @link http://github.com/friendica/red
|
||||
* @license http://opensource.org/unlicense.org
|
||||
|
@ -38,6 +38,12 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic
|
|||
* @var int $channel_id
|
||||
*/
|
||||
public $channel_id = 0;
|
||||
/**
|
||||
* @brief channel_account_id of the current channel of the logged-in account.
|
||||
*
|
||||
* @var int $channel_account_id
|
||||
*/
|
||||
public $channel_account_id = 0;
|
||||
/**
|
||||
* @brief channel_hash of the current channel of the logged-in account.
|
||||
*
|
||||
|
@ -53,7 +59,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic
|
|||
/**
|
||||
*
|
||||
* @see Browser::set_writeable()
|
||||
* @var \DAV\\Browser\\Plugin $browser
|
||||
* @var Sabre\DAV\Browser\Plugin $browser
|
||||
*/
|
||||
public $browser;
|
||||
/**
|
||||
|
@ -94,7 +100,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic
|
|||
*/
|
||||
protected function validateUserPass($username, $password)
|
||||
{
|
||||
|
||||
$channel = false;
|
||||
require_once('include/auth.php');
|
||||
$record = account_verify_password($username, $password);
|
||||
if ($record && $record['account']) {
|
||||
|
@ -135,6 +141,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic
|
|||
$this->channel_name = $channel['channel_address'];
|
||||
$this->channel_id = $channel['channel_id'];
|
||||
$this->channel_hash = $this->observer = $channel['channel_hash'];
|
||||
$this->channel_account_id = $channel['channel_account_id'];
|
||||
|
||||
if ($this->observer) {
|
||||
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||
|
|
|
@ -3,7 +3,6 @@ namespace Code\Storage;
|
|||
|
||||
|
||||
use App;
|
||||
use Sabre\;
|
||||
use Sabre\DAV;
|
||||
use Sabre\DAV\INode;
|
||||
use Code\Lib\PermissionDescription;
|
||||
|
@ -23,7 +22,7 @@ use function Sabre\HTTP\encodePath;
|
|||
* Browser is a SabreDAV server-plugin to provide a view to the DAV storage
|
||||
* for the webbrowser.
|
||||
*
|
||||
* @extends \DAV\\Browser\\Plugin
|
||||
* @extends DAV\\Browser\\Plugin
|
||||
*
|
||||
* @link http://framagit.org/hubzilla/core/
|
||||
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Code\Storage;
|
||||
|
||||
use App;
|
||||
use Sabre\;
|
||||
use Sabre\DAV;
|
||||
use Code\Lib\Libsync;
|
||||
use Code\Daemon\Run;
|
||||
|
@ -18,9 +17,9 @@ require_once('include/photos.php');
|
|||
*
|
||||
* A class that represents a directory.
|
||||
*
|
||||
* @extends \DAV\\Node
|
||||
* @implements \DAV\\ICollection
|
||||
* @implements \DAV\\IQuota
|
||||
* @extends DAV\\Node
|
||||
* @implements DAV\\ICollection
|
||||
* @implements DAV\\IQuota
|
||||
*
|
||||
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
|
||||
*/
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Code\Storage;
|
||||
|
||||
use App;
|
||||
use Code\;
|
||||
use Sabre\DAV;
|
||||
use Code\Lib\Libsync;
|
||||
use Code\Daemon\Run;
|
||||
|
@ -38,8 +37,8 @@ class File extends DAV\Node implements DAV\IFile {
|
|||
public $data;
|
||||
|
||||
/**
|
||||
* @see \\Sabre\\DAV\\Auth\\Backend\\BackendInterface
|
||||
* @var \Storage\\BasicAuth $auth
|
||||
* @see \Sabre\DAV\Auth\Backend\BackendInterface
|
||||
* @var \Code\Storage\BasicAuth $auth
|
||||
*/
|
||||
|
||||
private $auth;
|
||||
|
@ -106,7 +105,7 @@ class File extends DAV\Node implements DAV\IFile {
|
|||
intval($this->auth->owner_id)
|
||||
);
|
||||
|
||||
if ($this->data->is_photo) {
|
||||
if ($this->data['is_photo']) {
|
||||
$r = q("update photo set filename = '%s', display_path = '%s' where resource_id = '%s' and uid = %d",
|
||||
dbesc($newName),
|
||||
dbesc($x['path']),
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
*
|
||||
* @brief File/attach API with the potential for revision control.
|
||||
*
|
||||
* @TODO A filesystem storage abstraction which maintains security (and 'data'
|
||||
* contains a system filename which is inaccessible from the web). This could
|
||||
* get around PHP storage limits and store videos and larger items, using fread
|
||||
* or OS methods or native code to read/write or chunk it through.
|
||||
* @todo Also an 'append' option to the storage function might be a useful addition.
|
||||
*/
|
||||
|
||||
|
@ -1337,7 +1333,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null)
|
|||
$ret['data'] = $z[0];
|
||||
}
|
||||
} else {
|
||||
logger('attach_mkdir: ' . mkdir . ' ' . $os_basepath . $os_path . ' failed.');
|
||||
logger('attach_mkdir: ' . $os_basepath . $os_path . ' failed.');
|
||||
$ret['message'] = t('mkdir failed.');
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -4,7 +4,7 @@ require_once('boot.php');
|
|||
|
||||
// Everything we need to boot standalone 'background' processes
|
||||
|
||||
function cli_startup()
|
||||
function cli_startup(): void
|
||||
{
|
||||
sys_boot();
|
||||
App::set_baseurl(get_config('system', 'baseurl'));
|
||||
|
|
|
@ -42,7 +42,7 @@ require_once('include/photo_factory.php');
|
|||
function collect_recipients($item, &$private_envelope,$include_groups = true) {
|
||||
|
||||
|
||||
$private_envelope = ((intval($item['item_private'])) ? true : false);
|
||||
$private_envelope = (bool)intval($item['item_private']);
|
||||
$recipients = [];
|
||||
|
||||
if ($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
|
||||
|
@ -324,7 +324,6 @@ function can_comment_on_post($observer_xchan, $item)
|
|||
// 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.
|
||||
return true;
|
||||
break;
|
||||
case 'any connections':
|
||||
case 'specific':
|
||||
case 'contacts':
|
||||
|
@ -510,92 +509,6 @@ function validate_item_elements($message,$arr) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Limit length on imported system messages.
|
||||
*
|
||||
* The purpose of this function is to apply system message length limits to
|
||||
* imported messages without including any embedded photos in the length.
|
||||
*
|
||||
* @param string $body
|
||||
* @return string
|
||||
*/
|
||||
function limit_body_size($body) {
|
||||
|
||||
$maxlen = get_max_import_size();
|
||||
|
||||
// If the length of the body, including the embedded images, is smaller
|
||||
// than the maximum, then don't waste time looking for the images
|
||||
if($maxlen && (strlen($body) > $maxlen)) {
|
||||
|
||||
$orig_body = $body;
|
||||
$new_body = '';
|
||||
$textlen = 0;
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
while(($img_st_close !== false) && ($img_end !== false)) {
|
||||
|
||||
$img_st_close++; // make it point to AFTER the closing bracket
|
||||
$img_end += $img_start;
|
||||
$img_end += strlen('[/img]');
|
||||
|
||||
if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
|
||||
// This is an embedded image
|
||||
|
||||
if( ($textlen + $img_start) > $maxlen ) {
|
||||
if($textlen < $maxlen) {
|
||||
logger('The limit happens before an embedded image', LOGGER_DEBUG);
|
||||
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
|
||||
$textlen = $maxlen;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_start);
|
||||
$textlen += $img_start;
|
||||
}
|
||||
|
||||
$new_body = $new_body . substr($orig_body, $img_start, $img_end - $img_start);
|
||||
}
|
||||
else {
|
||||
if( ($textlen + $img_end) > $maxlen ) {
|
||||
if($textlen < $maxlen) {
|
||||
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
|
||||
$textlen = $maxlen;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_end);
|
||||
$textlen += $img_end;
|
||||
}
|
||||
}
|
||||
$orig_body = substr($orig_body, $img_end);
|
||||
|
||||
if($orig_body === false) // in case the body ends on a closing image tag
|
||||
$orig_body = '';
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
}
|
||||
|
||||
if( ($textlen + strlen($orig_body)) > $maxlen) {
|
||||
if($textlen < $maxlen) {
|
||||
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
|
||||
$textlen = $maxlen;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$new_body = $new_body . $orig_body;
|
||||
$textlen += strlen($orig_body);
|
||||
}
|
||||
|
||||
return $new_body;
|
||||
}
|
||||
else
|
||||
return $body;
|
||||
}
|
||||
|
||||
function get_item_elements($x,$allow_code = false) {
|
||||
|
||||
$arr = [];
|
||||
|
@ -965,7 +878,7 @@ function import_author_unknown($x) {
|
|||
'xchan_guid' => $x['url'],
|
||||
'xchan_url' => $x['url'],
|
||||
'xchan_updated' => datetime_convert(),
|
||||
'xchan_name' => (($name) ? $name : t('(Unknown)')),
|
||||
'xchan_name' => (($name) ?: t('(Unknown)')),
|
||||
'xchan_name_date' => datetime_convert(),
|
||||
'xchan_network' => 'unknown'
|
||||
]
|
||||
|
@ -994,7 +907,7 @@ function import_author_unknown($x) {
|
|||
}
|
||||
|
||||
function empty_acl($item) {
|
||||
return (($item['allow_cid'] === EMPTY_STR && $item['allow_gid'] === EMPTY_STR && $item['deny_cid'] === EMPTY_STR && $item['deny_gid'] === EMPTY_STR) ? true : false);
|
||||
return $item['allow_cid'] === EMPTY_STR && $item['allow_gid'] === EMPTY_STR && $item['deny_cid'] === EMPTY_STR && $item['deny_gid'] === EMPTY_STR;
|
||||
}
|
||||
|
||||
function encode_item($item,$mirror = false) {
|
||||
|
@ -1002,8 +915,6 @@ function encode_item($item,$mirror = false) {
|
|||
$x['type'] = 'activity';
|
||||
$x['encoding'] = 'zot';
|
||||
|
||||
$key = get_config('system','prvkey');
|
||||
|
||||
// If we're trying to backup an item so that it's recoverable or for export/imprt,
|
||||
// add all the attributes we need to recover it
|
||||
|
||||
|
@ -1153,6 +1064,7 @@ function translate_scope($scope) {
|
|||
return t('Visible to approved connections.');
|
||||
if(strpos($scope,'specific') === 0)
|
||||
return t('Visible to specific connections.');
|
||||
return ''; // This shouldn't happen.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1229,7 +1141,7 @@ function decode_item_meta($meta) {
|
|||
function termtype($t) {
|
||||
$types = array('unknown','hashtag','mention','category','personal_category','file','search','thing','bookmark', 'hierarchy', 'communitytag', 'forum');
|
||||
|
||||
return(($types[$t]) ? $types[$t] : 'unknown');
|
||||
return(($types[$t]) ?: 'unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1265,7 +1177,7 @@ function decode_tags($t) {
|
|||
$tag['ttype'] = TERM_FILE;
|
||||
break;
|
||||
case 'search':
|
||||
$tag['ttype'] = TERM_SEARCH;
|
||||
$tag['ttype'] = TERM_SAVEDSEARCH;
|
||||
break;
|
||||
case 'thing':
|
||||
$tag['ttype'] = TERM_THING;
|
||||
|
@ -1343,7 +1255,7 @@ function activity_sanitise($arr) {
|
|||
}
|
||||
}
|
||||
if (in_array($k, [ 'content', 'summary', 'contentMap', 'summaryMap' ])) {
|
||||
$ret[$k] = purify_imported_object($arr[$k]);
|
||||
$ret[$k] = purify_imported_object($x);
|
||||
continue;
|
||||
}
|
||||
if(is_array($x))
|
||||
|
@ -1938,7 +1850,7 @@ function item_store($arr, $allow_exec = false, $deliver = true, $linkid = true)
|
|||
$arr['id'] = $current_post;
|
||||
|
||||
if(! intval($r[0]['parent'])) {
|
||||
$x = q("update item set parent = id where id = %d",
|
||||
q("update item set parent = id where id = %d",
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
$arr['parent'] = $r[0]['id'];
|
||||
|
@ -1991,7 +1903,7 @@ function item_store($arr, $allow_exec = false, $deliver = true, $linkid = true)
|
|||
// that isn't aware that we were already told to delete it.
|
||||
|
||||
if(($deliver) && (! intval($arr['item_deleted']))) {
|
||||
send_status_notifications($current_post,$arr);
|
||||
send_status_notifications($arr);
|
||||
tag_deliver($arr['uid'],$current_post);
|
||||
}
|
||||
|
||||
|
@ -2388,7 +2300,7 @@ function item_update_parent_commented($item) {
|
|||
}
|
||||
|
||||
|
||||
function send_status_notifications($post_id,$item) {
|
||||
function send_status_notifications($item) {
|
||||
|
||||
// only send notifications for comments
|
||||
|
||||
|
@ -2483,7 +2395,7 @@ function send_status_notifications($post_id,$item) {
|
|||
}
|
||||
|
||||
|
||||
Enotify::submit(array(
|
||||
Enotify::submit([
|
||||
'type' => $notify_type,
|
||||
'from_xchan' => $item['author_xchan'],
|
||||
'to_xchan' => $r[0]['channel_hash'],
|
||||
|
@ -2491,9 +2403,9 @@ function send_status_notifications($post_id,$item) {
|
|||
'link' => $link,
|
||||
'verb' => $item['verb'],
|
||||
'otype' => 'item',
|
||||
'parent' => $thr_parent_id ? $thr_parent_id : $parent,
|
||||
'parent' => $thr_parent_id ?: $parent,
|
||||
'parent_mid' => $thr_parent_id ? $item['thr_parent'] : $item['parent_mid']
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2509,12 +2421,10 @@ function tag_deliver($uid, $item_id) {
|
|||
|
||||
$role = get_pconfig($uid,'system','permissions_role');
|
||||
$rolesettings = PermissionRoles::role_perms($role);
|
||||
$channel_type = isset($rolesettings['channel_type']) ? $rolesettings['channel_type'] : 'normal';
|
||||
$channel_type = $rolesettings['channel_type'] ?? 'normal';
|
||||
|
||||
$is_group = (($channel_type === 'group') ? true : false);
|
||||
$is_collection = (($channel_type === 'collection') ? true : false);
|
||||
|
||||
$mention = false;
|
||||
$is_group = $channel_type === 'group';
|
||||
$is_collection = $channel_type === 'collection';
|
||||
|
||||
/*
|
||||
* Fetch stuff we need - a channel and an item
|
||||
|
@ -2546,7 +2456,7 @@ function tag_deliver($uid, $item_id) {
|
|||
// after resetting ownership and permission bits
|
||||
|
||||
logger('updating edited tag_deliver post for ' . $u['channel_address']);
|
||||
start_delivery_chain($u, $item, $item_id, 0, false, true);
|
||||
start_delivery_chain($u, $item, $item_id, false, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2574,7 +2484,7 @@ function tag_deliver($uid, $item_id) {
|
|||
// and this will be turned into an embedded wall-to-wall post
|
||||
if(perm_is_allowed($uid,$item['author_xchan'],'post_wall')) {
|
||||
logger('group DM delivery for ' . $u['channel_address']);
|
||||
start_delivery_chain($u, $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
start_delivery_chain($u, $item, $item_id, false, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
q("update item set item_blocked = %d where id = %d",
|
||||
intval(ITEM_HIDDEN),
|
||||
intval($item_id)
|
||||
|
@ -2603,7 +2513,7 @@ function tag_deliver($uid, $item_id) {
|
|||
if ($id == z_root() . '/outbox/' . $u['channel_address']) {
|
||||
if(perm_is_allowed($uid,$item['author_xchan'],'post_wall')) {
|
||||
logger('group collection delivery for ' . $u['channel_address']);
|
||||
start_delivery_chain($u, $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
start_delivery_chain($u, $item, $item_id, false, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
q("update item set item_blocked = %d where id = %d",
|
||||
intval(ITEM_HIDDEN),
|
||||
intval($item_id)
|
||||
|
@ -2621,7 +2531,7 @@ function tag_deliver($uid, $item_id) {
|
|||
}
|
||||
// group delivery via W2W
|
||||
logger('rewriting W2W post for ' . $u['channel_address']);
|
||||
start_delivery_chain($u, $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
start_delivery_chain($u, $item, $item_id, false, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
q("update item set item_wall = 0 where id = %d",
|
||||
intval($item_id)
|
||||
);
|
||||
|
@ -2705,12 +2615,9 @@ function tag_deliver($uid, $item_id) {
|
|||
if (! link_compare($term['url'],$link)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mention = true;
|
||||
|
||||
logger('Mention found for ' . $u['channel_name']);
|
||||
|
||||
$r = q("update item set item_mentionsme = 1 where id = %d",
|
||||
q("update item set item_mentionsme = 1 where id = %d",
|
||||
intval($item_id)
|
||||
);
|
||||
|
||||
|
@ -2761,7 +2668,7 @@ function tag_deliver($uid, $item_id) {
|
|||
if ($is_group && intval($item['item_thread_top']) && (! intval($item['item_wall']))) {
|
||||
if (get_pconfig($uid,'system','post_via_mentions',in_array($role,['forum','forum_moderated'])) && perm_is_allowed($uid,$item['author_xchan'],'post_wall')) {
|
||||
logger('group mention delivery for ' . $u['channel_address']);
|
||||
start_delivery_chain($u, $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
start_delivery_chain($u, $item, $item_id, false, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
|
||||
q("update item set item_blocked = %d where id = %d",
|
||||
intval(ITEM_HIDDEN),
|
||||
intval($item_id)
|
||||
|
@ -2821,7 +2728,7 @@ function tag_deliver($uid, $item_id) {
|
|||
}
|
||||
|
||||
logger('Creating second delivery chain.');
|
||||
start_delivery_chain($u,$item,$item_id,null);
|
||||
start_delivery_chain($u,$item,$item_id, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2833,7 +2740,7 @@ function tag_deliver($uid, $item_id) {
|
|||
}
|
||||
|
||||
logger('Creating second delivery chain.');
|
||||
start_delivery_chain($u,$item,$item_id,null);
|
||||
start_delivery_chain($u,$item,$item_id,false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2939,8 +2846,8 @@ function tgroup_check($uid, $item) {
|
|||
}
|
||||
}
|
||||
}
|
||||
$unless = intval(get_pconfig($channel['channel_id'], 'system', 'unless_tag_count',
|
||||
get_config('system', 'unless_tag_count', 20)));
|
||||
$unless = intval(PConfig::Get($uid, 'system', 'unless_tag_count',
|
||||
Config::Get('system', 'unless_tag_count', 20)));
|
||||
if ($unless && count($terms) > $unless) {
|
||||
$tag_result= false;
|
||||
}
|
||||
|
@ -2992,9 +2899,9 @@ function i_am_mentioned($channel,$item) {
|
|||
* @param array $channel
|
||||
* @param array $item
|
||||
* @param int $item_id
|
||||
* @param boolean $parent
|
||||
* @param bool|array $parent
|
||||
*/
|
||||
function start_delivery_chain($channel, $item, $item_id, $parent, $group = false, $edit = false) {
|
||||
function start_delivery_chain($channel, $item, $item_id, bool|array $parent, $group = false, $edit = false) {
|
||||
|
||||
// btlogger('start_chain: ' . $channel['channel_id'] . ' item: ' . $item_id);
|
||||
|
||||
|
@ -3305,15 +3212,10 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false
|
|||
|
||||
$private = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0);
|
||||
|
||||
// Setting item_origin on a deleted item also seems to cause looping
|
||||
if (! intval($arr['item_deleted'])) {
|
||||
$arr['item_origin'] = 1;
|
||||
}
|
||||
|
||||
$item_origin = ($item['item_deleted']) ? 0 : 1;
|
||||
$item_wall = 1;
|
||||
$item_uplink = 0;
|
||||
$item_nocomment = 0;
|
||||
|
||||
$flag_bits = $item['item_flags'];
|
||||
|
||||
// maintain the original source, which will be the original item owner and was stored in source_xchan
|
||||
|
@ -3674,10 +3576,6 @@ function drop_items($items, $stage = DROPITEM_NORMAL, $force = false) {
|
|||
|
||||
$uid = 0;
|
||||
|
||||
if (($interactive) && (! (local_channel() || remote_channel()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (count($items)) {
|
||||
foreach ($items as $item) {
|
||||
$owner = drop_item($item, $stage, $force);
|
||||
|
@ -4240,7 +4138,7 @@ function zot_feed($uid, $observer_hash, $arr) {
|
|||
foreach($items as $item) {
|
||||
if($encoding === 'zot')
|
||||
$result[] = encode_item($item);
|
||||
elseif(encoding === 'activitystreams')
|
||||
elseif($encoding === 'activitystreams')
|
||||
$result[] = Activity::encode_activity($item);
|
||||
}
|
||||
|
||||
|
@ -4296,15 +4194,15 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
|
|||
|
||||
$sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options $item_normal ) ";
|
||||
|
||||
if(isset($arr['since_id']) && $arr['since_id']) {
|
||||
$sql_extra .= " and item.id > " . $since_id . " ";
|
||||
if (!empty($arr['since_id'])) {
|
||||
$sql_extra .= " and item.id > " . $arr['since_id'] . " ";
|
||||
}
|
||||
|
||||
if (isset($arr['cat']) && $arr['cat']) {
|
||||
if (!empty($arr['cat'])) {
|
||||
$sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY));
|
||||
}
|
||||
|
||||
if (isset($arr['gid']) && $arr['gid'] && $uid) {
|
||||
if ($uid && !empty($arr['gid'])) {
|
||||
$r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
|
||||
intval($arr['group']),
|
||||
intval($uid)
|
||||
|
@ -4587,8 +4485,9 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
|
|||
// sixteen bytes of the mid - which makes the link portable and not quite as daunting
|
||||
// as the entire mid. If it were the post_id the link would be less portable.
|
||||
|
||||
$post_id = intval($post_id);
|
||||
IConfig::Set(
|
||||
intval($post_id),
|
||||
$post_id,
|
||||
'system',
|
||||
$page_type,
|
||||
($pagetitle) ? $pagetitle : substr($mid,0,16),
|
||||
|
@ -4636,13 +4535,13 @@ function item_remove_cid($xchan_hash,$mid,$uid) {
|
|||
}
|
||||
|
||||
// Set item permissions based on results obtained from linkify_tags()
|
||||
function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, $profile_uid, $parent_item = false, &$private) {
|
||||
function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, $profile_uid, $parent_item, &$private) {
|
||||
$first_access_tag = true;
|
||||
|
||||
foreach($linkified as $x) {
|
||||
$access_tag = $x['success']['access_tag'];
|
||||
if(($access_tag) && (! $parent_item)) {
|
||||
logger('access_tag: ' . $tag . ' ' . print_r($access_tag,true), LOGGER_DATA);
|
||||
logger('access_tag: ' . print_r($access_tag,true), LOGGER_DATA);
|
||||
if ($first_access_tag && (! get_pconfig($profile_uid,'system','no_private_mention_acl_override'))) {
|
||||
|
||||
// This is a tough call, hence configurable. The issue is that one can type in a @!privacy mention
|
||||
|
@ -4834,10 +4733,8 @@ function fix_attached_permissions($uid,$body,$str_contact_allow,$str_group_allow
|
|||
|
||||
$attach = array_shift($attach_q);
|
||||
|
||||
$match = null;
|
||||
$existing_public = false;
|
||||
$new_public = (($str_contact_allow||$str_group_allow||$str_contact_deny||$str_group_deny) ? false : true);
|
||||
$existing_public = (($attach['allow_cid']||$attach['allow_gid']||$attach['deny_cid']||$attach['deny_gid']) ? false : true);
|
||||
$new_public = !(($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny));
|
||||
$existing_public = !(($attach['allow_cid'] || $attach['allow_gid'] || $attach['deny_cid'] || $attach['deny_gid']));
|
||||
|
||||
if ($existing_public) {
|
||||
// permissions have already been fixed and they are public. There's nothing for us to do.
|
||||
|
|
|
@ -201,7 +201,7 @@ function z_dns_check($h, $check_mx = 0)
|
|||
|
||||
// BSD variants have dns_get_record() but it only works reliably without any options
|
||||
if (stripos(PHP_OS, 'bsd') !== false) {
|
||||
return((@dns_get_record($h) || filter_var($h, FILTER_VALIDATE_IP)) ? true : false);
|
||||
return @dns_get_record($h) || filter_var($h, FILTER_VALIDATE_IP);
|
||||
}
|
||||
|
||||
// Otherwise we will assume dns_get_record() works as documented
|
||||
|
@ -211,7 +211,7 @@ function z_dns_check($h, $check_mx = 0)
|
|||
$opts += DNS_MX;
|
||||
}
|
||||
|
||||
return((@dns_get_record($h, $opts) || filter_var($h, FILTER_VALIDATE_IP)) ? true : false);
|
||||
return @dns_get_record($h, $opts) || filter_var($h, FILTER_VALIDATE_IP);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -458,7 +458,7 @@ function xml2array($contents, $namespaces = true, $get_attributes = 1, $priority
|
|||
if ($priority == 'tag') {
|
||||
$result = $value;
|
||||
} else {
|
||||
$result['value'] = $value; // Put the value in a assoc array if we are in the 'Attribute' mode
|
||||
$result['value'] = $value; // Put the value in an assoc array if we are in the 'Attribute' mode
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ function xml2array($contents, $namespaces = true, $get_attributes = 1, $priority
|
|||
if ($priority == 'tag') {
|
||||
$attributes_data[$attr] = $val;
|
||||
} else {
|
||||
$result['@attributes'][$attr] = $val; // Set all the attributes in a array called 'attr'
|
||||
$result['@attributes'][$attr] = $val; // Set all the attributes in an array called 'attr'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ function xml2array($contents, $namespaces = true, $get_attributes = 1, $priority
|
|||
}
|
||||
$repeated_tag_index[$tag . '_' . $level]++;
|
||||
} else { // If it is not an array...
|
||||
$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
|
||||
$current[$tag] = array($current[$tag],$result); //...Make it an array using the existing value and the new value
|
||||
$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
|
||||
|
@ -584,7 +584,7 @@ function email_header_encode($in_str, $charset = 'UTF-8', $header = 'Subject')
|
|||
base64-encoding 3 8-bit-chars are represented
|
||||
by 4 6-bit-chars. These 4 chars must not be
|
||||
split between two encoded words, according
|
||||
to RFC-2047.
|
||||
to RFC-2047.]
|
||||
*/
|
||||
$length = $length - ($length % 4);
|
||||
|
||||
|
@ -653,7 +653,7 @@ function discover_by_webbie($webbie, $protocol = '', $verify = true)
|
|||
if ($verify) {
|
||||
|
||||
$hsig = $record['signature'];
|
||||
if($hsig && ($hsig['signer'] === $url || $hsig['signer'] === $link['href']) && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
|
||||
if($hsig && $hsig['signer'] === $link['href'] && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
|
||||
$hsig_valid = true;
|
||||
}
|
||||
|
||||
|
@ -688,7 +688,7 @@ function discover_by_webbie($webbie, $protocol = '', $verify = true)
|
|||
|
||||
if ($verify) {
|
||||
$hsig = $record['signature'];
|
||||
if ($hsig && ($hsig['signer'] === $url || $hsig['signer'] === $link['href']) && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
|
||||
if ($hsig && $hsig['signer'] === $link['href'] && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
|
||||
$hsig_valid = true;
|
||||
}
|
||||
|
||||
|
@ -721,7 +721,7 @@ function discover_by_webbie($webbie, $protocol = '', $verify = true)
|
|||
if ($record) {
|
||||
if ($verify) {
|
||||
$hsig = $record['signature'];
|
||||
if ($hsig && ($hsig['signer'] === $url || $hsig['signer'] === $webbie) && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
|
||||
if ($hsig && $hsig['signer'] === $webbie && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
|
||||
$hsig_valid = true;
|
||||
}
|
||||
|
||||
|
@ -1139,7 +1139,7 @@ function check_channelallowed($hash)
|
|||
if ($bl === '*') {
|
||||
$retvalue = true;
|
||||
}
|
||||
if ($bl && (strpos($url, $bl) !== false || wildmat($bl, $url))) {
|
||||
if ($bl && (strpos($hash, $bl) !== false || wildmat($bl, $hash))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1149,7 +1149,7 @@ function check_channelallowed($hash)
|
|||
if ($bl === '*') {
|
||||
$retvalue = false;
|
||||
}
|
||||
if ($bl && (strpos($url, $bl) !== false || wildmat($bl, $url))) {
|
||||
if ($bl && (strpos($hash, $bl) !== false || wildmat($bl, $hash))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1194,7 +1194,7 @@ function check_pubstream_channelallowed($hash)
|
|||
if ($bl === '*') {
|
||||
$retvalue = true;
|
||||
}
|
||||
if ($bl && (strpos($url, $bl) !== false || wildmat($bl, $url))) {
|
||||
if ($bl && (strpos($hash, $bl) !== false || wildmat($bl, $hash))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1204,7 +1204,7 @@ function check_pubstream_channelallowed($hash)
|
|||
if ($bl === '*') {
|
||||
$retvalue = false;
|
||||
}
|
||||
if ($bl && (strpos($url, $bl) !== false || wildmat($bl, $url))) {
|
||||
if ($bl && (strpos($hash, $bl) !== false || wildmat($bl, $hash))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1293,7 +1293,7 @@ function network_to_name($s)
|
|||
* @param array $params an associative array with:
|
||||
* * \e string \b fromName name of the sender
|
||||
* * \e string \b fromEmail email of the sender
|
||||
* * \e string \b replyTo replyTo address to direct responses
|
||||
* * \e string \b replyTo address to direct responses
|
||||
* * \e string \b toEmail destination email address
|
||||
* * \e string \b messageSubject subject of the message
|
||||
* * \e string \b htmlVersion html version of the message
|
||||
|
@ -1429,7 +1429,7 @@ function getBestSupportedMimeType($mimeTypes = null, $acceptedTypes = false)
|
|||
$acceptedTypes = ((isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : EMPTY_STR);
|
||||
}
|
||||
|
||||
// Accept header is case insensitive, and whitespace isn’t important
|
||||
// Accept header is case-insensitive, and whitespace isn’t important
|
||||
$accept = strtolower(str_replace(' ', '', $acceptedTypes));
|
||||
// divide it into parts in the place of a ","
|
||||
$accept = explode(',', $accept);
|
||||
|
|
|
@ -231,7 +231,6 @@ function get_all_perms($uid, $observer_xchan, $check_siteblock = true, $default_
|
|||
// No permissions allowed.
|
||||
|
||||
$ret[$perm_name] = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$arr = array(
|
||||
|
@ -455,7 +454,7 @@ function get_all_api_perms($uid, $api)
|
|||
|
||||
$arr = array(
|
||||
'channel_id' => $uid,
|
||||
'observer_hash' => $observer_xchan,
|
||||
'observer_hash' => get_observer_hash(),
|
||||
'permissions' => $ret);
|
||||
|
||||
Hook::call('get_all_api_perms', $arr);
|
||||
|
@ -469,7 +468,7 @@ function api_perm_is_allowed($uid, $api, $permission)
|
|||
|
||||
$arr = array(
|
||||
'channel_id' => $uid,
|
||||
'observer_hash' => $observer_xchan,
|
||||
'observer_hash' => get_observer_hash(),
|
||||
'permission' => $permission,
|
||||
'result' => false
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue