UTF8 encoding issue with code igniter 2, PHP 7.4, oracle 11

what are the settings that i need to fix in php.ini, apache to show utf8 encoded text stored in oracle db to be displayed properly in a web page?

things i have done:

  • default charset settings to utf8
  • added explicit encoding in oci_connect

sample code:

<?php
function remove_utf8_bom($text)
{
    $bom = pack('H*','EFBBBF');
    $text = preg_replace("/^$bom/", '', $text);
    return $text;
}
?>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"></meta>
</head>
<?php
echo getenv('NLS_LANG');
echo '<br/>';
putenv("NLS_LANG=AMERICAN_AMERICA.UTF8");
echo getenv('NLS_LANG');
echo '<br/>';


header('Content-Type: text/html; charset=UTF-8');

$conn = oci_connect('xxx', 'xxx', 'xxx', 'AL32UTF8');

if (!$conn) {
    $e = oci_error();
    echo "Connection failed: " . $e['message'];
    exit;
}
// Set the NLS_LANG for the session
oci_execute(oci_parse($conn, "ALTER SESSION SET NLS_LANGUAGE='AMERICAN'"));
oci_execute(oci_parse($conn, "ALTER SESSION SET NLS_TERRITORY='AMERICA'"));
//oci_execute(oci_parse($conn, "ALTER SESSION SET NLS_CHARACTERSET='AL32UTF8'"));

oci_set_client_info($conn, "NLS_LANG=AMERICAN_AMERICA.AL32UTF8");
//mb_internal_encoding('UTF-8');


$query = 'SELECT * FROM FMS_BERUJU';
$stid = oci_parse($conn, $query);
oci_execute($stid);

while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
    //var_dump($row);
    $item = $row['FB_OFFICE_HEAD_NEP'];
    //$item = str_replace(0xFEFF, "", $item, 1);
    $item = remove_utf8_bom($item);
    echo 'Office Head Nepali: '.htmlspecialchars($item, ENT_QUOTES, 'UTF-8') ."<br>n";
    echo 'Office Head Nepali: '.mb_convert_encoding($item, 'UTF-8', 'auto') ."<br>n";
    echo 'Office Head Nepali: '.$row['FB_OFFICE_HEAD_NEP']."<br>n";
    echo 'Office Head Nepali: '.$item."<br>n";
    echo 'Office ID: '.$row['FB_OFFICE_ID']."<br>n";
    echo 'Office Fiscal Year: '.$row['FB_FISCAL_YEAR']."<br>n";
    echo "<br>n";
    echo "<br>n";
}

oci_free_statement($stid);
oci_close($conn);

output:

शà¥à¤°à¥€ कृषà¥à¤£ सिंह बसà¥à¤¨à¥‡à¤¤ / शà¥à¤°à¥€ सागर जà¥à¤žà¤µà¤¾à¤²à¥€

mbstring config in php.ini
enter image description here

How to upload a file to a /upload folder in PHP?

<?php
if($_SERVER["REQUEST_METHOD"] == "GET"){
    $file = $_GET["fname"];
}else{
    if(isset($_POST["content"]) && isset($_POST["file"])){
          $folder = "/uploads/";
          $file = $_POST["file"];
          $content = $_POST["content"];
          if(file_exists($file)){
               echo "<h1>That file already exists on the server</h1>";
          }else{
               file_put_contents(basename($folder, $file), $content);

          }
          
     }else{
     echo "<h1>Request has failed to be sent</h1>";
    }

}

I used file_put_contents because I thought I could just put the file there and so on.

I tried playing around with my code

wordpress show specific html for descktop and another html for mobile

In wordpress I have a header.php that inside it I coded desktop and mobile HTML together. the problem is that for each device the other html are loaded and I just make them display none by media query. that makes performance and SEO problems as I know.

I want to just load the html of desktop in desktop and mobile in mobile. I used wp_is_mobile() before but as you know this function doesn’t works when you enable cache.

this is a example of what is my header.php look like:

