Sometime this PHP code works and sometime don’t.. why?

I created a Php program in which a user will give his name and phone number and then the program will redirect to another Php file which is a preview page, after submitting it will go to the previous page and if everything is right it will show us ‘batch added successfully”, else it will show “duplicate value not possible”. Now yesterday this program worked, but today it is not working and fun fact, this same problem happened to my friend and i changed from $res = mysqli_query($conn, $sql); to $res = mysqli_query($conn,$sql); and it worked. But today both cases are not working in my program. Note : “phonenumber” is here UNIQUE in my “login” table and I am using XAMPP.

Code for pracaddtudent.php

<?php
include('connect1.php');
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="pracaddstudentsave.php" method="POST">
        <input type="text" name="sname" placeholder="enter student name">
        <input type="text" name="phonenumber" placeholder="enter student phonenumber">

        <input type="submit" name="add" value="Submit">
        <input type="reset" name="reset" value="Reset">
    </form>
    <?php if (isset($_SESSION['add'])) {
    echo $_SESSION['add'];
    unset($_SESSION['add']);
} ?>
</body>
</html>

Code for pracaddstudentsave.php

<?php

include('connect1.php');

$sname = $_POST['sname'];
$phonenumber = $_POST['phonenumber'];



?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>
    <div class="submit-form">
        <form action="" method="post">
          <input type="text" value=<?php echo $sname; ?> name="sname" readonly> 
          <input type="text" value=<?php echo $phonenumber; ?> name="phonenumber" readonly>
       
<input type="submit" name="save_student" value="Submit">
<input type="reset" name="reset" value="Reset">
        </form>
    </div>
</body>
</html>
<?php
    if (isset($_POST['save_student']) && $_POST['sname'] !="" ) {
       
        $sql = "insert into login set 
        sname='$sname',phonenumber='$phonenumber'";
        // $sql = "INSERT INTO login (sname, phonenumber) 
            // VALUES ('$sname', '$phonenumber')";
        $res = mysqli_query($conn,$sql);

        if ($res == true) {
            $_SESSION['add']= "Batch Added Successfully";
            header("Location:pracaddstudent.php");
            
        } else {
            
            $_SESSION['add']="Duplicate Value Not Possible";
            ?>
 <script> location.replace("pracaddstudent.php"); </script> 
            <?php
           echo mysqli_error($conn);
            
      }
}
?>

I tried it several times and most of the time it showed me “Duplicate value not possible” but yesterday same code worked. I was expecting it to work every time just like other web applications do. I also believe that there can be a problem about Session handling.

Laravel Livewire Event Not Received in Component After Pusher Broadcast

livewire=3 laravel =10
I am working on a Laravel project that uses Livewire for real-time messaging, with events being broadcasted via Pusher. The issue I am facing is that the event is recognized by Pusher, but my Livewire component is not receiving the broadcasted event.

Pusher Setup:
I have set up Pusher and can see events being broadcasted successfully in the Pusher dashboard.
The Pusher setup in resources/js/app.js looks like this:

import Echo from "laravel-echo";

import Pusher from "pusher-js";
window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: "pusher",
    key: import.meta.env.VITE_PUSHER_APP_KEY,
    cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? "mt1",
    wsHost: import.meta.env.VITE_PUSHER_HOST
        ? import.meta.env.VITE_PUSHER_HOST
        : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
    wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
    wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
});

and the event from livewire

$members = ConversationMember::where('conversation_id', $this->conversationId)->get();
        foreach ($members as $member) {
            if ($member->user_id != Auth::id()) {
                event(new MessageSent($this->newMessage, Auth::id(), $member->user_id, $this->conversationId));
            }
        }

MessageSent.php

<?php

namespace AppEvents;

use IlluminateBroadcastingChannel;
use IlluminateBroadcastingInteractsWithSockets;
use IlluminateFoundationEventsDispatchable;
use IlluminateQueueSerializesModels;
use IlluminateContractsBroadcastingShouldBroadcastNow;

