Can’t upload files larger than 8 MB on Azure App Service (Linux) with Laravel v11

I’m having trouble uploading files larger than 8 MB on my Laravel v11 application, which is hosted on Azure App Service running on Linux.

Here’s what I’ve already done to configure the upload limits:

  1. Set the client_max_body_size directive in Nginx, and verified it’s working as expected:

    client_max_body_size 50M;
    
  2. Updated PHP php.ini settings via PHP_INI_SCAN_DIR. Running php -i on the server’s shell (SSH) confirms that the correct parameters are loaded:

    upload_max_filesize = 30M
    post_max_size = 50M
    memory_limit = 256M
    

Despite these settings, I can only upload files smaller than 8 MB. Trying to upload a file around 10 MB results in the following error:

The server returned a "413 Content Too Large".

Interestingly, when I set post_max_size and upload_max_filesize to 1M, I’m still able to upload a 7 MB file successfully.

Here’s the output of php -i | grep max on the server:

    max_execution_time => 0 => 0
    max_file_uploads => 20 => 20
    max_input_nesting_level => 64 => 64
    max_input_time => -1 => -1
    max_input_vars => 1000 => 1000
    max_multipart_body_parts => -1 => -1
    post_max_size => 1M => 1M
    upload_max_filesize => 1M => 1M
    zend.exception_string_param_max_len => 15 => 15
    session.gc_maxlifetime => 1440 => 1440
    unserialize_max_depth => 4096 => 4096

What could be causing this issue? Any help would be greatly appreciated. Thanks in advance!

I’m having trouble receiving payments with Stripe

I used Stripe for payments but Stripe deducts the commission fee from the customer’s bank account

I want the commission fee to be collected from the amount to be reflected to the seller, not from the customer. I tried the fee_source parameter for this but it says you must be Stripe Connect. Can I do it without Stripe Connect?

Laravel Breeze prevent bail for password field, return all errors

Currently, Laravel Breeze seems to use bail default for the password field. So it does not return all errors at once.

Is there a way to prevent the bail for the password field using Breeze?

In my case I want to return all errors for the specific fields (in this case password).

Best would be if I could overwrite it similiar to how I did it for its validation in my AppServiceProvider:

        Password::defaults(function () {
            return Password::min(8)
                ->letters()
                ->numbers()
                ->symbols()
                ->mixedCase()
                ->uncompromised();
        });

Display in fullcalendar title and description PHP JS

i have a problem with full calendar, i can’t display the description in a new line, currently i have created a title which is a concatenations of the title and the description stored in the database mysql, but it is messy, i want to display in the event block in one row the title and in one row the description

calendar

For example in the yellow event i want in the first line Primo Soccorso and in the second line Gruppo A….

Currently the data is load from json from php mysql code using ajax.

$query = "select * from listaeventi";
if($result = mysqli_query($conn,$query)){
  while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){

      $data[] = [
          'id'              => $row["id"],
          'title'           => $row["titoloEvento"]." , ".$row["descrizioneEvento"],
          'description'     => $row["descrizioneEvento"],
          'type'            => "Corso",
          'start'           => $row["dataInizio"],
          'end'             => $row["dataFine"],
          'durata'          => $row["durataEvento"],
          'address'         => $row["indirizzoEvento"],
          'city'            => $row["paeseEvento"],
          'cliente'         => $row["cliente"],
          'sala'            => $row["sala"],
          'data_successiva' => $row["data_successiva"],
          'iscrizione'      => $row["iscrizione"],
          'borderColor'     => $row["bgcolor"],
          'backgroundColor' => $row["bordercolor"]
      ];

  }

}

The js code for full calendar it is this