<!DOCTYPE html>
<html lang="fa" dir="rtl">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
    <?php if (function_exists('wp_body_open')) {
        wp_body_open();
    } else {
        do_action('wp_body_open');
    } ?>
    <header>
        <div id="main-menu" class="<?php print_custom_header_classes(); ?>">
            <!------------------------------ mobile menu ------------------------------>
            <div class="mobile-nav">
                        <div class="navbar-toggler transparent-highlight">
                            <span class="nav-icon"></span>
                        </div>
                        <div class="header-brand header-brand--mobile">
                            <a class="header-brand__link transparent-highlight" href="<?php echo site_url(); ?>">
                                <img src="<?php echo get_template_directory_uri(); ?>/assets/images/logo.webp" alt="" width="100" height="80" class="header-brand__link--logo">
                            </a>
                        </div>
            </div>
            <div class="main-menu__wrapper main-menu__wrapper--mobile">
                    <?php wp_nav_menu(
                        array(
                            'theme_location' => 'siteMenu',
                            'container' => true,
                            'menu_class' => 'main-menu__list',
                            'li_class' => 'main-menu__item',
                            'a_class' => 'main-menu__link'
                        )
                    ); ?>
            </div>
            <!------------------------------ desktop menu ------------------------------>
            <div class="container">
                <div class="main-menu__wrapper">
                      <!---------- desktop content goes here I did not add in order not to write additional code ---------->
                </div>
            </div>
    </header>

another option is add by js but this approach is not good for SEO and also mybe load not as fast as html when defering. Is there any other options that I can use? Any helpful approach and efforts are appreciated.

Using original configs in OrchestraTestbench TestCase

In the OrchestraTestbench TestCase, how can I ensure that the original directories defined in the package, such as ./config, ./routes, and ./resources, are used instead of alternative ones? I know I can load the required configurations individually, but is there a way to validate them all at once with a native function?

My API isn’t working correctly, it pulls most data but not all data and I need someone to review my code, please [closed]

I made an API for my jobboard. It’s supposed to retrieve jobs from my ATS Vincere and put it in my plugin, WP Job Manager, that manages my jobs on my WordPress website. But every time I put in a Postman test run it puts in everything except the salary.

Here is the code for Postman:

{
    "id": "1109",  // Voeg hier een unieke job ID toe
    "job_title": "Projectleider Stenen Huizen",
    "public_description": "Als projectleider ben je verantwoordelijk voor het coördineren van infratechnische projecten van begin tot eind. Je werkt samen met diverse teams om ervoor te zorgen dat projecten op tijd, binnen budget en volgens de specificaties worden uitgevoerd. Je hebt de leiding over het projectteam en bent het eerste aanspreekpunt voor onze klanten.nn**Taken en verantwoordelijkheden:**n- Leidinggeven aan projecten in de infratechniek.n- Coördineren van werkzaamheden en het aansturen van projectteams.n- Communiceren met opdrachtgevers en andere stakeholders.n- Bewaken van budgetten en planningen.n- Rapporteren van voortgang en knelpunten aan het management.nn**Functie-eisen:**n- Afgeronde HBO- of WO-opleiding in de richting van civiele techniek of infratechniek.n- Minimaal 5 jaar ervaring in een vergelijkbare functie.n- Uitstekende communicatieve vaardigheden.n- Sterk in het plannen en organiseren.n- Kennis van relevante wet- en regelgeving.nn**Wat bieden wij:**n- Een uitdagende functie in een dynamische omgeving.n- Ruimte voor persoonlijke ontwikkeling en groei.n- Een marktconform salaris en goede secundaire arbeidsvoorwaarden.n- De mogelijkheid om aan interessante en duurzame projecten te werken.",
    "company_location_id": {
        "city": "Hempens, Nederland"
    },
    "compensation": {
        "salary": 5000,
        "salary_type": "MONTHLY"
    },
    "employment_type": "PartTime",
    "industry_id": "Infratechniek",
    "close_date": "2024-12-31"
}

And I tried so many times to include the salary, but it doesn’t work. Look here: http://nieuw.werkbron.nl/vacature/projectleider-stenen/

Here is the API-code:


