Local server not syncing data from Azure server [closed]

Our developer set up a webserver using WAMP with the goal of fetching web content hosted on Azure to our local server, allowing us to access this content locally. However, there’s an issue with the local server not synchronizing with the Azure server. As a result, any updates made to the web content aren’t reflecting on the local server.

What’s the possible solution?

I am not a technical person. I need soltuion for this problem.

What is any regular expression that matches and capture a multiline string predeced by an undefined number of new lines? [PCRE]

I have this multi-line string:

Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus
dictum, lorem et fringilla congue, velit libero sagittis eros, id
lobortis nisi risus ac mauris.

I would like to use PHP Compatible Regular Expression to “name capture” the second “paragraph” (the 3-line text after the new line).

I tried the following regular expression on regex101 and it works fine :

/n(n)+(?<namedGroup>([wd]+.*(n)?)+)/m

but when I tried it in PHP using the following code, nothing gets captured :

<?php
$text = file_get_contents("paragraphs.txt");

$regular_expression = '/n(n)+(?<namedGroup>([wd]+.*(n)?)+)/m';

preg_match($regular_expression, $text, $result);
print_r($result);
?>

Add “EAN” column to the products table in WooCommerce (wp-admin)

I use woocommerce v. 7.9.0
I inserted the following code in the theme’s functions.php file but no new column appears on the wp-admin/edit.php?post_type=product page.
Does anyone know how to solve it?

// Add "EAN" column to the products table in WooCommerce
function add_column_product_ean($columns) {
     $new_columns = array();

     foreach ($columns as $column_name => $column_info) {
         $new_columns[$column_name] = $column_info;
        
         if ($column_name === '_sku') {
             // Add "EAN" column after "SKU" column
             $new_columns['ean'] = 'EAN';
         }
     }

     return $new_columns;
}
add_filter('manage_edit-product_columns', 'add_column_product_columns');

// Populate the "EAN" column with the custom field data
function populate_column_product_ean($column, $post_id) {
     if ($column === 'ean') {
         $ean_value = get_post_meta($post_id, 'ean', true);
         echo $ean_value;
     }
}
add_action('manage_product_posts_custom_column', 'populate_column_product_ean', 10, 2);

I want to make a name-specific book preview in Woocommerce

I want to create a customizable product in WooCommerce. I want to create a flip book preview that changes based on name and gender. Example page:
https://mymagicname.com/book/

Is there a plugin I can buy to create this or is there a method that will help?

I tried to make a software myself. My PHP and WordPress knowledge was not enough to do this. I will prepare the software for myself. I looked for an example to examine the code structure to improve my knowledge, but I couldn’t find it.

PHP CryptoJS.MD5().toString() equivalent [closed]

I have a problem.

I would like to have the equivalent of this in php:

CryptoJS.MD5().toString()

I use like this:

let result = CryptoJS.MD5('111-1111111'+'Test'+150000+1007+'Test').toString()

result = 653ad7612a93e4b61f99a7a48d8c7077

Php code is: $myString = "111-1111111"."Test".150000.1007."Test";

$hash = md5($myString);

$hash = 32a0173df31947238b515d3a0664c2a0

Because when I use md5() of php, I don’t get the same result.

How to save files to the database in the order in which the user chooses them

I have no idea how to save files to a database in order that user chooses them in the input tag. I would to add sortable functionality to it with Jquery. In a database, I have a table files, that has id as a foreign key. The foreign key is used to connect to a post table. Thank you in advance for your answers.

I try to create a column in a database with position of a file, but it did not work out.

Laravel – PHP Fatal error when running php artisan serve with increased memory_limit

I’m encountering a PHP Fatal error in my Laravel project when running php artisan serve. The error message is as follows:

php artisan serve

   INFO  Server running on [http://127.0.0.1:8000].

   Press Ctrl+C to stop the server

   WARN  PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in C:projectslaravelstorageframeworkviews3013c4ad2c85349d3078c69a5161cf9c.php on line 96.

   WARN  PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 888832 bytes) in C:projectslaravelvendorspatieignitionsrcErrorPageErrorPageViewModel.php on line 104.

  2023-11-04 15:33:26 .............................................................................................. ~ 15s
  2023-11-04 15:33:26 ............................................................................................. ~ 133s

