Can’t install latest version of laravel on my windows with php8 installed [closed]

Due to some issues I encountered in my laravel 7 project, I decided to upgrade to the latest version.
So, I updated my composer version and installed php8 (I was previously running php7).
After installing composer, I installed laravel globally using composer global require laravel/installer.

At the end of the installation, the CLI showed me that the system is using laravel 5 installer as shown in the image below:

CLI showing laravel 5 installer

When I proceeded to install latest version of my laravel project using composer create-project laravel/laravel project-name --prefer-dist, it still installs laravel version 5.1

My composer.json is as shown below:

Composer.json

How can I fix this?

I have tried manually installing php8 from the official site. Did not work either.
I am currently using php8 built in xampp.
Composer version 2.6.2

Thank you very much.

How to call 2 different symfony voters

I have a symfony voter in a bundle that lives in the vendor folder. it works as expected:

class PlaylistVoter extends Voter
{

public function __construct()
    {}

    protected function supports($attribute, $subject)
    {}

    protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
      if(<someclause>) {
          return true;
      }

      return false;
    }

}

I am now configuring another voter, but this is in the symfony core (/src/mybundle). It is pretty much the same as the previous one, only the content of the voteOnAttribute method changes.

Using breakpoints, I can see the voteOnAttribute method in the voter in vendor gets called as expected, but the one in the voter in the core never gets called.

using debug:container, I can see they are both correctly configured. Also I can see the constructor gets called, but voteOnAttribute gets not.

thanks for any suggestion.

Javascript not working eptialy preent default

see below my code e.prevnt default not working the form got submited :

this is the modal its working without any probleme the only issue is preventing submition
so I need your help please take a look at this and let me know

   <div id="Edit-ROT" class="modal fade" tabindex="0" role="dialog" aria-labelledby="add-contactLabel" aria-hidden="true">
                        <div class="modal-dialog">
                <div class="modal-content">
                
                
                    <div class="modal-header">
                        <h5 class="modal-title" id="add-contactLabel">Modifier Recommandation OT</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    </div>
                    <div class="modal-body">
                    <div class="statusMsg"></div>
                    <div class="alert alert-success alert-dismissible" id="success" style="display:none;">
              <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
            </div>
               
                          
            <form id="ModifierROT" action="" method="post" >
                            
                        
                          
                                          
                                              
                                     <input type='hidden' name='ajouter' value='modifier_rot'/>
                      <input type='hidden' name='ideditROT' id='ideditROT' value=''/>
                            
                        
                     
                    
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default " data-dismiss="modal">Cancel</button>
                        <input type="submit" class="btn btn-primary "  id='submitbtn' name="ajouter_caution" value="Enregistrer">
                    </div>
                       </form>
            
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
        </div><!-- /.modal -->
            </div><!-- /.modal -->

this is the JS its working without any probleme the only issue is preventing submition
so I need your help please take a look at this and let me know if you require any further help

        // Modifier ROT


   $("#Modifierrot").on('submit', function(e){
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'caution/nouvelle_caution.php',
            data: new FormData(this),
            dataType: 'json',
            contentType: false,
            cache: false,
            processData:false,
            beforeSend: function(){
                $('.submitBtn').attr("disabled","disabled");
                $('#Modifierrot').css("opacity",".5");
            },
            success: function(response){
                $('.statusMsg').html('');
                if(response.status == 1){
                    $('#Modifierrot')[0].reset();
                    
             $('.statusMsg').html('<p class="alert alert-success">'+response.message+'</p>').delay(5000).fadeOut('slow');
                    
                }else{
                    $('.statusMsg').html('<p class="alert alert-danger">'+response.message+'</p>');
                }
                $('#Modifierrot').css("opacity","");
                $(".submitBtn").removeAttr("disabled");
            
             },
    error : function(request, status, error) {

        var val = request.responseText;
        alert("error"+val);
    }
        });
    });

PHP $_SESSION is inconsistent while authentication

I am trying to build an authentication system into my php website. I have no experiences with it so I go by documentation. No Frameworks or anything. Just plain vanilla PHP with a XAMPP Tech Stack on Windows.

  1. I check on my index.php at the beginning if the Session is already running. If not, create one with a dedicated Session Name, since I have several web services on my Apache and they shouldnt interfere with eachother.
  2. Then start the session if none is there.
  3. Check if $_SESSION[“loggedin” => true]. If yes, give me the content of the website. If not, display a login window
  4. After authentication in the login window, the website should redirect to the index.php, so the initialized $_SESSION will be validated again where $_SESSION[‘loggedin’ => true] and the content will be visible.

1. Problem: index.php

