How to process data of one client in different browser tabs? [closed]

There is such a difficulty. The client fills out a form on the site, with data on several clients, and does it not in turn, but in parallel, in several browser tabs. The question is, how to process such data?

If you store such data in sessions or cookies, they can be overwritten, I talked about localsession, but you can only work with it from js, is there a solution in php?

Change event date to TBD in Modern Event Calendar (aka MEC)

I want to change the date of a specific event to TBD, I can’t see any opton in Modern Event Calendar WordPress plugin. I have the php code but its not working.

add_filter('the_content', function($content) {
    if (is_singular('mec-events')) {
        $event_id = get_the_ID();
        $start_date = get_post_meta($event_id, 'mec_start_date', true);

        if ($start_date === '2099-12-31') {
            // Replace any date pattern with "TBD"
            $content = preg_replace('/d{1,2}s+w+s+d{4}/', 'TBD', $content);
            $content = str_replace('2099', 'TBD', $content); // fallback
        }
    }

    return $content;
});

I am adding this into code snippet but nothing changed.

PHP Equivalent of Mysql inet6_aton() function

Our client is using a version of Mysql that does not support the inet6_aton() function.

What would be the PHP equivalent for the inet6_aton function?

The inet6_aton() function returns the numeric value of the address in VARBINARY data type: VARBINARY(16) for IPv6 addresses and VARBINARY(4) for IPv4 addresses.

We have tried a few functions that convert IP to binary but none of them have the same output as the inet6_aton() function.

Below is the desired output that we are trying to achieve with PHP.

SELECT inet6_aton('214.0.0.0');

// OUTPUT

0xd6000000

CodeIgniter 4 CLI Server Infinite Loading When Navigating Between Pages [closed]

I’m facing an issue with my CodeIgniter 4 project when running the server using the built-in CLI (php spark serve). The application initially loads fine, but when I try to navigate from one page to another (using internal links or redirects), the browser enters an infinite loading state. It just keeps loading and nothing appears.

Here’s I’ve observed:

If I cancel the loading manually and then reload the page, it works fine.

If I stop the server and then start it again using php spark serve, it also works as expected temporarily.

Unable to Scrape Instagram Posts – Only Able to Retrieve Followers, Following, and Post Count

I’m working on an Instagram scraper using a DOM crawler. So far, I’m able to successfully extract basic profile information like:

  • Total number of posts
  • Number of followers
  • Number of accounts followed

However, I’m unable to retrieve the actual post content (images, captions, etc.) from the profile. It seems that Instagram’s frontend structure has changed, or the data is being loaded dynamically in a way that’s not accessible via simple HTML parsing.

Has anyone encountered this issue recently?
Is there a reliable method to extract post data without using the official Instagram Graph API?

Any help or suggestions would be appreciated.

How to check for uniqueness of multiple fields in a database?

I ran into a problem where I don’t know how to check the uniqueness of some fields in the database, I don’t have a field where only 1 element is unique, of course, except for the id, but I can’t compare values by id because this is auto_increment and not manual input.

Question: how to compare if there are fields label, table_id

                    $this->db->table('context')->insert([
                        'type_flow' => $node['name'],
                        'title' => $node['data']['title'],
                        'label' => $item['label'],
                        'type' =>  $item['type'],
                        'value' => $item['value'],
                        'table_id' => $node['id'],
                    ]);

mysql table

I need to implement this in codeigniter and if there is a comparison method, can you tell me of course I think I could manually try to extract fields from the database and compare but I think the code would not be entirely correct

If you need more data, please write in the comments.

my try:

$db_conn = $this->model->where('type_flow', $item['field'])->where('table_id', $node['id'])->where('type_flow', 'conditions')->first() ? true : false;
                    if (!$db_conn) {
                        $this->db->table('context')->insert([
                            'type_flow' => $node['name'],
                            'title' => $node['data']['title'],
                            'label' => $item['field'],
                            'type' =>  $item['type'],
                            'value' => $item['value'],
                            'table_id' => $node['id'],
                        ]);
                    }

Why Overriding MIME Type works but not Response Type? [closed]

I am new to ‘PHP and JavaScript’. The other day, I was coding for asynchronous request and response. Working sometime with fetch(), I thought of using the XMLHttpRequest(). It was a bit of work, but then I entered the following code:

<script>
let xhr = new XMLHttpRequest();

