diff --git a/boot.php b/boot.php index 95a9ff13d0..24e7559515 100644 --- a/boot.php +++ b/boot.php @@ -382,38 +382,6 @@ function is_site_admin() return local_user() && $admin_email && in_array($a->user['email'] ?? '', $adminlist); } -function explode_querystring($query) -{ - $arg_st = strpos($query, '?'); - if ($arg_st !== false) { - $base = substr($query, 0, $arg_st); - $arg_st += 1; - } else { - $base = ''; - $arg_st = 0; - } - - $args = explode('&', substr($query, $arg_st)); - foreach ($args as $k => $arg) { - /// @TODO really compare type-safe here? - if ($arg === '') { - unset($args[$k]); - } - } - $args = array_values($args); - - if (!$base) { - $base = $args[0]; - unset($args[0]); - $args = array_values($args); - } - - return [ - 'base' => $base, - 'args' => $args, - ]; -} - /** * Returns the complete URL of the current page, e.g.: http(s)://something.com/network * diff --git a/mod/item.php b/mod/item.php index 3474bea90c..911a9530c9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -904,40 +904,8 @@ function drop_item(int $id, string $return = '') } if ((local_user() == $item['uid']) || $contact_id) { - // Check if we should do HTML-based delete confirmation - if (!empty($_REQUEST['confirm'])) { - //
can't take arguments in its "action" parameter - // so add any arguments as hidden inputs - $query = explode_querystring(DI::args()->getQueryString()); - $inputs = []; - - foreach ($query['args'] as $arg) { - if (strpos($arg, 'confirm=') === false) { - $arg_parts = explode('=', $arg); - $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]]; - } - } - - return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [ - '$method' => 'get', - '$message' => DI::l10n()->t('Do you really want to delete this item?'), - '$extra_inputs' => $inputs, - '$confirm' => DI::l10n()->t('Yes'), - '$confirm_url' => $query['base'], - '$confirm_name' => 'confirmed', - '$cancel' => DI::l10n()->t('Cancel'), - ]); - } - // Now check how the user responded to the confirmation query - if (!empty($_REQUEST['canceled'])) { - DI::baseUrl()->redirect('display/' . $item['guid']); - } - - $is_comment = $item['gravity'] == GRAVITY_COMMENT; - $parentitem = null; if (!empty($item['parent'])) { - $fields = ['guid']; - $parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]); + $parentitem = Item::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]); } // delete the item @@ -949,7 +917,7 @@ function drop_item(int $id, string $return = '') $return_url = str_replace("update_", "", $return_url); // Check if delete a comment - if ($is_comment) { + if ($item['gravity'] == GRAVITY_COMMENT) { // Return to parent guid if (!empty($parentitem)) { DI::baseUrl()->redirect('display/' . $parentitem['guid']); diff --git a/mod/message.php b/mod/message.php index 6326bb9ea5..4f680aa0b7 100644 --- a/mod/message.php +++ b/mod/message.php @@ -141,36 +141,6 @@ function message_content(App $a) return; } - // Check if we should do HTML-based delete confirmation - if (!empty($_REQUEST['confirm'])) { - // can't take arguments in its "action" parameter - // so add any arguments as hidden inputs - $query = explode_querystring(DI::args()->getQueryString()); - $inputs = []; - foreach ($query['args'] as $arg) { - if (strpos($arg, 'confirm=') === false) { - $arg_parts = explode('=', $arg); - $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]]; - } - } - - //DI::page()['aside'] = ''; - return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [ - '$method' => 'get', - '$message' => DI::l10n()->t('Do you really want to delete this message?'), - '$extra_inputs' => $inputs, - '$confirm' => DI::l10n()->t('Yes'), - '$confirm_url' => $query['base'], - '$confirm_name' => 'confirmed', - '$cancel' => DI::l10n()->t('Cancel'), - ]); - } - - // Now check how the user responded to the confirmation query - if (!empty($_REQUEST['canceled'])) { - DI::baseUrl()->redirect('message'); - } - $cmd = $a->argv[1]; if ($cmd === 'drop') { $message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); diff --git a/mod/photos.php b/mod/photos.php index f078473a95..3b2fa0c3a8 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1039,7 +1039,6 @@ function photos_content(App $a) return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [ '$method' => 'post', '$message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'), - '$extra_inputs' => [], '$confirm' => DI::l10n()->t('Delete Album'), '$confirm_url' => $drop_url, '$confirm_name' => 'dropalbum', @@ -1146,7 +1145,6 @@ function photos_content(App $a) return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [ '$method' => 'post', '$message' => DI::l10n()->t('Do you really want to delete this photo?'), - '$extra_inputs' => [], '$confirm' => DI::l10n()->t('Delete Photo'), '$confirm_url' => $drop_url, '$confirm_name' => 'delete', diff --git a/mod/settings.php b/mod/settings.php index 39667af92f..92a7bb461f 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -829,26 +829,6 @@ function settings_content(App $a) $stpl = Renderer::getMarkupTemplate('settings/settings.tpl'); - // Private/public post links for the non-JS ACL form - $private_post = 1; - if (!empty($_REQUEST['public']) && !$_REQUEST['public']) { - $private_post = 0; - } - - $query_str = DI::args()->getQueryString(); - if (strpos($query_str, 'public=1') !== false) { - $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str); - } - - // I think $a->query_string may never have ? in it, but I could be wrong - // It looks like it's from the index.php?q=[etc] rewrite that the web - // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61 - if (strpos($query_str, '?') === false) { - $public_post_link = '?public=1'; - } else { - $public_post_link = '&public=1'; - } - /* Installed langs */ $lang_choices = DI::l10n()->getAvailableLanguages(); diff --git a/src/Content/Pager.php b/src/Content/Pager.php index a5e61bbf9f..477e535aec 100644 --- a/src/Content/Pager.php +++ b/src/Content/Pager.php @@ -128,7 +128,7 @@ class Pager /** * Sets the base query string from a full query string. * - * Strips the 'page' parameter, and remove the 'q=' string for some reason. + * Strips the 'page' parameter * * @param string $queryString */ diff --git a/src/Core/Addon.php b/src/Core/Addon.php index 0462504e70..8b95af328c 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -229,8 +229,6 @@ class Addon */ public static function getInfo($addon) { - $a = DI::app(); - $addon = Strings::sanitizeFilePathItem($addon); $info = [ diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 6e8778f179..03d67aa089 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -436,17 +436,6 @@ class Contact extends BaseModule if ($cmd === 'drop' && ($orig_record['uid'] != 0)) { // Check if we should do HTML-based delete confirmation if (!empty($_REQUEST['confirm'])) { - // can't take arguments in its 'action' parameter - // so add any arguments as hidden inputs - $query = explode_querystring(DI::args()->getQueryString()); - $inputs = []; - foreach ($query['args'] as $arg) { - if (strpos($arg, 'confirm=') === false) { - $arg_parts = explode('=', $arg); - $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]]; - } - } - DI::page()['aside'] = ''; return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [ @@ -454,9 +443,8 @@ class Contact extends BaseModule '$contact' => self::getContactTemplateVars($orig_record), '$method' => 'get', '$message' => DI::l10n()->t('Do you really want to delete this contact?'), - '$extra_inputs' => $inputs, '$confirm' => DI::l10n()->t('Yes'), - '$confirm_url' => $query['base'], + '$confirm_url' => DI::args()->getCommand(), '$confirm_name' => 'confirmed', '$cancel' => DI::l10n()->t('Cancel'), ]); diff --git a/view/templates/confirm.tpl b/view/templates/confirm.tpl index 496724e3d9..ea50846990 100644 --- a/view/templates/confirm.tpl +++ b/view/templates/confirm.tpl @@ -3,9 +3,6 @@

{{$message}}

- {{foreach $extra_inputs as $input}} - - {{/foreach}} diff --git a/view/theme/frio/templates/confirm.tpl b/view/theme/frio/templates/confirm.tpl index 36072a56b1..d17b94d760 100644 --- a/view/theme/frio/templates/confirm.tpl +++ b/view/theme/frio/templates/confirm.tpl @@ -1,9 +1,6 @@
{{$message}}
- {{foreach $extra_inputs as $input}} - - {{/foreach}}