class MessageSent implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $message;
    public $user_id;
    public $res_id;
    public $conversation_id;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($message, $user_id, $res_id, $conversation_id)
    {
        $this->message = $message;
        $this->user_id = $user_id;
        $this->res_id = $res_id;
        $this->conversation_id = $conversation_id;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return IlluminateBroadcastingChannel|array
     */
    public function broadcastOn()
    {
        return new Channel("users.{$this->user_id}");
    }

    /**
     * Get the broadcastable data.
     *
     * @return array
     */
    public function broadcastWith()
    {
        return [
            'conversation_id' => $this->conversation_id,
            'user_id' => $this->user_id,
            'message' => $this->message,
            'res_id' => $this->res_id,
        ];
    }
}

the event listener

  public function getListeners()
    {

        return [
            "echo-private:users.{$this->user_id},.App\Events\MessageSent" => 'receiveMessage_e',
            'conversationSelected' => 'loadConversation',
            'conversationStarted' => 'handleConversationStarted',
            'messageReceived' => 'receiveMessage'
        ];
    }

public function receiveMessage_e($event)
{
    dd($event); // This never gets triggered
}

and last the debug console “pusher” pusher

I configured Pusher correctly in app.js and verified that events are being broadcasted successfully to the Pusher dashboard. In my Livewire component, I set up the getListeners method to listen for the MessageSent event using the correct channel and event syntax.

What I Expected:
I expected the Livewire component to receive the broadcasted event and trigger the receiveMessage_e method, which would dump the event data.

What Happened:
The event was successfully broadcasted to Pusher, but the receiveMessage_e method in the Livewire component was never triggered, and the event data was not received in the browser.

Why getting this error message submitting a cakePHP file upload form data?

I added enctype=”multipart/form-data” In the form with the input fields for files or images.

Please, can you help me review my codes and why I have this error message issue below on trying to upload and submit a file form? :

” Call to a member function getClientFilename () on string”

I’m thinking the issue could be from my database structure.

I have included the link to my controller, template and MySQL file in GitHub.

https://github.com/olaolu20077

In “newprojectz” controller file and other necessary files.

Thank you.

I added enctype=”multipart/form-data” In the form with the input fields for files or images.

I expected graphics files are array of string and making my form field a multi part attributes would help in both array and string form input submission.

how to store created jpg file in my site root (images) no download by in php [duplicate]

my php code creat jpg file and download

require_once('persian_txt2pic.php');
 $mor_Radio = $_POST['mor-Radio'];
if ($mor_Radio == 'saat') { $im = imagecreatefromjpeg('saati.jpg'); } else { $im = imagecreatefromjpeg('rooz.jpg'); } 
....
.....    
if ($mor_Radio == 'saat') { 
    $mor_date = $_POST['mor-date'];
    $name = $_POST['mor-name'];
  .....
.....
    $mor_day_helper = imageTTFBbox(12,0,$font,$mor_day);
    $base_loc_mor_day = abs($mor_day_helper[4] - $mor_day_helper[0]);
    @imagettftext($im, 12, -1,158-$base_loc_mor_day, 155, $blue, $font, $mor_day);*/
        
    $mor_day_helper = imageTTFBbox(12,0,$font,$mor_date);
    .....
} else { 
    ....
} 
header('Content-type: image/jpeg');
header('Content-Disposition: attachment; filename="'.$_POST['mor-name']."_".$nowdate."_".$mor_Radio.'".jpg"');

    // download jpg
    imagejpeg($im);
   // Free up memory
imagedestroy($im);

but i want can the jpg file save to my folder in my site root (images)

InvalidRequestSignature on Amazon Pay API SDK (PHP)

I got this error after $client->createCheckoutSession($payload, $headers):

