Networking – How can I access the WAN IPs programmatically from a TP-Link multi-WAN router?

Our office uses a TP-Link TL-ER6020 multi-WAN router that supports up to 4 WAN connections, of which I use 2. For external access, I would like to register both IPs with AWS Route 53 DNS. Using another system from the office (like a Pi) does not work reliably because of methods like dig +short reports one of the IP addresses based on the path that the traffic has taken.

When checking the admin user interface, there seems to be no evidence of an API. Open ports seem to be:


I have activated and use SNMP snmpwalkI have some interesting variables, except the intranet IPs:

$ snmpwalk -c public -v 2c iso. | grep -vF 192.168.1. = IpAddress: = IpAddress:
iso. = IpAddress: bbb.bbb.bbb.1
iso. = IpAddress: bbb.bbb.bbb.181

Can I rely on this exit to give me the external IPs and consequent? Or do I have to match up iso. (MAC address) and iso. (IP) to be sure (what could I do with awk or Python)? Something like:

snmpwalk -c public -v 2c iso. | awk -v OFS=. '/Hex-STRING/ && /XX XX XX XX XX X(YY)/ {split ($1, a, "."); print a(12), a(13), a(14), a(15)}'

Are there any other options for this router?

Plugins – WordPress Stock Update programmatically

I'm trying to develop a plugin that updates the stock of products older than X days to 0 (sold out). The logic I use is:

  1. Select products with a modification date of more than X days (e.g. 10 days).
  2. Update the stock quantity to 0 (sold out)

SQL statement:

Select as product_id, 
t1.post_title as product_name,
t1.post_type as product_variant, 
t2.min_price as product_cost, 
t2.stock_quantity as product_stock_qty, 
t2.stock_status as product_stock_status, 
t3.user_nicename as vendor_name, 
t1.post_modified as product_stock_update, 
t4.frequency as frequency 
wp_posts t1 join 
wp_wc_product_meta_lookup  t2 on join 
wp_users t3 on join 
wp_cc_autostockaudit t4 on t4.author_id = t1.post_author 
where DATE(DATE_ADD(t1.post_modified, INTERVAL +  t4.frequency DAY )) <= now() LIMIT 500;

(t4.frequency = 10 days from my custom spreadsheet)

Now make an effort to remove the individual elements and throw them in the trash so that they are no longer in stock.