document.addEventListener('DOMContentLoaded', function() {
var url ='';

var vista = 'listMonth';
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
  var vista = 'listMonth';
}
    var calendarEl = document.getElementById('calendar');
    var calendar = new FullCalendar.Calendar(calendarEl, {
      initialView: vista,
      locale: 'it',
      headerToolbar: {
        left: 'prev,next,today',
        center: 'title',
        right: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth',
      },
      buttonText: {
        today:    'Oggi',
        month:    'Mese',
        week:     'Settimana',
        day:      'Giorno',
        list:     'Agenda'
      },


      navLinks: true, // can click day/week names to navigate views
      editable: true,
      selectable: true,
      eventDisplay: 'block',
      selectMirror: true,
      dayMaxEvents: true, // allow "more" link when too many events
      events: url+'calendar/load.php?filtro='+filtroCorso,
      contentHeight: 1500,
      allDaySlot: false, //evento allday
      firstDay: 1,
      select: function(arg) {

        var options = {'weekday': 'long', 'month': 'long', 'day': '2-digit'};

        var date = arg.start.toLocaleString('it-IT', options);

        // $("#data_inizio").val(arg.start.getFullYear()+"-"+(arg.start.getMonth()+1)+"-"+addZero(arg.start.getDate())+" "+addZero(arg.start.getHours())+":"+addZero(arg.start.getMinutes())+":"+addZero(arg.start.getSeconds()));
        // $("#data_fine").val(arg.end.getFullYear()+"-"+(arg.end.getMonth()+1)+"-"+addZero(arg.end.getDate())+" "+addZero(arg.end.getHours())+":"+addZero(arg.end.getMinutes())+":"+addZero(arg.end.getSeconds()));
        //
        // $("#data_evento").text(date);
        // $("#data_italiana").val(date);
        //
        // $("#ora_inizio").text(addZero(arg.start.getHours())+":"+addZero(arg.start.getMinutes()));
        // $("#ora_fine").text(addZero(arg.end.getHours())+":"+addZero(arg.end.getMinutes()));

        calendar.unselect()
      },

      //eventDrop is triggered when an event is dragged and dropped to another date or time.
      eventDrop: function(arg) {
          var start = arg.event.start.toDateString()+' '+arg.event.start.getHours()+':'+arg.event.start.getMinutes()+':'+arg.event.start.getSeconds();
          if (arg.event.end == null) {
              end = start;
          } else {
              var end = arg.event.end.toDateString()+' '+arg.event.end.getHours()+':'+arg.event.end.getMinutes()+':'+arg.event.end.getSeconds();
          }

          // $.ajax({
          //   url:url+"calendar/update.php",
          //   type:"POST",
          //   data:{id:arg.event.id, start:start, end:end},
          // });
      },
      //eventReize is very similar, this is triggered when an event is manually resized from a week or day view.
      eventResize: function(arg) {
          var start = arg.event.start.toDateString()+' '+arg.event.start.getHours()+':'+arg.event.start.getMinutes()+':'+arg.event.start.getSeconds();
          var end = arg.event.end.toDateString()+' '+arg.event.end.getHours()+':'+arg.event.end.getMinutes()+':'+arg.event.end.getSeconds();

          // $.ajax({
          //   url:url+"calendar/update.php",
          //   type:"POST",
          //   data:{id:arg.event.id, start:start, end:end},
          // });
      },

      eventClick: function(arg) {

        var id = arg.event.id;
        var options = {'weekday': 'long', 'month': 'long', 'day': '2-digit'};

        var date = arg.event.start.toLocaleString('it-IT', options);

        $.ajax({
          url:url+"calendar/getevent.php",
          type:"POST",
          dataType: 'json',
          data:{id:arg.event.id},
          success: function(data) {
            // alert(data[0].city);

              // alert(data[0].idRiferimento);
              $('#tipoEvento').html(data[0].type);
              $('#tipoEvento').css('color', data[0].backgroundColor);

              $('#titoloEvento').html(data[0].title);
              $('#titoloEvento').css('color', data[0].backgroundColor);
              globalID = data[0].id;

              $("#eliminaData").attr("href","https://corsi.gpserviziarco.it/calendario-corsi/index.php?delete="+globalID);

              globalTitolo = data[0].title;
              globalBackgroundColor = data[0].backgroundColor;


              // SETTO MAPPA USCITE PRATICHE

              if(data[0].address.includes("Circolo") || data[0].address.includes("Conca")){
                $('#mappa').attr('src', "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3324.708097095604!2d10.87475893318616!3d45.86273542875592!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x478210e9aaef5bf7%3A0x2e3475f668003103!2sCircolo%20Vela%20Torbole!5e1!3m2!1sit!2sit!4v1727274256988!5m2!1sit!2sit");
                $('#indirizzo-mobile').attr('href', "https://maps.app.goo.gl/wMCmuxbFp6fCnEog6");
              }else if(data[0].address.includes("Porto")){
                $('#mappa').attr('src', "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d6647.5929025257!2d10.853839376647468!3d45.87797800573525!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x478210d3a0a6edb3%3A0xd4ecc39b92163d32!2sPorto%20San%20Nicol%C3%B3!5e1!3m2!1sit!2sit!4v1727274370632!5m2!1sit!2sit");
                $('#indirizzo-mobile').attr('href', "https://goo.gl/maps/2gw4jFDzrbML83NE6");
              }else if(data[0].address.includes("San Nazzaro 2/D")){
                $('#mappa').attr('src', "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3322.6874817366593!2d10.849190576648251!3d45.89651450448972!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4782114dad8eac25%3A0xec24e7cccdbb556f!2sG%20%26%20P%20Servizi%20Srl!5e1!3m2!1sit!2sit!4v1727274332071!5m2!1sit!2sit");
                $('#indirizzo-mobile').attr('href', "https://goo.gl/maps/2gw4jFDzrbML83NE6");
              }else if(data[0].address.includes("Croseta 39")){
                $('#mappa').attr('src', "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3321.7411262686323!2d10.862404176648921!3d45.91232830342698!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xaa3df96f0daec2f7%3A0x9c56bae78c563eac!2sFeelwork%20sicurezza%20verticale!5e1!3m2!1sit!2sit!4v1727274399004!5m2!1sit!2sit");
                $('#indirizzo-mobile').attr('href', "https://maps.app.goo.gl/1iJBxVWkjJTZqxD39");
              }else if(data[0].address.includes("Piazza Maria Contini")){
                $('#mappa').attr('src', "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3322.7094054490444!2d10.844431726648251!3d45.896148104514396!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x478216c504b123a3%3A0xdb7e711b80b3da0c!2sPiscina%20Comunale%20Coperta%20Enrico%20Meroni!5e1!3m2!1sit!2sit!4v1727274590307!5m2!1sit!2sit");
                $('#indirizzo-mobile').attr('href', "https://maps.app.goo.gl/Eyo5AvC5ZLU2zKTw9");
              }



              // FINE SETTO MAPPA USCITE PRATICHE

              $('#descrizioneEvento').html(data[0].description);
              globalDescrizione = data[0].description;

              $("#indirizzoEvento").html(data[0].address);
              $("#paeseEvento").html(data[0].city);

              $("#iscrizioneEvento").html(data[0].iscrizione);
              if(data[0].iscrizione=="APERTA"){
                $("#badge-iscrizione").removeClass( "badge-danger" );
                $("#badge-iscrizione").addClass( "badge-success" );
                $("#apriIscrizione").prop("disabled",false);
              }else if(data[0].iscrizione=="CHIUSA"){
                $("#badge-iscrizione").removeClass( "badge-success" );
                $("#badge-iscrizione").addClass( "badge-danger" );
                $("#apriIscrizione").prop("disabled",true);
              }

              if(data[0].title.includes("scit")){
                $("#apriIscrizione").hide();
              }else{
                $("#apriIscrizione").show();
              }


              $("#durataEvento").html(data[0].durata);

              $("#sala").html(data[0].sala);


              $("#lezioneSucccessiva").html(data[0].data_successiva);


              $("#dataEvento").text(date);
              $("#oraInizio").text(addZero(arg.event.start.getHours())+":"+addZero(arg.event.start.getMinutes()));
              $("#oraFine").text(addZero(arg.event.end.getHours())+":"+addZero(arg.event.end.getMinutes()));

              globalData = date+" "+addZero(arg.event.start.getHours())+":"+addZero(arg.event.start.getMinutes())+" - "+addZero(arg.event.end.getHours())+":"+addZero(arg.event.end.getMinutes());


              $("#pdf_specifico").attr("href", "docs/"+data[0].pdf+".pdf");

              $("#export-corso").attr("href", "/calendario-corsi/export.php?corso="+globalTitolo+"&data="+globalData);

              // $("#lista-iscritti").attr("href", "/calendario-corsi/lista-iscritti.php?corso="+globalTitolo+"&data="+globalData);
              $("#lista-iscritti").attr("href", "/calendario-corsi/lista-iscritti.php?corso="+globalTitolo+"&data="+data[0].dataOra+"&data2="+globalData); //NUOVO MODELLO DATA LISTA ISCRITTI
              $("#linkIscrizione").attr("href", "/calendario-corsi/iscrizione.php?type=iscrizione&codice="+data[0].id+"&idRiferimento="+data[0].idRiferimento+"&data="+data[0].dataOra);


              $("#pdf_specifico").attr("download", data[0].pdf+".pdf");
              $('#pdf_specifico_span').text(data[0].pdf);
              if(data[0].pdf=="no-file"){
                $( "#pdf_specifico" ).hide();
              }else{
                $( "#pdf_specifico" ).show();
              }

              if(data[0].title=="Corso bagnini" || data[0].title=="Corso Bagnini" || data[0].title=="Corso Bagnini Piscina"){
                $("#selezioneMinorenne").show(); //METTERE SHOW
              }else{
                $("#selezioneMinorenne").hide();
                $("#rigaGenitore").hide();
              }

              if(data[0].title=="Patente nautica" || data[0].title=="Patente Nautica"  || data[0].title=="Patente nautica "){
                $("#rigaNauticaPartecipazione").show(); //METTERE SHOW
              }else{
                $("#rigaNauticaPartecipazione").hide();
              }


              $("#exampleModal").modal();
            }
        });

        /*$.ajax({
          url:url+"calendar/getDateSuccessive.php",
          type:"POST",
          dataType: 'json',
          data:{id:arg.event.id},
          success: function(data1) {


            for(let i = 0; i <= data1.length; i++) {
              // alert(data1[i].dataEvento);
              s = new Date(data1[i].start).toLocaleString('it-IT', options);
              oraI = new Date(data1[i].start).getHours();
              minutiI = new Date(data1[i].start).getMinutes();
              oraF = new Date(data1[i].end).getHours();
              minutiF = new Date(data1[i].end).getMinutes();


              $("#successive").append(s+" 0"+oraI+":"+minutiI+" - "+oraF+":"+minutiF+"<br>");
              $("#tmpDateEvento").val($("#tmpDateEvento").val()+s+" "+oraI+":"+minutiI+" - "+oraF+":"+minutiF+";");
              $("#numero").val(data1.length);
              $("#corsiSuccessivi").val($("#corsiSuccessivi").val()+data1[i].id+";");
            }

          }
        });*/

        $('#delete').on('click', function() {
            if(confirm("Sei sicuro di voler cancellare l'evento?")) {
                $.ajax({
                    url:url+"calendar/delete.php",
                    type:"POST",
                    data:{id:arg.event.id},
                });

                //close model
                $("#modalSlideLeft").modal('hide');

                //refresh calendar
                calendar.refetchEvents();

                if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
                  location.reload();
                }

                // $('body').pgNotification({style:'simple',message:'Evento cancellato correttamente!',type:'success'}).show();
            }
        });

        calendar.refetchEvents();
    }

    });



    calendar.render();

});