At any time when the index.php is checking the session, the session is not existent. And if php initializes it, it is filled like that $_SESSION[“loggedin” => false];. After the authentication it is supposed to be true. And before authentication $_SESSION[“loggedin”] it shouldnt be set at all since this step is only performed a few lines below.

2. Problem: The Controller post_login.php

After I start the session, the session is already authenticated with $_SESSION[“logged => true, “user” => “KENNUNG”];
How is it possible that index.php and post_login.php are handling different sessions? Or at least different session states?

The code is as follows:

/index.php

<?php

include_once("Config/settings.php"); //Some config values like $appName

if(!isset($_SESSION)) {
    session_name($appName);
    session_start([
        'cookie_lifetime' => 86400,
        //'cookie_domain' => $actual_link,
        'gc_maxlifetime'  => 86400,
        'use_cookies' => 1,
        'use_only_cookies' => 1
    ]);
}
// $_SESSION is already $_SESSION['loggedin' => false] at this point (?)

error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);

$ROOT = __DIR__;
$content = "";

if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] == 1) {
    $content = $ROOT . "/View/Authentication/content.php";
} else {
    $_SESSION["loggedin"] = false;
    $_REQUEST = array();
    $content = $ROOT . "/View/Authentication/login.php";
}
?>
<!doctype html>
<html lang="de">

<head>
    <title><?php $appName ?></title>
    <base href="" />

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="Assets/lib/jquery-3.7.0.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>

    <link rel="icon" type="image/x-icon" href="favicon.png">
    <link rel="stylesheet" href="index.css">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
    <script src="index.js"></script>
</head>

<body>
<div class="nav-bar" id="nav-bar">
    <?php include($ROOT . "/View/Nav/nav.php"); ?>
</div>
<?php require($content); ?>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
</body>

</html>

/View/Authentication/login.php

<?php
include_once(__DIR__ . "/../../Config/settings.php");

if (!isset($_SESSION)) {
    session_name($appName);
    session_start();
}

?>
<script src="View/Authentication/login.js" type="module"></script>
<style>
    @import url("./View/Authentication/login.css") screen;
</style>

<!-- Modal -->
<div class="modal fade" id="LoginModal" tabindex="-1" aria-labelledby="LoginModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h1 class="modal-title fs-5" id="LoginModalLabel">Login</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="login-form">
                    <label class="form-label" for="user_id">User ID</label>
                    <input class="form-control" type="text" id="user_id" name="user_id">

                    <label class="form-label" for="password">Password</label>
                    <input class="form-control" type="password" id="password" name="password">
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">Login</button>
                </form>
            </div>
        </div>
    </div>
</div>

/View/Authentication/login.js

//@Stackoverflow: Ignore Modal Initialization
openLoginModal();
function openLoginModal() {
    const modal = bootstrap.Modal.getOrCreateInstance('#LoginModal', {
        keyboard: false,
        backdrop: 'static'
    });
    modal.show();

    $("#login-form").on('submit', (event)=> {
        event.preventDefault();
        postAuthentication(event);
    });
}

function postAuthentication(event) {
    event.preventDefault();
    const formData = new FormData();
    const entries = $(event.currentTarget).serializeArray();

    for (const entry of entries) {
        formData.append(entry.name, entry.value);
    }

    $.ajax({
        url: '/mydomain/Controller/Auth/post_login.php',
        type: 'POST',
        data: formData,
        cache: false,
        processData: false,
        contentType: false,
        success: (response) => {
            window.location = "index.php"
        },
        error: (response) => {
            alert("Error: " + response.responseText);
        }
    });
}

/Controller/Authentication/post_login.php

<?php
include_once("Config/settings.php");

if(!isset($_SESSION))
{
    session_name($appName);
    session_start();
}


include_once(__DIR__ . "/../../Service/AuthenticationService.php");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: POST");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

$authenticationService = new AuthenticationService();
if ($_SERVER["REQUEST_METHOD"] !== "POST") {

    throw new Exception('Wrong method');
}
elseif (!isset($_POST['user_id'])|| !isset($_POST['password']) || empty(trim($_POST['user_id']))|| empty(trim($_POST['password']))) {
    throw new Exception('Please fill out all input fields!');
} elseif (strlen($_POST['password']) < 8) {
    throw new Exception('Password needs 8 figures!');
}

$return = $authenticationService->authenticate($_POST['user_id'], $_POST['password']);
header('Location: ../../index.php', true);
echo json_encode($return);

**/Service/AuthenticationService.php **

<?php
include_once("Config/settings.php");

if (!isset($_SESSION)) {
    session_name($appName);
    session_start();
}

