XAMPP redirect all pages except home page to localhost/dashboard [closed]

I installed XAMPP on Windows. In the htdocs folder I created a folder with my WP project. The problem is that the main page starts, and when you go to any other page on the site, it redirects to localhost/dashboard. How to fix it?
In addition to the project, the htdocs folder contains basic XAMPP files and folders like index.php, dashboard folders, etc.

<?php
    if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
        $uri = 'https://';
    } else {
        $uri = 'http://';
    }
    $uri .= $_SERVER['HTTP_HOST'];
    header('Location: '.$uri.'/dashboard/');
    exit;
?>

React page that fetch data from a php query and then send it to another php page

I’m new in react and I want to code a page (in react) that shows data from an external query in php and then, after the user update that data, axios send it to another php page. I can do a page that shows only the fetched data and one that sends data but not one that do everything.

Here’s my code

react page

import React, { Component } from 'react';
import axios from 'axios';

class ClientUpdate extends Component 
{
    state = {
      client: []
    }
    
    componentDidMount() 
    {
      const url = 'http://localhost:8888/select_client.php'
      axios.get(url).then(response =>
        this.setState({ client: response.data }));
    }
       
    handleInputChange = (event) => 
    {
      this.setState({name: event.target.value});
    };
      
    handleSubmit = (event) => 
    {
      event.preventDefault();
      
      axios
        .post("http://localhost:8888/update_client.php", formData)
        .then((response) => 
        {
          console.log(response);
        })
        .catch((error) => 
        {
          console.log(error);
        });
    };
      
    render() 
    {
      return (
                <div className="container-fluid d-flex justify-content-center">
                   {this.state.cliente.map((rs, index) => (
                    <form key={index} className="form-group" onSubmit={this.handleSubmit}>
                        <h1 className="mt-4 d-flex justify-content-center">UPDATE</h1>
                            <input type="hidden" className="form-control" name="id_cliente" id="id_cliente" value={rs.Id_cliente} />
                            <div>
                            <label htmlFor="username">Username:</label>
                            <input type="text" className="form-control" name="username" id="username" placeholder={rs.Username} autoComplete="on" value={rs.Username} onChange={this.handleInputChange/ />
                            </div>
                            <div>
                            <label htmlFor="email">Email:</label>
                            <input type="email"  className="form-control" name="email" id="email" placeholder={rs.Email} autoComplete="on" value={rs.Email} onChange={this.handleInputChange} />
                            </div>
                            <div>
                            <label htmlFor="password">Password:</label>
                            <input type="password" className="form-control" name="password" id="password" autoComplete="off" value={rs.Password} onChange={this.handleInputChange} />
                            </div>

                        <button type="submit" className="btn btn-primary btn-lg w-100 mt-3">Submit</button>
                    </form>
                    ))}
                </div>
        );
     }
}
      
export default ClientUpdate;

Thanks for your help.

Determine when two datetime ranges overlap

I have two datetime intervals, and I want to identify the overlapping period between them. For instance, if I have intervals:

  • 01-12-2023 01:00:00 to 12-12-2023 15:00:00
  • 10-12-2023 11:00:00 to 24-12-2023 16:00:00

I need to retrieve the common interval, which in this case is 10-12-2023 11:00:00 to 12-12-2023 15:00:00. How can I achieve this in PHP, either using native functions or a library like Carbon?

How to integrate PHP8.1 code to link QB desktop API

I have a small custom CRM we want some PHP 8.1.24 code that will link to “Quickbooks Desktop Pro Plus 2023 64bit”.

I open up a customer in the CRM it will have a many variables like: Company, Firstname, Lastname, StreetAddress, City, Zip, State, Phonenumber
I want to use those details to find a match to a customer or vendor in QB then return what details the customer/vendor profile has back to the CRM. Then in PHP the code to compare and if a detail doesn’t match or if they are empty the code will then tell QB to update those details.

I am familiar with PHP but on the other hands not good at linking QB desktop API.
Please let me know the detailed steps how to implement the linking API with PHP.

I am embarrassing not to be familiar with the steps how to start.
So I need collaborators’ help.
Thank you.

WordPress Hooks not setting the constructor data

I am making a logging sdk. The code I used in my plugin main file where the sdk starts is

function rpt_wpb()
            {
                global $rpt_wpb;

                if (!isset($rpt_wpb)) {
                    // Include  SDK.
                    // print_r(RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . '/lib/wpb-sdk/require.php');exit;
                    require_once RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . '/lib/wpb-sdk/require.php';
                    $rpt_wpb = new Logger(
                        array(
                            'id'    => 7,
                            'name'  => 'Related Posts Thumbnails Plugin for WordPress',
                            'slug' => 'related-posts-thumbnails',
                            'type' => 'plugin',
                            'path'  => __FILE__,
                            'version'   => RELATED_POSTS_THUMBNAILS_VERSION,
                            'public_key' => '7e240de74fb1ed08fa08d38063f6a691462a815',
                            'is_premium' => false,
                            'has_addons' => false,
                            'has_paid_plans' => false,
                            'menu' => array()
                        )
                    );
                }

                return $rpt_wpb;
            }

