how to allow user select shipping location(a custom locations dropdown) in checkout and recalculate values woocommerce

i need to know 2 things

  1. how do i add custom shipping zones to a determinate contry (I need to add some neightbours of a main city)
  2. How do i allow users to select the shipping zone when chekout or in the cart, and recalculate the total

Get_option use inside switch select option

I try to make inside theme custom admin panel a switch select option. but i cannot get the value of switch case. following is my code:

$  bannerchange = $  _POST['bannerchange'];  if( get_option('bannerchange') != get_option($  bannerchange)) {             $  bannerchange = update_option( 'bannerchange', get_option($  bannerchange));  }  <?php if(isset($  _POST['wphw_submit']) && $  chk):?>   <div id="message" class="updated below-h2">     <p>Content updated successfully</p>   </div>     <?php endif;?>       <form method="post" action="">  <select name="wphw_submit" onchange="this.form.submit()">      <option value="page1"<?php if ($  bannerchange == "page1") { echo " selected"; } ?>>Custom Departure</option>      <option value="page2"<?php if ($  bannerchange  == "page2") { echo " selected"; } ?>>Fixed Departure</option> </select> <noscript><input type="submit" value="Submit"></noscript>  </div> <input type="submit" name="wphw_submit" value="Save changes" class="button-primary" /> <?php  switch ($  bannerchange) {     case 'page2': ?>                  <p>two</p>          <?php         break;     case 'page1':         ?>         <p>one</p>         <?php         break;     }     ?> 

$ bannerchange get always undefined.

Select arbitrary single value for GROUP BY: What’s the fastest option?

I have a query that I use to indicate locations in a map where there are overlapping points:

select     min(objectid) as min_objectid,     longitudex,     latitudey,     count(1) as count,     min(shape) as min_shape from     workorders group by     longitudex,     latitudey having     count(1) > 1 

In the mapping software that I use, I need to include columns like objectid and shape. For those columns, it doesn’t matter which of the grouped-by rows the values come from, just as long as there is a value.

Presently, I’m using min() to get an arbitrary value for those columns. However, I don’t know if that’s the fastest option since finding the minimum value would require calculation — and I wonder if that time spent is unnecessary.

What is the fastest option for getting an arbitrary/single value for GROUP BY in an Oracle query?

Disable auditing of select statements

Somehow the auditing of select statements was enabled in our oracle database. We have several data processing apps that are generating upwards of 15 GB per day in the audit trail. Now we cannot turn it off because it seems that the noaudit command needs to match the original audit command, which of course no one knows. Does anyone know how to undo this? Can we turn off all auditing and then turn on the usual assortment of audit actions (alter, create, drop, etc.)? We have ran all kinds of noaduit permutations: “noaudit select table by USER;” and “noaudit select any table;” and yet it still posts select statements to the audit trail.

Does commit after a normal select can call any fsync or flush operations?

Coms counts taken at particular time for all 3 (insert,update,commit).

Com_inserts are in 1.1K  Com_updates are in 1.6k  Com_commit are in  10K 

When enabling general log, I could see after each selects there is a commit. Would this unnecessary commit can cause any fsync or any flush opertation to the server?


Select by mask

Hi @Sven
Could you have a look at the select by mask feature in the verified urls window please. I’ve been trying to select verified links by mask and it doesn’t matter how I enter keywords in there it doesn’t select all the links that I need. Actually it seems quite random to me. I’ve tried *keyword or *keyword* and only a few got selected I also tried keyword*|*keyword* but no joy

How can I carry out SQL insert injection when there’s a select statement beforehand

So here’s the deal. I’ve been working on an SQL injection challenge and here’s what comes up.

There’s a registration page where you input your Username, password and confirm password. It’s vulnerable to INSERT SQL injection, I’m basically trying to insert my own data and make myself and admin (admin=1). However, there is a SELECT statement before the INSERT statement that checks if the username exists in the database. The problem is, if I try inserting data with SQL injection, the SELECT statement will fail and will generate an error, and the INSERT statement will never be executed.

I’ve made an in-a-nutshell PHP code to show you how it works.

<?php     $  username = $  _POST['username'];     $  password = md5($  _POST['password']);      $  sql = mysqli_query("SELECT * FROM users WHERE username = '$  username';");     if(mysqli_num_rows($  sql) > 0 || !$  sql) {         // this code will be run if the username already exists OR an SQL error in the query above.     }     else {         $  sql = mysqli_query("INSERT INTO users (`id`,`username`,`password`,`admin`) VALUES (NULL,'$  username','$  password',0);");     } ?> 

So the thing is, if I tried signing up with the username "admintest','password',1);-- " which should in theory INSERT myself into the database as an admin, here comes the problems.

The problem, is the SELECT query. Watch what happens.

SELECT * FROM users WHERE username = 'admintest','password',1);-- '; 

This of course is a syntax-error, and as we saw by the code I provided above, an IF statement will confirm that the SQL query was a syntax error, and the INSERT statement will NEVER run.

In an ideal world, this should happen in the INSERT statement, which will insert me as an ADMIN.

INSERT INTO users (`id`,`username`,`password`,`admin`) VALUES (NULL,'admintest','password',1);-- ','password',0); 

I’ve tried to work out something that doesn’t generate a syntax error on the SELECT, and also INSERTs the data I want to insert. Would be appreciated if anyone could help out 🙂

Minimum number of nodes to select such that every node is at most k nodes away

I received this problem on an exam a few months ago, and have kept thinking about how to solve it with no luck.

Given a binary tree where each node in the tree can either be selected or unselected, implement a function k_away() which returns the minimum number of nodes that need to be selected so that every node in the tree is at most k nodes away from a selected node.

So, the nodes simply contain a pointer to the left child, a pointer to the right child, and a boolean marking it as selected or not:

struct Node {     Node *left;     Node *right;     bool selected = false; // starts out false }; 

The problem specifies a constraint of having a time complexity of O(n) and an auxiliary space complexity of O(n).

What I’ve thought of so far:

  • It seems like there are 2^n potential solutions (if I can choose to either select or not select every node and there are 2 of them), so brute force is a bad idea
  • I’ve searched around for similar problems and the closest thing I can find is the Dominating Set problem which seems… impossible to solve at this moment in polynomial time. I doubt this problem was given as an impossible problem.
  • Running DFS to get to the leaf nodes, then counting height as recursion unrolls. Every k away, marking the node as selected. This seems to work on small test cases, but does not return the minimum number away.
  • Running BFS on the root node to find all nodes k away while using another data structure to mark all visited nodes as ‘covered’, and then recursively running the BFS on each k-away node. This also seems to work on small test cases, but again doesn’t return the minimum number away.

Using Select with a function on 3d Table

From the following 3d-Table

t1={{{1, 1}, {2, 1}, {3, 4/3}}, {{1, 0}, {2, 1/2}, {3, 1}}, {{1, -1}, {2, 0}, {3, 2/3}}} 

I want to use Select for getting all pairs where the second Part is an Integer. So that I would get

{{{1, 1}, {2, 1}}, {{1, 0}, {3, 1}}, {{1, -1}, {2, 0}}} 

I can do it by

Pick[t1, Map[IntegerQ /@ #[[All, 2]] &, t1]] 

But there should be more elegant ways to do it. How to use Select or Select with Function or some other twist?