require_once(__DIR__ . "./../Data/UserRepository.php");

class AuthenticationService
{
    private UserRepository $userRepository;

    public function __construct()
    {
        $this->userRepository = new UserRepository();
    }

    public function authenticate(string $kennung, string $password): array
    {

        $user = strtoupper(trim($kennung));
        $PW = hash('sha3-512', trim($password));

        $returnData = [
            'loginOk' => false,
            'passwordOk' => false,
            'user' => $user
        ];

        $user = $this->userRepository->get($user);
        $dbPW = $user['password'];

        if ($dbPW == $PW) {

            $returnData['loginOk']    = true;
            $returnData['passwordOk'] = true;
            $returnData['$user'] = $user;

            //Password is correct, so start a new session
            //Store data in session variables
            $_SESSION["loggedin"] = true;
            $_SESSION["user"] = $user;
        }
        return $returnData;
    }
}

Set up DUO Mobile A2F in PHP with LDAP authentification [closed]

I need to protect a PHP web application with double authentication using DUO Mobile.

Here’s how I’d like it to work for a user wishing to access the application:

  1. User enters Active Directory login and password
  2. The application asks the user to perform double authentication
  3. A push notification arrives on the user’s phone.
  4. He confirms the connection
  5. The application grants access to the user.

Is this possible, and if so, how should I proceed?

Custom Function Not Found In debug.log File