`<?php
/*
Plugin Name: Vincere to WP Job Manager Integration
Description: Handles Vincere API callbacks and syncs jobs to WP Job Manager
Version: 1.31
Author: 
*/

define('VINCERE_API_TOKEN', 'YOUR_VINCERE_API_TOKEN'); // Vervang dit door je echte API-token
define('VINCERE_TENANT_URL', ''); // Je Tenant URL

function vincere_callback_handler() {
    if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
        wp_send_json_error('Invalid request method');
        exit;
    }

    $json_data = file_get_contents('php://input');
    $vincere_data = json_decode($json_data, true);

    if (!$vincere_data || !isset($vincere_data['id'])) {
        wp_send_json_error('Invalid data received');
        exit;
    }

    $job_data = array(
        'post_title' => sanitize_text_field($vincere_data['job_title']),
        'post_content' => wp_kses_post($vincere_data['public_description']),
        'post_status' => 'publish',
        'post_type' => 'job_listing',
    );

    $existing_job = get_posts(array(
        'post_type' => 'job_listing',
        'meta_key' => 'vincere_job_id',
        'meta_value' => $vincere_data['id'],
        'posts_per_page' => 1,
    ));

    if ($existing_job) {
        $job_data['ID'] = $existing_job[0]->ID;
        $job_id = wp_update_post($job_data);
    } else {
        $job_id = wp_insert_post($job_data);
    }

    if (is_wp_error($job_id)) {
        wp_send_json_error('Failed to create/update job listing');
        exit;
    }

    // Update job meta
    update_post_meta($job_id, 'vincere_job_id', $vincere_data['id']);
    update_post_meta($job_id, '_job_location', sanitize_text_field($vincere_data['company_location_id']['city']));
    update_post_meta($job_id, '_application', '');
    update_post_meta($job_id, '_job_expires', date('Y-m-d', strtotime($vincere_data['close_date'])));

   // Salary information
if (isset($vincere_data['compensation'])) {
    $compensation = $vincere_data['compensation'];
    // Debugging: log de ontvangen salarisgegevens
    error_log('Received Compensation Data: ' . print_r($compensation, true));
    
    $salary_from = isset($compensation['salary_from']) ? floatval($compensation['salary_from']) : 0;
    $salary_to = isset($compensation['salary_to']) ? floatval($compensation['salary_to']) : 0;
    
    // Debugging: log de verwerkte salarisgegevens
    error_log('Processed Salary From: ' . $salary_from);
    error_log('Processed Salary To: ' . $salary_to);
    
    update_post_meta($job_id, '_job_salary_minimum', $salary_from);
    update_post_meta($job_id, '_job_salary_maximum', $salary_to);
    update_post_meta($job_id, '_job_salary_unit', map_salary_unit($compensation['salary_type']));
    
    // Debugging: log de opgeslagen metadata
    error_log('Saved Salary Minimum: ' . get_post_meta($job_id, '_job_salary_min', true));
    error_log('Saved Salary Maximum: ' . get_post_meta($job_id, '_job_salary_max', true));
    error_log('Saved Salary Unit: ' . get_post_meta($job_id, '_job_salary_unit', true));
} else {
    // Debugging: log als er geen compensatiegegevens zijn
    error_log('No compensation data received');
}

    function display_job_salary( $atts ) {
    global $post;

    $salary_min = get_post_meta( $post->ID, '_salary_min', true );
    $salary_max = get_post_meta( $post->ID, '_salary_max', true );
    $job_salary = get_post_meta( $post->ID, '_job_salary', true );

    if ( !empty($salary_min) && !empty($salary_max) ) {
        return 'Salaris: ' . $salary_min . ' - ' . $salary_max;
    } elseif ( !empty($salary_min) ) {
        return 'Salaris vanaf: ' . $salary_min;
    } elseif ( !empty($salary_max) ) {
        return 'Salaris tot: ' . $salary_max;
    } else {
        return 'Salaris: ' . $job_salary;
    }
}

add_shortcode( 'job_salary', 'display_job_salary' );

    // Region
    $region = get_region($vincere_data['company_location_id']);
    if ($region) {
        wp_set_object_terms($job_id, $region, 'job_listing_region');
    }

    // Category (Sub industry in Vincere)
    if (isset($vincere_data['industry_id'])) {
        $category = map_category($vincere_data['industry_id']);
        wp_set_object_terms($job_id, $category, 'job_listing_category');
    }

    // Job Type
    $job_type = map_job_type($vincere_data['employment_type']);
    wp_set_object_terms($job_id, $job_type, 'job_listing_type');

    wp_send_json_success('Job listing created/updated successfully');
    exit;
}

function map_salary_unit($vincere_salary_type) {
    $map = [
        'HOURLY' => 'uur',
        'DAILY' => 'dag',
        'WEEKLY' => 'week',
        'MONTHLY' => 'maand',
        'YEARLY' => 'jaar'
    ];
    return isset($map[$vincere_salary_type]) ? $map[$vincere_salary_type] : 'maand';
}

function get_region($location_data) {
    // Haal de plaatsnaam uit de location_data
    $city = sanitize_text_field($location_data['city']);

    // Definieer een array met plaatsen en hun bijbehorende provincie en regio's
    $city_to_province = [
        // Friesland (Noord)
        'Hurdegaryp' => 'Friesland',
        'Leeuwarden' => 'Friesland',
        'Sneek' => 'Friesland',
        // Groningen (Noord)
        'Groningen' => 'Groningen',
        'Assen' => 'Drenthe',
        // Overijssel (Oost)
        'Zwolle' => 'Overijssel',
        // Noord-Holland (West)
        'Amsterdam' => 'Noord-Holland',
        // Zuid-Holland (West)
        'Rotterdam' => 'Zuid-Holland',
        // Noord-Brabant (Zuid)
        'Eindhoven' => 'Noord-Brabant',
        // Voeg hier meer steden toe zoals nodig
    ];

    $province_to_region = [
        'Friesland' => 'Noord',
        'Groningen' => 'Noord',
        'Drenthe' => 'Noord',
        'Overijssel' => 'Oost',
        'Gelderland' => 'Oost',
        'Noord-Holland' => 'West',
        'Zuid-Holland' => 'West',
        'Utrecht' => 'West',
        'Noord-Brabant' => 'Zuid',
        'Limburg' => 'Zuid',
        'Zeeland' => 'Zuid'
    ];

    // Zoek de provincie van de stad
    if (isset($city_to_province[$city])) {
        $province = $city_to_province[$city];
        // Geef de regio terug op basis van de provincie
        return $province_to_region[$province];
    }

    // Als de stad niet in de lijst staat, return null of een standaardwaarde
    return null;
}

function map_job_type($vincere_employment_type) {
    $map = [
        'FULL_TIME' => 'Fulltime',
        'PART_TIME' => 'Parttime',
        'CONTRACT' => 'Tijdelijk',
        'FREELANCE' => 'Freelance',
        'INTERIM' => 'Interim'
    ];
    return isset($map[$vincere_employment_type]) ? $map[$vincere_employment_type] : 'Fulltime';
}

function map_category($vincere_sub_industry) {
    $map = [
        // 1. Bouw en Infrastructuur
        'Bouwbedrijven' => 'Bouw en Infrastructuur',
        'Projectontwikkeling' => 'Bouw en Infrastructuur',
        'Infratechniek' => 'Bouw en Infrastructuur',
        'Woningcorporaties' => 'Bouw en Infrastructuur',
        'Architectuur en Ontwerp' => 'Bouw en Infrastructuur',

        // 2. Techniek en Industrie
        'Installatietechniek' => 'Techniek en Industrie',
        'Elektrotechniek' => 'Techniek en Industrie',
        'Werktuigbouwkunde (WTB)' => 'Techniek en Industrie',
        'Mechatronica' => 'Techniek en Industrie',
        'Lastechniek' => 'Techniek en Industrie',
        'Metaalbewerking en Machinebouw' => 'Techniek en Industrie',
        'Voedingsmiddelenindustrie (Food)' => 'Techniek en Industrie',
        'Kunststofverwerking' => 'Techniek en Industrie',
        'Chemie en Farmacie' => 'Techniek en Industrie',
        'Hout- en Timmerindustrie' => 'Techniek en Industrie',

        // 3. ICT en Digitalisering
        'Softwareontwikkeling' => 'ICT en Digitalisering',
        'Webontwikkeling' => 'ICT en Digitalisering',
        'Online Marketing' => 'ICT en Digitalisering',
        'Systeembeheer' => 'ICT en Digitalisering',
        'Data Science' => 'ICT en Digitalisering',
        'IT-consultancy' => 'ICT en Digitalisering',

        // 4. Groen, Agrarisch en Milieu
        'Landbouw en Veeteelt' => 'Groen, Agrarisch en Milieu',
        'Tuin- en Landschapsinrichting' => 'Groen, Agrarisch en Milieu',
        'Bosbouw en Natuurbeheer' => 'Groen, Agrarisch en Milieu',
        'Afvalverwerking en Recycling' => 'Groen, Agrarisch en Milieu',
        'Milieutechniek' => 'Groen, Agrarisch en Milieu',

        // 5. Transport en Logistiek
        'Wegtransport' => 'Transport en Logistiek',
        'Distributie en Warehousing' => 'Transport en Logistiek',
        'Zee- en Luchtvaart' => 'Transport en Logistiek',
        'Supply Chain Management' => 'Transport en Logistiek',

        // 6. Financiële Sector
        'Accountancy' => 'Financiële Sector',
        'Verzekeringen' => 'Financiële Sector',
        'Banken en Financieringen' => 'Financiële Sector',
        'Administratiekantoor' => 'Financiële Sector',
        'Fintech' => 'Financiële Sector',

        // 7. Onderwijs en Opleiding
        'Basis- en Voortgezet Onderwijs' => 'Onderwijs en Opleiding',
        'Hoger Onderwijs en Wetenschap' => 'Onderwijs en Opleiding',
        'Bedrijfsopleidingen en Training' => 'Onderwijs en Opleiding',
        'Coaching en Advies' => 'Onderwijs en Opleiding',

        // 8. Zorg en Welzijn
        'Gezondheidszorg (Ziekenhuizen, Klinieken)' => 'Zorg en Welzijn',
        'Thuiszorg en Ouderenzorg' => 'Zorg en Welzijn',
        'Jeugdzorg en Maatschappelijke Zorg' => 'Zorg en Welzijn',
        'GGZ (Geestelijke Gezondheidszorg)' => 'Zorg en Welzijn',
        'Farmacie' => 'Zorg en Welzijn',

        // 9. Commercie en Retail
        'Groothandel' => 'Commercie en Retail',
        'Detailhandel (Retail)' => 'Commercie en Retail',
        'Fast Moving Consumer Goods (FMCG)' => 'Commercie en Retail',
        'E-commerce' => 'Commercie en Retail',

        // 10. Overheid en Publieke Sector
        'Gemeentelijke Overheden' => 'Overheid en Publieke Sector',
        'Rijksdiensten' => 'Overheid en Publieke Sector',
        'Non-profitorganisaties' => 'Overheid en Publieke Sector',
        'Veiligheidssector (Politie, Brandweer)' => 'Overheid en Publieke Sector',
        'Militaire en Defensiesector' => 'Overheid en Publieke Sector',

        // 11. Horeca en Toerisme
        'Hotels en Catering' => 'Horeca en Toerisme',
        'Restaurants en Cafés' => 'Horeca en Toerisme',
        'Recreatie en Toerisme' => 'Horeca en Toerisme',
        'Eventmanagement' => 'Horeca en Toerisme',

        // 12. Consultancy en Advies
        'Bedrijfsadvies' => 'Consultancy en Advies',
        'Technisch Advies' => 'Consultancy en Advies',
        'Duurzaamheid en Innovatie' => 'Consultancy en Advies',
        'Managementadvies' => 'Consultancy en Advies',

        // 13. Energie en Duurzaamheid
        'Energietransitie' => 'Energie en Duurzaamheid',
        'Hernieuwbare Energie (Zonne- en Windenergie)' => 'Energie en Duurzaamheid',
        'Waterstoftechnologie' => 'Energie en Duurzaamheid',
        'Circulaire Economie' => 'Energie en Duurzaamheid',
    ];
    return isset($map[$vincere_sub_industry]) ? $map[$vincere_sub_industry] : 'Overig';
}


add_action('rest_api_init', function () {
    register_rest_route('vincere/v1', '/callback', array(
        'methods' => 'POST',
        'callback' => 'vincere_callback_handler',
    ));
});

`

