nginx: how to redirect depending on a range of IP addresses?

I am trying to make a site only accessible from the local network and people on the external network will get a static page that says some other message.

This is what I'm trying to do, but it doesn't seem to work. Where did I go wrong?

         if ($remote_addr != 192.168.1.0/24) {
                   rewrite ^/* /covid19 last;
         }

Search engine indexing: Why do Google snippets change depending on the search for the contraction of my company's full name?

I have been really struggling with how to say this. I am a beginner in SEO and website content.
My employer Melbourne Satellites actively uses the Melbsat shrink in marketing material, as it is easier for clients to remember and write.
I have edited the meta descriptions to show pages on google and the correct content appears when searching for & # 39; Melbourne Satellites & # 39 ;. However, when searching for & # 39; Melbsat & # 39 ;, the meta descriptions do not display correctly.

Any advice?

compile: compile a function depending on an external function

Consider the simple case:

g[x] := x^3;
f[x] := x^2 + g[x];
cf = Compile[{{x, _Real}}, x^2 + g[x]]

In evaluating the two functions, Mathematica complains that the second one depends on the function g[x], saying:

CompiledFunction :: cfex: Failed to complete external evaluation in statement 2; proceed with an uncompiled evaluation.

What is the correct way to compile the function? f in this case?

php – Mysql add column lines depending on the value of a third

I am using php and the tables are in a Mysql database
in the class it manages, use DB;

I have two tables to use:
1st) diariolineas is where the lines to compare are, in the subcuentad_id and subcuentah_id columns and the columns to be added, in the imported and importah columns
2nd) subaccounts is where the lines to compare are; in the id column
The graphic operation would be:
For each subaccount-> id, go to the diarioline table and add with a positive sign all the amounts whose
sub-account_id matches sub-account-> id and with negative sign all amounts whose sub-account_id matches sub-account-> id.
The code used and that does not work is as follows

 $subcuentas=Subcuenta::where('suscriptor_id','=',$suscriptor)->
                                            whereRaw("subcuenta>= $min AND  subcuenta <= $max") ->get();
 foreach($subcuentas as $subcuenta){


$totales = DB::select("SELECT  SUM(if(subcuentad_id  =  $subcuenta->id) imported) AS totdebe"
                                                . " ,SELECT  SUM(if(subcuentah_id  =  $subcuenta->id) importeh)  AS tothaber"
                                                . ", WHERE ejercicio_id = $ejercicio_id AND suscriptor_id = $suscriptor  "
                                                . "FROM diarioslineas" ); 
$sumasdebe=$totales(0)->totdebe;
$sumashaber=$totales(0)->tothaber;

8 – How to correctly restrict access to nodes (including update / delete) depending on the value of the field?

I have the following requirements:

  • Users have (among others) "tier1", "tier2" or "tier3" roles. A higher value means more permissions and anonymous users are considered "tier0".
  • Users of tier2 and tier3 can create a certain type of node: MyNode. And only these users can update and delete them.
  • The node type MyNode contains the field (my custom) to restrict access: it is a simple integer. 0 means that all users can access it, 1 means that users of level 1-3 can access it, etc.

What is the correct way to implement the node restriction?

What I tried and a longer description of the problem

After searching Google and reading the documentation, I found hook_entity_access. I will simply read all the fields and if I found my type of access field, I read the value and managed it. It worked quite well to view, edit and delete. But not for opinions, they completely ignored that.

After searching a little more on Google, I discovered that hook_entity_access / hook_node_access is ignored in the views as explained in the node access rights. This page also explains that this problem must be resolved using hook_query_TAG_alter, however, I cannot understand how it should be used. I think I'm missing a bigger image and I couldn't google it. But I found another solution: use hook_node_access_records with hook_node_grants. I implemented this solution (with a tutorial help).

Therefore, each instance of MyNode provides a grant based on the value of the field, e.g. gid 2 means that level 2-3 can access the node. Each user receives subsidies based on their level function, p. the user with level 1 receives subsidies with gid 1, 2 and 3. This fixed view problem, but caused another: if I set the access of a node to 3, users of level 0-2 cannot see it (that's right) , but the user of level 2 can Edit that is a problem)

After some tests, it seems that permissions are handled differently to view and update / delete. Permission view permissions are AND-ed with a basic permission system (/ admin / people / permissions), but update / delete permissions are OR-ed. I used the basic permission system to determine which roles can generally create, update and delete MyNode nodes.

So, my current solution is the fusion of both approaches: granting system for views and hook_node_access to work with nodes directly. However, it seems a rather dirty and hacky solution: I practically implemented the same thing twice in different systems, because each system can only handle a subset of all operations. So, my question is: what is the proper implementation? What is correct Drupal-way?

Note: of course, I looked at the modules to solve this. I rejected most of them, because they are still in alpha / beta / rc phase, while the life of D8 is ending. How long would I have to wait for D9 implementation? Others were too bloated to "simple" "compare the numerical value with the role and accept / reject."

My system

Theming: is there any way to place a block depending on the width of the screen?

I have a mobile block and a desktop block. The design is very different for each one, so I created a block for each one. The blocks have accordions and many other elements that require identification, so I can't show them: none based on the maximum width of the @media screen. I have the context installed, but I don't see where I can choose blocks according to the screen width.

list: automatic filling data, depending on the selection

Waiting for some help here.

I have a SharePoint list that my team is populating. What I would like to happen is that, when they choose a particular Store, they populate a specific region in the adjacent field.

For example, Stores A, B and C are in Region 1. Stores D, E and F are Region 2. If in the Choice field choose Store B, the Region field will be automatically filled in with & # 39; Region 1 & # 39 ;.

I have all stores and their corresponding region in a separate SharePoint list. Is what I ask you possible?

Thanks in advance for any help or advice.

Sincerely

php – Assign roles depending on where you click

I would like to assign roles depending on which button the user clicks:

redirect buttons

For example:
– If you click on I want to be an Advisor, redirect to the Laravel registration form and assign the role of advisor.
– If the user clicks on I want to be a Buyer, who refers to the Laravel registration form and assigns the buyer role.

But I do not know how to do it.
I have this code in my 'RegisterController':

protected function create(array $data)
{
    $user = User::create((
        'name' => $data('name'),
        'email' => $data('email'),
       //'password' => Hash::make($data('password')), //mutador en User model
        'password' => $data('password'),
        'surname1' => $data('surname1'),
        'surname2' => $data('surname2'),
        'comunidad_id' => $data('cbx_comunidad'),
        'provincia_id' => $data('cbx_provincia'),  
        'municipio_id' => $data('cbx_municipio'),
    ));

    //dd(Request::url());
    // $user->assignRole('Asesor');
    //quiero asignar varios roles depende de el botón que clicken

    return $user;

}

But the route is always the same "Register" I do not know if you should pass some parameter to the routes … any help?

php – Show price with and without TAX depending on user role

The base price of my store includes TAXES. What I am trying to do is show the price of some user roles with and without TAX, and for other user roles, I want to show only prices without TAX.

I tried using the "price display suffix" field and hiding unwanted items with display: none, but it can't be done due to the html structure I get.

Now I am trying to use woocommerce_get_price_html where I verify the user role and then turn off taxes for specific roles, although I don't know if it's safe and it still doesn't work as I want.

function tax_price_based_on_role( $price ) {
    $current_user = wp_get_current_user();
    $allowed_roles = array( 'user_role1', 'user_role2' );
    if ( is_user_logged_in() && array_intersect( $current_user->roles, $allowed_roles ) ) {
        WC()->customer->set_is_vat_exempt( true );
        //need to also show price with TAX
        return $price .= ' ' . __('without TAX');
    }
    else{
        return $price .= ' ' . __('with TAX');  //show only price with TAX
    }
}
add_filter( 'woocommerce_get_price_html', 'tax_price_based_on_role' );

I only managed to show the price with TAXES to a role and a price without taxes to the role of another user. I tried to add taxes to $price, but failed because it contains price chain and currency. Maybe there is a better way to do this?