Difference in date between Js code in React project and Browser

Currently creating a simple React project which displays the date and shows future / past dates based on the user inputting the number of days difference. The date I’ve inputted as the date to measure from doesn’t come up as the same when on the Browser. I have no idea why this has happened but I’m assuming its something with Vite because this doesn’t happen when not using it.
Code for displaying time
Browser Output

Initially tried showing the current date with ‘new Date()’ but even with a specific date (e.g. new Date(‘october 04 2025’), a completely different date is logged by the console.

PayStackAPIError: Bearer Authorization header may not have been set | Unauthorized (401)

This is my first time of integrating payment gateway to my website using official paystack-node sdk package in my node.js application, but after following through the documentation i’m facing this error: PayStackAPIError: Bearer Authorization header may not have been set | Unauthorized (401).

This is my code sequence on the server side:

    const Paystack = require('paystack-node');
    const {PaystackPaymentSetupValidator,throwValidationError} = require('../utils/schemas');
    const router = require('express').Router();
    const ExpressError = require('../utils/express_error');
    const paystack = new Paystack(process.env.PAYSTACK_SECRET_KEY, process.env.NODE_ENV);
    const _isDevt = (process.env.NODE_ENV !== 'production');
    const callback_url = process.env.PAYSTACK_CALLBACK_URL;

// Middleware to validate Paystack requests
    const _validateRequest = async (req, resp, next) => {
        try{
            const {req_typ} = req.body;
            const {error} = await req_typ=='paystack-payment-setup-req'? PaystackPaymentSetupValidator.validate(req.body,{abortEarly:false}) : throwValidationError(req.body);
            if (error) {
                let msg = error? error.details.map(el => el.message).join('n# ') : 'Invalid Session Data!';
                if(_isDevt){
                    console.log('validation err:',error,msg);
                    msg = `n# ${msg}.`;
                } else {
                    msg = '';
                } // end if
                req.app.locals.appfx.log(new ExpressError('Validation Error',msg,0,req.body));
                return resp.send({error: {text: msg||'Invalid Request format.'}});
            } // end if
            return next();
        } catch(err) {
            if(_isDevt){
                console.log('catch err:',error);
            } // end if
            req.app.locals.appfx.log(error);
            return resp.send({error: {text:`Request Error!${_isDevt?`n${error}`:''}`}});
        } // end catch    
    } // end fx

    // Middleware to initialize Paystack
    const _initiatePayment = async (req, resp) => {
        try {
            const {email, amount, metadata} = req.body;
            const response = await paystack.initializeTransaction({
                email: email,
                amount: amount * 100, // Amount in kobo
                metadata: metadata || {},
                callback_url: callback_url
            });
            console.log('resp:',response);
            if(response.status) {
                return resp.send({success: {text: 'Paystack initialized successfully.', data: response.data}});
            } else {
                return resp.status(400).send({error: {text: 'Failed to initialize Paystack transaction.'}});
            } // end if
        } catch (error) {
            if(_isDevt){
                console.log('catch err:',error);
            } // end if
            req.app.locals.appfx.log(error);
            return resp.status(500).send({error: {text:`Request Error!${_isDevt?`n${error}`:''}`}});        
        } // end catch
    } // end fx

    // Middleware to verify Paystack transaction
    const _verifyPayment = async (req, resp, next) => {
        const {reference} = req.body||req.query;
        if(!reference) {
            return resp.status(400).send({error: {text: 'Transaction reference is required.'}});
        } // end if
        try {
            const response = await paystack.verifyTransaction({reference});
            // Handle successful verification (e.g., update order status)
            if(response.data.status && response.data.data.status === 'success') {
                req.transaction = response.data.data;
                return next();
            } else {
                return resp.status(400).send({error: {text: 'Transaction verification failed.'}});
            } // end if
        } catch (error) {
            if(_isDevt){
                console.log('catch err:',error);
            } // end if
            req.app.locals.appfx.log(error);
            return resp.status(500).send({error: {text: 'An error occurred while verifying the transaction.'}});
        } // end catch
    } // end fx

    // Define routes
    router.get('/', (req, resp) => {
        return resp.render('paystack', { title: 'Paystack Payment Gateway Handler', user: req.user, _csrf: req.app.locals._csrf, payment_setup_url:'payment_setup/initiate' });
    });
    router.route('/initiate').post(_validateRequest, _initiatePayment);
    router.route('/verify').post(_validateRequest, _verifyPayment, (req, resp) => {
        return resp.send({success: {text: 'Transaction verified successfully.', data: req.transaction}});
    });

    module.exports = router;

After running this, I get this error:
PayStackAPIError: Bearer Authorization header may not have been set | Unauthorized (401).

I was hoping for smooth running, please can anyone help me through this…

There is a syntax error somewhere within this code [closed]

There is a syntax error on the result line

I have watched so many videos but i need a good ttorial or help please

image is here – https://1drv.ms/i/c/36fc60b41c9287f8/EW6nARgyeilNgyVWKVhUDcMBiyytOFryjcX13FzUaMLdtg?e=t3XG7l

code–

<?php 
if(isset($_POST['create'])){
    $firstname = $_POST['firstname']; 
    $lastname = $_POST['lastname'];
    $email = $_POST['email'];
    $phonenumber = $_POST['phonenumber'];
    $password = $_POST['password'];
    
    $sql = "INSERT INTO useraccounts (firstname, lastname, email, phonenumber, password) VALUES (?,?,?,?,?)";
    $stmtinsert = $db->prepare($sql);
    $result = $stmtinsert->execute([$firstname, $lastname, $email, $phonenumber, $password]);
    
    if($result){
        echo 'successfully saved';  
    }else{
        echo ('errors found, contact the admins');  
    }
}
?>

Asset not loading – Laravel | FilamentPHP v4 | SimpleLightBox

When I go to the info list, the lightbox does not load. I click on the photo and it opens in a new tab. I click back and click on the image again, and then the photo opens in the lightbox.

GitHub package:
https://github.com/solutionforest/Filament-SimpleLightBox

Package Version
1.0.0

PHP Version
8.4

Laravel Version
12

FilamentPHP Version 4.1.1

Which operating systems does with happen with?
macOS

INFOLIST:

Section::make('Galeria zdjęć')
                ->schema([
                    ImageEntry::make('gallery')
                        ->label('Galeria zdjęć')
                        ->view('filament.components.lightbox-gallery')
                        ->simpleLightbox(fn($record) => $record->getFirstMediaUrl('gallery')),
                ]),

VIEW:

@php
    $mediaItems = $getRecord()->getMedia('gallery');
@endphp

@if ($mediaItems->count())
    <div class="flex flex-wrap gap-2">
        @foreach ($mediaItems as $media)
            <a
                href="{{ $media->getUrl('fullhd') }}"
                data-fslightbox="gallery"
            >
                <img
                    src="{{ $media->getUrl('thumb') }}"
                    class="h-24 rounded shadow"
                    alt="media"
                />
            </a>
        @endforeach
    </div>
@endif

Scraping booking.com with PHP Curl

I’m trying to setup a simple php script (below) to check when a certain property becomes available on booking.com.
The site seems to work with some pretty simple query parameters – you can just go directly to eg https://www.booking.com/searchresults.en-gb.html?ss=New+York&checkin=2026-03-01&checkout=2026-03-05&group_adults=2 and it will process the search correctly, no need to be logged in, or click through from the previous search page etc.
But the following script just returns empty search results, with no search parameters filled in:

<?php
   
$ch = curl_init();
$timeout = 180;       
$url="https://www.booking.com/searchresults.en-gb.html?ss=New+York&checkin=2026-03-01&checkout=2026-03-05&group_adults=2";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION , 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);   
$output = curl_exec($ch);
curl_close($ch);  
echo $output;
 