I changed the code of the API, I tried to change functions.php, asked AI and more.

How to reuse colour palettes across multiple PHP GD canvases/images?

How can I draw and refer to the same set of colours across multiple GD canvasses?

I am new to using PHP-GD for images, I have only done a couple very basic things with it.

I am creating a map generator that will have 3+ scales as GD canvases. Each scale represents zooming in to the previous scale, and adding more details. The first scale is a 20×20 image with land and water colours. The second scale is 60×60 pixels (each pixel turns into a 3×3 grid of pixels), and does some interpolation to round out the pixels of the first scale.

Everything is working fine, except PHP doesn’t seem to provide any way to reuse and reference colours across multiple images. My map generation is entirely based on the colour of pixels read from the image canvas. I want to reference the same colours in all 3 scales of my map, but I am being forced to create these silly “colour references” as returned by imagecolorallocate(). True colour images do not have palettes, you just use any colour you want. Why doesn’t PHP allow proper true colour images without palettes?

I need to be able to do the following:

  • Check pixel colours in all 3 of my GD canvasses to see if they match a specific list of colours (land, water, etc.)
  • Draw pixels in any of the 3 GD canvasses using the same list of colours (land, water, etc.)

I’m looking for a way to avoid repeating variables for each colour, like I currently have:

$Colour_Water_1 = imagecolorallocate($Scale_1, 68, 97, 147);
$Colour_Land_1  = imagecolorallocate($Scale_1, 99, 67, 33);