I am creating one plugin and it’s for contact forms and they have file field i am save that file in custom folder and for that i am using function named “aaiof_upload_dir” but in debug.log it’s says function not found.my code is metion below.
add_filter('upload_dir', 'aaiof_upload_dir'); //define function of aaior_upload_dir
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); //using for upload file in default uploads folder
remove_filter(‘upload_dir’, ‘aaiof_upload_dir’);
`

if (!function_exists( 'aaiof_upload_dir')){
        function aaiof_upload_dir($upload) {
            $upload['subdir'] = '/contact_form';      
            $upload['path']   = $upload['basedir'] . $upload['subdir'];    
            $upload['url']    = $upload['baseurl'] . $upload['subdir'];      
            return $upload;
        }
     }

Need help in PHP table alignment after getting data from MYSQL

I need help to align all the “tick” in one rows rather than multiple rows after getting data from MYSQL.

As some of the MYSQL data not starting in January (eg. Aug, Sep), how do I get the result to be shown same row as well?

My code is not the cleanest and I do hope there is a neater way of doing it. Appreciate your help. Thanks in advance.

<?php


include 'library/config.php';
include 'library/opendb.php';



$queryname12 = "SELECT * FROM tang WHERE stillhere='yes' ORDER BY fullname ASC";
$result12=mysql_query($queryname12);

if(mysql_num_rows($result12) > 0) {   


while($row12 = mysql_fetch_array($result12))
{
   
        $fullname12      = $row12['fullname'];




$querypaid = "SELECT * FROM expenselist WHERE paid='on' AND fullname = '$fullname12' AND type='Income' AND listyear='2023' AND field='Payment' ORDER BY fullname, listmonth ASC, field";



$resultpaid=mysql_query($querypaid);

echo mysql_error();

echo "<br><table border=1>";
echo "<tr><td width=100 align=middle><font face='Verdana' size='2'><small><b>&nbsp;</td>
<td width=40 align=middle colspan=12><font face='Verdana' size='2'><small><b>Month (Year 2023)</td></tr>";
echo "<td>Name</td><td>Jan</td><td>Feb</td><td>Mar</td><td>Apr</td><td>May</td><td>Jun</td><td>Jul</td><td>Aug</td><td>Sep</td><td>Oct</td><td>Nov</td><td>Dec</td></tr>";

if(mysql_num_rows($resultpaid) > 0) {   
    
    while($rowpaid = mysql_fetch_assoc($resultpaid)){
        $IDpaid            = $rowpaid['ID'];
        $datetodaypaid     = $rowpaid['datetoday'];    
        $fullnamepaid      = $rowpaid['fullname'];
        $remarkspaid       = $rowpaid['remarks'];
        $monthpaid         = $rowpaid['listmonth'];
        $yearpaid          = $rowpaid['listyear'];




    $remarkspaid1 = explode(" ", $rowpaid['remarks']);


$ar0 = $remarkspaid1[0]; //monthly
$ar1 = $remarkspaid1[1]; //payment
$ar2 = $remarkspaid1[2]; //for
$ar3 = $remarkspaid1[3]; //Sep-2023
$ar4 = $remarkspaid1[4]; //etc,etc


if ($ar0 == "Monthly" AND $ar1 == "payment" AND $ar2 == "for" ) 
{
$monthis1 = $remarkspaid1[3];  
$cutoutmonth = substr($monthis1, 0, 3); 
    
    
    if ($cutoutmonth == "Jan"){
        $mthpaid = "1";
    }
            
    else if ($cutoutmonth == "Feb"){
        $mthpaid = "2";
    }
    
    else if ($cutoutmonth == "Mar"){
        $mthpaid = "3";
    }
    else if ($cutoutmonth == "Apr"){
        $mthpaid = "4";
    }
    else if ($cutoutmonth == "May"){
        $mthpaid = "5";
    }
    else if ($cutoutmonth == "Jun"){
        $mthpaid = "6";
    }
    else if ($cutoutmonth == "Jul"){
        $mthpaid = "7";
    }
    else if ($cutoutmonth == "Aug"){
        $mthpaid = "8";
    }
    else if ($cutoutmonth == "Sep"){
        $mthpaid = "9";
    }
    else if ($cutoutmonth == "Oct"){
        $mthpaid = "10";
    }
    else if ($cutoutmonth == "Nov"){
        $mthpaid = "11";
    }
    else if ($cutoutmonth == "Dec"){
        $mthpaid = "12";
    }
    
}

$shortname = substr($fullname12, 0, 5) . "..";


echo "<tr><td width=20 valign=top align=middle bgcolor=$bgcolor><font face='Verdana' size='2'><small>";
echo $shortname ."</td>";

echo "<td>";
if ($mthpaid == 1){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 2){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 3){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 4){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 5){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 6){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 7){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 8){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 9){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 10){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 11){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td>";

echo "<td>";
if ($mthpaid == 12){
    
echo "<input id="online" name="monthpaid" type="checkbox" title="". $cutoutmonth. "Month paid (name: monthpaid)" checked>"; 
}
    else {
        echo "0";
    }
echo "</td></tr>";

}
}
echo "</table>";
}
}

?>

How do I solve ERR_TOO_MANY_REDIRECTS error?

I applied the solution proposed on to many redirects login security.yml but I’m still getting the same error.

security.yaml

security:
    encoders:
        AppEntityUser:
            algorithm: auto

providers
    providers:
        app_user_provider:
            entity:
                class: AppEntityUser
                property: email
                
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        # Added this to the code in order to solve ERR_TOO_MANY_REDIRECTS issue 
        login_firewall:
            pattern: ^/login$
            anonymous: ~

        main:
            anonymous: true
            lazy: true
            provider: app_user_provider
            guard:
                authenticators:
                    - AppSecurityLoginFormAuthenticator
            logout:
                path: app_logout
                
            remember_me:
                secret:   '%kernel.secret%'
                lifetime: 604800 # 1 week in seconds
                path:     /

    access_control:
        - { path: ^/usuarios, roles: ROLE_ADMIN }
        - { path: ^/usuario, roles: ROLE_ADMIN }
        - { path: ^/incidencias, roles: ROLE_ADMIN }
        - { path: ^/incidencia, roles: ROLE_ADMIN }
        - { path: ^/modulos, roles: ROLE_ADMIN }
        - { path: ^/modulo, roles: ROLE_ADMIN }
        - { path: ^/categorias, roles: ROLE_ADMIN }
        - { path: ^/categoria, roles: ROLE_ADMIN }
        - { path: ^/generos, roles: ROLE_ADMIN }
        - { path: ^/genero, roles: ROLE_ADMIN }
        - { path: ^/estadisticas, roles: ROLE_ADMIN }
        # - { path: ^/profile, roles: ROLE_USER }

I also removed a redirect from DefaultController.php in order to avoid extra redirects. However, I need to keep the redirect for the case in which the user is not found.

DefaultController.php

use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationRedirectResponse;

class DefaultController extends AbstractController
{
    public function index()
    {
        //$request = Request::createFromGlobals();
        
        //redirect to workinprogress again if the url target is not from workinprogress webpage
        //if (!$request->query->get('from')) {
        //    $redirect = new RedirectResponse('/');
        //    $redirect->setTargetUrl('https://estudio-workinprogress.com/area-privada/');
        //    return $redirect;
        //}

        if($this->getUser() == null) {
            return $this->redirectToRoute('app_login');
        }
            
        return $this->redirectToRoute('get_escenas');
    }
}

Disabled default logout page wordpress

normally login and logout functionality works as I expected in my application however something goes wrong when users login and then the user decide to change his/her password after changing his password, the user will then tried to logout however their is a default logout page in wordpress says that “Are you sure to logout in [Your THEME NAME] ?” How can I disabled that default logout page or maybe redirect to my custom logout page ?

So I did try to have wp_logout_url(‘/custom_page_logout/’) because I did saw some solution they also did that however for me it still didn’t work.

So this is the code I use for changing the password of the user and staying him a logging In because usually when changing password the user is automatically logout

`
$new_password = $_POST[‘newpassword’];
$confirm_password = $_POST[‘confirmpassword’];