?>

Not sure if it’s down to booking.com implementing some kind of anti-bot protection behind the scenes which is actively blocking it, or if there’s just some simple thing I’m missing?

Get previous and next data from glob based on timestamp

I have the following code to sort the items based on a timestamp.

$arr = [];
foreach(glob('*.json') AS $item) {
    $data = json_decode(file_get_contents($item), true);
    $arr[] = [
        'taken' => $data['taken'],
        'file-name' => $data['file-name'],
        'account' => (empty($data['account']) ? null : $data['account'])
    ];
}

usort($arr, function($x, $y) { return $x['taken'] - $y['taken']; });

Here is the content of 4 of these JSON files I have in my folder:

{"hash":"1b668ef9398fe5fc9f68a3ad87d04a77","account":null,"file-name":"DSC00045","place":null,"taken":1663759434,"uploaded":1759397192},{"hash":"bccfb4221adc1e00b4fa34eef309d025","account":null,"file-name":"DSC00170","place":null,"taken":1663760473,"uploaded":1759397201},{"hash":"5aa05170b8e6c21b947db1a20b5a93ac","account":null,"file-name":"DSC00230","place":null,"taken":1663773888,"uploaded":1759397227},{"hash":"8de553beeda575d16377e62e77183507","account":null,"file-name":"DSC00318","place":null,"taken":1547596822,"uploaded":1759397265}

