loading content thru PHP to simplify or is there a way to load it in a div? [closed]

I have my header/css and part of the body including the <div tag for the cell the content is in as one file and then the footer with the and and segment as another file and then have the following code:
How do I make it so it will load content per a PHP page with the content in it… it’s all supposed to go in one div on the page and then the header and footer (the parts of the page that stay the same which is everything except that div) saved as separate files to minimize loading time…

<!DOCTYPE html>
<html lang="en">
    <?php

$PageTitle="Havent // Heavent Made // Hellt Mindedt // Manualt";

function customPageHeader(){?>
  <!--Arbitrary HTML Tags-->
<?php }

include_once('file:///home/chronos/u-57608984ca0e6dfae1c20c6c0ed79e71e9626f08/MyFiles/Downloads/header.php');

include_once("content");

include_once('file:///home/chronos/u-57608984ca0e6dfae1c20c6c0ed79e71e9626f08/MyFiles/Downloads/footer.php');
?>

How do I use php to add custom properties to docx

I am trying to prepare a docx template file with pre-inserted custom properties (Quick Part -> Fields) from a database. The file starts as an empty docx file created in MS Word.

I reviewed this question

But it does not answer my question.

My code is as follows:

$blank_DOCX_template = DATAPATH."formletter_blank_templates/blank.docx";
        
$zip = new ZipArchive;

if ($zip->open($blank_DOCX_template) == true) {
    $updatedXmlContent = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">';
    $id_num = 2;
    foreach($properties as $prop_name=>$prop_val){
         $updatedXmlContent .= '<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="'.$id_num.'" name="'.$prop_name.'"><vt:lpwstr>'.$prop_val.'</vt:lpwstr></property>';
         $id_num++;
    }
    $updatedXmlContent .= '</Properties>';

    $zip->addFromString('docProps/custom.xml', $updatedXmlContent);
    $zip->close();

}else{
    echo "could not open file";
}

Once the code has run (it produces no errors), I can look into the zip file ‘docProps/custom.xml’ and every thing looks right. The xml file exists and has the same content as a file with the same properties manually inserted through the MS Word interface, but when I open the file in MS Word the custom properties inserted from my php code do not appear.

What am I missing?

how can I Deploying multiple projects to the same repository

How can I trigger the deployment of a vercel project only when code changes are made in a subdirectory?

I have a repository with three subdirectories of that corresponds to vercel’s three projects, now every time I push the code will trigger the deployment of the three projects, I want to in which subdirectory there is a change in the code, the corresponding project repository before triggering the deployment, what should I do?

when i try the Ignored Build Step feature, it tell me:

Configuration Settings in the current Production deployment differ from your current Project Settings.

Laravel Set-Cookie Response Header Problem With Cloudflare Cache Mechanism

We have a website built with Laravel 10 (upgraded from Laravel 5.6 to 9, and then to version 10). For this website, we use a load balancer on Cloudflare. However, since we are using the StartSession (IlluminateSessionMiddlewareStartSession) and VerifyCsrfToken (AppHttpMiddlewareVerifyCsrfToken) middleware, the response headers for every page include two Set-Cookie headers. Because of the Set-Cookie headers in the response, Cloudflare prevents the page from being cached and directly serving from the Cloudflare cache for subsequent requests.

How can we resolve this issue to allow Cloudflare to cache the pages while still using the necessary middleware in Laravel?

Cloudflare documentation: https://developers.cloudflare.com/cache/concepts/cache-control/#conditions

Cloudflare documentation page

Our website response header:
Our web site response headers

Not able to publish application on play store?

I created one small application using flutter only then I created new account in google play console and try to publish my application, but my application is 3 times rejected, reason is showing only “Your app requires more testing to access Google Play production” but same application I published in App Store , it is successfully published but ion play store it is not. So please provide me correct solution how I resolve this issue.

Stop WordPress from stripping out custom element

I am using the Tatsu page builder and using their Code module to insert dotlottie code, such as:

<dotlottie-player src="https://lottie.host/******************.lottie" background="transparent" speed="1"  loop autoplay></dotlottie-player>

This works fine; however when I use the usual WordPress Update button for other reasons not related to the page builder, WordPress strips out this code.

I have tried adding the below code to functions.php, but it still got stripped.

function allow_lottie_tags($tags, $context) {
    // Add for all contexts
    $allowed_atts = array(
        'src' => true,
        'background' => true,
        'speed' => true,
        'loop' => true,
        'autoplay' => true,
        'class' => true,
        'id' => true,
        'style' => true
    );

    // Apply to both default and 'post' context
    if ($context === 'post' || $context === 'default') {
        $tags['dotlottie-player'] = $allowed_atts;
    }

    return $tags;
}

// Apply to multiple filters to catch different contexts
add_filter('wp_kses_allowed_html', 'allow_lottie_tags', 999, 2);
add_filter('post_allowed_html', 'allow_lottie_tags', 999, 2);

I then tried adding this, with no luck.

// Also try to force it globally
function hook_lottie_early() {
    global $allowedposttags, $allowedtags;

    $allowed_atts = array(
        'src' => true,
        'background' => true,
        'speed' => true,
        'loop' => true,
        'autoplay' => true,
        'class' => true,
        'id' => true,
        'style' => true
    );

    $allowedposttags['dotlottie-player'] = $allowed_atts;
    $allowedtags['dotlottie-player'] = $allowed_atts;
}
add_action('init', 'hook_lottie_early', 1);

What am I doing wrong? Should I go to a dynamic shortcode instead, or is there another way to handle this?

PHP multiple Object creation from DB

Hi I am very new to PHP and Objects and have become very confused on the best way to create a collection of objects created from a database. Below is an example of what is working for me but its a single object with array properties. Is this the best options or do I create multiple objects for each book and if I create multiple objects how do I loop through to display on my grid.

<?php
declare(strict_types=1); // FAIL FAST
//##############################################
class Books {
// Properties
    protected $id_type=array();
    protected $title=array();
    protected $brief=array();
//==============================================    
function set_books($id, $mysqli)
    {
        //DB Query 
        $result = $stm->get_result();
        $stm->close();

        while ($rows = $result->fetch_assoc()) {
        $this-title[] = $rows['title'];
        $this->brief[] = $rows['brief'];
        }
    }
//==============================================
function get_title()
    {
        return $this->title;
    }
//==============================================
}
$books = new Books();
$books->set_books(4, $mysqli);
$book_count = count($books->get_title());
$i=0;
while ($i < $book_count) {
    
echo "<h1>".$books->get_title()[$i]."</h1>";    

$i++;
}
?>

I have google and cannot find the exact answer I am looking for most examples show a single object like displaying a single book not a list of books.

Curl not passing post data to api [closed]

I am posting form data to a curl script which is received by curl properly but curl is not posting that data to api and null data is returned.

