sql server – how to change “localhost” in MariaDB

I wonder if there is any way to change ‘localhost’ in MariaDB. for example, when you create a user in database, it shows ‘user’@’localhost’
I would like to know how to change ‘localhost’ to any other name. for example, I will be able to create a user in database like the following: ‘user’@’mydomain.com’
by the way, I’m very new in MariaDB and SQL server stuff.
thank you in advance!

mongo db-Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2

while adding secondary member in replica set, i get following error:
"Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2"
my first machine configuration is:enter image description here

enter image description here

enter image description here

second node config:
enter image description here

design patterns – Interfacing with records on remote DB from localhost Application Logic

There are times when I have to fix/update records on a Production and/or Staging environment for a Web App. These are remote DBs.

Rather than push application code to fix the data, I’ve been “interfacing” my localhost’s version of the running app with the remote DBs. I can do this by simply changing an ENV var for the DB URI.

I’m doing this as opposed to shelling into DB and updating records because I need some actual code to massage data too.

Any insights on this pattern? Thanks!

linux – Alternative for “nc -z localhost 3300” for windows [netcat]

I have a sh that is meant to run in linux.

But im using windows, and I must be able to run it in windows

Theres a piece of code that does the following

while ! nc -z localhost 3300; do
    echo "Waiting for MariaDb"
    sleep 0.1
done

But im unable to replicate it in windows since nc doesnt work.

What is the alternative to the exact command?

ubuntu – Prevent docker container from accessing localhost

I noticed that I can access the host from a docker container by using the docker0 gateway address. For security reasons I want to block / limit this access.

I already used the following iptables rule to prevent the container from accessing my local network:

iptables -A INPUT -i docker0 -d 192.168.0.0/16 -j DROP
iptables -A FORWARD -i docker0 -d 192.168.0.0/16 -j DROP

Running curl 192.168.1.1 inside the container results in a timeout (as expected).

I want to achieve the same when accessing my host system using the docker default gateway, i.e. curl 172.17.0.1 should also result in a time out.

Furthermore I want to block all ports except one. On my host system runs a mysql server (port 3306) which should be accessible by all containers.

design – HTTPS headless browser to HTTP localhost Flask

I have two Docker containers:

  1. Headless browser grabbing images by running JavaScript
  2. Flask server analysing these images (and sending results to another server)

I’m using a bridge network to communicate, but I’m running into a lot of problems:

  1. Flask is HTTP, headless grabs from an HTTPS website, causing “mixed content” errors
  2. Change the call and the Flask server to HTTPS with ad-hoc SSL, which gives me ERR_CERT_AUTHORITY_INVALID
  3. Add tag gives me net::ERR_SSL_PROTOCOL_ERROR

This feels too complicated to send an extracted image from a headless browser to another Docker container. Is there a different way I can design this to prevent these HTTP/HTTPS call workarounds altogether?

Separate Register page in woocommerce not work on my site but work on localhost