            // Init .
            rpt_wpb();

            do_action('rpt_wpb_loaded');
        }

Then is my logger class where I am using a constructor to get the data that is logged from the class initialization in plugin main file. And inside the constructor I am using a function that call up all the hooks (dynamic_init()).

public function __construct($product_data)
    {
        // print_r($product_data);exit;
        self::$product_data = $product_data;
        // echo "<pre>";print_r(self::$product_data);exit;
        $this->dynamic_init();
    }

    /**
     * Call wp hooks to initialize logger actions.
     *
     * @return void
     */
    public function dynamic_init()
    {   
        // $product_data = self::$product_data;
        // echo "<pre> Product Data: ";print_r($product_data);exit;
        add_action('init', array($this, 'set_logs_schedule'));
        add_action('wpb_logger_cron_' . self::$product_data['slug'], array($this, 'log_plugin'));
        add_action('admin_footer', array($this, 'deactivation_model'));
        add_action('wp_ajax_wpb_sdk_' . self::$product_data['slug'] . '_deactivation', array($this, 'ajax_deactivation'));

        register_activation_hook(self::$product_data['path'], array(__CLASS__, 'log_activation'));
        register_deactivation_hook(self::$product_data['path'], array(__CLASS__, 'product_deactivation'));
        register_uninstall_hook(self::$product_data['path'], array(__CLASS__, 'log_uninstallation'));
    }

Now the main issue is that in below functions

public function set_logs_schedule()
    {   
        // print_r(self::$product_data['slug']);exit;

        if (!wp_next_scheduled('wpb_logger_cron_' . self::$product_data['slug'])) {
            wp_schedule_event(time(), 'weekly', 'wpb_logger_cron_' . self::$product_data['slug']);
        }
    }

    /**
     * Add deactivation model.
     *
     * @return void
     */
    public function deactivation_model()
    {
        // print_r((self::$product_data['slug']));exit;

        if (function_exists('get_current_screen')) {

            $screen = get_current_screen();

            if ('plugins.php' === $screen->parent_file) {
        
                $product_slug = self::$product_data['slug'];
                $product_name = self::$product_data['name'];
                $has_pro_version = (in_array($product_slug, self::$has_pro_version)) ? true : false;

                include dirname(__DIR__) . '/views/wpb-sdk-deactivate-form.php';
            }
        }
    }

The product_data of the plugin is not coming instead the data of last plugin in the list that contains sdk comes up.

I expect that the data of product_data should come up in set_logs_schedule() and deactivation_model(). Moreover I am new in wordpress plugin development so that’s why I am struggling.

Environment variables in html

there is an environment variable in which I want to hide the token from the bot’s telegrams, the script is written in php and vlucas/phpdotenv is installed. I have configured all the files, but when I upload the site to html, the script does not work.

Renaming it index.html in index.php and then the site doesn’t work anymore. I am far from web development, but most likely everything is much more complicated to put a website in php.

The code looks like this. If you can help, I will be grateful, perhaps there is some easier way.

<?php
require 'vendor/autoload.php'; // Подключаем автозагрузчик Composer

$dotenv = DotenvDotenv::createImmutable(dirname('my.site.name'));

$dotenv->load();

$token = $_ENV['TOKEN']; // Используем токен из переменной окружения

// Теперь можно использовать переменную $token в вашем коде
?>

<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">

Переименовываю index.html в index.php

Can anyone help me out with my issue please

I have created a website on php (just learning) and now when i click on property the url comes like this property_detail.php?property=Nw== i want to correct this as per the url structure rule with keywords n all.

i tried .htaccess but not worked please suggest me

Http client getting status() in retries is broken

Laravel Version

10.35.0

PHP Version

8.1.26

Database Driver & Version

Mysql 5.7

Description

When using the retries feature of the Http client, attempting to get the status from the response as per the docs throws an error and I’m unable to get the response status code.

Steps To Reproduce

  1. Make a get request anywhere to a domain that doesn’t exist via the Http client
  2. Implement the retries function like this:
$client = $client->retry(3, 100, function (Exception $exception, PendingRequest $request) {
    Log::debug('foo');
    Log::debug($exception->response->status()); // <-- this line is erroring
    Log::debug('bar'); // <-- I never make it here

    return true;
});

Observe the error:

Undefined property: IlluminateHttpClientConnectionException::$response

Also, I see my foo log but never the bar log.

Either the docs is wrong, or getting the response is broken. The domain I used deliberately is one that hangs, which is intentional: sdfsd.com

How to Reserve a Custom Arrow Box Space in a SplideJS Grid Layout?

I am working on implementing a custom grid layout using SplideJS with the Grid extension where I need to reserve space for a custom arrow box for navigation. The layout consists of two rows of slides, with the first row containing four slides. In the second row, I want the first cell to be a dedicated arrow box and the next three cells to be slides. The layout looks something like this:

First row: Slide 01, Slide 02, Slide 03, Slide 04
Second row: Arrow Box, Slide 05, Slide 06, Slide 07

I have managed to create the two rows of slides, but I am struggling with reserving the space for the arrow box. Here is the code I’ve used to initialize the SplideJS grid:

desired output

new Splide('#splide', {
  type: 'grid',
  grid: {
    rows: 2,
    cols: 4,
  },
  // other options...
}).mount();

I want the arrow box to be part of the grid, not floating or absolutely positioned over the slider. I expected to be able to somehow designate a cell for the arrow box, but I’m not sure how to proceed with SplideJS grid configuration or custom CSS to achieve this.

Has anyone encountered a similar issue or have suggestions on how to reserve a space for an arrow box within a SplideJS grid layout?

PHP Products export

I have PrestaShop XML module which exports products.

I want that my category_name, category_id and category_link would be in father. For example:

<categories>
<category_name></category_name>
<category_id></category_id>
<category_link></category_link>
</categories>

What I need to change in this code:

$xmlProduct = $this->document->createElement('product');
$xmlProduct->setAttribute('id', $xmlProductId);
$xmlProduct->appendChild($this->getCDATAElement('title', $xmlProductName));
$xmlProduct->appendChild($this->document->createElement('price', $xmlProductPrice));
$xmlProduct->appendChild($this->document->createElement('stock', $product['quantity']));
$xmlProduct->appendChild($this->document->createElement('product_url', $xmlProductUrl));
$xmlProduct->appendChild($this->document->createElement('category_id', $product['id_category_default']));
$xmlProduct->appendChild($this->getCDATAElement('category_name', $product['category']));
$xmlProduct->appendChild($this->document->createElement('category_link', $productProvider->getCategoryLink($product['id_category_default'], $product['category_rewrite'])));

I tried to change, but I don’t have enough knowledge in PHP to solve that.

Inserting a data into database

I’m new, this is laravel, react + inertia,

I want to insert a data, name and photo when button create is being clicked. Can you check what is wrong, and please explain to me.

StoreController.php

<?php

declare(strict_types=1);

namespace PetcheckrCommonUiHttpAdminControllersAnimalBreeds;

use IlluminateHttpRedirectResponse;
use PetcheckrCommonApplicationAnimalBreedsCommandsStore;
use PetcheckrCommonUiHttpAdminRequestsAnimalBreedsStoreRequest;

class StoreController
{
    public function __invoke(StoreRequest $request): RedirectResponse
    {
        dispatch_sync(
            job: Store::fromArray(
                payload: $request->validated(),
            ),
        );
        return response()->redirectToRoute(
            'petcheckr.config.animal-breeds.index'
        )->with('flash.message', 'Animal Breed successfully created!');
    }
}

Store.php:

<?php

declare(strict_types=1);

namespace PetcheckrCommonApplicationAnimalBreedsCommands;

use IlluminateFoundationBusDispatchable;
use IlluminateHttpUploadedFile;
use RamseyUuidUuid;

class Store extends Update
{
    use Dispatchable;

    public function __construct(
        string $name,
        UploadedFile|null $photo = null,
    ) {
        parent::__construct(
            breed_id: Uuid::uuid4()->toString(),
            name: $name,
            photo: $photo,
        );
    }
    public static function fromArray(array $payload): Store
    {
        return new Store(
            name: $payload['name'] ?? null,
            photo: $payload['photo'] ?? null,
        );
    }
}

Update.php:

<?php

declare(strict_types=1);

namespace PetcheckrCommonApplicationAnimalBreedsCommands;

use IlluminateFoundationBusDispatchable;
use IlluminateHttpUploadedFile;