xhr.open('POST', 'http://localhost/test/test.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
xhr.responseType = 'json';

xhr.onload = function() {
    if (xhr.status != 200){
        console.log(`Error ${xhr.status}: ${xhr.statusText}`);
    } else {
        document.getElementById("lull").innerHTML = xhr.response
    }
};

xhr.send("url=wikipedia.org");
</script>

I tried whole night debugging why this is returning null in its response. Then I stumbled upon this and casually changed the xhr.responseType = 'json'; to xhr.overrideMimeType("application/json"); and it worked! So, I am trying to understand how the two differs in their working? The mdn_website says responseType() can be used to change the response type, and many other sources have used it!

The php file that open is refrencing is just listening for url key in the $_POST array and is responding with the html web page using file_get_contents() and encoding it using json_encode().

The php file required is:

<?php 
if (isset($_POST['url'])){
    header('Content-Type: application/json');
    $data = [
        "html"  => file_get_contents('https://www.' . $_POST['url'])
    ];
    echo json_encode($data);
}

And to add, it works completely fine when using fetch() and even with XMLHttpRequest when using Content-Type: text/html.

“use setasignFpdiFpdi” command doesn’t work in php [duplicate]

I follow this tutorial https://transloadit.com/devtips/merging-pdf-documents-in-php-using-fpdi-and-fpdf/#install-fpdi-and-fpdf.

I installed packages by composer require setasign/fpdf:1.8.* and then composer require setasign/fpdi:^2.0.

Then I run in php -a:

require 'vendor/autoload.php';

use setasignFpdiFpdi;

$pdf = new Fpdi();

It throws error “PHP Warning: Uncaught Error: Class “Fpdi” not found in php shell code:1″.

But directly $pdf = new setasignFpdiFpdi(); without using use works. What is the reason?

I am getting net::ERR_TOO_MANY_REDIRECTS in PHP code

I am getting net::ERR_TOO_MANY_REDIRECTS

When I search treatments according to the department dropdown getting error and jquery is not working,jquery is not loading and the dependent dropdown is not working

<script>
       $(document).ready(function() {
        // When the department dropdown is changed
        alert('Hi');
        $('#department').on('change', function() {
            var departmentId = $(this).val();
            var departmentName = $(this).find('option:selected').text();

            if (departmentId) {
                $.ajax({
                    url: 'get_treatments.php',
                    type: 'POST',
                    data: {
                        department_id: departmentId,
                        department_name: departmentName
                    },
                    success: function(response) {
                        $('#treatment').html(response);
                        updateDepartmentName(departmentId, departmentName);
                    }
                });
            } else {
                $('#treatment').html('<option value="">Select Department first</option>');
            }
        });

alert not working

Laravel serving private user images via custom route — image URL returns 200 but image not displayed

I have a laravel project serving domain.com and there is a subdomain for user profile as profile.domain.com,

Now on edit profile blade, I need to show the uploaded avatar image of user which is uploaded and stored at root project storage directory:

/home/myuser/domain.com/storage/app/private/public/users/{userId}/{filename}

I made a route like this:

Route::get('/private-file/{type}/{userId}/{filename}', function ($type, $userId, $filename) {
    $allowedTypes = ['users', 'members'];
    if (!in_array($type, $allowedTypes)) {
        abort(404);
    }

    $mainStoragePath = '/home/pachim/ino-official.org/storage/app/private/public';

    $path = $mainStoragePath . "/{$type}/{$userId}/{$filename}";

    if (!file_exists($path)) {
        abort(404);
    }

    $mimeType = mime_content_type($path);

    return response()->file($path, ['Content-Type' => $mimeType]);
})->name('private.file');

And it is working and show the user avatar image like this:

https://profile.domain.com/private-file/users/115/Hq6VhEg1YSJQG82ALfabShAQPWTSPWUCf58vtLYu.png

But in the blade, the image not showing up, despite the correct source which is accessible by now:

<div class="col-md-6 mb-4">
    <label for="avatar" class="form-label fw-bold">Profile Picture</label>
        <div class="d-flex align-items-center">
            <div class="me-3">
                @php
                // Default placeholders if no images
                $defaultAvatar = asset('/assets/img/profile.png');
                $defaultPassport = asset('assets/img/passport-placeholder.jpg');

                // Build URLs using your new route if avatar/passport_photo exist
                $avatarUrl = $user->avatar
                    ? url('user-image/' . $user->avatar)
                    : $defaultAvatar;

                $photoUrl = $detail?->passport_photo
                    ? url('user-image/' . $detail->passport_photo)
                    : $defaultPassport;
                @endphp

                <img id="avatarPreview" src="{{ $avatarUrl }}" alt="User Avatar" class="rounded-circle border" style="width: 100px; height: 100px; object-fit: cover;">
            </div>
            <div class="flex-grow-1">
                <input type="file" name="avatar" class="form-control @error('avatar') is-invalid @enderror" id="avatar" accept="image/*" onchange="previewAvatar(this)">
                @error('avatar')
                    <div class="invalid-feedback">{{ $message }}</div>
                @enderror
                <small class="text-muted">Accepted: JPG, PNG. Max size: 2MB</small>
            </div>
        </div>

How i can integrate Zoom call API in Laravel for users

i want to integrate Zoom call API so users can talk with each other but i don’t want to create host my self so if user created the call the user should be the host

`public function createMeeting($data)
{
$accessToken = $this->getAccessToken();

    try {
        $response = $this->client->request('POST', 'users/me/meetings', [
            'headers' => [
                'Authorization' => 'Bearer ' . $accessToken,
                'Content-Type' => 'application/json',
            ],
            'json' => array_merge($data, [
                    'agenda' => "xxx Zoom Meeting",
                    "duration"=> 60,
                    "approval_type"=> 2,
                    "contact_name" =>"jhon",
                      'settings' => [
                'join_before_host' => true, // Allow participants to join before the host
                'waiting_room' => false, // Disable waiting room if you want participants to join directly
            ],


            ]),
        ]);

        return json_decode($response->getBody(), true);
    } catch (RequestException $e) {
        return json_decode($e->getResponse()->getBody()->getContents(), true);
    }
}`

if you are familier with fiverr calls i need same

laravel react + filament, admin page running too slow [closed]

When i inspect it and head to the network page it goes like this
here

CreateCommitee.php

<?php

namespace AppFilamentResourcesCommiteeResourcePages;

use AppFilamentResourcesCommiteeResource;
use FilamentActions;
use FilamentResourcesPagesCreateRecord;

class CreateCommitee extends CreateRecord
{
    protected static string $resource = CommiteeResource::class;
}

EditCommitee.php

    <?php

namespace AppFilamentResourcesCommiteeResourcePages;

use AppFilamentResourcesCommiteeResource;
use FilamentActions;
use FilamentResourcesPagesEditRecord;

class EditCommitee extends EditRecord
{
    protected static string $resource = CommiteeResource::class;

    protected function getHeaderActions(): array
    {
        return [
            ActionsDeleteAction::make(),
        ];
    }
}

ListCommitee.php

<?php

namespace AppFilamentResourcesCommiteeResourcePages;

use AppFilamentResourcesCommiteeResource;
use FilamentActions;
use FilamentResourcesPagesListRecords;

class ListCommitees extends ListRecords
{
    protected static string $resource = CommiteeResource::class;

    protected function getHeaderActions(): array
    {
        return [
            ActionsCreateAction::make(),
        ];
    }
}

this is all the code in my app/Filament/Resources/CommiteeResources/Pages did i do something wrong here??

CommiteeResource.php

<?php

namespace AppFilamentResources;

use AppFilamentResourcesCommiteeResourcePages;
use AppFilamentResourcesCommiteeResourceRelationManagers;
use AppModelsCommitee;
use FilamentForms;
use FilamentFormsForm;
use FilamentResourcesResource;
use FilamentTables;
use FilamentTablesTable;
use IlluminateDatabaseEloquentBuilder;
use IlluminateDatabaseEloquentSoftDeletingScope;

class CommiteeResource extends Resource
{
    protected static ?string $model = Commitee::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                FormsComponentsTextInput::make('nama')
                    ->required()
                    ->maxLength(255),
                FormsComponentsTextInput::make('nim')
                    ->required()
                    ->maxLength(255),
                FormsComponentsTextInput::make('jurusan')
                    ->required()
                    ->maxLength(255),
                FormsComponentsTextInput::make('angkatan')
                    ->required()
                    ->numeric(),
                FormsComponentsTextInput::make('kode_referral')
                    ->maxLength(255)
                    ->default(null),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TablesColumnsTextColumn::make('nama')
                    ->searchable(),
                TablesColumnsTextColumn::make('nim')
                    ->searchable(),
                TablesColumnsTextColumn::make('jurusan')
                    ->searchable(),
                TablesColumnsTextColumn::make('angkatan')
                    ->numeric()
                    ->sortable(),
                TablesColumnsTextColumn::make('kode_referral')
                    ->searchable(),
                TablesColumnsTextColumn::make('created_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TablesColumnsTextColumn::make('updated_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                //
            ])
            ->actions([
                TablesActionsEditAction::make(),
            ])
            ->bulkActions([
                TablesActionsBulkActionGroup::make([
                    TablesActionsDeleteBulkAction::make(),
                ]),
            ])
            
            ->headerActions([
                // Tambahkan baris ini dan biarkan kosong untuk menghilangkan tombol "New commitee"
                // Atau, jika Anda ingin menambahkan tindakan lain di header, tambahkan di sini.
                // Contoh: TablesActionsAction::make('Custom Action')->action(fn () => dd('Custom action clicked')),
            ]);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => PagesListCommitees::route('/'),
            'edit' => PagesEditCommitee::route('/{record}/edit'),
        ];
    }
}

