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
*
}
if ((local_user() == $item['uid']) || $contact_id) {
- // Check if we should do HTML-based delete confirmation
- if (!empty($_REQUEST['confirm'])) {
- // <form> 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
$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']);
return;
}
- // Check if we should do HTML-based delete confirmation
- if (!empty($_REQUEST['confirm'])) {
- // <form> 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()]);
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',
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',
$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();
/**
* 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
*/
*/
public static function getInfo($addon)
{
- $a = DI::app();
-
$addon = Strings::sanitizeFilePathItem($addon);
$info = [
if ($cmd === 'drop' && ($orig_record['uid'] != 0)) {
// Check if we should do HTML-based delete confirmation
if (!empty($_REQUEST['confirm'])) {
- // <form> 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'), [
'$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'),
]);
<form action="{{$confirm_url}}" id="confirm-form" method="{{$method}}">
<h3 id="confirm-message">{{$message}}</h3>
- {{foreach $extra_inputs as $input}}
- <input type="hidden" name="{{$input.name}}" value="{{$input.value}}" />
- {{/foreach}}
<input class="confirm-button" id="confirm-submit-button" type="submit" name="{{$confirm_name}}" value="{{$confirm}}" />
<input class="confirm-button" id="confirm-cancel-button" type="submit" name="canceled" value="{{$cancel}}" />
<form action="{{$confirm_url}}" id="confirm-form" method="{{$method}}" class="generic-page-wrapper">
<div id="confirm-message">{{$message}}</div>
- {{foreach $extra_inputs as $input}}
- <input type="hidden" name="{{$input.name}}" value="{{$input.value}}" />
- {{/foreach}}
<div class="form-group pull-right settings-submit-wrapper" >
<button type="submit" name="{{$confirm_name}}" id="confirm-submit-button" class="btn btn-primary confirm-button" value="{{$confirm}}">{{$confirm}}</button>