class Update
{
    use Dispatchable;

    public function __construct(
        private string $breed_id,
        private string $name,
        private UploadedFile|null $photo = null,
        private bool|null $photoDeleted = null,
    ) {
    }

    public function getBreedId(): string
    {
        return $this->breed_id;
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function getPhoto(): ?UploadedFile
    {
        return $this->photo;
    }

    public function getPhotoDeleted(): ?bool
    {
        return $this->photoDeleted;
    }

StoreRequest.php:

<?php

declare(strict_types=1);

namespace PetcheckrCommonUiHttpAdminRequestsAnimalBreeds;

use IlluminateFoundationHttpFormRequest;
use IlluminateHttpUploadedFile;
use XocdrAuthDomainRulesPasswordRule;

/**
 * @property-read string $breed_id
 * @property-read string $name
 * @property-read UploadedFile|null $photo
 */
class StoreRequest extends FormRequest
{
    public function authorize(): bool
    {
        return !empty($this->user()) && in_array(
            $this->user()->role,
            [
                'PETCHECKR.ADMIN',
                'VET_PRACTICE.ADMIN',
            ]
        );
    }

Create.vue:

<script setup>
import HeadingWithDescriptionAndActions from "@/Xocdr/Components/Panels/Heading/HeadingWithDescriptionAndActions.vue";
import Card from "@/Xocdr/Components/Panels/Card.vue";
import {ChevronLeftIcon} from "@heroicons/vue/20/solid/index.js";
import {router, useForm, usePage} from "@inertiajs/vue3";
import StackedForm from "@/Xocdr/Components/Forms/StackedForm.vue";
import TextInput from "@/Xocdr/Components/Forms/Fields/TextInput.vue";
import ImageUpload from "@/Xocdr/Components/Forms/Fields/ImageUpload.vue";

import {useI18n} from "vue-i18n";
const { t } = useI18n();
import getLanguages from '@/Xocdr/Config/Languages.js';
const languages = getLanguages(
    t,
    usePage().props?.languages || ['en']
);

const form = useForm({
    name: null,
    photo: null,
});

const user = usePage().props.auth.user;

const fields = [
    {
        identifier: 'name',
        label: t('petcheckr.configuration.name'),
        required: true,
        component: TextInput,
        placeholder: t('petcheckr.configuration.name'),
        information: null,
    },
    {
        identifier: 'photo',
        label: t('xocdr.auth.profile_picture'),
        required: false,
        component: ImageUpload,
        information: null,
    },
]

function backToOverView() {
    router.get(
        route("petcheckr.config.animal-breeds.index")
    );
}

function submitForm() {
    form.post(
        route('petcheckr.config.animal-breeds.store'),
    );
}

</script>
<template>
    <Card class="mb-10" :header-no-margin="true" :content-no-margin="true">
        <template v-slot:header>
            <HeadingWithDescriptionAndActions
                :title="'Title'"
                :actions="[
                    {
                        identifier: 'back',
                        icon: ChevronLeftIcon,
                        title: $t('petcheckr.configuration.back_to_overview'),
                    }
                ]"
                :context="{}"
                @back-click="backToOverView"
            >
            </HeadingWithDescriptionAndActions>
        </template>
        <template v-slot>
            <StackedForm
                :fields="fields"
                v-model="form"
                @delete-photo="(options) => { form.photo = ''; options.callback && options.callback();}"
                :submit-button-title="'Create'"
                @submit="submitForm"
            />
        </template>
    </Card>
</template>

<style scoped>

</style>

for routes:
authenticated.php

use PetcheckrCommonUiHttpAdminControllersAnimalBreedsCreateController as AnimalBreedsCreateController;
use PetcheckrCommonUiHttpAdminControllersAnimalBreedsStoreController as AnimalBreedsStoreController;

Route::get(
    '/animal-breeds/create',
    AnimalBreedsCreateController::class,
)->name('config.animal-breeds.create');

Route::post(
    'animal-breeds',
    AnimalBreedsStoreController::class,
)->name('config.animal-breeds.store');

To those who mastered this language I’m seeking help.

I almost 2 weeks now, I can’t fix the problem.
I copy from the other files insert functions and applied to mine but doesn’t work

Stop Rehub from automatically cropping feautured image in posts

I am using the Worpress theme Rehub which automatically crops my featured images in posts. I do not wish for it to do that, and when inspecting the rendered image I see the below:

enter image description here

I have tried changing the source in the following files and setting to no avail:
functions.php
styles.css
Miscelaneous files in inc/
style-editor.css
Settings, Media (cropping is disabled)
Theme, Settings (cropping is disabled)

I have found the file containing code with

    #rh_wide_inimage figure

but that file does not contain code setting height to 550 px or cropping. I have found a custom resizer in the theme, but not sure how to disable it safely.

Why is only the last liked item deleted and not the chosen one?

Hello i made a like/favorites button with Livewire and it works untill you have multiple likes and when you want to unlike/delete, only the last one added is deleted and the others lose their blue color but when you refresh they appear again. How can i solve this?
I tried many things but could not find a solution.

namespace AppHttpLivewire;

use LivewireComponent;
use IlluminateSupportFacadesAuth;
use AppModelsVacature;
use AppModelsFavoriet;
use IlluminateContractsViewView;
use WithPagination;

class Vacatures extends Component
{
    public $orderBy = "Sorteer: Nieuwste Vacatures";
    public $vacids = [];
    public $favoriet;
    public $updatePage = false;

    public function mount()
      {
        if(Auth::id()) {
        $user = Auth::user();
        $this->favoriet = Favoriet::where('user_id',$user->id)->get();
        foreach($this->favoriet as $this->favoriet){
          $this->vacids[] = $this->favoriet->vacature_id;
        }
      }    
    }

    public function saveFavoriet($id){
    if(Auth::id()) {
       $user = Auth::user();
       $vacature = Vacature::find($id);
       $this->favoriet = new Favoriet;
       $this->favoriet->user_id = $user->id;
       $this->favoriet->vacature_id = $vacature->id;
       $this->favoriet->vacature_naam = $vacature->naam;
       $this->favoriet->beschrijving = $vacature->beschrijving;
       $this->favoriet->save();  
       $this->updatePage = false;
       $this->mount();
    }
    else{
     return redirect('login')->with('message', 'Log in om je favorieten op te slaan, je kunt ze dan altijd terugvinden in jouw favorieten menu.');
  }
}

  public function deleteFavoriet()
   {
        $this->favoriet->delete();
        $this->updatePage = true;
   }




     @if(in_array($vac->id, $this->vacids))
     @if($this->updatePage==false)
          <div>
          <a wire:click.prevent="deleteFavoriet()" class="bi bi-heart-fill fa-lg m-2" href=""
           data-tooltip="tooltip" data-placement="top" title="Is al favoriet">
          </a>
           <div>
         </div>
          </div>
          @else
          <div>
         <a wire:click.prevent="saveFavoriet({{ $vac['id'] }})" class="bi bi-heart fa-lg m-2" href="" 
           data-tooltip="tooltip" data-placement="top" title="Voeg toe aan favorieten">
          </a>
         </div>
         @endif
         @else
         <div>
         <a wire:click.prevent="saveFavoriet({{ $vac['id'] }})" class="bi bi-heart fa-lg m-2" href="" 
           data-tooltip="tooltip" data-placement="top" title="Voeg toe aan favorieten">
          </a>
         </div>
          @endif         
          <div class="border"></div>
          @endforeach 
        </div>         
        </div>  
       @endif
      </div>    
        </section>




Speed up PHP calculations

I wrote a simple program to count the number of Sunday days between two dates. If there are large gaps between dates, the script takes a very long time to execute. Can this be somehow optimized?

   $sunDay = 0;
   $start = DateTime::createFromFormat('m.d.X', "02.12.2023");
   $end = DateTime::createFromFormat('m.d.X', "04.12.292277026596");

   for ($i = $start; $i <= $end; $i = $i->modify('+1 day')) {
      if ($i->format('N') > 6) $sunDay++;
   }

Livewire 3 Nested Data Binding in Multiple Inputs [Array]

I would like to create 3 inputs to input video so here but it should depend in array. Nested Data binding is not supported in Livewire 3. However, I need to achieve video.1 video.2, and video.3

Livewire [ListingEdit Component]

protected $rules = [
    'video.*' => 'nullable',
];

class ListingEdit extends Component
{
    use WithFileUploads;
    public ListingData $listing;

    public $video = []; // video 1, video 2, video 3

Livewire [ListingEdit Blade]

@for ($i = 1; $i <= 3; $i++)
    <div class="{{ $i != 3 ? 'mb-3' : '' }}">
        <x-input-label for="video{{$i}}" :value="__('Video [num]', ['num' => $i])" />
        <x-text-input-post id="video{{$i}}" :type="old('video')" wire:model="video.{{$i}}"
            placeholder="Embed youtube video" maxChar="80"
            autocomplete="video" />

    </div>
@endfor

The wire:model would be look like video.1, video.2, video.3