if ($new_password === $confirm_password) {

$current_user = wp_get_current_user();
    $current_user_id = $current_user->ID;
    $users_login = $current_user->user_email;
wp_set_password($new_password, $current_user_id);

    $user_data = array(
        'user_login'     => $users_login,
        'user_password'    => $new_password,
        'remember'        => false
  );
     $result = wp_signon( $user_data );

`

Can we say that php is a compiled language after adding JIT?

Today I read an article about the JIT compiler and a fragment of text from this article:

Translating human-readable code to machine code can happen in three different ways: Ahead Of Time (AOT) compilation, Just In Time (JIT)
compilation or, our favorite, interpretation (or Implicit
Compilation).

gave me the following thoughts:

One of the popular questions about php is whether php is a compiled language or an interpreted language. If you google it now, you will get a seemingly clear answer, but is it?

enter image description here

A JIT compiler was added to PHP 8. Can we now say that PHP since version 8 is a compiled language? Or would “partially compiled” be a better definition?

How can I remove the numbers at the end of the product title?

I can’t get rid of the ellipsis and the hyphen. Is there anyone who can help?

Using the code below I was finally able to remove the Stock Codes at the end of the Product Title. But I still couldn’t get rid of the hyphen and there are three dots at the end of the product titles.

add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
function shorten_woo_product_title( $title, $id ) {
    if ( get_post_type( $id ) === 'product' ) {
        return wp_trim_words( $title, -1 ); // change last number to the number of WORDS you want
    } else {
        return $title;
    }
}

I had this;

T-shirt – 953854864

Now there is this;

T-shirt -…

How to format Telegram bot text by http_build_query

I found a php script, to send messages to a Telegram channel.
Everything works, but I can’t format the text.

For example, to make it bold, I tried to include the HTML tags or the pair of asterisks at the beginning and end of the text, but I don’t get my text formatted. I can only (with n) wrap the text. How can I solve it?.

Here the script:

$TelegramChatID=-'***********';

  $apiToken = "bla bla bla";

  $data = [
      'chat_id' => '**********', 
      'text' => "**My text**"
  ];

  $response = file_get_contents("https://api.telegram.org/bot$apiToken/sendMessage?" . http_build_query($data) );

Calcul between two rows SQL with conditions

I have an SQL database containing invoice data. It includes columns for “sum” and “invoice_id,” where the total amount is stored (for sum), and if it’s a down payment (invoice_id contained the other invoice id). What I need to do is calculate the sum minus the down payment, if there is one. For example, these two lines represent one project: invoice id 1567 is the down payment, and invoice id 1551 is the final invoice. Here’s an image for referenceenter image description here. The total of both sums needs to be 2902.75 for my PHP function without altering the data in this row.

For now my PHP function to calculate the sum is :

$result = Invoice::find_by_sql("
     SELECT 
         sum(invoices."sum") as "summary" 
     FROM 
         invoices 
     WHERE 
         estimate != 1 
     AND due_date < CURDATE() 
 ");

So for the exemple of above with the tow lines, I got 4063,65.

PS: I use Codeingniter in PHP framwork for my app : The full php function

/**
    ** Get sum of late
    ** return object
    **/
    public static function latePayments($option="")
    {
        if ($option == "all")
        {
            $result = Invoice::find_by_sql("
                SELECT 
                    sum(invoices.`sum`) as `summary` 
                FROM 
                    invoices 
                WHERE 
                    estimate != 1 
                    AND due_date < CURDATE() 
            ");
        }
        else
        {
            $result = Invoice::find_by_sql("
                SELECT 
                    sum(invoices.`sum`) as `summary`
                FROM 
                    invoices 
                WHERE 
                    (status = 'Open' OR status = 'Sent' OR status = 'PartiallyPaid') 
                    AND estimate != 1 
                    AND due_date < CURDATE() 
            ");
        }
        return $result[0]->summary;
    }
}

Edit 1 : The link for the sql file of the two lines : File

phpmyadmin interface issue

I installed XAMPP with PHP 8.2.4 and phpMyAdmin 5.2.1 on my windows server 2016, The issue on phpMyAdmin the interface is not working properly.

All URLs and buttons not working and cannot do anything. check screen shot.

I need your help please.

enter image description here