Here the link https://corsi.gpserviziarco.it/calendario-corsi/

What i have to do to show the description
Thanks !

Why does the data i enter in the form doesn’t show in my database in phpMyAdmin? [closed]

In the following code, it takes the information of the user while submitting his message in a ‘Contact Us’ form, but when I click on the submit button, the database doesn’t show the data and it only shows me the massage “Message sent successfully.” , but if i upload a file, the file will be downloaded in my web server without it being shown in my db in phpMyAdmin.
I’m sure that the SQL code is perfect, since the db was made in phpMyAdmin. And how can i view a file that was uploaded and view it from phpMyAdmin?

<?php
// Database connection
$servername = "localhost";  
$username = "root";         
$password = "";             
$dbname = "contact_form_db"; 

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = mysqli_real_escape_string($conn, $_POST['name']);
    $email = mysqli_real_escape_string($conn, $_POST['email']);
    $phone = mysqli_real_escape_string($conn, $_POST['phone']);
    $message = mysqli_real_escape_string($conn, $_POST['message']);
    
    $file_path = '';
    if (isset($_FILES['file']) && $_FILES['file']['error'] == 0) {
        $file_tmp = $_FILES['file']['tmp_name'];
        $file_name = basename($_FILES['file']['name']);
        $file_size = $_FILES['file']['size'];
        $file_type = $_FILES['file']['type'];
        
        $allowed_types = ['image/jpeg', 'image/png', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
        $max_size = 5 * 1024 * 1024; 
        
        if (in_array($file_type, $allowed_types) && $file_size <= $max_size) {
            $upload_dir = 'uploads/';
            
            if (!is_dir($upload_dir)) {
                mkdir($upload_dir, 0755, true);
            }
            
            $unique_file_name = uniqid('file_') . "_" . $file_name;
            $file_path = $upload_dir . $unique_file_name;
            
            if (move_uploaded_file($file_tmp, $file_path)) {
                echo "<p>File uploaded successfully!</p>";
            } else {
                echo "<p>There was an error uploading your file.</p>";
            }
        } else {
            echo "<p>Invalid file type or size. Please upload a valid file.</p>";
        }
    }

    $sql = "INSERT INTO contact_info (Name, Email, Phone, Message, FilePath) 
            VALUES ('$name', '$email', '$phone', '$message', '$file_path')";
    
    if ($conn->query($sql) === TRUE) {
        echo "<p>Message sent successfully!</p>";
    } else {
        echo "<p>Error: " . $conn->error . "</p>";
    }

    $conn->close();
}