$Colour_Water_2 = imagecolorallocate($Scale_2, 68, 97, 147);
$Colour_Land_2  = imagecolorallocate($Scale_2, 99, 67, 33);

I would be fine with one $Variable for each individual colour across every scale, but not different variables for every colour at every scale! What approach does anyone suggest I take?

Ideal would be one global array of colours usable by every GD canvas:

$Map_Colours = array(
   "Water" => array(68, 97, 147),
   "Land"  => array(99, 67, 33),
);

The documentation for imagecolorallocate() does not even specify what is returned by the function. What is the “colour reference” that is returned?

I have considered creating one giant canvas with the 3 smaller images drawn onto different locations of the giant canvas, which avoids having multiple palettes, but this is non-ideal and kind of stupid, and will be more and more wasteful as I keep adding further zoomed-in scales to my map generator.

It doesn’t matter to me if the map images are in true colour or palette based. I originally made the images as palette based, but once I realised the palettes being used are not the same between different GD canvasses, and I can’t reference the same colours in each canvas, that idea fell apart. I then switched to true colour images because I thought they would “just work”, because of not having a palette internally, but PHP GD still requires the use of imagecolorallocate() on true colour images!

I found the function imagepalettecopy(), but it has the same issue that each canvas requires its own separate colour reference variables.