I want to get the previous and next item based on taken (which is the timestamp).

Currently I have made a mess and used the following to get the current item:

foreach($arr_test AS $test) {
    if($test['file-name'] == $get_image) {
        $current = $test;
    }
}

var_dump($current);

$get_item is the variable for (isset($_GET['img']) ? safetag($_GET['img']) : null) which contains the file name.

But now I am stuck. I have no clue what so ever how to get the previous and next item based on the timestamp.

My goal is to sort all items from the first foreach based on taken, and then get current, previous, and next file name based on when the photos were taken no matter how they are sorted in the folder. It’s for a photo gallery.

Variables not populating from PHP Script to mail message [duplicate]

The script does run, and I get the email. None of the information in the variables appears in the message, though. I get the plain text (“Query from” in the subject and “From” in the body). I have pasted the PHP script and the HTML form below. I would love to use PHPMail, but I don’t know if it is in the hosting environment I use, and I cannot install it myself. Until I can find out, I am using the native mail() function. Thanks in advance.

PHP Code 
<?php $to = "[email protected]"; 
$subject = "Query from" . htmlspecialchars($_POST['customer']); 
$msgBody = htmlspecialchars($_POST['msgBody']) . " From: "; 
$from = htmlspecialchars($_POST['subAdd']); $message = $from . " " . $msgBody;

if (mail($to, $subject, $message)){
    header("Location: https://bkjdesignspa.com");
}
else{
     echo "<script>window.alert('There was a problem sending the message.')</script>";
}

?>

HTML form

<form id="contactInfo" method="post" action="contactForm.php">                 
    <label>Name</label><br>                 
    <input type="text" placeholder="Name" required><br>                 
    <label>Email</label><br>                 
    <input type="email" id="subAdd" placeholder="Email Address" required><br>                 
    <label>Details</label><br>                 
    <textarea id="msgBody" placeholder="Details of request" style="width: 10em; height: 5em;" required></textarea><br>                                <input type="submit" value="Submit">             
</form><br>

“Docker Compose Laravel setup: Nginx shows 404, phpMyAdmin cannot connect to db”

Laravel + Docker Compose on macOS: Nginx (web, ports 8081:80, volumes ./src:/var/www/html, default.conf root /var/www/html/public, fastcgi_pass app:9000) returns 404 on http://localhost:8081, while phpMyAdmin (8080:80) cannot reach MySQL 8 service db (3307:3306) even with PMA_HOST=db (getaddrinfo / mysqli_real_connect errors). How can I diagnose the network/volume/config issue and fix both 404 and DB login?