Mode LastWriteTime Length Name

—- ————- —— —-

d—– 11/4/2023 2:50 PM .git

d—– 11/4/2023 2:50 PM .vite

d—– 11/4/2023 2:50 PM app

d—– 11/4/2023 2:50 PM bootstrap

d—– 11/4/2023 2:50 PM config

d—– 11/4/2023 2:50 PM database

d—– 11/4/2023 2:50 PM node_modules

d—– 11/4/2023 2:50 PM public

d—– 11/4/2023 2:50 PM resources

d—– 11/4/2023 2:50 PM routes

d—– 11/4/2023 2:50 PM storage

d—– 11/4/2023 2:50 PM tests

d—– 11/4/2023 2:52 PM vendor

-a—- 11/2/2023 12:25 PM 258 .editorconfig

-a—- 11/4/2023 2:43 PM 1171 .env

-a—- 11/2/2023 12:25 PM 1116 .env.example

-a—- 11/2/2023 12:25 PM 186 .gitattributes

-a—- 11/2/2023 12:25 PM 243 .gitignore

-a—- 11/2/2023 12:25 PM 1686 artisan

-a—- 11/2/2023 3:02 PM 1553 base.txt

-a—- 11/4/2023 2:30 PM 58167 composer-setup.php

-a—- 11/2/2023 12:25 PM 1882 composer.json

-a—- 11/2/2023 12:25 PM 296306 composer.lock

-a—- 11/2/2023 12:25 PM 113 db.sql

-a—- 11/2/2023 12:25 PM 83555 package-lock.json

-a—- 11/2/2023 12:25 PM 415 package.json

-a—- 11/2/2023 12:25 PM 1084 phpunit.xml

-a—- 11/2/2023 12:25 PM 80 postcss.config.js

-a—- 11/2/2023 6:30 PM 4230 README.md

-a—- 11/2/2023 12:25 PM 218 tailwind.config.js

-a—- 11/2/2023 12:25 PM 263 vite.config.js

Here are some details about my environment:

  • Laravel Installer: 5.1.3

  • PHP Version: 8.2.12

  • Operating System: Windows

  • Database: MySQL

I’ve attempted to increase the memory_limit in my php.ini file from 256M to 512M, but I’m still encountering the same error when running php artisan serve.

I would appreciate any guidance or insights into resolving this issue. Thank you for your assistance!

Additional Information:

  • Laravel Installer: 5.1.3

  • PHP Version: 8.2.12

  • Operating System: Windows

  • Database: MySQL

  • Memory limit in php.ini: memory_limit = 512M

Need StackExchange API for question count for particular tag

I tried Questions Dos from stackexchange to get total count of questions for perticular tag
but it has some limitation like That API return only 30 data at a time and max 100 data(question) But I need more than 10,000 counts, If I go through all page and count those questions using js or php it will take lots of time any sort way to get the total count of that question?

Example API: https://api.stackexchange.com/2.3/questions?tagged=airflow&site=stackoverflow;

I tried https://api.stackexchange.com/2.3/questions?tagged=airflow&site=stackoverflow API

and I get the first 30 items

But I want total number of those questions
Screenshot

Fatal error: Uncaught Error: Call to undefined function wp_generate_password() or wp_mail()

I would like to generate a unique password hash and try to use the following wordpress function:

$activation_token = wp_generate_password();
update_user_meta($user_id, 'activation_token', $activation_token);

Unfortunately, it not work because Fatal error: Uncaught Error: Call to undefined function wp_generate_password()

Is this function deprecated? I cannot find anything else in WordPress documentation.

Edit: I try the code in my wordpress theme and in works! So the problem is, i cannot call any wordpress core functions? I have the same problem with wp_mail()