I also found this comment on php.net which stated you can reference any colour in a true colour image as if it were already allocated, but the code they provided wasn’t very clear to me:

jessiedeer at hotmail dot com - 11 years ago

There is no need to allocate colors with imagecreatetruecolor. All [256 x 256 x 256 x 128] true colors are already allocated, and you can use the color indexes directly.

Examples :
Blue => color index 255.
White => color index 16777215 (= 255*256² + 255*256+255).
Full transparent => color index 2130706432 (= 127*256^3).

This looks similar to how QBASIC referenced 6-bit VGA colours (RGB values from 0 to 63):

(Red) + (Green * 256) + (Blue * 65536)

Also, why do they list the alpha as 128 (only 7bits instead of 8bits)?

If this method does work using the correct formula, it would also need to be usable when checking a pixel on the canvas to see if it matches a particular colour (land, water, etc.).

Keeping Laravel Powergrid table’s first row visible while loading with wire

I’m using Laravel Powergrid and I’ve added the wire:loading directive to show a skeleton loader whenever table actions are performed (e.g., page change, per-page value update, filter, and search).

The thead is always visible during these actions, but I also want to keep the first tr inside the tbody (which contains the filter/search row) visible while the table is loading. The goal is to prevent it from being hidden during any refresh or load triggered by these actions.

Here’s a simplified version of the code I’m working with:

@props([
    'theme' => null,
    'readyToLoad' => false,
    'items' => null,
    'lazy' => false,
    'tableName' => null,
])
<div @isset($this->setUp['responsive']) x-data="pgResponsive" @endisset>
    <table
        id="table_base_{{ $tableName }}"
        class="table power-grid-table {{ data_get($theme, 'table.tableClass') }}"
        style="{{  data_get($theme, 'tableStyle') }}"
    >
        <thead
            class="{{ data_get($theme, 'table.theadClass') }}"
            style="{{ data_get($theme, 'table.theadStyle') }}"
        >
            {{ $header }}
        </thead>
        <tbody
            class="{{  data_get($theme, 'table.tbodyClass') }}"
            style="{{  data_get($theme, 'table.tbodyStyle') }}"
            wire:loading.remove
        >
            @if ($readyToLoad)
                {{ $body }}
            @endif
        </tbody>
    </table>

    <div wire:loading class="p-2 space-y-4 animate-pulse">
        <!-- Skeleton loading content -->
    </div>
</div>

In this case, whenever the table is loading (due to filters, pagination, etc.), the entire tbody disappears, which removes the first tr (the filter/search row) that I want to keep visible at all times.

I tried this approach by removing wire:loading from tbody and manually writing the tr inside it:

<tbody
    class="{{  data_get($theme, 'table.tbodyClass') }}"
    style="{{  data_get($theme, 'table.tbodyStyle') }}"
>
    <tr 
        class="{{ data_get($theme, 'table.trClass') }}"
        style="{{ data_get($theme, 'table.trStyle') }}"
    >
    </tr>

    @if ($readyToLoad)
        {{ $body }}
    @endif
</tbody>

However, this doesn’t seem to be working correctly, and I’m unsure how to keep the first tr (the filter/search row) persistent without disrupting the table’s behavior. Any guidance on how to properly implement this would be greatly appreciated!