"{"reasonCode":"InvalidRequestSignature","message":"Unable to verify signature, signing String [AMZN-PAY-RSASSA-

My customer gives me the public_key_id and pem file via Amazon Seller Central, the public_key_id is correct.

Could this error be caused by an incorrect PEM file? Should I ask the customer to verify if the PEM file was downloaded from Amazon Seller Central?

I have already run the same code on two different devices and confirmed that the environment meets the SDK requirements.

Thank you.

My code:

<?php
require __DIR__ . '/vendor/autoload.php';
$amazonpay_config = array(
    'public_key_id' => 'SANDBOX-XXXXXXX',
    'private_key'   => './private.pem',
    'region'        => 'US',
    'algorithm'     => 'AMZN-PAY-RSASSA-PSS-V2',
);

$payload = array(
'webCheckoutDetails' => array(
    'checkoutReviewReturnUrl' => 'https://localhost/store/checkout_review',
    'checkoutResultReturnUrl' => 'https://localhost/store/checkout_result'
),
'storeId' => 'amzn1.application-oa2-client.XXXXXXXXXXX'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
$client = new AmazonPayAPIClient($amazonpay_config);
$resultCheckOut = $client->createCheckoutSession($payload, $headers);

var_dump($resultCheckOut);exit;

How to Add a New Line Break in WhatsApp API Messages?

I’m working with the WhatsApp API and trying to send a message in php that includes a new line break. However, I’m having trouble getting the line break to appear in the message.

  $msg  =  'Name : '.$posted_data['text-438'];
  $msg  .= 'Phone Number : '.$posted_data['tel-214'];
  $msg  .= 'Email : '.$posted_data['email-809'];
  $msg  .= 'Course : '.$posted_data['menu-290'][0];
  $msg  .= 'Message : '.$posted_data['textarea-412'];
  $txtMessage = $msg;

%0A,
,n , \n , <br/> , rn , %%0A , %0A , %5Cn , rn , %0D , %0a , %0d%0a , %%0a , %%0A ,nl2br

I tried Above codings .. but none of these not working

Is there a specific way to format messages to include line breaks in the WhatsApp API? Any guidance or suggestions would be greatly appreciated.

Is there any way that can fix this fatal error? [duplicate]

This is the problem I’m encountering right now.

enter image description here

I’ve been fixing this for 3 days now and I can’t seem to find what’s the solution here. I tried to reinstall my xampp but it didn’t fix anything. I used PHP programming language and this is our Capstone Project.

I’m expecting that it’ll get this fixed.

Laravel register singleton in class constructor

Is it ok to register singleton in constructor instead of service provider? any drawback?

E.g. i have an abstract class

abstract class AbstractClassA
{
    public function __construct()
    {
        app()->singleton(get_class($this), $this);
    }
    ...
}

So that any class that extends it will automatically register singleton.

Tested working. Just curious any bug/issue if doing this

$passwords_manager->validate impossble [duplicate]

I have a problem for a few days now, I can’t check the phpbb3 password stored in my database (HASH) but I really can’t do it after a sleepless night, I turns towards you.

I created a phpbb3 forum but my site is not just a forum so on my login page I need to check the password but impossible

here is my PHP code which serves as an API for calls to the database

my file tree is

CSS
Forum(phpbb3)
Image
JS
translation
Video
Dowload.html
Forum.html
Login.html
SingUp.html
Status.html
api.php

<?php
header("Content-Type: application/json");

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './Forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx); 




$servername = "localhost";
$dbUsername = "root";
$dbPassword = "";  // Renommé pour éviter toute confusion
$dbname = "phpbb3";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbUsername, $dbPassword);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    http_response_code(500);
    echo json_encode(["message" => "Connection failed: " . $e->getMessage()]);
    exit();
}

$method = $_SERVER['REQUEST_METHOD'];
$input = json_decode(file_get_contents('php://input'), true);

switch ($method) {
    case 'POST':
        if (isset($input['username']) && isset($input['password'])) {
            loginUser($input['username'], $input['password']);
        } else {
            http_response_code(400);
            echo json_encode(["message" => "Username and password are required"]);
        }
        break;
    case 'OPTIONS':
        http_response_code(200);
        exit();
    default:
        http_response_code(405);
        echo json_encode(["message" => "Method not allowed"]);
        break;
}