foreach($productdatas as $productdata){
    $out_of_stock_staus  = 'outofstock';
    $product_id          = $productdata->product_id;
    $product_title       = $productdata->product_name;
    $product_vendor      = $productdata->vendor_name;

echo "About to trash $product_id 
"; update_post_meta($product_id, '_stock', 0); update_post_meta( $product_id, '_stock_status', wc_clean( $out_of_stock_staus ) ); wp_set_post_terms( $product_id, 'outofstock', 'product_visibility', true );

My problem:

  1. The products are correctly marked as out of stock, but since my SQL code reads the last change that is not updated, setting a cron job would cause problems as it runs indefinitely every time.
  2. If I include another function to change the post status, wp_update_post (array (& # 39; ID & # 39; => $ product_id, & # 39; post_status & # 39; => & # 39; draft & # 39 ;)); the inventory update does not work. Based on my experience with this code, either the products are updated to design status or the inventory is set to 0, but never both.

I'm looking for a more reliable way to do this. Can someone please help and suggest a better way to solve this?

Version information:
WP: 5.3.2, Woocommerce: 3.8.1

8 – Error adding program variations to shopping cart programmatically

I added a custom submission handler to my web form. From here I try to add product variations to the shopping cart. My function for adding variations looks like this (using a recurring module – payment method):

function _add_variation_to_cart($variation_id)
  $store_id = 1;
  $order_type = 'recurring'; // we have "recurring" and "default" order types!!

  $cart_manager = Drupal::service('commerce_cart.cart_manager');
  $cart_provider = Drupal::service('commerce_cart.cart_provider');

  $store = Drupal::entityTypeManager()->getStorage('commerce_store')->load($store_id);

  $product_variation = Drupal::entityTypeManager()->getStorage('commerce_product_variation')->load($variation_id);

  $cart = $cart_provider->getCart($order_type, $store);
  if (!$cart) {
    $cart = $cart_provider->createCart($order_type, $store);

  $order_item = Drupal::entityTypeManager()->getStorage('commerce_order_item')->create(array(
    'type' => 'default', // Also, Commerce 2.x have a feature to define custom "line item types".
    'purchased_entity' => (string) $variation_id,
    'quantity' => 1, // Amount or quantity to be added to the cart.
    'unit_price' => $product_variation->getPrice(),
  $cart_manager->addOrderItem($cart, $order_item);


I used this function and modified it slightly:

Rejected calls just replaced.

But in the last step, this code crashes with an error:

Error: Call to a member function toBillingPeriod() on null in Drupalcommerce_recurringRecurringOrderManager->refreshOrder() (line 103 of modules/contrib/commerce_recurring/src/RecurringOrderManager.php).

The code that actually crashes at the end looks like this:

   * {@inheritdoc}
  public function refreshOrder(OrderInterface $order) {
    /** @var Drupalcommerce_recurringPluginFieldFieldTypeBillingPeriodItem $billing_period_item */
    $billing_period_item = $order->get('billing_period')->first();
    $billing_period = $billing_period_item->toBillingPeriod();

$billing_period_item after the call is zero and $billing_period then crushed when trying to call toBillingPeriod() on null,

Any idea what I'm doing wrong? why this $order has not billing_period Member object?

magento 1.9 – programmatically changing user-defined attributes

I am trying to create a program that can be used to edit some data in the backend without having to do this manually via the administrator.

So when I change data for the group_price attribute, I do the following:

  $product->setData('group_price', array());
  $product->setPrice(round(($product->getPrice())-$oldToll, 2));

Use this to delete existing data. Before that, I create an array that contains all the necessary information.

     $oldToll = $_POST('afgift')/3;
     $product = Mage::getModel('catalog/product')->load($id);
     $products = $product->getData('group_price');

     $i = 0;
     $group_array = array();
     foreach($products as $prod) {
     $group_array($i)('cust_id') = $prod(cust_group);
     $group_array($i)('price') = round($prod(price)-$oldToll, 2);

Then I push all the relevant information into a new array.

$new_prices = array();
foreach ($group_array as $elem) {
array_push($new_prices, array ('website_id'=>0, 'cust_group'=>$elem('cust_id'), 'price'=>$elem('price')));

And save:

$product->setData('group_price', $new_prices);

Works well. Now I would assume that this would be the same for a custom attribute. So I'm pretty much doing the same process for an attribute code called "afgift".

  $test_ar = array();
  array_push($test_ar, array ('website_id'=>0, 'country'=>'DK', 'value'=>$_POST('afgift')));

Set the data as before and save it. So it seems that this does nothing. And if I try to manually insert something into this attribute field and run the code, it will reset for some reason.

What's happening? What am I doing wrong?

Thank you in advance.

7 – Programmatically adding and storing values ​​in the field collection

I have a field collection in a field collection, which in turn contains some fields. I want to upload a CSV file that contains details about these fields, and when I upload the CSV I want these fields and field collections to be saved.

Since I didn't generate an HTML structure, I can't use the submit form FieldCollectionItemEntity Object. I tried to save data directly to the database using insert queries, but this does not reflect the values ​​in the frontend.

Is there a way to do this?

Programmatically add / remove a person from the SharePoint group in the C # console application

Dear Stackoverflow community:

What we have?
There is a SharePoint site with different folders and subfolders etc.
Except for the default SharePoint groups (and their permission levels) – custom groups have been created for some folders. These groups have special / user-defined authorization levels.

What I have to do is:
1. Enter the web path in the folder using the console, e.g. B.
2. Enter the email / username in the C # -based console application of the user to be added to the custom group available at this address
3. Enter the email address / username of the user you want to remove from the custom group available for that address

In short, how I access a specific web path, remove users from the groups available in a specific web path.
That is pretty much all this tool will do. I guess the code must also send my credentials to the portal so that it can do its job.

What have I tried so far?
I've read a few articles and posts about it, but so far I've only "worked" with desktop-based tools (amateur level) that perform local tasks, and I'm fairly new to web projects, so I would like some support need. πŸ™‚

magento2 – Additional quantity when programmatically adding products to the shopping cart

I use this code below to add a product with a custom option value to the cart. However, the total number of shopping carts takes the value "Maximum allowable quantity in the shopping cart" and then adds 1. If, for example, the maximum permitted amount in the shopping cart is 10, the number in the shopping cart is specified as 11 and the warning "The exceeds the requested amount the maximum amount allowed in the shopping cart. "I use the following code.

$gproductId = 16213;
            $product = $objectManager->create('MagentoCatalogModelProduct')->load($gproductId);
            $cart = $objectManager->create('MagentoCheckoutModelCart');  
            $formKey = $objectManager->create('MagentoFrameworkDataFormFormKey')->getFormKey();  
            $option = array('49064'=>'865759');

            $params = array(
            'form_key' => $formKey,
            'product' => $gproductId, //product Id
            'item' => $gproductId, //product Id
            'qty'   =>0, //quantity of product                
            'options' => $option,
            'allow_partial_payment' => 0

            // echo "
"; print_r($params); die();                   
             try {                  
             $cart->addProduct($gproductId, $params);
            }  catch (Exception $e) {
                echo $e->getMessage();


Please let me know if you have a solution to this problem.