October 22, 2024
Chicago 12, Melborne City, USA
PHP

Symfony Rate Limiter with additional blocking time option

I need a rate limiter where you can configure a separate blocking time when the limit has been exceeded. The use case would be, for example, that 20 accesses are allowed in one minute, if this number is exceeded, access should be blocked for 30 minutes. The usual Symfony rate limiters do not seem to

Read More
PHP

How can I stop WooCommerce from loading the Inter font on my product page?

I’m using WooCommerce on my WordPress site, and I noticed that it is loading a large font file called Inter-VariableFont_slnt,wght.woff2. This font file is as large as my entire page and is significantly slowing down the loading speed and blocking my FCP. My theme (Uncode) is already loading all the fonts I need, so I

Read More
PHP

Regular expression to identify CSS functions

I have a variable called $value that contains a string with a css expression. It can be a value or a function: rgb( 25, 128, 128 );, transform( -50% -50% );, bottom 50px right 100px;, #198080;, bold;, 1px solid red; I want to be able to identify if the expression contains a function or a

Read More
PHP

I have a problem connecting laravel to my database

This is the error that i get: Illuminate\Database\QueryException could not find driver (Connection: mysql, SQL: select exists (select 1 from information_schema.tables where table_schema="fitnessapp" and table_name="migrations" and table_type in ('BASE TABLE', 'SYSTEM VERSIONED')) as `exists`) at vendor\laravel\framework\src\Illuminate\Database\Connection.php:825 821▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 822▕ ); 823▕ } 824▕ ➜ 825▕ throw new QueryException( 826▕ $this->getName(), $query, $this->prepareBindings($bindings),

Read More
PHP

Why does PHP preg_replace() not propery replace “µ” in string?

I got this string: "Grünkohl (gegart) [vom Bauern, -50% gewaschen([{vBü,_-4%?+#*^°\ß´`&§"!<>|'~.:,;µ{}/$²³}])" I want to have all characters except some allowed ones replaced by "-". This is my function call: preg_replace('/[^a-z0-9äöü°!"²§³\\$&\\(\\[\\)\\]=ß´\\+\\*~\'\\-_\\.:\\,;<>@€]/i', '-', $string); And this is the string I get: "Grünkohl-(gegart)-[vom-Bauern,--50--gewaschen([-vBü,_-4--+-*-°-ß´-&§"!<>-'~.:,;�----$²³-])" Why is the "µ" not propery replaced? (it turned to "�-") You need to sign in

Read More
PHP

json_encode is passing invalid data

A json payload is being sent from one website through my middleware and then to a final website. The json object that is being sent looks like this: { "event": "donation_completed", "payload": { "email": "myemail@yahoo.com", "fields": { "mrcC3": "1.05", "country": "US", "lastName": "Beasley", "firstName": "John", "mrcDateC3": "2024-10-21 03:06:24 UTC" }, "overwrite": true } } In

Read More
PHP

how change schema product yoast on image?

I noticed that the Google snippet does not display a photo of the product. I changed the plugin code, but the test showed no results. plugin Yoast SEO: WooCommerce code protected function filter_variations( $data, $product ) { if ( ! isset( $data['offers'] ) || $data['offers'] === [] ) { return $data; } $data['@type'] = 'ProductGroup';

Read More
PHP

How to check if two unix timestamps are included in five minutes by using DateTime Class

How to check in PHP if 2 unix timestamps are in a range on 5 minutes by using DateTime Class? I’m refering to five minutes of clock, not (5*60 secs). When exactly the minute passes when you look at the system clock. So it could be for example a range from 04:59 to 05:04. In

Read More
PHP

When execute multiple ajax function in async way. PHP response in sync way

Here show js function, But my response received from PHP which is in sequence. So I expecting queries to execute all in one go. PHP queries public function get_filtered_data_01(){...} public function get_filtered_data_02(){...} JS query //Example ajax query 01 as like below we have few more query function load_filtered_data_1(data_params) { $.ajax({.....}); } async function loadAllFilters(data_params) {

Read More
PHP

Laravel can't get redis key value on For loop

I had a problem with Laravel when get a Redis value on loop public function testLoop() { for($i = 0; $i < 3; $i++) { Redis::set('key_'.$i, 'value_'.$i); Log::info(Redis::get('key_'.$i)); } return true; } Laravel successfully set the key but any error on get key here is the logs, only get the first key [2024-10-21 09:05:13] local.INFO:

Read More