I want the data to be posted to api and return json data,which i will display on screen.

  • $url = “https://myapiurl.com/”;
  • $userid = $_POST[‘clientid’];
  • $token = $_POST[‘apikey’];
  • $headers = array(
  • 'Method: GET',
    
  • 'Authorization: Basic '. base64_encode($userid.':'.$token)
    
  • );
    
  • $curl = curl_init();
  • $fields = array(
  • 'panchangdate' => $_POST["panchangdate"],
    
  • 'panchanglongitude' => $_POST["panchanglongitude"],
    
  • 'panchanglatitude' => $_POST["panchanglatitude"],
    
  • 'panchangtimezone' => $_POST["panchangtimezone"]
    
  • );
  • $fields_string = http_build_query($fields);
  • curl_setopt($curl, CURLOPT_URL, $url);
  • curl_setopt($curl, CURLOPT_POST, TRUE);
  • curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
  • curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
  • curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  • curl_setopt($curl, CURLOPT_POSTFIELDS, $fields_string);
  • curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  • $response = curl_exec($curl);
  • $err = curl_error($curl);
  • curl_close($curl);
  • if ($err) {
  • echo “cURL Error #:” . $err;
  • else {
  • //echo $response;
  • /*
  • echo “
    ";
  • echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
  • echo “”;
  • */
  • $data = json_decode($response);
  • ?>

The problem with getting metadata using the yt-dlp library from YouTube

I have a problem using the yt-dlp library to download videos from YouTube

When getting the name of a video, sometimes the program gives out the wrong name, which does not exist at all

I use php for the query

Can you tell me how to make more stable queries to get the name of the video?

your text$metadata_command = “$yt_dlp_path –dump-json –verbose “$user_url””;
your text$metadata_output = [];
your text$metadata_return_var = 0;
your textexec($metadata_command, $metadata_output, $metadata_return_var);
your textif ($metadata_return_var !== 0) {
your text echo “Metadata retrieval error: ” . implode(“n”, $metadata_output);
your text throw new Exception(‘Metadata retrieval error video from YouTube’);
your text}
your textif ($metadata_return_var === 0) {
your text $metadata = json_decode(implode(“n”, $metadata_output), true);
your text if ($metadata === null) {
your text throw new Exception(‘Error decoding JSON metadata.’);
your text }
your text $video_title = $metadata[‘title’];
your text}

I tried to find mentions of a similar error on the Internet, but to no avail

Doctrine Migrations: Repeatedly Generating the Same ALTER TABLE Statement

I recently upgraded my Symfony project from 5.4 to 6.4.13. Now, I am encountering an issue with Doctrine Migrations in my Symfony project. When I run the doctrine:migrations:diff command, it generates an ALTER TABLE statement to change a column type and default value. However, after applying the migration and running the doctrine:migrations:diff command again, the same ALTER TABLE statement is generated repeatedly.

Here is the generated SQL statement:

$this->addSql('ALTER TABLE my_entity CHANGE my_column my_column DOUBLE PRECISION DEFAULT 0');

Entity:

#[ORMEntity]
class MyEntity
{
    ...

    #[ORMColumn(type: 'float', nullable: true, options: ['default' => 0])]
    #[AssertRange(min: 0)]
    private ?float $myColumn = 0;

    ...
}

Migration Configuration:

doctrine.yaml:

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
    orm:
        auto_generate_proxy_classes: true
        mappings:
            App:
                type: attribute
                is_bundle: false
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'AppEntity'
                alias: App

doctrine_migrations.yaml:

doctrine_migrations:
    migrations_paths:
        'AppMigrations': '%kernel.project_dir%/src/Migrations'
    storage:
        table_storage:
            table_name: 'migration_versions'
            version_column_name: 'version'
            version_column_length: 192
            executed_at_column_name: 'executed_at'
    check_database_platform: true

Project Details:

  • Symfony version: 6.4.13
  • PHP version: 8.1
  • Composer dependencies include doctrine/doctrine-migrations-bundle v3.3.1 and doctrine/doctrine-bundle v2.13.1.

Question:
Why, in the first place, does Doctrine generate this ALTER TABLE statement, and why does Doctrine keep generating the same ALTER TABLE statement, after it has been executed?

How to submit a form and display the content from database to the Placeholder component in filament

I have a form, when i submit the form, it dispatches an event, which sends an external api request and then stores the response in the database. I have created an endpoint that can be used to check if the response has been stored in the database. I would like to use the Placeholder component to poll this endpoint, and display the content, without page refresh. See the image bellow. This is the form image

I am new to Filament, what is the possible solution to this?

How to make a custom function called whenever a method of the PDO class is invoked

I am attempting to hook into the functions within the PDO class.

I declared the zend_execute_internal function and hooked it by setting the address of my custom function, but in the code of New Relic or Datadog, it seems they use zend_hash_str_find_ptr to perform the operation within the PHP_MINIT_FUNCTION.

However, I couldn’t figure out exactly how they are hooking the functions. I’ve spent a month searching through a vast amount of materials, but none of the explanations worked as described.

How can I make my function execute first and then execute the original function?

Or is there a way to use symbols like in C..?

tried many approaches, but the most promising code was the one below. However, the result of zend_hash_str_find_ptr always returned NULL no matter where it was executed.

I want to create a feature that collects transactions performed by the user through PDO and displays them as statistics, unlike a custom class.

zend_class_entry *ce = zend_hash_str_find_ptr(CG(class_table), "PDO", sizeof("PDO")-1);
if (ce != NULL) {
    original = zend_hash_str_find_ptr(&ce->function_table, "exec", sizeof("exec")-1);

    if (original != NULL) {
        original_handler_pdo_exec = original->internal_function.handler;
        original->internal_function.handler = my_overwrite_pdo_exec;
    }
}

How to Pass Parameters to the handle() Function in Laravel Artisan Commands?

I am creating a custom Artisan command in Laravel, and I need to pass parameters to the handle() function. However, I’m not sure how to define and access these parameters when running the command.

Here’s what I have so far:

class UpdatePlacesImages extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:update-places-images';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Fetch places data(specially images) from Places API and save it in the goog_data field';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        /* We are updating google_data field by using two separate functions 
        1: updatePlacesImages()
            Updating ""google_data"" field using ""place_id"" for all places ""Expect Lounges"" because Lounges places
            are stored in table name ""lounges"" and DB name ""newairport"" while the remaining all places are 
            saved in table name ""places"" and DB name ""airport_remote  
            
        2: updateLoungesImages()
            Updating ""google_data"" field using ""place_id""  only for lounges place
        */

        $this->updatePlacesImages();
        $this->updateLoungesImages();
    }
}