Commitee.php (Models)

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class Commitee extends Model
{
    use HasFactory;

    protected $table = 'commitee'; 
    protected $fillable = [
        'nama',
        'nim',
        'jurusan',
        'angkatan',
        'kode_referral',
    ];

}

migration

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

return new class extends Migration
{
     /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('commitee', function (Blueprint $table) {
            $table->id();
            $table->string('nama');
            $table->string('nim')->unique(); 
            $table->string('jurusan'); 
            $table->string('angkatan'); 
            $table->string('kode_referral')->nullable(); 
            $table->timestamps(); // Kolom created_at dan updated_at
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('commitee');
    }
};

How i solve the problem, i already using php artisan icons:cache but it didn’t work

How can I translate JetEngine Dynamic Field values (from a custom query) into Persian inside a Listing in Elementor?

I’m working on a WordPress website using JetEngine and Elementor.

I have created a custom query in JetEngine (via Query Builder) that fetches data directly from the database — specifically, WooCommerce order records.

This custom query is then used as the source of a Listing in Elementor, which displays each record using JetEngine’s Dynamic Field widget.


Here’s the problem:

One of the fields in the query is status, and its values are in English (e.g.):

  • wc-completed
  • wc-pending
  • wc-cancelled

When I use the Dynamic Field widget inside the Listing, these English values are shown directly on the page.


What I want:

I want to translate these field values into Persian for display in the frontend, like:

  • wc-completedتکمیل شده
  • wc-pendingدر انتظار
  • wc-cancelledلغو شده

Limitations:

  • I can only use JetEngine’s Dynamic Field widget inside the Listing.
  • I cannot use HTML widgets, shortcodes, or custom templates.
  • I prefer a solution with minimal or no PHP code, using built-in JetEngine features like:
    • Output filters
    • Macros
    • Callbacks
    • Conditional logic (if available)

My question:

How can I map or translate the field values returned from a custom query in JetEngine, and display them as Persian text inside a Listing, using only the Dynamic Field widget in Elementor?

If there’s no code-free solution, what is the simplest PHP-based workaround (e.g., via a callback function or filter) to transform these values before they are rendered in the Dynamic Field?

Thanks in advance!

using for loop to render image in background image [closed]

I am trying to render an image in my carousel from the database, using a for loop.

But I am stuck on how to use a for loop here, and how to render an image in style="background-image:url.

My code:

<div class="banner-carousel banner-carousel-1 mb-0">
    @for ($i = 0; $i < count($sliders); i++)
        <div class="banner-carousel-item" style="background-image:url(images/{{$sliders[i]['']]}})">
            <div class="slider-content">

                <div class="row align-items-center h-100">
                    <div class="col-md-12 text-center">
                        <p data-animation-in="slideInLeft" data-duration-in="1.2">
                        <h2 class="slide-title" data-animation-in="slideInDown">Meet Our Engineers</h2>
                        <h2 class="slide-title" data-animation-in="slideInLeft">17 Years of excellence in</h2>
                        <h3 class="slide-sub-title" data-animation-in="slideInRight">Construction Industry
                        </h3>
                        </p>
                    </div>
                </div>

            </div>
        </div>
    @endfor
</div>

My image is in public/images folder in the app.

apply same css styles to divs in the arithmetic sequence of three

I have 10 items in my database table. I want to apply same CSS style to the divs in the arithmetic sequence of 3 items.

For example, items [0, 3,6,9] will have css style slideInDown, items [1,4,7] will have css style slideFloat and items [2,5,8] will have style slideInUp.
@if ($i % 3 == 0), I think this will satisfy the series [0, 3,6,9] but how to write logic for other two series.

My code::

@for ($item = 0; $item < count($posts); $item++)
    @if ($i % 3 == 0)    <!-- for items [0,3,6,9]  -->                
        <div class="content">
            <div class="slideInDown text-center">
                <p> $posts[$item]['post_content'] </p>
            </div>
        </div>
    @elseif($i == 2) <!-- what will be logic for items [2,5,8]  --> 
        <div class="content">
            <div class="slideInUp">
                <p> $posts[$item]['post_content'] </p>
            </div>
        </div>
    @else  <!-- for items [1,4,7]  --> 
        <div class="content">
            <div class="slideFloat">
                <p> $posts[$item]['post_content'] </p>
            </div>
        </div>
    @endif
@endfor