Docker- PHP application image for deployment not working locally

I am trying to test my php server to run the application before deploying it on AWS (first time) Doesn’t work for me locally with my docker configuration.

I use:

docker build -f docker-configs/php/Dockerfile -t php-service .

docker run -p 9000:9000  php-service

and there is no response from localhost:9000

Logs show:

[23-Aug-2023 08:37:53] NOTICE: fpm is running, pid 1

[23-Aug-2023 08:37:53] NOTICE: ready to handle connections

but can’t connect.

My Dockerfile

FROM php:8.2-fpm

RUN apt-get update && apt-get install -y 
    git 
    unzip 
    libicu-dev 
    libpq-dev 
    wget 
    && apt-get install -y 
    librabbitmq-dev 
    libssh-dev 
    sqlite3 
    libsqlite3-dev 
    && docker-php-ext-install 
    bcmath 
    sockets 
    pdo pdo_mysql pdo_sqlite 
    && pecl install amqp 
    && docker-php-ext-enable amqp

# Installing Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer --version

RUN apt-get -y install cron default-mysql-client

WORKDIR /app

# Copy application files into the container
COPY . /app

# Expose port 9000 for the PHP-FPM server
EXPOSE 9000

# The startup command to run PHP-FPM
CMD ["php-fpm"]

Also, I found out that – PHP-FPM doesn’t handle HTTP requests directly; it needs a web server like Nginx or Apache to translate HTTP requests into FastCGI requests that PHP-FPM can handle.

So I guess need image which I can access with HTTP request?

Also my docker-compose.yaml file

version: '3.8'
services:
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - "./docker-configs/nginx.conf:/etc/nginx/conf.d/default.conf"
      - ".:/app:cached"
  php:
    build:
      context: ./docker-configs/php
    volumes:
      - "./docker-configs/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
      - ".:/app:cached"
    environment:
      PHP_IDE_CONFIG: "serverName=Docker"

  database:
    image: nouchka/sqlite3:latest
    stdin_open: true
    tty: true
    volumes:
      - ./sqlite-data:/var/lib/sqlite

Can someone please help? Thanks

How to solve the Undefined MYSQLI and Uncaught TypeError: MySQLI_Query()

Please help me to solve this,

Warning: Undefined variable $mysqli in
C:xampphtdocssyslaporanauthauth.php on line 10

Fatal error: Uncaught TypeError: mysqli_query(): Argument #1 ($mysql)
must be of type mysqli, null given in
C:xampphtdocssyslaporanauthauth.php:10 Stack trace: #0
C:xampphtdocssyslaporanauthauth.php(10): mysqli_query(NULL,
‘SELECT * FROM t…’) #1 {main} thrown in
C:xampphtdocssyslaporanauthauth.php on line 10

I just update my XAMPP to the new one, and use PHP 8 right now. I just started to learning php and start with configure my login page.

Koneksi.php

Auth.php

Give me advice, Give me some codes to solve my problem

please help me and solve

my contact form not working …

0) {

$to = $_POST[‘to’][‘val’]; // “.
“Here are the details:

“;
foreach ($_POST as $key => $value) {
$email_body .= “” . $value[‘label’] . “: ” . $value[‘val’] . “

“;
}

$headers = “From:n”;
$headers.= “Content-Type:text/html; charset=UTF-8”;
if($email_address != “”) {
mail($to,$email_subject,$email_body,$headers);
return true;
}
}
?>

Problem authenticating users using ladps from 3 different windows domains

I am authenticating users using ladps from 3 different windows domains. Each has its own DC. I assign the certificates directly in the php code.
It works perfectly for only one domain.

Example:
After restarting Apache.
A user from domain1 logs in. It is authenticated and other users from domain1 can also authenticate.
If the user logs in from domain2 (or from another), he does not log in. An error of the certificate issuer failed to be verified appears in Apache’s error.log.
After restarting Apache.
A user from domain2 logs in. Users from domain1 (or from another) no longer.