?>




<!-- Contact Form -->
<div class="contact-form-container">
    <div class="contact-info-left">
        <h2>Contact Us</h2>
        <div class="contact-details">
            <p><i class="fas fa-map-marker-alt"></i> Zone 2, 3rd Floor, KOM4<br>
            Knowledge Oasis Muscat<br>
            PO Box 35, PC 135 Rusayl<br>
            Sultanate of Oman</p><br>
            <p><i class="fas fa-phone-alt"></i> 80077767 / +968 2417 1111</p><br>
            <p><i class="fas fa-clock"></i> from 8 AM - 5:30 PM</p><br> 
        </div>
    </div>
    <form class="contact-form" method="POST" action="" enctype="multipart/form-data">
    <!-- Personal Information Section -->
    <div class="form-section">
        <h3>Personal Information</h3>
        <label for="name">Name</label>
        <input type="text" id="name" name="name" pattern="[A-Za-z]+" title="Only letters are allowed" required>
        
        <label for="phone">Phone Number</label>
        <input type="tel" id="phone" name="phone" pattern="[0-9]{8,15}" title="Phone number should contain only numbers and be 8 to 15 digits long" required oninput="this.value = this.value.replace(/[^0-9]/g, '');">
        
        <label for="email">Email</label>
        <input type="email" id="email" name="email" required>
        <label for="file">Attach File (optional)</label>
        <input type="file" id="file" name="file" accept="image/*,.pdf,.docx,.txt">

    </div>
    
    <!-- Message Details Section -->
    <div class="form-section">
        <h3>Message Details</h3>
        <label for="message">Message</label>
        <textarea id="message" name="message" rows="10" required></textarea>
    </div>

    <button type="submit">Send Message</button>
    
