Is it possible to handle multipart form data fields first then file? [closed]

So I was trying to handle the multipart form data.

The expected workflow:

  1. Incoming multipart form data. (2 files, 5 text fields)
  2. If a field is missing, reject the request.
  3. If all fields exist, save files.

The assumption is listed below:

  1. Assume the fields and files order are random
  2. File sizes are big (>1 GB)

The frameworks I tried are FastAPI, Express.js (Multer, Busboy), Crow.cpp.

Both of them seem to block and wait for the file saving to be done and perform a checking on fields, which is time-consuming if the requst is bad.

How to prevent browser’s default reload confirmation popup and show custom modal in React (Next.js)? [duplicate]

I’m building a React (Next.js) application with a form. When the user tries to reload the page (e.g., pressing F5, Ctrl+R, or clicking refresh), I want to disable the browser’s default confirmation popup and instead show my own custom modal with OK and Cancel buttons.

I tried using the beforeunload / onbeforeunload events:

useEffect(() => {
  window.addEventListener("beforeunload", (e) => {
    e.preventDefault();
    e.returnValue = ""; // triggers default popup
  });
}, []);

Is there a way to detect that the browser is being reloaded so I can cancel it and show my own custom popup instead of the default one?

Java-Script for indesign that reminds me to check everything

Im very bad at Java but need a Script for InDesign that creates a popup-window, where every time i want to close a document it asks me if i checked everything. Then if i click “yes” it can close, but if i click “no”, it has to stay open. This also needs to work if i open the document through something like woodwing studio, where the files are saved on a website.

I found one here that works with normal documents but still closes them when i opened them through the browser, which is kinda dumb since i want it to work all the time.

How to prevent browser’s default reload confirmation popup and show custom modal in React (Next.js)?

I’m building a React (Next.js) application with a form. When the user tries to reload the page (e.g., pressing F5, Ctrl+R, or clicking refresh), I want to disable the browser’s default confirmation popup and instead show my own custom modal with OK and Cancel buttons.

I tried using the beforeunload / onbeforeunload events:

useEffect(() => {
  window.addEventListener("beforeunload", (e) => {
    e.preventDefault();
    e.returnValue = ""; // triggers default popup
  });
}, []);

Is there a way to detect that the browser is being reloaded so I can cancel it and show my own custom popup instead of the default one?

getting error while fetching data between two dates in Laravel, php or mysql

I does a big mistake i store date in varchar field in database, and when i try to use whereBetween function to get data it gives me annonoumus result due to string nature,

Can anyone tell me how to make this working without affecting database because i no longer have access to the database i can only change this on view

I tried this but this didn’t work ;

SELECT * 
FROM `cpds`
WHERE `user_id` = 21
  AND STR_TO_DATE(`date`, '%Y-%m-%d') BETWEEN STR_TO_DATE('2025-01-01', '%Y-%m-%d')
                                          AND STR_TO_DATE('2025-12-31', '%Y-%m-%d');

extract with EXTR_PREFIX_ALL does not give me variables

I’m trying use extract() to create prefixed variables. However, the variable I expect is not being created, and I get an undefined variable warning.

Here’s my code:

<?php
    $my_user_id = 1;


    $stmt = $mysqli->prepare("SELECT id, email FROM users_index WHERE user_id=?"); 
    $stmt->bind_param("i", $my_user_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $row = $result->fetch_assoc();
    $stmt->close();
    if (!$row) {
        echo "<p>There was no rows returned for your user session.</p>"; die;
    }
    extract($row, EXTR_PREFIX_ALL, 'sql_my_');

    if (empty($sql_my_id)) {
        echo "
        <p>PHP Error: The variable is blank. row['id']={$row['id']} sql_my_id=$sql_my_id.</p>
        <pre>";
        print_r($row);
        echo "</pre>";
        die;
    }

Output:

Warning: Undefined variable $sql_my_id in C:Apache24htdocswebsitetest.php

PHP Error: The variable is blank. row[‘id’]=1 sql_my_id=.

Array
(
[id] => 1
[email] => [email protected]
)

Problem:
I expected extract($row, EXTR_PREFIX_ALL, 'sql_my_') to create $sql_my_id and $sql_my_email, but $sql_my_id is not defined.

What I’ve tried:

  • Using EXTR_PREFIX_ALL with a prefix.
  • Checking if $row is empty before extracting.

Why isn’t $sql_my_id being created by extract()? How can I correctly create prefixed variables from my associative array?

Need to create an Age Verification plugin for WordPress to connect to an external API [closed]

I’ve been asked to create an Adult Verification plugin to connect to an external API using Verifymy (https://verifymy.io/), they have some documentation, but I’m unsure how to build something to get people to age verify when people land on a website after they have signed up for an account.

Anyone have any working examples that I can look at/take inspiration from.

Any help would be absolutely awesome!

Many Thanks

Chris

autoformat with CS Fixer exited with non-zero code

I’m trying to set up PHP Coding Standards Fixer with PhpStorm but when I run the code auto formatter (Ctrl Alt L) I get an error:

PHP External Formatter: Process exited with non-zero code

error bubble

Clicking the notification doesn’t expands any info and I don’t know where to get this output or code.

I had set PHP CS Fixer as the external formatter in “Quality tools”, activated the inspection in “Quality tools > PHP CS Fixer” and the validate for “PHP CS Fixer path” does not show any issues.

I have also setted “Run built-in formatter before external formatter” in Advanced settings.

I have my .php-cs-fixer.dist.php not in the root of my project but in a symfony folder (so path is symfony/.php-cs-fixer.dist.php). Could this be the issue? How can I set this path if it is the case?

How can I fix this error? I would prefer not to ignore it…

Block style is not getting a priority over Font awesome icon

I have added a Font Awesome Icon to my WordPress website which should trigger on small screens such as mobile devices. But it looks like this

Image showing website

It is getting triggered even on larger screens. The problem is, this header was created as a custom block and registered in functions.php using the init hook. But the font awesome scripts are being registered using wp_enqueue_scripts() hook. I am guessing that since init hook is prioritised before wp_enqueue_scripts() hook, even when I have the styles to not show the icon on large screens, the icon styles since registered later gets a priority and shows up in on the screen. I was wondering if there was another way to register font awesome so that this would not happen.

This is my functions.php code

function create_block_temp_block_block_init() {
/**
 * Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s)
 * based on the registered block metadata.
 * Added in WordPress 6.8 to simplify the block metadata registration process added in WordPress 6.7.
 *
 * @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
 */
if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
    wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
    return;
}

/**
 * Registers the block(s) metadata from the `blocks-manifest.php` file.
 * Added to WordPress 6.7 to improve the performance of block type registration.
 *
 * @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
 */
if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
    wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
}
/**
 * Registers the block type(s) in the `blocks-manifest.php` file.
 *
 * @see https://developer.wordpress.org/reference/functions/register_block_type/
 */
$manifest_data = require __DIR__ . '/build/blocks-manifest.php';
foreach ( array_keys( $manifest_data ) as $block_type ) {
    register_block_type( __DIR__ . "/build/{$block_type}" );
}
}
add_action( 'init', 'create_block_temp_block_block_init' );

function university_files() {
wp_enqueue_style('custom-google-fonts', '//fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:100,300,400,400i,700,700i');
wp_enqueue_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
}

add_action('wp_enqueue_scripts', 'university_files');

In Inspector it’s showing that my icon styles with classname fa are getting priority over my own styles with classname site-header__menu-trigger

Image showing inspector tools

Here is my git repository for reference:
https://github.com/Revolter23/fictional-block-copy

I can’t seem to center a text in a prime react dropdown input

So I’m trying to center the text from this dropdown by Primereact, but I’ve been struggling with the css theme for quite long now and Still have no clue…enter image description here

I’ll share just the dropdown and the css from the theme attached to the dropdown, I hope it’s enough to get the context and fix it.

the dropdown component is close after the return statement:

                <div className='mr-55'>
                  <Dropdown
                    value={lazyState.rows}
                    onChange={({ value }) =>
                      setLazyState(prev => ({ ...prev, page: 0, rows: value }))
                    }
                    options={[
                      { label: '20 per page', value: 20 },
                      { label: '30 per page', value: 30 },
                      { label: '50 per page', value: 50 },
                      { label: '100 per page', value: 100 },
                      { label: '200 per page', value: 200 },
                    ]}
                  />
                </div>
// core
.p-dropdown {
  display: inline-flex;
  cursor: pointer;
  position: relative;
  user-select: none;
  height: 32px;
  width: 148px;
}

.p-dropdown-clear-icon {
  position: absolute;
  top: 50%;
  margin-top: -0.5rem;
}

.p-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.p-dropdown-label {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  flex: 1 1 auto;
  width: 1%;
  text-overflow: ellipsis;
  cursor: pointer;
  height: 100%;
}

.p-dropdown-label-empty {
  overflow: hidden;
  opacity: 0;
}