phpMyAdmin cannot connect to MySQL in a Docker Compose Laravel stack: all containers (app, web, db, phpmyadmin) are Up; Laravel connects using DB_HOST=db; MySQL is exposed as 3307:3306; phpMyAdmin has PMA_HOST=db; yet login fails with getaddrinfo ENOTFOUND db / php_network_getaddresses. Why does service name resolution or port mapping fail, and what exact configuration is required for phpMyAdmin → MySQL 8 in this setup?

Stuck with Nginx 404 and phpMyAdmin DB connection error in Laravel + Docker Compose: route:list shows / and /author/add, Nginx config sets root /var/www/html/public and try_files … /index.php, but visiting http://localhost:8081 or /author/add returns 404; phpMyAdmin at http://localhost:8080 cannot connect to db (MySQL 8). Compose uses ./src:/var/www/html and 8081:80 / 3307:3306. What am I missing?

Docker Compose Laravel environment on macOS: Nginx (8081:80) serves 404 despite correct default.conf (root /var/www/html/public, try_files, fastcgi_pass app:9000), and phpMyAdmin (8080:80) cannot log in to MySQL service db (3307:3306) with PMA_HOST=db set—DNS resolves intermittently, mysqli_real_connect fails. What are the definitive steps to verify container networking, volumes, and phpMyAdmin/MySQL 8 auth so both issues are resolved?

How to integrate v3 invisible recaptcha to Magento 2.4.6 search

I have integrated recaptcha in search form but the issue is when user directly hit the search url like catalogsearch/result/?q=ring, there also i have integrate recaptcha. Please suggest some method. I have integrated it but when i search for the first time, it refreshes and redirect to homepage. Rest in second time it is working
Code of my form.mini.phtml

    <?php
$helper = $this->helper('MagentoSearchHelperData');
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$scopeConfig   = $objectManager->get(MagentoFrameworkAppConfigScopeConfigInterface::class);
$siteKey       = $scopeConfig->getValue(
    'recaptcha_frontend/type_recaptcha_v3/public_key',
    MagentoStoreModelScopeInterface::SCOPE_STORE
);
?>

<i id="searchIcon" class="search-icon icon-search "></i>
<div id="screen" class="search-screen">
  <div class="container">

    <form class="form minisearch" id="search_mini_form2" action="<?php echo $helper->getResultUrl() ?>" method="get">
      <div class="field search">
        <div class="search-input">
          <input id="search2"
                 data-mage-init='{"quickSearch":{
                      "formSelector":"#search_mini_form2",
                      "url":"<?php echo $block->getUrl('search/ajax/suggest'); ?>",
                      "destinationSelector":"#search_autocomplete"}
                 }'
                 type="text"
                 name="<?php echo $helper->getQueryParamName() ?>"
                 value="<?php echo $helper->getEscapedQueryText() ?>"
                 placeholder="<?php echo __('Search'); ?>"
                 class="search-box input-text"
                 aria-labelledby="search_autocomplete"
                 maxlength="<?php echo $helper->getMaxQueryLength();?>"
                 role="combobox"
                 aria-haspopup="false"
                 aria-autocomplete="both"
                 autocomplete="off"/>
          <div id="search_autocomplete" class="search-autocomplete"></div>
        </div>

        <!-- hidden field for v3 token -->
        <input type="hidden" name="g-recaptcha-response" id="recaptchaResponseSearch" />

        <div class="search-button">
          <button type="submit"
                  class="action search"
                  value="submit"
                  style="display: none;">
              <span><p style="display: none;">Search</p></span>
          </button>
        </div>
      </div>   
    </form>

    <!-- reCAPTCHA v3 API -->
    <script src="https://www.google.com/recaptcha/api.js?render=<?php echo $siteKey ?>"></script>
    <script>
    require(['jquery'], function($) {
        $(document).ready(function() {
            var $form = $('#search_mini_form2');
            var $input = $('#recaptchaResponseSearch');

            if (!$form.length || !$input.length) return;

            // Hook into quickSearch before AJAX request
            $form.on('submit', function(e) {
                e.preventDefault();

                // Generate reCAPTCHA token
                grecaptcha.ready(function() {
                    grecaptcha.execute('<?php echo $siteKey ?>', {action: 'search'}).then(function(token) {
                        $input.val(token);

                        // Now manually trigger quickSearch AJAX
                        if ($form.data('mage-init')) {
                            $form.trigger('search'); // triggers quickSearch submit
                        } else {
                            // fallback to normal submit
                            $form.off('submit'); // prevent loop
                            $form.submit();
                        }
                    });
                });
            });
        });
    });
    </script>

    <span class="close-icon"><i id="closeIcon" class="icon-close"></i></span>
  </div>