i use code to separate regiter form in woocomerce
this code work on wamp local server
but i have error in my website not work(https://khutwabooks.com/reg/ ) .
so what the problem here ? and how i can add jquery check for this form before submit
my code is

/**
 * @snippet       WooCommerce User Registration Shortcode
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 4.0
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
   
add_shortcode( 'wc_reg_form_bbloomer', 'bbloomer_separate_registration_form' );
    
function bbloomer_separate_registration_form() {
   if ( is_admin() ) return;
   //if ( is_user_logged_in() ) return;
   ob_start();
   // if (is_user_logged_in() ){ header( 'Location:http://127.0.0.1/2021/my-account' ); die; }
if ( is_user_logged_in() ) {
   wc_add_notice( sprintf( __( 'أنت الآن مسجل الدخول. إذا كنت ترغب في التسجيل بحساب مختلف من فضلك قم بـ <a href="%s">تسجيل الخروج</a> ', 'bbloomer' ), wc_logout_url() ) );
   wc_print_notices();
  
   
  // echo get_site_url();
   ?>
   <br> <p class="woocommerce-message">  سيتم تحويل إلى الصفحة الرئيسية خلال 5 ثواني</p>
  <meta http-equiv="refresh" content="5;url= <?php echo get_site_url()?>" />
  

<?php
} else {
   // NOTE: THE FOLLOWING <FORM></FORM> IS COPIED FROM woocommercetemplatesmyaccountform-login.php
   // IF WOOCOMMERCE RELEASES AN UPDATE TO THAT TEMPLATE, YOU MUST CHANGE THIS ACCORDINGLY
 
   do_action( 'woocommerce_before_customer_login_form' );
 
   ?>
      <form method="post" class="woocommerce-form woocommerce-form-register register" <?php do_action( 'woocommerce_register_form_tag' ); ?> >
 
         <?php do_action( 'woocommerce_register_form_start' ); ?>
 
         <?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?>
 
            <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
               <label for="reg_username"><?php esc_html_e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label>
               <input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="username" id="reg_username" autocomplete="username" value="<?php echo ( ! empty( $_POST('username') ) ) ? esc_attr( wp_unslash( $_POST('username') ) ) : ''; ?>" /><?php // @codingStandardsIgnoreLine ?>
            </p>
 
         <?php endif; ?>
 
         <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
            <label for="reg_email"><?php esc_html_e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
            <input type="email" class="woocommerce-Input woocommerce-Input--text input-text" name="email" id="reg_email" autocomplete="email" value="<?php echo ( ! empty( $_POST('email') ) ) ? esc_attr( wp_unslash( $_POST('email') ) ) : ''; ?>" /><?php // @codingStandardsIgnoreLine ?>
         </p>
 
         <?php if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) : ?>
 
            <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
               <label for="reg_password"><?php esc_html_e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label>
               <input type="password" class="woocommerce-Input woocommerce-Input--text input-text" name="password" id="reg_password" autocomplete="new-password" />
            </p>
 
         <?php else : ?>
 
            <p><?php esc_html_e( 'A password will be sent to your email address.', 'woocommerce' ); ?></p>
 
         <?php endif; ?>
 
         <?php do_action( 'woocommerce_register_form' ); ?>
 
         <p class="woocommerce-FormRow form-row">
            <?php wp_nonce_field( 'woocommerce-register', 'woocommerce-register-nonce' ); ?>
            <button type="submit" class="woocommerce-Button woocommerce-button button woocommerce-form-register__submit" name="register" value="<?php esc_attr_e( 'Register', 'woocommerce' ); ?>"><?php esc_html_e( 'Register', 'woocommerce' ); ?></button>
         </p>
 
         <?php do_action( 'woocommerce_register_form_end' ); ?>
 
      </form>
 
   <?php
     
   return ob_get_clean();
}}

and

// Custom function with all extra field data arrays
function extra_register_fields() {
    $text_domain  = 'woocommerce';
    return array(
        'first_name' => array('type' => 'text',    'class' => ('form-row-first'), 'required' => 1, 'label' => __('First name', $text_domain) ),
        'last_name'  => array('type' => 'text',    'class' => ('form-row-last'),  'required' => 1, 'label' => __('Last name', $text_domain) ),
        'country'    => array('type' => 'country', 'class' => ('address-field'),  'required' => 1, 'label' => __( 'المنطقة', $text_domain ) ),
        'state'      => array('type' => 'state',   'class' => ('address-field'),  'required' => 1, 'label' => __( 'State', $text_domain ) ),
        'address_1'   => array('type' => 'text',  'placeholder'=>'الحي',   'class' => ('form-row-wide'),  'required' => 1, 'label' => __( 'عنوان الشارع / الحي', $text_domain ) ),
        'address_2'   => array('type' => 'text',  'placeholder'=>'عنوان الشارع',   'class' => ('form-row-wide'),  'required' => 1, 'label' => __( '', $text_domain ) ),
        'phone'      => array('type' => 'tel', 'placeholder'=>'هاتفك الأساسي',    'class' => ('form-row-wide'),  'required' => 1, 'label' => __( 'Phone', $text_domain ) ),
        'phone2'      => array('type' => 'tel','placeholder'=>'هاتف إضافي في حال انشغال السابق',   'class' => ('form-row-wide'),  'required' => 1, 'label' => __( 'هاتف إضافي آخر', $text_domain ) ),
        'facebook'   => array('type' => 'text', 'placeholder'=>'للتواصل في حال عدم الرد على الهاتف',   'class' => ('form-row-wide'),  'required' => 1, 'label' => __( 'حساب فيس بوكـ أو انستغرام ', $text_domain ) ),
    );
}
//billing_address_2
// Add extra register fields
add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
function wooc_extra_register_fields() {
    foreach ( extra_register_fields() as $fkey => $values ) {
        if( $fkey === 'phone' ) $values('clear') = 1;
        if( $fkey === 'state' ) $values('validate') = ('state');

        $value = isset($_POST('billing_'.$fkey)) ? esc_attr($_POST('billing_'.$fkey)) : '';

        woocommerce_form_field( 'billing_'.$fkey, $values, $value );
    }
    wp_enqueue_script('wc-country-select', get_site_url().'/wp-content/plugins/woocommerce/assets/js/frontend/country-select.min.js', array('jquery'), true);
}

// Extra register fields validation
add_action( 'woocommerce_register_post', 'wc_validate_reg_form_fields', 10, 3 );
function wc_validate_reg_form_fields( $username, $email, $validation_errors ) {
    foreach ( extra_register_fields() as $fkey => $values ) {
        if (isset($_POST('billing_'.$fkey)) && empty($_POST('billing_'.$fkey)) && $values('required') ) {
            $validation_errors->add( 'extra_fields', sprintf('%s is a required field', $values('label')) );
        }
    }
    return $validation_errors;
}

// Save extra register fields values
add_action( 'woocommerce_created_customer', 'wooc_save_extra_register_fields' );
function wooc_save_extra_register_fields( $customer_id ) {
    foreach( extra_register_fields() as $fkey => $values ) {
        if ( isset($_POST('billing_'.$fkey)) ) {
            $value = in_array($fkey, ('country', 'state')) ? sanitize_text_field($_POST('billing_'.$fkey)) : esc_attr($_POST('billing_'.$fkey));

            update_user_meta( $customer_id, 'billing_'.$fkey, $value );

            if ( in_array($fkey, ('first_name', 'last_name','facebook', 'address_1','address_2', 'phone2')) )
                update_user_meta( $customer_id, $fkey, $value );
        }
    }
}
?>
<?php
// Display Facebook and WhatsApp fields in My account eddit billing address
add_filter( 'woocommerce_billing_fields', 'additional_billing_fields', 20, 1 );
function additional_billing_fields($billing_fields) {
    if ( is_wc_endpoint_url( 'edit-address' ) ) {
        foreach ( extra_register_fields() as $fkey => $values ) {
            if ( in_array($fkey, ('address_1','address_2','facebook', 'whatsapp', 'phone2')) ) {
                $billing_fields('billing_'.$fkey) = $values;
            }
        }
    }
    return $billing_fields;
}
?>
<?php
// WordPress User: Add Facebook and WhatsApp fields to billing section
add_filter('woocommerce_customer_meta_fields', 'wordpress_user_account_billing_birthdate_field');
function wordpress_user_account_billing_birthdate_field( $fields ) {
    foreach ( extra_register_fields() as $fkey => $values ) {
        if ( in_array($fkey, ('address_1','address_2','facebook', 'whatsapp','phone2')) ) {
            $fields('billing')('fields')('billing_'.$fkey) = array(
                'label'       => $values('label'),
                'description' => ''
            );
        }
    }
    return $fields;
}
?> ```