This commit is contained in:
Mike Macgirvin 2022-09-03 15:23:54 +10:00
parent 5516481a49
commit bca644ddd3
21 changed files with 113 additions and 119 deletions

View file

@ -1936,7 +1936,7 @@ class Channel
$cover = [ 'href' => z_root() . '/' . self::get_default_cover_photo($cover_width) ];
}
$o .= replace_macros(Theme::get_template('zcard.tpl'), array(
$o = replace_macros(Theme::get_template('zcard.tpl'), array(
'$maxwidth' => $maxwidth,
'$scale' => $scale,
'$translate' => $translate,

View file

@ -77,7 +77,7 @@ class Display extends Controller
'allow_location' => ((intval(get_pconfig($channel['channel_id'], 'system', 'use_browser_location'))) ? '1' : ''),
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'acl' => Libacl::populate($channel_acl, true, PermissionDescription::fromGlobalPermission('view_stream'), Libacl::get_post_aclDialogDescription(), 'acl_dialog_post'),
'permissions' => $channel_acl,
'bang' => '',
@ -438,7 +438,7 @@ class Display extends Controller
break;
case 'atom':
$atom = replace_macros(Theme::get_template('atom_feed.tpl'), array(
$atom = replace_macros(Theme::get_template('atom_feed.tpl'), [
'$version' => xmlify(System::get_project_version()),
'$generator' => xmlify(System::get_project_name()),
'$generator_uri' => z_root(),
@ -448,9 +448,9 @@ class Display extends Controller
'$author' => '',
'$owner' => '',
'$profile_page' => xmlify(z_root() . '/display/?mid=' . $target_item['mid']),
));
]);
$x = ['xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => $params];
$x = ['xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => []];
Hook::call('atom_feed_top', $x);
$atom = $x['xml'];

View file

@ -105,6 +105,7 @@ class Filestorage extends Controller
}
$owner = intval($channel['channel_id']);
$which = $channel['channel_address'];
$observer = App::get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');

View file

@ -10,8 +10,9 @@ class Jwks extends Controller
public function init()
{
Keyutils::pemtome(get_config('system', 'pubkey'), $m, $e);
$m = '';
$e = '';
Keyutils::pemToMe(get_config('system', 'pubkey'), $m, $e);
/**
* RFC7518

View file

@ -23,12 +23,14 @@ class Like extends Controller
$undo = false;
$object = $target = null;
$tgttype = '';
$owner_uid = 0;
$post_type = EMPTY_STR;
$objtype = EMPTY_STR;
$allow_cid = $allow_gid = $deny_cid = $deny_gid = '';
$output = EMPTY_STR;
$channel = App::get_channel();
$observer = App::get_observer();
// Figure out what action we're performing

View file

@ -63,25 +63,26 @@ class Notify extends Controller
intval(local_channel())
);
$notif_content = '';
if ($r) {
foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl, array(
$notif_content .= replace_macros($not_tpl, [
'$item_link' => z_root() . '/notify/view/' . $it['id'],
'$item_image' => $it['photo'],
'$item_text' => strip_tags(bbcode($it['msg'])),
'$item_when' => relative_date($it['created'])
));
]);
}
} else {
$notif_content .= t('No more system notifications.');
}
$o .= replace_macros($notif_tpl, array(
return replace_macros($notif_tpl, [
'$notif_header' => t('System Notifications'),
'$tabs' => '', // $tabs,
'$notif_content' => $notif_content,
));
]);
return $o;
}
}

View file

@ -249,6 +249,8 @@ class Photos extends Controller
if ($ph && $ph->is_valid()) {
$rotate_deg = ((intval($_POST['rotate']) == 1) ? 270 : 90);
$ph->rotate($rotate_deg);
$width = $ph->getWidth();
$height = $ph->getHeight();
$edited = datetime_convert();
@ -338,8 +340,6 @@ class Photos extends Controller
);
}
$item_private = (($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny) ? true : false);
$old_is_nsfw = $p[0]['is_nsfw'];
if ($old_is_nsfw != $is_nsfw) {
$r = q(
@ -375,7 +375,7 @@ class Photos extends Controller
$orig_text = $linked_item['body'];
$matches = [];
if (preg_match('/\[footer\](.*?)\[\/footer\]/ism', $orig_text, $matches)) {
if (preg_match('/\[footer](.*?)\[\/footer]/ism', $orig_text, $matches)) {
$footer_text = $matches[0];
}
@ -512,7 +512,7 @@ class Photos extends Controller
$partial = false;
if (array_key_exists('HTTP_CONTENT_RANGE', $_SERVER)) {
$pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/', $_SERVER['HTTP_CONTENT_RANGE'], $matches);
$pm = preg_match('/bytes (\d*)-(\d*)\/(\d*)/', $_SERVER['HTTP_CONTENT_RANGE'], $matches);
if ($pm) {
logger('Content-Range: ' . print_r($matches, true));
$partial = true;
@ -656,9 +656,10 @@ class Photos extends Controller
if ($can_post) {
$uploader = '';
$ret = array('post_url' => z_root() . '/photos/' . App::$data['channel']['channel_address'],
$ret = ['post_url' => z_root() . '/photos/' . App::$data['channel']['channel_address'],
'addon_text' => $uploader,
'default_upload' => true);
'default_upload' => true
];
Hook::call('photo_upload_form', $ret);
@ -710,12 +711,12 @@ class Photos extends Controller
$def_album = get_pconfig(App::$data['channel']['channel_id'], 'system', 'photo_path');
if ($def_album) {
$selname = filepath_macro($def_album);
$albums['album'][] = array('text' => $selname);
$albums['album'][] = ['text' => $selname];
}
}
$tpl = Theme::get_template('photos_upload.tpl');
$upload_form = replace_macros($tpl, array(
$upload_form = replace_macros($tpl, [
'$pagename' => t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
@ -740,7 +741,7 @@ class Photos extends Controller
'$uploadurl' => $ret['post_url'],
'$submit' => t('Upload')
));
]);
}
//
@ -1097,7 +1098,7 @@ class Photos extends Controller
$folder_list = attach_folder_select_list($ph[0]['uid']);
$edit_body = htmlspecialchars_decode(undo_post_tagging($link_item['body']), ENT_COMPAT);
// We will regenerate the body footer
$edit_body = preg_replace('/\[footer\](.*?)\[\/footer\]/ism', '', $edit_body);
$edit_body = preg_replace('/\[footer](.*?)\[\/footer]/ism', '', $edit_body);
$edit = [
'edit' => t('Edit photo'),

View file

@ -7,9 +7,7 @@ use Code\Web\Controller;
use Code\Lib\Libprofile;
use Code\Lib\ActivityStreams;
use Code\Lib\Activity;
use Code\Lib\LDSignatures;
use Code\Lib\Channel;
use Code\Web\HTTPSig;
use Code\Lib\Navbar;
use Code\Lib\Head;
use Code\Extend\Hook;
@ -102,13 +100,13 @@ class Profile extends Controller
if (!(perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_profile'))) {
notice(t('Permission denied.') . EOL);
return;
return '';
}
if (argc() > 2 && argv(2) === 'vcard') {
header('Content-type: text/vcard');
header('Content-Disposition: attachment; filename="' . t('vcard') . '-' . $profile['channel_address'] . '.vcf"');
header('Content-Disposition: attachment; filename="' . t('vcard') . '-' . App::$profile['channel_address'] . '.vcf"');
echo App::$profile['profile_vcard'];
killme();
}
@ -117,7 +115,7 @@ class Profile extends Controller
if (App::$profile['hidewall'] && (!$is_owner) && (!remote_channel())) {
notice(t('Permission denied.') . EOL);
return;
return '';
}
Head::add_link([

View file

@ -501,7 +501,7 @@ class Profile_photo extends Controller
if (!array_key_exists('imagecrop', App::$data)) {
$tpl = Theme::get_template('profile_photo.tpl');
$o .= replace_macros($tpl, [
$o = replace_macros($tpl, [
'$user' => App::$channel['channel_address'],
'$info' => ((count($profiles) > 1) ? t('Your default profile photo is visible to anybody on the internet. Profile photos for alternate profiles will inherit the permissions of the profile') : t('Your profile photo is visible to anybody on the internet and may be distributed to other websites.')),
'$importfile' => (($importing) ? App::$data['importfile'] : ''),
@ -533,7 +533,7 @@ class Profile_photo extends Controller
$filename = App::$data['imagecrop'] . '-' . App::$data['imagecrop_resolution'];
$resolution = App::$data['imagecrop_resolution'];
$o .= replace_macros(Theme::get_template('cropbody.tpl'), [
$o = replace_macros(Theme::get_template('cropbody.tpl'), [
'$filename' => $filename,
'$profile' => intval($_REQUEST['profile']),
'$resource' => App::$data['imagecrop'] . '-' . App::$data['imagecrop_resolution'],

View file

@ -347,7 +347,7 @@ class Profiles extends Controller
$channel = App::get_channel();
$default_vcard_cat = ((defined('DEFAULT_VCARD_CAT')) ? DEFAULT_VCARD_CAT : 'HOME');
$default_vcard_cat = 'HOME';
$defcard = [
'fn' => $name,

View file

@ -627,7 +627,7 @@ class Channel
$tag_count = get_pconfig(local_channel(), 'system', 'unless_tag_count',
get_config('system', 'unless_tag_count', 20));
$o .= replace_macros(Theme::get_template('settings.tpl'), [
$o = replace_macros(Theme::get_template('settings.tpl'), [
'$ptitle' => t('Channel Settings'),
'$submit' => t('Submit'),
'$baseurl' => z_root(),
@ -636,7 +636,6 @@ class Channel
'$nickname_block' => $prof_addr,
'$h_basic' => t('Basic Settings'),
'$username' => array('username', t('Full name'), $username, ''),
'$email' => array('email', t('Email Address'), $email, ''),
'$timezone' => array('timezone_select', t('Your timezone'), $timezone, t('This is important for showing the correct time on shared events'), get_timezones()),
'$defloc' => array('defloc', t('Default post location'), $defloc, t('Optional geographical location to display on your posts')),
'$allowloc' => array('allow_location', t('Obtain post location from your web browser or device'), ((get_pconfig(local_channel(), 'system', 'use_browser_location')) ? 1 : ''), '', $yes_no),

View file

@ -44,8 +44,8 @@ class Tokens
"select count(atoken_id) as total where atoken_uid = %d",
intval(local_channel())
);
if ($r && intval($r[0]['total']) >= $max_tokens) {
notice(sprintf(t('This channel is limited to %d tokens'), $max_tokens) . EOL);
if ($r && intval($r[0]['total']) >= $max_atokens) {
notice(sprintf(t('This channel is limited to %d tokens'), $max_atokens) . EOL);
return;
}
}
@ -126,8 +126,8 @@ class Tokens
if (!$atoken_id) {
// If this is a new token, create a new abook record
$closeness = get_pconfig($uid, 'system', 'new_abook_closeness', 80);
$profile_assign = get_pconfig($uid, 'system', 'profile_assign', '');
$closeness = get_pconfig($channel['channel_id'], 'system', 'new_abook_closeness', 80);
$profile_assign = get_pconfig($channel['channel_id'], 'system', 'profile_assign', '');
$r = abook_store_lowlevel(
[
@ -150,9 +150,9 @@ class Tokens
/** If there is a default group for this channel, add this connection to it */
if ($channel['channel_default_group']) {
$g = AccessList::rec_byhash($uid, $channel['channel_default_group']);
$g = AccessList::rec_byhash($channel['channel_id'], $channel['channel_default_group']);
if ($g) {
AccessList::member_add($uid, '', $atoken_xchan, $g['id']);
AccessList::member_add($channel['channel_id'], '', $atoken_xchan, $g['id']);
}
}
@ -282,9 +282,7 @@ class Tokens
$checkinherited = PermissionLimits::Get(local_channel(), $k);
// For auto permissions (when $self is true) we don't want to look at existing
// permissions because they are enabled for the channel owner
if ((!$self) && ($existing[$k])) {
if ($existing[$k]) {
$thisperm = "1";
}
@ -293,14 +291,14 @@ class Tokens
$tpl = Theme::get_template("settings_tokens.tpl");
$o .= replace_macros($tpl, array(
$o = replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_tokens"),
'$title' => t('Guest Access Tokens'),
'$desc' => $desc,
'$desc2' => $desc2,
'$tokens' => $t,
'$atoken' => $atoken,
'$atoken_xchan' => $atoken_chan,
'$atoken_xchan' => $atoken_xchan,
'$url1' => z_root() . '/channel/' . $channel['channel_address'],
'$url2' => z_root() . '/photos/' . $channel['channel_address'],
'$name' => array('name', t('Login Name') . ' <span class="required">*</span>', (($atoken) ? $atoken['atoken_name'] : ''), ''),

View file

@ -13,7 +13,6 @@ namespace Code\Module;
use App;
use DBA;
use PDO;
use Code\Lib\System;
use Code\Web\Controller;
use Code\Lib\Channel;
use Code\Lib\Url;
@ -27,7 +26,7 @@ use Code\Storage\Stdio;
class Setup extends Controller
{
private static $install_wizard_pass = 1;
private $install_wizard_pass = 1;
/**
* {@inheritDoc}
@ -89,9 +88,6 @@ class Setup extends Controller
$dbdata = trim($_POST['dbdata']);
$dbtype = intval(trim($_POST['dbtype']));
// $siteurl should not have a trailing slash
$siteurl = rtrim($siteurl, '/');
require_once('include/dba/dba_driver.php');
$db = DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
@ -110,7 +106,6 @@ class Setup extends Controller
$dbpass = trim($_POST['dbpass']);
$dbdata = trim($_POST['dbdata']);
$dbtype = intval(trim($_POST['dbtype']));
$servertype = intval(trim($_POST['servertype']));
$phpath = trim($_POST['phpath']);
$timezone = trim($_POST['timezone']);
$adminmail = trim($_POST['adminmail']);
@ -284,7 +279,6 @@ class Setup extends Controller
'$baseurl' => z_root(),
]);
return $o;
break;
}
case 2:
@ -345,7 +339,6 @@ class Setup extends Controller
'$dbpass' => $dbpass,
'$dbdata' => $dbdata,
'$dbtype' => $dbtype,
'$servertype' => $servertype,
'$adminmail' => ['adminmail', t('Site administrator email address'), '', t('Required. Your account email address must match this in order to use the web admin panel.')],
'$siteurl' => ['siteurl', t('Website URL'), z_root(), t('Required. Please use SSL (https) URL if available.')],
'$sitename' => ['sitename', t('Website name'), '', t('The name of your website or community.')],

View file

@ -19,7 +19,7 @@ class Theme
/**
* @brief Array with base or fallback themes.
*/
public static $base_themes = array('redbasic');
public static $base_themes = ['redbasic'];
/**

View file

@ -13,19 +13,24 @@ class Album
public function widget($args)
{
$owner_uid = App::$profile_uid;
$sql_extra = permissions_sql($owner_uid);
if (!perm_is_allowed($owner_uid, get_observer_hash(), 'view_storage')) {
return '';
}
// We will need this to map mimetypes to appropriate file extensions
$ph = photo_factory('');
$phototypes = $ph->supportedTypes();
$album = '';
$title = '';
if ($args['album']) {
$album = $args['album'];
}
if ($args['title']) {
$title = $args['title'];
}
@ -98,20 +103,16 @@ class Album
}
}
$tpl = Theme::get_template('photo_album.tpl');
$o .= replace_macros($tpl, array(
return replace_macros(Theme::get_template('photo_album.tpl'), [
'$photos' => $photos,
'$album' => (($title) ? $title : $album),
'$album' => ($title) ?: $album,
'$album_id' => rand(),
'$album_edit' => array(t('Edit Album'), $album_edit),
'$album_edit' => [t('Edit Album'), $album_edit],
'$can_post' => false,
'$upload' => array(t('Upload'), z_root() . '/photos/' . App::$profile['channel_address'] . '/upload/' . bin2hex($album)),
'$upload' => [t('Upload'), z_root() . '/photos/' . App::$profile['channel_address'] . '/upload/' . bin2hex($album)],
'$order' => false,
'$upload_form' => $upload_form,
'$usage' => $usage_message
));
return $o;
'$upload_form' => '',
'$usage' => ''
]);
}
}

View file

@ -38,7 +38,7 @@ class Item
$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'
and iconfig.k = 'WEBPAGE' and item_type = %d $sql_options $revision limit 1",
and iconfig.k = 'WEBPAGE' and item_type = %d $sql_extra limit 1",
intval($channel_id),
dbesc($arr['title']),
intval(ITEM_TYPE_WEBPAGE)

View file

@ -825,8 +825,8 @@ function photos_list_photos($channel, $observer, $album = '')
*
* @param int $channel_id id of the channel
* @param string $observer_hash
* @param string $album name of the album
* @return bool
* @param string $album name ofb the album
* @return bool|array
*/
function photos_album_exists($channel_id, $observer_hash, $album)
{

View file

@ -161,7 +161,7 @@ function xchan_store($arr)
);
}
return $true;
return true;
}

View file

@ -129,7 +129,7 @@ $res = $filelist;
$i = 0;
do {
$i = count($res);
echo $i . '/' . count($fileset) . " elements remaining. \n";
echo $i . '/' . count($filelist) . " elements remaining. \n";
$res = reduce($res, count($res) / 2);
shuffle($res);
} while (count($res) < $i);

View file

@ -1,32 +1,31 @@
<div class="container mt-4 mb-4">
<div class="jumbotron">
<h1>{{$title}}</h1>
<hr class="my-4">
<h2><i class="fa fa-database"></i>&nbsp; {{$pass}}</h2>
</div>
<div class="alert alert-info">
{{$info_01}}<br>
{{$info_02}}<br>
{{$info_03}}
</div>
<div class="jumbotron">
<h1>{{$title}}</h1>
<hr class="my-4">
<h2><i class="fa fa-database"></i>&nbsp; {{$pass}}</h2>
</div>
<div class="alert alert-info">
{{$info_01}}<br>
{{$info_02}}<br>
{{$info_03}}
</div>
{{if $status}}
<div class="alert alert-danger">{{$status}}</div>
{{/if}}
{{if $status}}
<div class="alert alert-danger">{{$status}}</div>
{{/if}}
<form id="install-form" action="{{$baseurl}}/setup" method="post">
<input type="hidden" name="phpath" value="{{$phpath}}" />
<input type="hidden" name="pass" value="3" />
<form id="install-form" action="{{$baseurl}}/setup" method="post">
<input type="hidden" name="phpath" value="{{$phpath}}" />
<input type="hidden" name="pass" value="3" />
{{include file="field_input.tpl" field=$dbhost}}
{{include file="field_input.tpl" field=$dbport}}
{{include file="field_input.tpl" field=$dbuser}}
{{include file="field_password.tpl" field=$dbpass}}
{{include file="field_input.tpl" field=$dbdata}}
{{include file="field_select.tpl" field=$dbtype}}
{{include file="field_input.tpl" field=$dbhost}}
{{include file="field_input.tpl" field=$dbport}}
{{include file="field_input.tpl" field=$dbuser}}
{{include file="field_password.tpl" field=$dbpass}}
{{include file="field_input.tpl" field=$dbdata}}
{{include file="field_select.tpl" field=$dbtype}}
<button class="btn btn-primary" id="install-submit" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button>
</form>
<button class="btn btn-primary" id="install-submit" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button>
</form>
</div>

View file

@ -1,29 +1,29 @@
<div class="container mt-4 mb-4">
<div class="jumbotron">
<h1>{{$title}}</h1>
<hr class="my-4">
<h2><i class="fa fa-cogs"></i>&nbsp; {{$pass}}</h2>
</div>
<div class="jumbotron">
<h1>{{$title}}</h1>
<hr class="my-4">
<h2><i class="fa fa-cogs"></i>&nbsp; {{$pass}}</h2>
</div>
{{if $status}}
<div class="alert alert-danger">{{$status}}</div>
{{/if}}
{{if $status}}
<div class="alert alert-danger">{{$status}}</div>
{{/if}}
<form id="install-form" action="{{$baseurl}}/setup" method="post">
<input type="hidden" name="dbhost" value="{{$dbhost}}" />
<input type="hidden" name="dbport" value="{{$dbport}}" />
<input type="hidden" name="dbuser" value="{{$dbuser}}" />
<input type="hidden" name="dbpass" value="{{$dbpass}}" />
<input type="hidden" name="dbdata" value="{{$dbdata}}" />
<input type="hidden" name="dbtype" value="{{$dbtype}}" />
<input type="hidden" name="pass" value="4" />
<form id="install-form" action="{{$baseurl}}/setup" method="post">
<input type="hidden" name="dbhost" value="{{$dbhost}}" />
<input type="hidden" name="dbport" value="{{$dbport}}" />
<input type="hidden" name="dbuser" value="{{$dbuser}}" />
<input type="hidden" name="dbpass" value="{{$dbpass}}" />
<input type="hidden" name="dbdata" value="{{$dbdata}}" />
<input type="hidden" name="dbtype" value="{{$dbtype}}" />
<input type="hidden" name="pass" value="4" />
{{include file="field_input.tpl" field=$adminmail}}
{{include file="field_input.tpl" field=$siteurl}}
{{include file="field_input.tpl" field=$sitename}}
{{include file="field_input.tpl" field=$phpath}}
{{include file="field_select_grouped.tpl" field=$timezone}}
{{include file="field_input.tpl" field=$adminmail}}
{{include file="field_input.tpl" field=$siteurl}}
{{include file="field_input.tpl" field=$sitename}}
{{include file="field_input.tpl" field=$phpath}}
{{include file="field_select_grouped.tpl" field=$timezone}}
<button class="btn btn-primary" id="install-submit" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button>
</form>
<button class="btn btn-primary" id="install-submit" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button>
</form>
</div>