What I Want:

1: I want to pass a parameter places or lounges.

Example:

1: php artisan app:update-places-images places

or

2: php artisan app:update-places-images lounges

Error: SyntaxError: Unexpected non-whitespace character after JSON at position 52 (line 1 column 53)

I’m experiencing a JSON parsing error with the message:

‘SyntaxError: Unexpected non-whitespace character after JSON at
position 52 (line 1 column 53)’.

Could you help me understand what might be causing this? I suspect there might be some unexpected characters or output before the JSON response.

this is my code:

function bayar() {
    const tagihan = <?php echo json_encode($tagihan_belum_dibayar[0] ?? null) ?>;
    
    if (!tagihan) {
        Swal.fire({
            icon: 'error',
            title: 'Error',
            text: 'Tidak ada tagihan yang perlu dibayar'
        });
        return;
    }

    Swal.fire({
        title: 'Memproses Pembayaran',
        text: 'Mohon tunggu...',
        allowOutsideClick: false,
        didOpen: () => {
            Swal.showLoading();
        }
    });

    fetch('./process_payment.php', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        },
        body: JSON.stringify({
            total_tagihan: parseFloat(tagihan.total_tagihan)
        })
    })
    .then(response => {
        // Pastikan response dalam format JSON
        const contentType = response.headers.get('content-type');
        if (!contentType || !contentType.includes('application/json')) {
            throw new Error('Bukan respon JSON');
        }
        return response.json();
    })
    .then(data => {
        Swal.close();
        if (data.status === 'success') {
            $('#orderIdInput').val(data.order_id);
            $('#jumlahPembayaranInput').val(new Intl.NumberFormat('id-ID', {
                style: 'currency',
                currency: 'IDR'
            }).format(data.total_bayar));
            
            $('#modalPembayaranBaru').modal('hide');
            $('#modalUploadBukti').modal('show');
        } else {
            throw new Error(data.message || 'Terjadi kesalahan');
        }
    })
    .catch(error => {
        console.error('Error:', error);
        Swal.fire({
            icon: 'error',
            title: 'Gagal',
            text: error.message || 'Terjadi kesalahan dalam pemrosesan'
        });
    });
}