</div>

//Code of plugin  is 
namespace CustomSearchCaptchaPlugin;

use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppRequestInterface;
use MagentoFrameworkAppObjectManager;
use MagentoFrameworkControllerResultFactory;
use MagentoStoreModelScopeInterface;

class SearchDispatchPlugin
{
    public function aroundDispatch(Action $subject, Closure $proceed, RequestInterface $request)
    {
        $module     = $request->getModuleName();
        $controller = $request->getControllerName();
        $action     = $request->getActionName();

        // Only for catalogsearch/result/index
        if ($module === 'catalogsearch' && $controller === 'result' && $action === 'index') {
            $token = $request->getParam('g-recaptcha-response');

            // Load dependencies only when needed
            $objectManager  = ObjectManager::getInstance();
            $scopeConfig    = $objectManager->get(MagentoFrameworkAppConfigScopeConfigInterface::class);
            $messageManager = $objectManager->get(MagentoFrameworkMessageManagerInterface::class);
            $resultFactory  = $objectManager->get(ResultFactory::class);

            if (!$token) {
                $siteKey = $scopeConfig->getValue(
                    'recaptcha_frontend/type_recaptcha_v3/public_key',
                    ScopeInterface::SCOPE_STORE
                );

                echo '<html><head><script src="https://www.google.com/recaptcha/api.js?render=' . $siteKey . '"></script>
                <script>
                grecaptcha.ready(function() {
                    grecaptcha.execute("' . $siteKey . '", {action: "search"}).then(function(token) {
                        let url = window.location.href;
                        if(url.indexOf("g-recaptcha-response") === -1) {
                            if(url.indexOf("?") > -1) {
                                url += "&g-recaptcha-response=" + token;
                            } else {
                                url += "?g-recaptcha-response=" + token;
                            }
                            window.location.href = url;
                        }
                    });
                });
                </script></head><body>Please wait... validating search...</body></html>';
                exit;
            }

            // If token exists, verify
            if (!$this->verifyRecaptcha($token, $scopeConfig)) {
                $messageManager->addErrorMessage(__('CAPTCHA verification failed. Please try again.'));
                $resultRedirect = $resultFactory->create(ResultFactory::TYPE_REDIRECT);
                $resultRedirect->setPath('/');
                return $resultRedirect;
            }
        }

        return $proceed($request);
    }

    protected function verifyRecaptcha($token, $scopeConfig)
    {
        $secret = $scopeConfig->getValue(
            'recaptcha_frontend/type_recaptcha_v3/private_key',
            MagentoStoreModelScopeInterface::SCOPE_STORE
        );

        $verifyUrl = 'https://www.google.com/recaptcha/api/siteverify';
        $response  = file_get_contents($verifyUrl . '?secret=' . $secret . '&response=' . $token);
        $result    = json_decode($response, true);

        return isset($result['success'], $result['score'], $result['action']) &&
               $result['success'] === true &&
               $result['score'] >= 0.5 &&
               $result['action'] === 'search';
    }
}

Indexed DB code does not run inside a click event?