The PowerGrid table structure for reference:
code-structure

how can i get the last row with a given foreign key in yii2 with relations?

i have 2 tables

tickets:
-id
etc..

comments:
-id
-ticket_id
-datetime
etc...

ticket_id is the ticket’s id on which the comment was made.

one ticket can have 0 or more comments in this way

how should i go about creating a relation in my Ticket model, to fetch it’s last comment?

part of my Ticket Model:


class Ticket extends ActiveRecord
{
public function getComments(): ActiveQuery
    {
        return $this->hasMany(Comment::class, ['ticket_id' => 'id']);
    }

    public function getHandler(): ActiveQuery
    {
        return $this->hasOne(User::class, ['id' => 'handler_id']);
    }

    public function getLastComment()
    {
        //???
    }
}


How to read code from Azure Blob storage in to PHP?

I have a WordPress plugin that reads and displays image files from the plugin folder, the plugin reads and displays the images name from a CSV as there is almost 200+ files. Now the client wants to migrate the images to Azure Blob storage.
The current code looks like below.

‘<div style=”background-image: url(‘+csvData[‘logo’]+’)”>’ +
‘<div style=”background-image:url(‘+csvData[‘banner’]+’)”></div>’

Can you please help me how to implement this in PHP? I have seen in an example to implement as below

$storageAccountName = 'name';

$accessKey = "xxxxxxxx";

$containerName = 'test';

$blobName = 'sample.png';

However in this case the $blobName cannot be defined as there is 200+ files in Container. The images need to display at multiple locations.

The files are private (no anonymous access).

Thanks

so I am trying to route gayahidup.blade.php to berpakaian.blade.php but it gives me an error “Undefined variable $berpakaian”

it gives me an error like this

and then if you take a look at my code in controller and web.php

Route::get('/gayahidup/{id}',[GayaHidupController::class,'showGayaHidup'])>name('gayahidup.show');
Route::get('gayahidup', [GayaHidupController::class, 'index'])->name('gayahidup.index');
Route::get('gayahidup/create', [GayaHidupController::class, 'create'])->name('gayahidup.create');
Route::post('gayahidup/store', [GayaHidupController::class, 'store'])->name('gayahidup.store');
Route::delete('gayahidup/{id}', [GayaHidupController::class, 'destroy'])->name('gayahidup.destroy');
Route::get('/gayahidup/berpakaian/{id}', [GayaHidupController::class, 'showBerpakaian'])->name('gayahidup.berpakaian.detail');
Route::get('/gayahidup/kecantikan/{id}', [GayaHidupController::class, 'showKecantikan'])->name('gayahidup.kecantikan.detail');
Route::get('/gayahidup/traveling/{id}', [GayaHidupController::class, 'showTraveling'])->name('gayahidup.traveling.detail');
Route::get('/gayahidup/kuliner/{id}', [GayaHidupController::class, 'showKuliner'])->name('gayahidup.kuliner.detail');
        
Route::get('/gayahidup/berpakaian', [GayaHidupController::class, 'berpakaian'])->name('gayahidup.berpakaian');

and if you look my controller


    public function showGayaHidup($id)
{
    $gayahidup = GayaHidup::find($id);
    return view('pages.secnavbar.gayahidup.subhidup.berpakaian', compact('gayahidup'));
}

  
public function berpakaian()  
{  
    $berpakaian = GayaHidup::where('sub_categories', 'Berpakaian')->get();  // Ini mengambil data dari database
    return view('pages.secnavbar.gayahidup.subhidup.berpakaian', compact('berpakaian'));  // Ini mengirim variabel $berpakaian ke view
}

yea I know I use “showGayaHidup”, because if I don’t I get an error like this :

Call to undefined method AppHttpControllersGayaHidupController::showGayaHidup()

so what should I do? I am so clueless to connect it to this path resourcesviewspagessecnavbargayahidupsubhidupberpakaian.blade.php

tbh, I already admin’s panel and send it to another blade. and it works perfectly. But not this one. So I am so confused
this is the blade that show my data
this is my admin’s panel

how to pull data from gitlab with php script in laravel?

I create new project in gitlab.

I upload my project in host, I need get last update form gitlab with function in laravel.

My function:

function execPrint($command = "git pull user:[email protected]/myProject.git") {
    $result = array();
    exec($command, $result);
    print("<pre>");
    foreach ($result as $line) {
        print($line . "n");
    }
    print("</pre>");
}