</form>
<script>
function submitForm(event) {
    event.preventDefault(); 
    
    alert("Message sent successfully!"); 
}
</script>
</div>

I don’t know if the HTML code has something to do with it, but I did try to get help from ChatGPT and it keeps saying that there is no problem with the code. And sometimes it changes many things in the code and makes it completely different.
I’ve tried to change the variables names but It still did not work.

Woocommece update mini cart count ajax

I am using following code to add product to cart on my button click. It works fine (product is added to cart), but the count in mini cart is only updated after second add. First time I click add, there is no update visible in cart mini icon (unless I refresh the page).

I use default WordPress theme.

php:

add_action('wp_ajax_map_woo_add_to_cart', 'map_woo_add_to_cart');

function map_woo_add_to_cart(){

    if(isset($_POST['product_id'])){

        $product_id = $_POST['product_id'];
        
            ob_start();

            $quantity          = 1;
            $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity ); 
            $product_status    = get_post_status( $product_id );
            $added             = WC()->cart->add_to_cart( $product_id, $quantity );

            if ( $passed_validation && $added && 'publish' === $product_status ) {
                ob_start();

                woocommerce_mini_cart();

                $mini_cart = ob_get_clean();

                $data = array(
                    'fragments'  => apply_filters(
                        'woocommerce_add_to_cart_fragments',
                        array(
                            'div.widget_shopping_cart_content' => '<div class="widget_shopping_cart_content">' . $mini_cart . '</div>',
                        )
                    ),
                    'cart_hash'  => WC()->cart->get_cart_hash(),
                    'ajax_nonce' => wp_create_nonce( 'map_woo-security-nonce' ),
                );

                wp_send_json_success( $data );
            } else {
                $data = array(
                    'message'     => __( 'The product was not added to the cart', MAP_WOO_TEXTDOMAIN ),
                    'product_url' => apply_filters( 'woocommerce_cart_redirect_after_error', get_permalink( $product_id ), $product_id ), 
                    'product_id'  => $product_id,
                );
                wp_send_json_error( $data );
            }
       

          }
      }

javascript:

function addProductToCart(postId, data){

        const params = new URLSearchParams();
        params.append("action", 'map_woo_add_to_cart');
        params.append("product_id", postId);

        var xhrRequest = new XMLHttpRequest();
        xhrRequest.onreadystatechange = function() {
            if (this.readyState == 4) {
                var result = JSON.parse(this.responseText);
                console.log(result);

                if ( result.data.fragments ) {
                 
                    jQuery( document.body ).trigger( 'wc_fragment_refresh' );
                    jQuery( document.body ).trigger( 'added_to_cart', [ result.data.fragments, result.data.cart_hash ] );
              
                }

            }
        }
        xhrRequest.onerror = function(e) { 
            console.log('Error add_to_cart: ' + e);
        };
        xhrRequest.open('POST', settings.ajax_url);
        xhrRequest.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
        xhrRequest.send(params);

    }

Equal Height Tiny Slider Carousel

I would like the slides to be other equal height, so the slides will match the height all the tallest slide. Ideally with the two bottom information (1,500 SQFT and Enquire) staying at the bottom of the container.

I’m using PropertyHive, which is using the tiny slider package inside of the plugin to make this carousel.

https://dovesmanagement.co.uk/

screenshot of the current carousel with unequal heights, with annotation

Accessing a class constant from a trait in php gives error in VScode

I have in laravel inside the same App folder a class and a trait

MyClass.php

<?php

namespace App;

class MyClass {

    use myTrait;
    CONST MY_CONST = 'CONST';
    
    public function showConst() {
        echo $this->myTraitMethod();
    }
    
}

MyTrait.php

<?php

namespace App;

class MyTrait {
    
    public function myTraitMethod() {
        return self::MY_CONST; // Undefined class constant 'MY_CONST'
        return static::MY_CONST; // Undefined class constant 'MY_CONST'
        return MyClass:MY_CONST; // This is the only one that works but I'm forcing the class name
    
    }
}

the issue is that I cannot access MY_CONST except if I force the parent class name that is not a solution for me.

The issue is just with vscode, I mean the code runs fines with both self and static but vscode returns the error

Undefined class constant 'MY_CONST'

Magento 2: Incorrect Price Calculation for Multiple Quantities in Checkout with Stripe

I’m facing an issue in my Magento 2 store during checkout when using Stripe as the payment method. When a customer adds the same product to the cart multiple times (e.g., three units of a single product) and proceeds through the checkout process, the total amount displayed on the final order placement page is incorrect. It seems as though the total is being miscalculated, possibly multiplied or inflated unexpectedly.