I cannot add a record to the db when inside a click event

var indexed_DB='atest';  
var db;
var request = indexedDB.open(indexed_DB);//see above
var zzz;
request.onupgradeneeded = function(event) { 
  var db = event.target.result;
  var objectStore = db.createObjectStore("barcode", {keyPath: "id"});
};

function one_line_barbones(s){
    request.onsuccess = function(event) {
      db = event.target.result;
      
      var transaction = db.transaction(["barcode"], "readwrite");
      var objectStore = transaction.objectStore("barcode");
      var request = objectStore.add(s);
    };//request.onsuccess = function(event) {
}//function one_line_barbones(something){


 $("button").click(function(){
 alert('t');//this will alert 't' so  works fine, so this click event is triggered
 zzz={id: '123',cn: 234456};//works fine when NOT wrapped in this function
 one_line_barbones(zzz); //Save data to indexed db right here and works fine when NOT wrapped in this function
 });

Well by removing the click event function the record is added perfectly.

Does anyone know how to get this code to work inside the click event?

Thanks,
Jim

How remove duplicate objects by lower index from array

I have function which add errors to array and if error it’s with same values it just removing that, and keep one

   setErrorField(errorArray.filter((value:any, index:any, self:any) =>
        index === self.findIndex((t:any) => (
          t.field === value.field,
          t.errorType === value.errorType
        ))
      ))

But it’s removing object with higher index ,but I need remove objects with lower index, basically I just need to do this function in reverse

I appreciate any idea. Cheers

Text Pagination based on the display element size (React)

I divide a text into the pages based on each page will have max 100 words. However, I want to divide the text based on the display element size (w, h).

What I want to achieve:

  1. Find the available size (w, h) of element displaying the text
  2. Fill the with the words as long as no overflow.
  3. When overflow will happen, create a next page for the rest of the text.
  4. Keep applying 2nd and 3rd steps until no words left.

I assume I need:

  1. A method: finds the current size (w, h) of the element as the size changes.

  2. A method: calculateHeight(currentWidth, currentHeight, text) returns calculatedHeight for the text input.

    2.1. Calculate the height, starting from word1 until wordX by adding words into the page.

    2.2. if the calculatedHeight is larger than the currentHeight, the rest of the text will be on the next page.

  3. Implement the 2nd step until no words left.

My question:

  • Am I doing an overkill to achieve this? Is there a better way?

Vue 3 Payment Success Page API Called Twice in Production After Stripe Redirect

I’m building a Vue 3 SPA with Vuex and Vue Router. On my Payment Success page, I call an API to assign purchased drinks:

created() {
  this.buyDrink()
},

methods: {
  buyDrink() {
    const payload = { cart: this.cartItems, payment_id: sessionStorage.getItem('payment_id') }
    mydrinksService.giftDrinkToFriend(payload)
      .then(res => { ... })
      .catch(err => { ... })
  }
}

The page works fine in development, but in production, this API call fires twice after a successful Stripe payment.
The root component (App.vue) looks like this:

<router-view v-slot="{ Component }" class="wrapper">
  <transition :name="isBack ? 'slide-right' : 'slide-left'">
    <component :is="Component" />
  </transition>
</router-view>

I suspect the double call happens due to component remounts or Stripe redirects, but I’m not sure.

What I’ve tried:

  • Checked that created() only calls the API once in dev.
  • Confirmed that Stripe redirects to the Payment Success route once.

Question:
Why would a Vue 3 SPA component call an API twice in production but not in development?
How can I ensure the API is only called once, even after Stripe redirects or route transitions?

How can i test my projects without HTTPS?

every time i want to test a project in my phone or another laptop the brwsr say


Error accessing media devices: DOMException: The request is not allowed by the user agent or the platform in the current context.


and say the Connection isn’t secure and this website don’t have SSL cert
enter image description here
SORRY FOR VIBE CODED CSS

i tried to disable HTTPS only mod and i changed many things from setting