function loginUser($username, $password) {
    global $conn;

    $phpbb_container = phpbbdicontainer::get_instance();
    // Obtenez le gestionnaire de mots de passe
    $passwords_manager = $phpbb_container->get('passwords.manager');

    // Préparer la requête pour récupérer le hash du mot de passe pour l'utilisateur donné
    $stmt = $conn->prepare("SELECT username, user_password FROM phpbb_users WHERE username = :username");
    $stmt->bindParam(':username', $username);
    $stmt->execute();
    $result = $stmt->fetch(PDO::FETCH_ASSOC);

    // Vérifier si un résultat a été trouvé
    if ($result) {
        // Afficher le hash du mot de passe
        echo json_encode($result['user_password']);

        // Vérifier si le mot de passe fourni correspond au hash dans la base de données
        if ($passwords_manager->validate($password, $result['user_password'])) {
            echo json_encode(["message" => "Connection reussi: "]);
            exit();
        } else {
            echo json_encode(["message" => "Nom d'utilisateur ou mot de passe incorrect.", "status" => "error"]);
        }
    } else {
        echo json_encode(["message" => "Nom d'utilisateur ou mot de passe incorrect.", "status" => "error"]);
    }
}
?>

//I can't use
$phpbb_container = phpbbdicontainer::get_instance();
$passwords_manager = $phpbb_container->get('passwords.manager');
if ($passwords_manager->validate($password, $result['user_password']))

here is the answer it gives me

General Error

/* <![CDATA[ */

  • { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: “Lucida Grande “, Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } #wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } .panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px #A9B8C2; } #errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } #errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em “Lucida Grande “, Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; }
    /* ]]> */
    Return to index page

    General Error

    Illegal use of $_SERVER. You must use the request class to access input data. Found in C:wamp64www????api.php on line 26. This error message was generated by deactivated_super_global.

    Please notify the board administrator or webmaster: [email protected]

    Powered by phpBB® Forum Software © phpBB Limited

Class “FFMpegFFMpeg” not found

I installed ffmpeg on xampp by COMPOSER. I installed FFMPEG on windows before.
enter image description here

Then with the command composer require php-ffmpeg/php-ffmpeg installed php-ffmpeg
enter image description here

I use code below (from php-ffmpeg github) for a test but this does not work

<?php

require '../../phpMyAdmin/vendor/autoload.php';

$ffmpeg = FFMpegFFMpeg::create(); // line 5 that error referees to 
$video = $ffmpeg->open('video.mpg');
$video
    ->filters()
    ->resize(new FFMpegCoordinateDimension(320, 240))
    ->synchronize();
$video
    ->frame(FFMpegCoordinateTimeCode::fromSeconds(10))
    ->save('frame.jpg');
$video
    ->save(new FFMpegFormatVideoX264(), 'export-x264.mp4')
    ->save(new FFMpegFormatVideoWMV(), 'export-wmv.wmv')
    ->save(new FFMpegFormatVideoWebM(), 'export-webm.webm');

?>

This is the error I encounter.
enter image description here

I read many and many similar questions but almost all of them suggest require '../../phpMyAdmin/vendor/autoload.php'; that I have it in my code.

PHP 2D array finding values by certain criteria

Each item of PHP 2D array $g contains

  • ID in index 0,
  • delay in index 5,
  • binary in index 6,
  • category in index 7,
  • weight in index 8

For each ID show cat for binary 1 having highest delay along with weight and category for binary 0 having highest delay along with weight.

If multiple categories have delay within 60 between each other, chose the one where weight for binary 0 and 1 for the same category and delay are closest to each other. The categories shown for 0 and 1 must be the same.

Example data

<?php