I updated the wordpress installation, use the default Twenty theme and deactivated all other plugins but i have still the same probelm! wp_ functions not work in plugin, why?

Track Woocommerce Orders only with phone numbers

I am using this woocommerce default code for tracking where customer have to enter both order id and phone number to track the order.

enter image description here

and here is the code for this

// Create a custom tracking shortcode
add_shortcode( 'dvs_order_tracking', 'dvs_tracking_request' );
function dvs_tracking_request() {
    if ( is_null( WC()->cart ) ) {
        return;
    }
    $nonce_value = wc_get_var( $_REQUEST['woocommerce-order-tracking-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) );

    if ( isset( $_REQUEST['orderid'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-order_tracking' ) ) { 
        $order_id    = empty( $_REQUEST['orderid'] ) ? 0 : ltrim( wc_clean( wp_unslash( $_REQUEST['orderid'] ) ), '#' );
        $order_email = empty( $_REQUEST['order_email'] ) ? '' : sanitize_text_field( wp_unslash( $_REQUEST['order_email'] ) );
        $order_phone = empty( $_REQUEST['order_phone'] ) ? '' : sanitize_text_field( wp_unslash( $_REQUEST['order_phone'] ) );   
        $dvs_tracking_phone = get_option( 'dvs_tracking_phone' );

        if ( current_user_can( 'manage_options' ) ) {
            if ( ! $order_id ) {
            wc_print_notice( __( 'Order number is required', 'woocommerce' ), 'error' );
            }
            else {
                $order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
                if ( $order && $order->get_id() ) {
                    do_action( 'woocommerce_track_order', $order->get_id() );
                    wc_get_template(
                        'order/tracking.php',
                        array(
                            'order' => $order,
                        )
                    );
                    return;
                } else {
                    wc_print_notice( __( 'Sorry, order could not be found.', 'woocommerce' ), 'error' );
                }
            }
        }
        else if($dvs_tracking_phone == 1) {
            if ( ! $order_id ) {
                wc_print_notice( __( 'Order number is required', 'woocommerce' ), 'error' );
            } elseif ( ! $order_phone ) {
                wc_print_notice( __( 'Mobile Number is required', 'woocommerce' ), 'error' );
            } else {
                $order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
                if ($order_phone == '1122') {
                    do_action( 'woocommerce_track_order', $order->get_id() );
                    wc_get_template(
                        'order/tracking.php',
                        array(
                            'order' => $order,
                        )
                    );
                    return;                    
                }
                if ( $order && $order->get_id() && strtolower( $order->get_billing_phone() ) === strtolower( $order_phone ) ) {
                    do_action( 'woocommerce_track_order', $order->get_id() );
                    wc_get_template(
                        'order/tracking.php',
                        array(
                            'order' => $order,
                        )
                    );
                    return;
                } else {
                    wc_print_notice( __( 'Sorry, the order could not be found. Please contact us if you are having difficulty finding your order details.', 'woocommerce' ), 'error' );
                }
            }
        }
        else {
            if ( ! $order_id ) {
                wc_print_notice( __( 'Order number is required', 'woocommerce' ), 'error' );
            } elseif ( ! $order_email ) {
                wc_print_notice( __( 'Email Address is required', 'woocommerce' ), 'error' );
            } else {
                $order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
                if ($order_email == '1122') {
                    do_action( 'woocommerce_track_order', $order->get_id() );
                    wc_get_template(
                        'order/tracking.php',
                        array(
                            'order' => $order,
                        )
                    );
                    return;                    
                }
                if ( $order && $order->get_id() && strtolower( $order->get_billing_email() ) === strtolower( $order_email ) ) {
                    do_action( 'woocommerce_track_order', $order->get_id() );
                    wc_get_template(
                        'order/tracking.php',
                        array(
                            'order' => $order,
                        )
                    );
                    return;
                } else {
                    wc_print_notice( __( 'Sorry, the order could not be found. Please contact us if you are having difficulty finding your order details.', 'woocommerce' ), 'error' );
                }
            }            
        }
    }
    wc_get_template( 'order/form-tracking.php' );

?>

<?php } 

I wanted to give an option to my customers that they can either put their order number or phone number and their order tracking page will pop up.

Note: All my orders have phone numbers so there will be no issue with an empty phone number field.

How to implement a web activity tracker using php and kafka

I’d like to implement a web activity tracker with php and kafka but i am a newbie with all these technologies and i’d like to know where to start with all of this . I’ve already install kafka dependencies using php . Could you help me with some advices , references or any type of resources ??? Thanks

Shopware 6 Plugin: How can I check wildcard emails against a blacklist

I have developed a Shopware 6 plugin that checks if an email is in a blacklist before allowing reviews. It works but currently does a database query for every email being checked. If I am in a scheduled task run that sends out 50 emails and I have 1000 entries with wildcard entries, this code won’t work anymore.

I would like to optimize the plugin to:

  • Support wildcard patterns in the blacklist (e.g. *@amazon.com)
  • Fetch the blacklist once and loop through it instead of separate queries

Here is the current code:

use MonologLogger;
use ShopwareCoreFrameworkContext;
use ShopwareCoreFrameworkDataAbstractionLayerEntityRepository;
use SwaProductReviewsComponentsLoggerHelper;
use ShopwareCoreFrameworkDataAbstractionLayerSearchCriteria;
use ShopwareCoreFrameworkDataAbstractionLayerSearchFilterEqualsFilter;


class MailWithBlacklist {
    private EntityRepository $blacklistRepository;
    protected LoggerHelper $loggerHelper;
    
    public function __construct(EntityRepository $blacklistRepository, LoggerHelper $loggerHelper) {
        $this->blacklistRepository = $blacklistRepository;
        $this->loggerHelper = $loggerHelper;
    }
    
    /**
     * 
     * @param string $email
     * @param Context $context
     * @return bool
     */
    public function isEmailBlacklisted(string $email, Context $context): bool
    {

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('email', $email));

        
        $blacklistEntry = $this->blacklistRepository->search($criteria, $context)->first();

        $this->loggerHelper->addDirectRecord(Logger::DEBUG, 'end of isEmailBlacklisted' , ['blacklistEntry' => $blacklistEntry]);
        return $blacklistEntry !== null;
    }
}

How can I modify this code?

Any help is appreciated.

Interoperability of PHP, OpenSSL and C# regarding AES encryption

Given a PHP script that encrypts a string with openssl_encrypt, I want to decrypt the output with openssl CLI and C#.
Although I can encrypt and decrypt the string in each programming language on its own with key and IV, I cannot decrypt the PHP output with openssl CLI and C#.

This is the PHP script:

<?php

function bad_crypt($string, $action = 'e') {
    if (empty($string)) {
        return "";
    }

    $encrypt_method = "AES-256-CBC";
    $key = "3d13b07f244861f2d323d1734d773ce4bd079e2c17deb5695911e1387e0b579a";
    $iv = "d9ec53dadaf1e968"; // bad practice, but this is just a test

    echo "key:";
    echo "<br>";
    echo $key;
    echo "<br>";

    echo "iv:";
    echo "<br>";
    echo $iv;
    echo "<br>";

    if ($action == 'e') {
        $output = base64_encode(openssl_encrypt($string, $encrypt_method, $key, 0, $iv));
    } else if ($action == 'd') {
        $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
    }

    return $output;
}

$info = "mysecret";
$encInfo = bad_crypt($info);

echo "encrypted:";
echo "<br>";
echo $encInfo;

echo "<br>";
echo "<br>";
echo "<br>";

$t = bad_crypt($encInfo, "d");

echo "decrypted:";
echo "<br>";
echo $t;
?>

which gives the following output:

key:
3d13b07f244861f2d323d1734d773ce4bd079e2c17deb5695911e1387e0b579a
iv:
d9ec53dadaf1e968
encrypted:
QVBBaDcrdkRUdVFqZDV5cGFMNHJCdz09


key:
3d13b07f244861f2d323d1734d773ce4bd079e2c17deb5695911e1387e0b579a
iv:
d9ec53dadaf1e968
decrypted:
mysecret

I have tried numerous combinations of options for openssl; none did reproduce the PHP encryption result or decrypted it.

Example openssl encryption command:

openssl.exe enc -e -aes-256-cbc -a -K 3d13b07f244861f2d323d1734d773ce4bd079e2c17deb5695911e1387e0b579a -iv d9ec53dadaf1e968 -in mysecret.txt

with mysecret.txt containing mysecret results in plQ2hEAoywxUeFWniDszdQ==.

Any help is appreciated.
Looking forward to a working openssl cli command and a C# program.

Unable to Print Laravel API One to Many Relationship data on Angular Frontend

I have Angular App connected with Laravel API. In Laravel API there are one to many relationship between Employee and Salary Models.
Employee.php

protected $fillable = ['birth_date','first_name','last_name','gender','hire_date'];

    protected $primaryKey = 'emp_no';

     public function salaries(): HasMany
    {
        return $this->hasMany(Salary::class, 'emp_no','emp_no');
    }

and Salary.php

protected $fillable = ['salary','from_date','to_date'];

    public function employee(): BelongsTo
    {
        return $this->belongsTo(Employee::class, 'emp_no');
    }

now I need print Salary Model data on Angular app. so, I try in this way

<div class="basic-info">
    <p>Employee Name : {{employee.first_name}}</p>
    <p>Date of Birth :</p>
    <p>Gender :</p>
    <p>Hire Date :</p>
</div> 
 <div class="salary-topic">
    <h4><b>Salary Details</b></h4>
</div>
<div class="salary-details">
    <table class="table">
        <thead>
            <tr>
                <th scope="col">salary {{employee.salary}}</th>
                <th scope="col">From Date{{employee.from_date}}</th>
                <th scope="col">To Date{{employee.to_date}}</th>
            </tr>
        </thead>
</table>
</div>

my data.service.ts is like this

getEmployeeById(id: string){
    return this.httpClient.get('http://127.0.0.1:8000/api/employee/'+id);
  }

and employee-by-id.ts is

getData() {
    this.dataService.getEmployeeById(this.id).subscribe(res => {
     // console.log(res);
     this.data = res;
     this.employee = this.data;
    })
  }

Laravel Controller for get Employee by id

public function getEmployeeById($id) {
        $employee = Employee::with('titles','salaries')->find($id);
        if(is_null($employee)) {
            return response()->json(['message' => 'Employee Not Found'], 404);
        }
        return response()->json($employee::with('titles','salaries')->find($id), 200);
    }

api route

//get specific employee
Route::get('employee/{id}','AppHttpControllersEmployeeController@getEmployeeById');

my Employee model data is printing well. but relathionship Salary Model is not printing. in browser element printing both model data well in json format. how could I fix this problem?
json output

Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. node.js:383
Angular is running in development mode. vendor.js:47622:13
XHRGET
http://127.0.0.1:8000/api/employee/1
[HTTP/1.1 200 OK 228ms]

    
emp_no  1
birth_date  "1983-10-05"
first_name  "David"
last_name   "Koner"
gender  "male"
hire_date   "2023-09-18"
created_at  null
updated_at  null

salaries    [ {…} ]
0   Object { emp_no: 1, salary: 27000, from_date: "2023-09-22", … }
emp_no  1
salary  27000
from_date   "2023-09-22"
to_date "2023-09-19"
created_at  "2023-10-09T08:17:26.000000Z"
updated_at  "2023-10-09T08:48:02.000000Z"

Is there a solution to ‘This page isn’t working If the problem continues, contact the site owner’ when conneting mySQL with php to my website [closed]

I need to connect my website to MySQL database using php,and after completing to write the php code. I head over to the registration form to try and create a new user but upon clicking the register button, browser redirects me to a page that says ‘This page isn’t working If the problem continues, contact the site owner.
HTTP ERROR 405’