diff --git a/Code/Lib/Channel.php b/Code/Lib/Channel.php index ed7c4f2ef..7fd644227 100644 --- a/Code/Lib/Channel.php +++ b/Code/Lib/Channel.php @@ -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, diff --git a/Code/Module/Display.php b/Code/Module/Display.php index b4aab0630..cad16bf3d 100644 --- a/Code/Module/Display.php +++ b/Code/Module/Display.php @@ -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']; diff --git a/Code/Module/Filestorage.php b/Code/Module/Filestorage.php index f4402e2a6..1d8337cae 100644 --- a/Code/Module/Filestorage.php +++ b/Code/Module/Filestorage.php @@ -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'] : ''); diff --git a/Code/Module/Jwks.php b/Code/Module/Jwks.php index bc7a6af04..2e66a44b5 100644 --- a/Code/Module/Jwks.php +++ b/Code/Module/Jwks.php @@ -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 diff --git a/Code/Module/Like.php b/Code/Module/Like.php index ed8dd3096..aadca4501 100644 --- a/Code/Module/Like.php +++ b/Code/Module/Like.php @@ -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 diff --git a/Code/Module/Notify.php b/Code/Module/Notify.php index a01780311..c8c3fc476 100644 --- a/Code/Module/Notify.php +++ b/Code/Module/Notify.php @@ -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; } } diff --git a/Code/Module/Photos.php b/Code/Module/Photos.php index 558e5d71c..8d3585749 100644 --- a/Code/Module/Photos.php +++ b/Code/Module/Photos.php @@ -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'), diff --git a/Code/Module/Profile.php b/Code/Module/Profile.php index 3bd4d81a3..d84f6bc75 100644 --- a/Code/Module/Profile.php +++ b/Code/Module/Profile.php @@ -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([ diff --git a/Code/Module/Profile_photo.php b/Code/Module/Profile_photo.php index 1a8346eb1..9d606bac5 100644 --- a/Code/Module/Profile_photo.php +++ b/Code/Module/Profile_photo.php @@ -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'], diff --git a/Code/Module/Profiles.php b/Code/Module/Profiles.php index 10548f373..c3c874241 100644 --- a/Code/Module/Profiles.php +++ b/Code/Module/Profiles.php @@ -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, diff --git a/Code/Module/Settings/Channel.php b/Code/Module/Settings/Channel.php index 6e5a924fc..4d47b8711 100644 --- a/Code/Module/Settings/Channel.php +++ b/Code/Module/Settings/Channel.php @@ -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), diff --git a/Code/Module/Settings/Tokens.php b/Code/Module/Settings/Tokens.php index e7039011c..d76088300 100644 --- a/Code/Module/Settings/Tokens.php +++ b/Code/Module/Settings/Tokens.php @@ -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') . ' *', (($atoken) ? $atoken['atoken_name'] : ''), ''), diff --git a/Code/Module/Setup.php b/Code/Module/Setup.php index 3c6ebde29..0f6981cd9 100644 --- a/Code/Module/Setup.php +++ b/Code/Module/Setup.php @@ -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.')], diff --git a/Code/Render/Theme.php b/Code/Render/Theme.php index 5db6ccb5c..a792c9ec3 100644 --- a/Code/Render/Theme.php +++ b/Code/Render/Theme.php @@ -19,7 +19,7 @@ class Theme /** * @brief Array with base or fallback themes. */ - public static $base_themes = array('redbasic'); + public static $base_themes = ['redbasic']; /** diff --git a/Code/Widget/Album.php b/Code/Widget/Album.php index 7b18a55c8..a1b1bddb6 100644 --- a/Code/Widget/Album.php +++ b/Code/Widget/Album.php @@ -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' => '' + ]); } } diff --git a/Code/Widget/Item.php b/Code/Widget/Item.php index 4506ab26e..6e9967254 100644 --- a/Code/Widget/Item.php +++ b/Code/Widget/Item.php @@ -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) diff --git a/include/photos.php b/include/photos.php index d45e5e613..798edc159 100644 --- a/include/photos.php +++ b/include/photos.php @@ -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) { diff --git a/include/xchan.php b/include/xchan.php index db659ae8f..5933878f9 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -161,7 +161,7 @@ function xchan_store($arr) ); } - return $true; + return true; } diff --git a/util/docblox_errorchecker.php b/util/docblox_errorchecker.php index 259486514..17b64c4f1 100644 --- a/util/docblox_errorchecker.php +++ b/util/docblox_errorchecker.php @@ -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); diff --git a/view/tpl/install_db.tpl b/view/tpl/install_db.tpl index b526a7f54..0067e6452 100755 --- a/view/tpl/install_db.tpl +++ b/view/tpl/install_db.tpl @@ -1,32 +1,31 @@
-
-

{{$title}}

-
-

  {{$pass}}

-
-
- {{$info_01}}
- {{$info_02}}
- {{$info_03}} -
+
+

{{$title}}

+
+

  {{$pass}}

+
+
+ {{$info_01}}
+ {{$info_02}}
+ {{$info_03}} +
- {{if $status}} -
{{$status}}
- {{/if}} + {{if $status}} +
{{$status}}
+ {{/if}} -
- - + + + - {{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}} - -
+ +
- diff --git a/view/tpl/install_settings.tpl b/view/tpl/install_settings.tpl index fd1aa99d9..8e9dbb9e8 100755 --- a/view/tpl/install_settings.tpl +++ b/view/tpl/install_settings.tpl @@ -1,29 +1,29 @@
-
-

{{$title}}

-
-

  {{$pass}}

-
+
+

{{$title}}

+
+

  {{$pass}}

+
- {{if $status}} -
{{$status}}
- {{/if}} + {{if $status}} +
{{$status}}
+ {{/if}} -
- - - - - - - + + + + + + + + - {{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}} - -
+ +