$g[0]=array('18572','1713654000','751','759','aB3cD','14','0','38','160','1');
$g[1]=array('18572','1713654000','751','759','eF4gH','14','0','40','169','1');
$g[2]=array('18572','1713654000','751','759','J7kLm','14','0','42','182','1');
$g[3]=array('18572','1713654000','751','759','N8oPq','14','0','44','199','1');
$g[4]=array('18572','1713654000','751','759','R1sTu','14','0','46','217','1');
$g[5]=array('18572','1713654000','751','759','vW9xY','14','0','48','237','1');
$g[6]=array('18572','1713654000','751','759','zZ2aB','14','0','50','252','1');
$g[7]=array('18572','1713654000','751','759','6C7dE','25056','0','38','157','1');
$g[8]=array('18572','1713654000','751','759','fG8hI','25056','0','42','177','1');
$g[9]=array('18572','1713654000','751','759','L3mNo','25056','0','44','193','1');
$g[10]=array('18572','1713654000','751','759','pQ4rS','25056','0','46','210','1');
$g[11]=array('18572','1713654000','751','759','T5uVw','25056','0','48','229','1');
$g[12]=array('18572','1713654000','751','759','xY6zA','25056','0','50','244','1');
$g[13]=array('18572','1713654000','751','759','B7cDe','25057','0','40','165','1');
$g[14]=array('18572','1713654000','751','759','F9gHj','14','1','38','235','1');
$g[15]=array('18572','1713654000','751','759','Q2rSt','14','1','40','219','1');
$g[16]=array('18572','1713654000','751','759','V4wXy','14','1','42','201','1');
$g[17]=array('18572','1713654000','751','759','Z5aBc','14','1','44','184','1');
$g[18]=array('18572','1713654000','751','759','gH6iJ','14','1','46','170','1');
$g[19]=array('18572','1713654000','751','759','kL7mN','14','1','48','159','1');
$g[20]=array('18572','1713654000','751','759','oP8qR','14','1','50','153','1');
$g[21]=array('18572','1713654000','751','759','rS9tU','25056','1','38','242','1');
$g[22]=array('18572','1713654000','751','759','vW1xY','25056','1','42','207','1');
$g[23]=array('18572','1713654000','751','759','zX2aB','25056','1','44','189','1');
$g[24]=array('18572','1713654000','751','759','D3eFg','25056','1','46','175','1');
$g[25]=array('18572','1713654000','751','759','E4fGh','25056','1','48','163','1');
$g[26]=array('18572','1713654000','751','759','F5gHi','25056','1','50','156','1');
$g[27]=array('18572','1713654000','751','759','G6hIj','25057','1','40','226','1');
$g[28]=array('18573','1713654000','755','745','H7jK8','23734','0','58','224','1');
$g[29]=array('18573','1713654000','755','745','I8kL9','23734','0','60','251','1');
$g[30]=array('18573','1713654000','755','745','J9lM0','23792','0','54','195','1');
$g[31]=array('18573','1713654000','755','745','K0mN1','25057','0','48','156','1');
$g[32]=array('18573','1713654000','755','745','L1nO2','25057','0','50','167','1');
$g[33]=array('18573','1713654000','755','745','M2oP3','25057','0','52','179','1');
$g[34]=array('18573','1713654000','755','745','N3pQ4','25057','0','54','194','1');
$g[35]=array('18573','1713654000','755','745','O4qR5','25057','0','56','210','1');
$g[36]=array('18573','1713654000','755','745','P5rS6','25057','0','58','224','1');
$g[37]=array('18573','1713654000','755','745','Q6sT7','25057','0','60','251','1');
$g[38]=array('18573','1713654000','755','745','R7tU8','24938','1','48','243','1');
$g[39]=array('18573','1713654000','755','745','S8uV9','24938','1','52','204','1');
$g[40]=array('18573','1713654000','755','745','T9vW0','24938','1','54','187','1');
$g[41]=array('18573','1713654000','755','745','U0wX1','25057','1','48','244','1');
$g[42]=array('18573','1713654000','755','745','V1xY2','25057','1','50','222','1');
$g[43]=array('18573','1713654000','755','745','W2yZ3','25057','1','52','205','1');
$g[44]=array('18573','1713654000','755','745','X3zA4','25057','1','54','188','1');
$g[45]=array('18573','1713654000','755','745','Y4aB5','25057','1','56','175','1');
$g[46]=array('18573','1713654000','755','745','Z5bC6','25057','1','58','166','1');
$g[47]=array('18573','1713654000','755','745','a6C7d','25057','1','60','153','1');
$g[48]=array('18574','1713657600','749','817','b8D9e','28656','0','32','149','1');
$g[49]=array('18574','1713657600','749','817','c9E0f','28656','0','34','161','1');
$g[50]=array('18574','1713657600','749','817','d0F1g','28656','0','36','173','1');
$g[51]=array('18574','1713657600','749','817','e1G2h','28656','0','38','191','1');
$g[52]=array('18574','1713657600','749','817','f2H3i','28656','0','40','206','1');
$g[53]=array('18574','1713657600','749','817','g3I4j','28656','0','42','221','1');
$g[54]=array('18574','1713657600','749','817','h4J5k','28656','0','44','250','1');
$g[55]=array('18574','1713657600','749','817','i5K6l','28656','1','32','262','1');