important part of code:

               
                $certpath=$this->globalparameter->parameters["constants"]["CertifPath"];
                switch ($domainname) {
                      case "imofa":
                        $DC=$this->globalparameter->parameters["constants"]["DcIMF"];
                        $certname=$this->globalparameter->parameters["constants"]["CertifIMF"];  
                      break;
                      case "havexmobility2":
                        $upn=str_ireplace("mobility2","mobility",$upn);  //kvůli úpravě DC pro o365 
                        $DC=$this->globalparameter->parameters["constants"]["DcHXM"];
                        $certname=$this->globalparameter->parameters["constants"]["CertifHXM"]; 
                      break;
                    default:   // default je "havex2"
                        $upn=str_ireplace("havex2","havex",$upn);  //kvůli úpravě DC pro o365 
                        $DC=$this->globalparameter->parameters["constants"]["DcHXA"];
                        $certname=$this->globalparameter->parameters["constants"]["CertifHXA"];                      
                }

                ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);  //zapnout debug
                ldap_set_option(null, LDAP_OPT_X_TLS_CACERTDIR, $certpath);  
                ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, $certpath.'\'.$certname);                
                $s="ldaps://".$DC;
                $ds= ldap_connect($s,636);

        if ($ds) {
            ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
            ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
            error_reporting(0); 
            ldap_start_tls($ds);
            $r=ldap_bind ($ds, $upn, $password);
...
...
ldap_unbind($ds);

example log after restart apache – OK:

ldap_connect_to_host: TCP DCM1.HAVEXMOBILITY2.CZ:636
ldap_new_socket: 1660
ldap_prepare_socket: 1660
ldap_connect_to_host: Trying 192.168.30.250:636
ldap_pvt_connect: fd: 1660 tm: -1 async: 0
attempting to connect: 
connect success
TLS trace: SSL_connect:before SSL initialization
TLS trace: SSL_connect:SSLv3/TLS write client hello
TLS trace: SSL_connect:SSLv3/TLS write client hello
TLS trace: SSL_connect:SSLv3/TLS read server hello
TLS certificate verification: depth: 1, err: 0, subject: /DC=cz/DC=havexmobility2/CN=havexmobility2-DCM1-CA, issuer: /DC=cz/DC=havexmobility2/CN=havexmobility2-DCM1-CA
TLS certificate verification: depth: 0, err: 0, subject: /CN=DCM1.havexmobility2.cz, issuer: /DC=cz/DC=havexmobility2/CN=havexmobility2-DCM1-CA
TLS trace: SSL_connect:SSLv3/TLS read server certificate
TLS trace: SSL_connect:SSLv3/TLS read server key exchange
TLS trace: SSL_connect:SSLv3/TLS read server certificate request
TLS trace: SSL_connect:SSLv3/TLS read server done

example the same domain unable to get local issuer certificate:

connect success
TLS trace: SSL_connect:before SSL initialization
TLS trace: SSL_connect:SSLv3/TLS write client hello
TLS trace: SSL_connect:SSLv3/TLS write client hello
TLS trace: SSL_connect:SSLv3/TLS read server hello
TLS certificate verification: depth: 0, err: 20, subject: /CN=DCM1.havexmobility2.cz, issuer: /DC=cz/DC=havexmobility2/CN=havexmobility2-DCM1-CA
TLS certificate verification: Error, unable to get local issuer certificate
TLS trace: SSL3 alert write:fatal:unknown CA
TLS trace: SSL_connect:error in error
TLS: can't connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed (unable to get local issuer certificate).
ldap_err2string

Is it possible somewhere to force a reset before ldap_connect?

Export all contents from my Joomla website

I have a Joomla website and I recently discovered that there are a number of malicious files on different directories. I have a backup and want to setup a new Joomla site and use the previous website data from the backup database.

I checked the database and found that the content and category tables use the assets table. But do not know if there are other related tables or so. I checked the assets table and could not understand the use of lft and rgt columns.

I want to write a PHP script to copy content data from the old backup and write to a new Joomla site.

I am not that familiar with the Joomla db structure. If anyone can guide me to understand the table relations or refer me to a doc that would be a great help.

How to handle array_shift() on Null?

Please take a look at this code:

$end = isset($newvar) ? array($newvar) : null;
while($ends = array_shift($end)){
  ...

It was working well when I was using PHP 7.2, but after upgrading to 8.1, it throws:

PHP Fatal error: Uncaught TypeError: array_shift(): Argument #1 ($array) must be of type array, null given in /path/to/qanda.php:469

Any idea how can I fix it?

Laravel & Carbon : retrieve the next 5 days not week ends

I’m trying to get Carbon to retrieve the next 5 working days. Since my week ends are sundays and mondays, I have put the following code in my Laravel AppServiceProvider.php :

public function boot()
    {
        Carbon::setLocale(config('app.locale'));
        Carbon::setWeekendDays([
            Carbon::SUNDAY,
            Carbon::MONDAY,
        ]);
    }

Then, I use this code to display the next 5 working days :

<table>
    <tr style="font-size: medium;text-align: center">
      @for ($i=1; $i < 6; $i++)
        <td>{{ IlluminateSupportCarbon::now()->addWeekdays($i)->translatedFormat("D d") }}</td>
      @endfor
    </tr>
</table>

my problem is that Carbon is returning : tuesday, wednesday, thursday, friday, and monday.

So it seems like my setWeekendDays is ignored.

Any idea as to how achieve my goal please ?

Adam

broken php script link/page [closed]

I have a problem with this page https://orangeroommusic.com/artist-management it doesn’t display. I only see a white page then when I refresh it gives me a 500 server error.

I tried to re-install, refreshing it the file but still everypage works fine except https://orangeroommusic.com/artist-management

kind regards
johnny

tried to re intall it the file but still

Add a where condition to a joined table using NeoTable and Doctrine in PHP

I am using NeoTable and Doctrine for database interactions with php,
I need to add one where condition for a joined table, below is the controller code.

TutorTable::create($this->userRecord, $this->translator, $this->ismobile)
    ->base('student')
    ->parentTable('Student')
    ->childTable('Tutor')
    ->recordTemplateName('record')
    ->parentField('studentID')
    ->childField('tutorID')
    ->noAutoSuffix()
    ->m('ctrac')
    ->relateTable("StdIins")
    ->customRecordTemplate()
    ->getRecords($this->view);

$debug ? neolog("post tutor") : false

There are two models , Student and instructor, one student can have many Tutors and vise versa,
StdIins is the intermediate table that stores the relations between student and instructors, it contains columns StudentID, tutorID, centerID. I want to add a where condition in above code so that it fetches records for a specific centerID, Does anyone have any idea?

I tried putting a where condition directly for Studenttoins but it resulted in doctrine exception.

Keep getting black diamond question mark despite everything in UTF-8 in a PHP script [duplicate]

In a PHP script that should perform some tasks (no output except for logging messages) I extract data from MySQL DB. I noticed that echoing some data has black diamond question mark like Componenti Elettronici�. Seems that everything is in UTF-8 and I don’t know where that diamond comes from (no trace in DB field, apparently) and, most important, how to remove/replace

On top of PHP script I have:

ini_set('default_charset', 'utf-8');
header("Content-Type: application/json");

DB table collation is utf8_general_ci.

What I tried so far:

  • echo strlen($str); outputs 23, that is the real 22 chars of Componenti Elettronici + black diamond
  • echo mb_detect_encoding($str, mb_list_encodings(), true); outputs UTF-8
  • echo iconv(mb_detect_encoding($str, mb_list_encodings(), true), "UTF-8", $str); does not change output: the black diamond is still there, of course because I’m converting from UTF-8 to UTF-8, thus doing absolutely nothing

That black diamond prevents me from indexing data in an Elasticsearch environment, that’s the big problem

So, why I have that black diamond? How can I remove or replace it? Thanks in advance

PHP’s phar extension is missing

When I am running “composer -v” commond in kali linux terminal then this error is coming “PHP’s phar extension is missing. Composer requires it to run. Enable the extension or recompile php without –disable-phar then try again” why this error coming ?

enter image description here

Fichier php inaccessible [closed]

Bonjour,

j’ai un soucis que je n’ai jamais rencontré en plus de 10 ans de dev et là je sèche.

J’ai un fichier, qui est censé connecté un user google, mais ce fichier, même en tentant d’y accéder directement, me fou dehors.

Si j’y accède par http://localhost/pages/function/google_login_back.php, il me renvoi directement à la racine du dossier function, et je n’ai aucune idée de pourquoi..

Voici le code php de ce fichier

<?php
echo 'ok';
die();

if (!isset($_SESSION['email'])) {
    header('Location: http://localhost');
    die();
}

if ((isset($_SESSION['logged']) && $_SESSION['logged'] == false) || !isset($_SESSION['logged'])) {
    $usr = new jokerUser();

    $usr->googleAccount($_SESSION['email'], $_SESSION['fullname'], $_SESSION['verified']);

    if(isset($_SESSION['back_url'])){
        header('Location: ' . $_SESSION['back_url']);
    } else {
        header('Location: http://localhost');
    }
} 
else {
    echo 'Une erreur est survenue veuillez rééssayer. <a href="./">Retour à l'accueil</a>';
}

Et voici le htaccess que j’ai volontairement Allow pour des tests

Allow From All

Quelqu’un à déjà eu ce soucis svp ?

Je précise, je suis sous xampp, en php 8.2. J’ai codé avant-hier et tout fonctionnait, c’est aujourd’hui que je ne sais pour quel raison, il ne veut pas. Merci.

Tente d’accéder à un fichier php.

A way to showcase the Sales price to all the user in Woocommerce (B2b Site and using B2bking plugin )

I have a b2b woocommerce site and I’m using the b2bking plugin for this functionality. Now I want to create a stock clearance category where all of my users can view the decreased prices.
Now, on my site, I have made two groups: group 1 and Group 2, and the users in each are able to see the discounted price off the MSRP on whole site.
So, when I use the dynamic rule from the b2bking plugin for stock clearing, the rule applies to the MSRP rather than the price of each group.

I tested the dynamic rule, in which  any product in the stock clearance category would receive a 50% discount, however the discount is computed off the MSRP rather than the individual group price, which already includes the discount price off the MSRP.(Since we are B2B Site )
So here’s an example: Group 1 receives a 10% discount off the MSRP. Group 2 receives a 20% discount off the MSRP.
This is exactly what I want (Any logic applied 50% off group pricing)
Gropu 1 will have a 10% + 50% off MSRP.
Group 2 will receive a 20% + 50% discount off the MSRP.

How to handle getOffers request pagination on Mirakl PHP SDK for sellers?

I took care to read the documentation of the Mirakl PHP SDK, but I am facing an issue regarding the use of the API OF21: List offers of a shop. I use the PHP SDK in version 1.18.1

I want to retrieve all the offers from my shop (there are around 700) to store them once a day in a database on my side (and thus not systematically call the marketplace API).
In particular, I need to access the Offers > Active and Offers > Inactivity_reasons information that is not found in the API OF51 Get offers CSV file.

I’m using the PHP SDK so I understand there is a limit to the number of results returned, but I don’t see a way to handle pagination when using the SDK getOffers function

How to proceed to be able to retrieve and store on my side the list of all the offers via this API OF21, because I don’t see anything about the possibility of using pagination in the getOffers function (expected parameters in particular)?

Thank you for your help.

For reference, here’s, in a simplified way, what I was headed for

$api = new ShopApiClient($apiUrl, $apiKey, $shopId);

function fetchAllOffers(ShopApiClient $api, $shopId) {
    $allOffers = [];
    $offset = 0;
    $max = 100; // Max query results

    $totalOffersCount = 0; // Initialiser à 0
    do {
        $request = new GetOffersRequest($shopId);
        $request->set('max', $max);
        $request->set('offset', $offset);
    
        $promise = $api->async()->getOffers($request);
        $response = $promise->wait();
    
        // Read and json_decode the response
        $body = (string) $response->getBody();
        $data = json_decode($body, true);
        
        // Get the total offers count
        $totalOffersCount = $data['total_count'] ?? 0;

        $offers = $data['offers'] ?? [];
    
        $allOffers = array_merge($allOffers, $offers);
        $offset += $max;
    
    } while (count($allOffers) < $totalOffersCount);

    return $allOffers;
}

function displayOffers($allOffers) {
    echo '<table border="1">';
    echo '<tr><th>SKU</th></tr>';

    foreach ($allOffers as $offer) {
        echo '<tr>';
        echo '<td>' . $offer['product_sku'] . '</td>';
        echo '</tr>';
    }

    echo '</table>';
}

try {
    $allOffers = fetchAllOffers($api, $shopId);
    displayOffers($allOffers);
} catch (ClientException $e) {
    echo 'Error : ' . $e->getMessage();
}```