Environment Details:

  • Magento Version: 2
  • PHP Version: 8.2
  • Theme: SM Market Theme

This miscalculation occurs specifically when selecting Stripe as the payment method and appears on the order review page right before placing the order. Any insights into why this might happen or where to check for possible configuration issues would be greatly appreciated.

Steps to Reproduce:

  • Log into a customer account.
  • Navigate to the shop page.
  • Add the same product to the cart three times.
  • Proceed to checkout.
  • Review the cart and shipping information.
  • Continue to payment method selection (Stripe).
  • On the final order placement page, the total amount is incorrect.

What I’ve Tried:

  • Cleared the cache to rule out caching issues.
  • Reviewed the XML configuration file for any discrepancies in checkout block settings.
  • Inspected the code responsible for calculating checkout totals to identify potential errors.

Expected Behavior:
When a single product is added to the cart multiple times, the total should calculate as:
(Product Price × Quantity) + Shipping Cost = Total

Actual Behavior:
After adding the same product to the cart three times, the checkout displays an incorrect total, as if the total amount has been multiplied by 3. This unexpected calculation results in an inflated final price.

Questions:

  • What could be causing this incorrect calculation during checkout when using Stripe?
  • Are there common configuration issues with Magento 2 that could lead to this inflated total when multiple quantities are added to the cart?
  • Where should I check further to troubleshoot the issue, especially within the checkout and payment gateway configurations?

Any guidance or suggestions on how to resolve this issue would be greatly appreciated!

API endpoint to retrieve version of a WordPress site?

Simple question:

Is there an API endpoint to retrieve the version of a specific WordPress site?
I need to monitor different WordPress sites and want to retrieve the version of these sites to be collected and checked for WordPress updates.

Is there a simple solution, something like example.com/api/version ?

how to fix model boot method not working properly?

protected static function boot()
    {
        parent::boot();
        self::creating(function ($model) {
            $model->unique_id = self::generateUniqueId();
        });

        self::deleting(function (Submission $submission) {
            Log::info('Deleting model:', ['model' => $submission]);
            dd($submission);
            // Delete all associated media
            $submission->clearMediaCollection('files');
            $submission->clearMediaCollection('images');
        });
    }

i have this method in my submission model the creating works on each new model while creating but the deleting is not working it just deletes the model and this doesnt works

my submission model


namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;
use IlluminateSupportFacadesLog;
use SpatieMediaLibraryHasMedia;
use SpatieMediaLibraryInteractsWithMedia;
use SpatieMediaLibraryMediaCollectionsFile;

class Submission extends Model implements HasMedia
{
    use InteractsWithMedia, HasFactory;
    protected $fillable = [
        'unique_id',
        'user_id',
        'title',
        'description',
        'status',
    ];

    protected static function boot()
    {
        parent::boot();
        self::creating(function ($model) {
            $model->unique_id = self::generateUniqueId();
        });

        self::deleting(function (Submission $submission) {
            Log::info('Deleting model:', ['model' => $submission]);
            dd($submission);
            // Delete all associated media
            $submission->clearMediaCollection('files');
            $submission->clearMediaCollection('images');
        });
    }

    public static function generateUniqueId()
    {
        do {
            $uniqueId = str_pad(rand(0, 99999999), 12, '0', STR_PAD_LEFT);
        } while (self::where('unique_id', $uniqueId)->exists());

        return $uniqueId;
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function replies()
    {
        return $this->hasMany(SubmissionReply::class);
    }

    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('files')
            ->useDisk('submissions')
            ->acceptsFile(function (File $file) {
                return in_array($file->mimeType, [
                    'image/jpeg',
                    'image/png',
                    'application/pdf',
                    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
                    'text/plain'
                ]);
            });

        $this->addMediaCollection('images')
            ->useDisk('submissions')
            ->singleFile()
            ->acceptsMimeTypes([
                'image/jpeg',
                'image/png',
                'image/jpg',
            ]);
    }
}

Incorrect French characters php – website [duplicate]

I inherited a website to rebuild, which is displaying French characters incorrectly (’ for ‘, é for é, è for è and so on). These characters are also present as such in the mysql database. The database collation and the collation of content tables was set to “latin_swedish1_ci” when I received it. The websites html header contains <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />.

In order to correct the data I have updated the database collation and the one from one table (as a test) to “utf8mb4_unicode_ci” through phpmyadmin > operations which (as far as I understood) applies an ALTER function. However after these actions, the strings in the database and the table still contain the incorrect characters. Also when exported with utf-8 encoding, the content in the table is showing the incorrect characters.

db and server character and collation values

Does this mean I would need to clean up all the records in the database, or do I overlook something and is there still a way to get the correct characters through the charsets and collation settings?

(Watch Full Video) Imsha Rehman Leaked Video