The code below works well for highest delay, but for lowest returns the same. How should I modify the code to work correctly for lowest as well? E. g. for the ID 18572 the output should be Lowest Delay: cat: 44, Outcome 0: 184, Outcome 1: 199, Delay: 14


$g = array ( /* see example data above */);
$groupedById = [];

foreach ($g as $entry) {
    $id = $entry[0];
    if (!isset($groupedById[$id])) {
        $groupedById[$id] = [];
    }
    $groupedById[$id][] = $entry;
}

foreach ($groupedById as $id => $entries) {
    $bin0 = [];
    $bin1 = [];

    foreach ($entries as $entry) {
        if ($entry[6] == '0') {
            $bin0[] = $entry;
        } elseif ($entry[6] == '1') {
            $bin1[] = $entry;
        }
    }

    usort($bin0, fn($a, $b) => $b[5] - $a[5]);
    usort($bin1, fn($a, $b) => $b[5] - $a[5]);

    $highest = getBestMatch($bin0, $bin1);
    $lowest = getBestMatch(array_reverse($bin0), array_reverse($bin1));

    echo "ID: $idn";
    echo "Highest Delay:n";
    echo "cat: {$highest['cat']}, Bin 0: {$highest['$w0']}, Bin 1: {$highest['$w1']}, Delay: {$highest['delay']}n";
    echo "Lowest Delay:n";
    echo "cat: {$lowest['cat']}, Bin 0: {$lowest['$w0']}, Bin 1: {$lowest['$w1']}, Delay: {$lowest['delay']}n";
}

function getBestMatch($bin0, $bin1) {
    $bestMatch = null;
    $minwDiff = PHP_INT_MAX;

    foreach ($bin0 as $o0) {
        foreach ($bin1 as $o1) {
            if ($o0[7] == $o1[7] && abs($o0[5] - $o1[5]) <= 60) {
                $wDiff = abs($o0[8] - $o1[8]);
                if ($wDiff < $minwDiff) {
                    $minwDiff = $wDiff;
                    $bestMatch = [
                        'cat' => $o0[7],
                        '$w0' => $o0[8],
                        '$w1' => $o1[8],
                        'delay' => max($o0[5], $o1[5]),
                    ];
                }
            }
        }
    }

    return $bestMatch;
}

?>

SLES 15 SP6 – Problem with Passbolt-Installation – ERROR: unable to bind listening socket for address ‘/run/php-fpm/www.sock’: Permission denied (13)

we will install the Passbolt-Password-Manager on a SLES-System.

We use SLES 15 SP6. We are follow the Instrauction from this Installation-Guide:

https://www.passbolt.com/docs/hosting/install/ce/sles/

After the last Step:

sudo /usr/local/bin/passbolt-configure