input.p-dropdown-label {
  cursor: default;
}

.p-dropdown .p-dropdown-panel {
  min-width: 100%;
}

.p-dropdown-panel {
  position: absolute;
  top: 0;
  left: 0;
}

.p-dropdown-items-wrapper {
  max-height: 40px;
  overflow-y: auto;
}

.p-dropdown-item {
  cursor: pointer;
  font-weight: normal;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.p-dropdown-item-group {
  cursor: auto;
}

.p-dropdown-items {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

.p-dropdown-filter {
  width: 100%;
}

.p-dropdown-filter-container {
  position: relative;
}

.p-dropdown-filter-icon {
  position: absolute;
  top: 50%;
  margin-top: -0.5rem;
}

.p-fluid .p-dropdown {
  display: flex;
}

.p-fluid .p-dropdown .p-dropdown-label {
  width: 1%;
}

// theme
.p-dropdown {
  background: $inputBg;
  border: $inputBorder;
  transition: $formElementTransition;
  border-radius: $borderRadius;
  outline-color: transparent;

  &:not(.p-disabled):hover {
    border-color: $inputHoverBorderColor;
  }

  &:not(.p-disabled).p-focus {
    @include focused-input();
  }

  &.p-variant-filled {
    background: $inputFilledBg;

    &:not(.p-disabled):hover {
      background-color: $inputFilledHoverBg;
    }

    &:not(.p-disabled).p-focus {
      background-color: $inputFilledFocusBg;

      .p-inputtext {
        background-color: transparent;
      }
    }
  }

  &.p-dropdown-clearable {
    .p-dropdown-label {
      padding-right: nth($inputPadding, 2) + $primeIconFontSize;
    }
  }

  .p-dropdown-label {
    background: transparent;
    border: 0 none;

    &.p-placeholder {
      color: $inputPlaceholderTextColor;
    }

    &:focus,
    &:enabled:focus {
      outline: 0 none;
      box-shadow: none;
    }
  }

  .p-dropdown-trigger {
    background: transparent;
    color: $inputIconColor;
    width: $inputGroupAddOnMinWidth;
    border-top-right-radius: $borderRadius;
    border-bottom-right-radius: $borderRadius;
    height: 100%;
  }

  .p-dropdown-clear-icon {
    color: $inputIconColor;
    right: $inputGroupAddOnMinWidth;
  }

  &.p-invalid.p-component {
    @include invalid-input();
  }
}

.p-dropdown-panel {
  background: $inputOverlayBg;
  color: $inputListTextColor;
  border: $inputOverlayBorder;
  border-radius: $borderRadius;
  box-shadow: $inputOverlayShadow;

  .custom-dropdown {
    max-height: 300px;
    overflow-y: auto;
  }

  .p-dropdown-header {
    padding: $inputListHeaderPadding;
    border-bottom: $inputListHeaderBorder;
    color: $inputListHeaderTextColor;
    background: $inputOverlayHeaderBg;
    margin: $inputListHeaderMargin;
    border-top-right-radius: $borderRadius;
    border-top-left-radius: $borderRadius;

    .p-dropdown-filter {
      padding-right: nth($inputPadding, 2) + $primeIconFontSize;
      margin-right: -1 * (nth($inputPadding, 2) + $primeIconFontSize);
    }

    .p-dropdown-filter-icon {
      right: nth($inputPadding, 2);
      color: $inputIconColor;
    }
  }

  .p-dropdown-items {
    padding: $inputListPadding;

    .p-dropdown-item {
      margin: $inputListItemMargin;
      padding: $inputListItemPadding;
      border: $inputListItemBorder;
      color: $inputListItemTextColor;
      background: $inputListItemBg;
      transition: $listItemTransition;
      border-radius: $inputListItemBorderRadius;

      &:first-child {
        margin-top: 0;
      }

      &:last-child {
        margin-bottom: 0;
      }

      &.p-highlight {
        color: $highlightTextColor;
        background: $highlightBg;

        &.p-focus {
          background: $highlightFocusBg;
        }
      }

      &:not(.p-highlight):not(.p-disabled) {
        &.p-focus {
          color: $inputListItemTextHoverColor;
          background: $inputListItemHoverBg;
        }
      }

      .p-dropdown-check-icon {
        position: relative;
        margin-left: -1 * $inlineSpacing;
        margin-right: $inlineSpacing;
      }
    }

    .p-dropdown-item-group {
      margin: $submenuHeaderMargin;
      padding: $submenuHeaderPadding;
      color: $submenuHeaderTextColor;
      background: $submenuHeaderBg;
      font-weight: $submenuHeaderFontWeight;
    }

    .p-dropdown-empty-message {
      padding: $inputListItemPadding;
      color: $inputListItemTextColor;
      background: $inputListItemBg;
    }
  }
}

scheduleatfixedrate sseemitter but the front end only get message once [duplicate]

I use scheduleatfixedrate and sseemitter, but the front end only get message once.
my backend code is like this

 var scheduledFuture =
        sseExecutor.scheduleAtFixedRate(
            () -> {
              try {
                SseEmitter.SseEventBuilder event =
                    SseEmitter.event()
                        .data("SSE MVC - " + LocalTime.now())
                        .id(String.valueOf(System.currentTimeMillis()))
                        .name("sse event - mvc");

                emitter.send(event);
                log.info("Sent SSE message at {}", LocalTime.now());
              } catch (Exception ex) {
                log.error("SSE error: {}", ex.getMessage(), ex);
                emitter.completeWithError(ex);
              }
            },
            0,
            5,
            TimeUnit.SECONDS);

and I can get the message from the curl as below

curl result

but from the browser chrome, it only get the first message after 5s, instead of keeping on push message to the browser
browser result

js code is like this

 response = await fetch(sseUrl, {
          method: 'GET',
          headers: {
            Accept: 'text/event-stream',
            'Content-Type': 'application/json',
            Authorization: `Bearer ${token}`,
            'Cache-Control': 'no-cache',
          },
          signal: abortController.signal,
        })

Debugging Mindmap Extension — Reference Duplication Issue [closed]

This project is a Chrome extension that is kind of like a project that you can edit your history tab, add nodes from there, make nodes, make searchable nodes, drag the nodes, create new pages, delete them, send them to the back, front etc, save project, load project.

  • We start by clicking the M for Mindmap Tabs:

    enter image description here

  • Once clicked this is what we get:

    enter image description here

  • However once we right click on this node we get a lot of options:

    enter image description here

To get to the main problem that I wanted to ask you about, I need to show a couple of functionalities of this extension.

  • When we right click on the node we see an option pop up that says New Project which is supposed to create new project:

    enter image description here

  • Once Clicked we get this option to name our file and this is our Custom Name:

    enter image description here

  • Once we press ok then we get this message:

    enter image description here

  • Then we get this node pretty much the same as when we started earlier:

    enter image description here

One of the first prerequisite concepts that we have to understand is that extension is supposed to be able create pages within this particular project that we created as you see here that we called 20TestParent. And Pay attention that it says 1/1 because once we press create page it is suppose to say 1/2 on the first page an 2/2 on the second.

enter image description here

  • Once we created a page it’s just blank for now:

    enter image description here

  • Now we have 2/2 because we created a page and the total there are now is 2 and we are on the second page. So second prerequisite is that this extension is suppose to add nodes and be able to make a child and parent node links.

    enter image description here

  • We have to add a new node first so we press the add node option:

    enter image description here

  • We see that the node is added & we see we are on the second page so we want to rename just for reference for right now

    enter image description here

  • We want to call this ChildLINK because we want to make a link between the nodes and it will make sense in the next couple of pictures.

    enter image description here

  • So we click Create Child Link option

    enter image description here

  • and we get this as an Alert

    enter image description here

  • Now when we press Prev page

    enter image description here

  • We get to the 1st page and also it is here that we want to click the create parent link option:

    enter image description here

  • Once we clicked create parent we can click select or double click on the node and we will appear at the child node’s location:

    enter image description here

  • Once we click the select this is what we get:

    enter image description here

  • and once we press ok we are back at the child node:

    enter image description here

  • Also when you right click on the child you can go back to the parent by pressing go to root node as in here:

    enter image description here

  • We get the dialogue box again:

    enter image description here

  • We are right where we started:

    enter image description here

This same concept is supposed to work across pages however it doesn’t work. We added a new node and press the Make Parent Option:

enter image description here

We get the dialogue box:

enter image description here

however when we create a new project completely or load an existing project from the loads:

enter image description here

and when we click the Make Child Project From Selected option:

enter image description here

It says New Node is the entry for this newly made child project however it should say the ParentNodeForProject is the entry point for this newly child project also there should be go to Parent Node For project option here too that sends you back to that node and similarly that that node from that project can send you back here to this child project and back and forth.

enter image description here

So the code is in the bottom and hopefully the problem and expected result makes sense I made two video also that explain in video style more about this problem and the other features of the extension.

  1. Debugging Mindmap Extension — Reference Duplication Issue (Official) (Summarized/Short – 10:56 min.)

  2. Debugging Mindmap Extension — Reference Duplication Issue (Full – 28:11 min.)

Issue with reply buttons to sent mail when sending with google apps scripts mail merger

So i am developing a mail merger in google apps script (javascript) for the purpose of sending mail to multiple recipients at once.
I am currently looking into how to change the reply address into a different one than the sender’s, so that when the receiver clicks on the ‘reply’ button the address i choose will appear as receiver insted of the one i am sending from.
To achieve this i am using GmailApp.sendEmail with the replyTo field set to whatever address i need.
For the purpose of this project i would need ONLY the address i chose to appear as receiver when replying to a mail, however when a mail is sent with more than a single address in the ‘to’ field of the mail, i only get a single ‘reply’ button which acts as a ‘reply all’ (includes the address i chose as reply address as well as all other addresses in the ‘to’ field except for the receiver).

For testing purposes i have tried manually changing the reply address of my mail and sending a test email with two people in the ‘to’ field, and as expected both a ‘reply’ and a ‘reply all’ button appeared. It would seem that i only get this problem when sending mail with the mail merger i developed;
The same problem also occurs when using MailApp for sending instead of GmailApp.
However putting the other addresses in CC instead makes the correct buttons appear with the correct behavior (reply button only shows the address i chose as reply-to, reply all shows all the addresses).

Is there something i’m missing here? Is there any way to fix this to make it act the way i want?
The reply-to variable i am feeding GmailApp.sendEmail only contains the address i chose, so all i can think of is that this somehow depends on something both GmailApp and MailApp are doing when sending mail.

Testcafe how to force click on the element itself without responding to click on child elements

My test page has two elements. The width and height of the child element are larger than the parent element. When I execute the following code, the child element will be automatically scrolled. Is there any way to prevent the child element from scrolling and make the click only on the parent element?

test('test_temp', async t => {
        await t.wait(1000)
        await t.click('.parent',{
            offsetX: 300,
            offsetY: 300
        })
        await t.wait(5000)
        await t.eval(() => {
            window.HTMLElement.prototype.scrollIntoView = function () {
        // 禁用所有元素的滚动
    };
});
        await t.click('.parent',{
            offsetX: 20,
            offsetY: 20
        })
    })
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>testChild</title>
</head>
<body>
    <style>
        .parent {
            position: relative;
            width: 200px;
            height: 200px;
            overflow: auto;
            border: 2px solid black;
            z-index: 3;
            /* background: blueviolet; */
        }

        .child {
            content: "";
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            width: 1000px;
            height: 1000px;
            background: linear-gradient(#0602f5, #01ff40, #f50222,#f1f502);
        }
</style>

<div class="parent">
    <div class="child">
    </div>
</div>

<script>
    const parent = document.querySelector('.parent');
    parent.addEventListener('click', function (e) {
        console.log(e, e.target, e.currentTarget);

    });
       const child = document.querySelector('.child');
       child.addEventListener('click', function (e) {
        console.log(e, e.target, e.currentTarget);
        e.stopPropagation(); 
       })
</script>

    
</body>
</html>

JavaScript Regex to capture multiple occurrences of a pattern

I am trying to parse a string like this:

something[one][two]

into ['something', 'one', 'two]`. There may be zero or more expressions in square brackets.

The closest I have got to is:

^(.*?)(?:(?:[(.*?)])(?![))*$

That separates out the first part, and survives not having anything in square brackets. However, I can’t find a way of separating the two expressions in square brackets: ['something', 'one][two'].

I thought that:

  • the lazy match (.*?)]) would stop on the next closing bracket, but it seems to go on.
  • the negative lookahead ((?![)) would stop the expression going on to the next square brackets.

What do I need to pick up the mutliple square bracket expressions?

I’m doing this in JavaScript, though I think the regex would be very similar for PHP or Perl.

The question at Regular expression to extract text between square brackets doesn’t capture the parts not in square brackets.

Note:

  • When the time comes, I really want to parse the string:

    something#thing.stuff[one][two]
    

    so I’ll need more than just picking out the square brackets. I’ve got most of the first part working, and it’s not a problem. However, I’ve narrowed down the problem to the multiple square brackets, which is the question here.

  • I think the question would apply to any repeated pattern after the initial part, so it’s really a question of how to pick up a repeated pattern.