A recent video of Imsha Rehman, a popular TikTok creator, has quickly gone viral, capturing attention across social media platforms. Known for her creative content, Imsha Rehman’s video tutorial has spread rapidly, especially on platforms like X (formerly Twitter) and Telegram.

CLICK HERE ==►► WATCH NOW

This original video has sparked considerable interest and discussion, highlighting her growing influence in the digital space.

Laked Video Imsha Rehman Video Tutorial Original Video Viral Video Laked on X Twitter

Imsha Rehman Video Tutorial Original Video video oficial twitter

Laked VideoImsha Rehman Video Tutorial Original Video Viral Video Laked on X Twitter

Is there a way to duplicate all the variations and their values of one product in WooCommerce to all the other products in a given category?

I have over 400 products in my WooComerce store, and they all were done as a simple product. The problem is that now I have to add variations to all the products (to satify a shipping plugin) and it will take me forever if I have to do this manually for each product.

I have setup one of my product with all the variations and values needed to be duplicated to the other products of the same category.

I tried piecing together a simple plugin to do this based on TSCAmerica.com answer.

Below is the complete plugin code for anyone to try out and see if it is working for them or where it needs to be fixed:

<?php

/*
Plugin Name:  WC Copy Variations
Plugin URI:   https://www.example.com
Description:  Copy a Woocommerce Product's Variations From One Product to Another
Version:      1.0
Author:       Wayne Schulz
Author URI:   https://www.example.com
License:      GPL2
License URI:  https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  wc-copy-variations
Domain Path:  /languages
*/

// plugin settings menu
add_action('admin_menu', 'wcvc_create_menu');

function wcvc_create_menu() {

    //create new top-level menu
    add_menu_page('WC Copy Variations Settings', 'Copy Variations', 'administrator', __FILE__, 'wcvc_settings_page' , plugins_url('/images/icon.png', __FILE__) );

    //call register settings function
    add_action( 'admin_init', 'register_wcvc_settings' );
}


function register_wcvc_settings() {
    //register our settings
    register_setting( 'wcvc-settings-group', 'source_product_id' );
    register_setting( 'wcvc-settings-group', 'target_product_id' );
        register_setting( 'wcvc-settings-group', 'wcvc_status' );
    
}

function wcvc_settings_page() {

// Trigger wcv copy
$wcvc_status = get_option('wcvc_status');
    if(str_contains($wcvc_status, 'yes')) {
        perform_wcv_copy();
    }

?>
<div class="wrap">
<h1>WC Copy Variations</h1>

<form method="post" action="options.php">
    <?php settings_fields( 'wcvc-settings-group' ); ?>
    <?php do_settings_sections( 'wcvc-settings-group' ); ?>
    <table class="form-table">
        <tr valign="top">
        <th scope="row">Source Product ID</th>
        <td><input type="text" name="source_product_id" value="<?php echo esc_attr( get_option('source_product_id') ); ?>" /></td>
        </tr>
         
        <tr valign="top">
        <th scope="row">Target Product ID</th>
        <td><input type="text" name="target_product_id" value="<?php echo esc_attr( get_option('target_product_id') ); ?>" /></td>
        </tr>
        
        <tr valign="top">
        <th scope="row">Type 'yes' to copy</th>
        <td><input type="text" name="wcvc_status" value="<?php echo esc_attr( get_option('wcvc_status') ); ?>" /></td>
        </tr>
    </table>
    <?php submit_button(); ?>
</form>

</div>
<table><tr><td style="vertical-align: top;"><?php show_wcv_source(); ?></td><td style="vertical-align: top;"><?php show_wcv_target(); ?></td></tr></table>

<?php }

function perform_wcv_copy() {
    global $options;
    $source_product_id = get_option('source_product_id');
    $target_product_id = get_option('target_product_id');

    $source_product = wc_get_product($source_product_id);

    // Check if the source product has variations
    if ($source_product->is_type('variable')) {
        // Get the variations of the source product
        $variations = $source_product->get_children();

        foreach ($variations as $variation_id) {
            $variation = wc_get_product($variation_id);

            // Create a new variation for the target product
            $new_variation = new WC_Product_Variation();
            $new_variation->set_parent_id($target_product_id);
            
            // Set attributes and other settings from the source variation
            $new_variation->set_attributes($variation->get_attributes());
            $new_variation->set_regular_price($variation->get_regular_price());
            $new_variation->set_sale_price($variation->get_sale_price());
            $new_variation->set_weight($variation->get_weight());
            $new_variation->set_length($variation->get_length());
            $new_variation->set_height($variation->get_height());
            $new_variation->set_width($variation->get_width());
            
            // Save the new variation
            $new_variation->save();
        }
    }
    update_option( 'wcvc_status', 'done' );
}