// Update form submission handler
document.getElementById('uploadBuktiForm').addEventListener('submit', function(e) {
    e.preventDefault();
    
    const formData = new FormData(this);
    
    Swal.fire({
        title: 'Mengupload Bukti Pembayaran',
        text: 'Mohon tunggu...',
        allowOutsideClick: false,
        didOpen: () => {
            Swal.showLoading();
        }
    });

    fetch('', {
        method: 'POST',
        body: formData
    })
    .then(response => {
        Swal.fire({
            icon: 'success',
            title: 'Berhasil',
            text: 'Bukti pembayaran berhasil diupload'
        }).then(() => {
            window.location.reload();
        });
    })
    .catch(error => {
        Swal.fire({
            icon: 'error',
            title: 'Gagal',
            text: 'Gagal mengupload bukti pembayaran'
        });
    });
});

Can you advise on how to troubleshoot this issue and ensure a clean JSON response?

“I tried to send a JSON request from the client-side using JavaScript’s fetch API to a PHP backend. I was expecting a clean JSON response that would be parsed without any errors.

Specifically:

  • I sent a POST request to process a payment

  • The server-side PHP script was supposed to generate a JSON response

  • Instead, I received this parsing error at position 52

What I expected was a response like:

{
  "status": "success",
  "order_id": "123456",
  "total_bayar": 500000
}

But the error suggests something unexpected is being sent before or within the JSON data.

I’ve already tried:

  • Checking server-side PHP for any extra output

  • Using ob_clean() to clear output buffer

  • Verifying Content-Type headers

  • Ensuring no error messages are printed

Could you help me identify what might be causing these unexpected characters?

How do I print multiple tickets on one sheet?

I am trying to print tickets for a concert.
At the moment I can print each ticket on a separate sheet of paper. But I would like to be able to print each ticket, with a small gap after each one, on as fewer pages as possible.

Here is the code I have:

    for($i = 0; $i < 5; $i++){
        $pdf->AddPage();

        // background
        $pdf->SetAlpha($alpha);
        $pdf->Image('../img/banners/'.$row['banner'], 10, 10, 0, 107);
        // draw border around image
        $pdf->SetAlpha(1);
        $pdf->Cell(0,107,'',1,1, 'C');

        // logo
        $pdf->Image('../img/logo/logo-trans-bg.png', 20, 20, 20, 20);

        // name
        $pdf->SetFont('Courier','I',12);
        $pdf->Text(105 - ($pdf->GetStringWidth($row['name']) / 2), 32, $row['name']);

        // price
        $pdf->SetFont('Courier','',12);
        $price1 = "£".$row['t1_price'];
        $pdf->Text(175 - ($pdf->GetStringWidth($price1) / 2), 32, $price1);

        // date
        $pdf->SetFont('Courier','B',12);
        $pdf->Text(155 - ($pdf->GetStringWidth($date) / 2), 105, $date);

        // web address
        $pdf->SetFont('Courier','BI',12);
        $pdf->Text(40 - ($pdf->GetStringWidth('dwhsociety.co.uk') / 2), 105, 'dwhsociety.co.uk');

        // concert title
        $pdf->SetFont('Courier','B',16);
        $pdf->Text(105 - ($pdf->GetStringWidth($row['title']) / 2), 60, $row['title']);

        // Adult
        if($row['type_1'] != '0'){
            $adult = "1 ticket ".$row['t1_label'];
            $pdf->SetFont('Courier','',12);
            $pdf->Text(105 - ($pdf->GetStringWidth($adult) / 2), 67, $adult);
        }
    
        // venue
        $pdf->SetFont('Courier','',12);
        $pdf->Text(105 - ($pdf->GetStringWidth($row['venue']) / 2), 77, $row['venue']);
    }

This of course creates a new page on every loop, which I don’t want.

Any help greatly appreciated.