we have set the Path to the Certificates an start the Process and End with this Message:

Setting up SSL...
    Do you want to setup a SSL certificate and enable HTTPS now?
    - manual: Prompts for the path of user uploaded ssl certificates and set up
nginx
    - auto:   Will issue a free SSL certificate with https://www.letsencrypt.org
 and set up nginx
    - none:   Do not setup HTTPS at all
================================================================================
1) manual
2) auto
3) none
#? 1
Enter the path to the SSL certificate: /root/cert.pem
Enter the path to the SSL privkey: /root/key.pem
=============================
Installing os dependencies...
=============================
====================================
Opening ports 80 and 443 on firewall
====================================
success
success
===================
Setting up nginx...
===================
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
/usr/local/bin/passbolt-configure: line 645: [: missing `]'
extension=gnupg.so
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
Job for php-fpm.service failed because the control process exited with error code.
See "systemctl status php-fpm.service" and "journalctl -xeu php-fpm.service" for details.

When we type:

systemctl status php-fpm.service

and become this Message:

php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Fri 2024-08-16 10:32:54 CEST; 5min ago
    Process: 7426 ExecStart=/usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php8/fpm/php-fpm.conf (code=exited, status=78)
   Main PID: 7426 (code=exited, status=78)
        CPU: 153ms

Aug 16 10:32:54 LX-test0100 systemd[1]: Starting The PHP FastCGI Process Manager...
Aug 16 10:32:54 LX-test0100 php-fpm[7426]: [16-Aug-2024 10:32:54] ERROR: unable to bind listening socket for address '/run/php-fpm/www.sock': Permission denied (13)
Aug 16 10:32:54 LX-test0100 php-fpm[7426]: [16-Aug-2024 10:32:54] ERROR: FPM initialization failed
Aug 16 10:32:54 LX-test0100 systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG
Aug 16 10:32:54 LX-test0100 systemd[1]: php-fpm.service: Failed with result 'exit-code'.
Aug 16 10:32:54 LX-test0100 systemd[1]: Failed to start The PHP FastCGI Process Manager.

Can you help me to install passbolt? What is the Reason?

FilamentPHP – Table actions not firing

I have a table function in a custom Filament page:

I have initialized the page like this:

class IncentiveOverview extends Page implements HasTable, HasForms, HasActions
{
    use InteractsWithTable;
    use InteractsWithForms;
    use InteractsWithActions;
    use HasTabs;
    
    //...

And my table like below:

public function table(Table $table): Table
    {
        return $table
        ->query(function (): Builder {
                return $this->getIncentiveRequests()->groupBy(['branch_id', 'department_id']);
            })
            ->modifyQueryUsing($this->modifyQueryWithActiveTab(...))
            ->columns([
                TextColumn::make('department.name')
                    ->label('Department')
                    ->sortable(),
                TextColumn::make('gp')
                    ->label('GP')
                    ->money('eur', true)
                    ->state(function ($record) {
                        return $this->calculateGP($record);
                    })
                    ->sortable(),
            ])
            ->actions([
                Action::make('view_incentive_details')
                    ->label('View Incentive Details')
                    ->action(function ($record) {
                        dd($record);
                    })
                ]);
    }

Then, the blade view is looking like this:

<x-filament::page>
    <div class="flex flex-col gap-4">
        <x-filament-panels::resources.tabs />
        <div class="relative">
            {{ $this->table }}
        </div>
         <x-filament-actions::modals />
    </div>
</x-filament::page>

When I try to trigger the view_incentive_details, I would for now, expect that it would just dd the $record, however, when I click it, a spinner is just shown briefly:

image

Is there a way to dynamically make functions public in the child class?

I have an interface class that is used for API, and most of the functions are protected.
So when I do unit test on these, I normally create a child test class from the target class I want to test, and overwrite the visibility of the parent class’ functions for testing.

My question is if there is a way to simplify this by doing this dynamically, which would simplify the maintenance? Let’s say in the tester class’ constructor – or any other way?