function show_wcv_source() {

    global $options;
    $source_product_id = get_option('source_product_id');
    $target_product_id = get_option('target_product_id');
    echo '<p><strong>Source Product ID: '.$source_product_id.'</strong><br />';
    echo 'Product Categories: '.wc_get_product_category_list($source_product_id).'</p>';
    $source_product = wc_get_product($source_product_id);

    // Check if the source product has variations
    if ($source_product->is_type('variable')) {
        // Get the variations of the source product
        $s_variations = $source_product->get_children();
        
        foreach ($s_variations as $s_variation_id) {
            $s_variation = wc_get_product($s_variation_id);
            
            echo '<div class="wrap"><p>';
            
            //$raw_variation = var_export($variation, true);
            //echo 'Variation ID: '.$raw_variation.'<br />';

            echo 'Attributes: ';
            var_dump($s_variation->get_attributes());
            echo '<br />';
            
            $s_regular_price = $s_variation->get_regular_price();
            echo 'Regular Price: '.$s_regular_price.'<br />';

            $s_sale_price = $s_variation->get_sale_price();
            echo 'Sale Price: '.$s_sale_price.'<br />';
            
            $s_weight = $s_variation->get_weight();
            echo 'Weight: '.$s_weight.'<br />';
            
            $s_length = $s_variation->get_length();
            echo 'Length: '.$s_length.'<br />';
            
            $s_height = $s_variation->get_height();
            echo 'Height: '.$s_height.'<br />';
            
            $s_width = $s_variation->get_width();
            echo 'Width: '.$s_width.'<br />';
            
            echo '</p></div>';
        }
    }
}

function show_wcv_target() {

    global $options;
    $source_product_id = get_option('source_product_id');
    $target_product_id = get_option('target_product_id');
    echo '<p><strong>Target Product ID: '.$target_product_id.'</strong><br />';
    echo 'Product Categories: '.wc_get_product_category_list($target_product_id).'</p>';
    $target_product = wc_get_product($target_product_id);

    // Check if the target product has variations
    if ($target_product->is_type('variable')) {
        // Get the variations of the target product (if any)
        $variations = $target_product->get_children();
        
        foreach ($t_variations as $t_variation_id) {
            $t_variation = wc_get_product($t_variation_id);
            
            echo '<div class="wrap"><p>';
            
            // $raw_variation = var_export($variation, true);
            // echo 'Variation ID: '.$raw_variation.'<br />';

            echo 'Attributes: ';
            var_dump($t_variation->get_attributes());
            echo '<br />';
            
            $t_regular_price = $t_variation->get_regular_price();
            echo 'Regular Price: '.$t_regular_price.'<br />';

            $t_sale_price = $t_variation->get_sale_price();
            echo 'Sale Price: '.$t_sale_price.'<br />';
            
            $t_weight = $t_variation->get_weight();
            echo 'Weight: '.$t_weight.'<br />';
            
            $t_length = $t_variation->get_length();
            echo 'Length: '.$t_length.'<br />';
            
            $t_height = $t_variation->get_height();
            echo 'Height: '.$t_height.'<br />';
            
            $t_width = $t_variation->get_width();
            echo 'Width: '.$t_width.'<br />';
            
            echo '</p></div>';
        }
    }
}

?>

Enter the source ID and the target ID and hit save, then it will dispaly any variations in the source and target products. If you want to perform the copy, enter ‘yes’ in the last field and hit save again.

The issue I am having is that it is not saving the new variations to the target product. I VAR DUMPED every possible variable and the data is there in the right places. After the save command, the ID does increment for each new variation, however, either the save() is not working properly for some reason or WooComerce is deleting the saved variation immediately after the save.

What am I missing or doing wrong?

Avoid php malicious code hidden in uploaded image files? [duplicate]

I have created a PHP class which I use to resize uploaded images.
The class checks the extension of the file and accordingly calls the proper function to start editing the image, like imagecreatefromjpeg, imagecreatefrompng, and so on…

I read that it is possible to embed malicious code in the EXIF data or other part of an image.

So how can I optimize my code and make it more secure in order to prevent that a compromised image file can run malicious code?
Is there a better way to detect the file type other that checking at its extension?

I already checked the answers given to another question (Malicious Code Through Image Upload), but it doesn’t tackle all my doubts.

A more robust code would help everyone handling uploaded images with PHP.

The workflow I am using is basically this for a JPEG file:

$uploaded_file = 'uploaded/image.jpg';
$destination_file_url = 'uploaded/image_resized.jpg';
$extension = strtolower(strrchr($uploaded_file, '.'));

.....

if (getimagesize($uploaded_file) === false) {
   die("This is not an image!");
}

$newImage = imagecreatetruecolor($newWidth, $newHeight);
$image = imagecreatefromjpeg($uploaded_file);

imagecopyresampled($newImage, $image, $cropStartX, $cropStartY, 0, 0, $optimalWidth, $optimalHeight, $original_width, $original_height);

$exif = @exif_read_data($uploaded_file);
.....

imageinterlace($newImage, 1);
imagejpeg($newImage, $destination_file, 90);

imagedestroy($image);
imagedestroy($newImage);

Thanks a lot for your help!