After run this function:

ssh: Could not resolve hostname shayvard: Temporary failure in name resolution
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

How to issue this code?

Azure WAF is blocking URL with .php

We are using own cloud for cloud storage, whenever we upload file to own cloud, we are facing issues in WAF Detection which ever url has .php in it, the url is getting blocked from azure.

From azure we are getting error message “Method is not allowed by policy”

I had tried to give user agent for own cloud service, but its not working
I noticed which all url have the .php in it its causing the issue.

Ruled : 911100

PHP PDO Microsoft Access Driver is returning a 500 error [duplicate]

Attempting to read an access file into a PDO.

$db = "D:/VacConJobTrackerbe.accdb";

if (!file_exists($db)) {die("Could Not find database file.");}
else {echo "Found Database file.<br/>";}

$jobTrackerConn = new PDO("odbc:Dbq=$db;Charset=UTF-8;Driver={Microsoft Access Driver (*.mdb, *.accdb)};Uid=Admin;");

I get a 500 error.

The php logs are clean. Other parts of my application successfully read from a sql server.

odbc Data Source Administrator 64-bit lists ‘Microsoft Access Driver (*.mdb, *.accdb)’
16.00.18025.20030

PDO::getAvailableDrivers() returns odbc & mysql

php.ini has both extension=odbc and extension=pdo_odbc un-commented

php 8.3.12, 64 bit

office 365 & access runtime version 16.0.18025.20160 64 bit

Windows Server 2016 Datacenter
IIS Version 10.0.14393.0

I’ve tried swapping the driver & dbq in the connection string, omitting charset, and many other permutations. Adding Uid=Admin had no effect. Misspelling the driver results in a different (non-500) error. So does misspelling the file.

AWS PHP SDK issue with credentials after upgrading to v3

I have an issue on getting credentials after upgrading from 2nd version to 3rd.
My service gets credentials from metaserver and cache them in file.
Here is how service definition looks like on 2nd version:

my_app.infrastructure.s3.client.credentials_cache.adapter:
        class: DoctrineCommonCacheFilesystemCache
        public: false
        arguments:
            - '%kernel.cache_dir%/aws_credentials'

my_app.infrastructure.s3.client.credentials_cache:
        class: GuzzleCacheDoctrineCacheAdapter
        public: false
        arguments:
            - '@my_app.infrastructure.s3.client.credentials_cache.adapter'

my_app.infrastructure.s3.client:
        class: AwsS3S3Client
        factory: [ 'AwsS3S3Client', 'factory' ]
        arguments:
            - region: "%my_app_organization_dictionary_aws_s3_region%"
              credentials.cache: '@my_app.infrastructure.s3.client.credentials_cache'

with that config it works for a while, after upgrading I changed a way how to cache credentials from meta server.

    my_app.infrastructure.s3.client.credentials_cache.adapter:
        class: DoctrineCommonCacheFilesystemCache
        public: false
        arguments:
            - '%kernel.cache_dir%/aws_credentials'

    my_app.infrastructure.s3.client.credentials_cache:
        class: AwsDoctrineCacheAdapter
        public: false
        arguments:
            - '@my_app.infrastructure.s3.client.credentials_cache.adapter'

    my_app.infrastructure.s3.client.credentials_provider:
        class: AwsCredentialsCredentialProvider
        factory: [ 'AwsCredentialsCredentialProvider', 'defaultProvider' ]
        public: false

    my_app.infrastructure.s3.client.cached_credentials_provider:
        class: AwsCredentialsCredentialProvider
        factory: [ 'AwsCredentialsCredentialProvider', 'cache' ]
        arguments:
            - '@my_app.infrastructure.s3.client.credentials_provider'
            - '@my_app.infrastructure.s3.client.credentials_cache'
        public: false

    my_app.infrastructure.s3.client:
        class: AwsS3S3Client
        factory: [ 'AwsS3S3Client', 'factory' ]
        arguments:
            - region: "%my_app_organization_dictionary_aws_s3_region%"
              version: 'latest'
              credentials: '@my_app.infrastructure.s3.client.cached_credentials_provider'

but still get an error

FAIL AWS S3: Fail check the AWS S3 with bucket "my_app_bucket". 
Reason: [AwsExceptionCredentialsException] 
Error retrieving credentials from the instance profile metadata server. 
(cURL error 28: Operation timed out after 1001 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://169.254.169.254/latest/api/token).

Any ideas on what’s wrong with my setup?