Possible security problem with the custom taxonomy search function

I would like to add some features to a client WordPress site that allow you to include taxonomy terms from custom post types in WordPress search, and encounter the following answer:

Include a custom taxonomy term in the search

This solution works, but in the comments, one user mentioned that "it is probably not a good idea to insert the raw publicly available search string directly into an SQL query". and added a link for further reading. I can't see anything in this link that relates to the details of the answer.

For quick reference, the code for the answer is below. Would this code be a security risk? If so, what would the solution look like so that you still have the functionality to be able to include taxonomy terms in the WP search without any security risk?

Many thanks

// search all taxonomies, based on: http://projects.jesseheap.com/all-projects/wordpress-plugin-tag-search-in-wordpress-23

function atom_search_where($where){
global $wpdb;
if (is_search())
    $where .= "OR (t.name LIKE '%".get_search_query()."%' AND {$wpdb->posts}.post_status = 'publish')";
return $where;
}

function atom_search_join($join){
global $wpdb;
if (is_search())
    $join .= "LEFT JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id";
return $join;
}

function atom_search_groupby($groupby){
global $wpdb;

// we need to group on post ID
$groupby_id = "{$wpdb->posts}.ID";
if(!is_search() || strpos($groupby, $groupby_id) !== false) return $groupby;

// groupby was empty, use ours
if(!strlen(trim($groupby))) return $groupby_id;

// wasn't empty, append ours
return $groupby.", ".$groupby_id;
}

add_filter('posts_where','atom_search_where');
add_filter('posts_join', 'atom_search_join');
add_filter('posts_groupby', 'atom_search_groupby');

Search and print on Linux

Question: – Write a grep command that contains all the lines with the word & # 39; good & # 39; issues.

An Excel file contains 42,000 lines, and I just want to find and print the line that contains the word "Good" under section "C".
But the word & # 39; good & # 39; can also be found in the & # 39; D & # 39; appear because it also prints the wrong lines that I don't want to see.

I need some help with the code.

Link to the picture: https://i.stack.imgur.com/3WJrP.png

Chess – Search for legal knights in a chessboard in APL (follow-up)

This question is a continuation of my previous question.

I wrote (and now rewrote) a function that uses as input a vector with two integers between 1 and 8 that represent a position in a chessboard. This function should output a vector in which each cell is a similar vector of integers, with the positions a knight could reach in the input position.

E.g. For input 1 1 my function should output (2 3) (3 2).

KnightMovesRevised ← {
  ⍝ Monadic function, expects a vector with 2 integers, e.g. (1 1)
  ⍝ Given a chessboard position, find the legal knight moves.
  ⍝ Returns vector of 2-integer vectors, e.g. (2 3)(3 2)

  ⍝ aux train to check if position is inside chessboard
  isInsideBoard ← ∧/(1∘≤∧≤∘8)

  signs ← ¯1 1 ∘., ¯1 1
  offsets ← (1 2)(2 1)
  moves ← , signs ∘.× offsets
  ⍝ list all the locations the knight could go to
  locations ← moves + ⊂⍵
  ⍝ and keep the valid ones
  valid ← isInsideBoard¨ locations
  valid/locations
}

Changes

From the previous version to this one, i

  • Reformat the code a little with a suggested naming convention by naming a tool train and adding a few more comments.
  • The train used for writing has been removed offsetsthat I had only used to try the tacit programming. This is such a small vector that I think it makes more sense to hard code it.
  • Rewritten signs by writing the ¯1 1 and remove ,, . This made it a little easier to digest and not much more annoying to type;

These changes were motivated by the two great reviews I received (here and here), and I hoped that I could get reviews about these changes because I tried to stick to their suggestions, but I didn't necessarily agree with all of them to.

ask

(paired with the above)

  • Are the additional comments ok or too much?
  • are signs and offsets defined in an acceptable manner? I like the trade-off between hard coding too much and using too many functions to create just a few constants.
  • What is the standard distance notation around ¨? Should I write f¨ arg, f ¨ arg, f ¨arg or f¨arg?

html – Search an online tool that displays linked images of a website

I'm looking for an online tool that displays linked images from an HTML directory. In particular, I have numerous links to HTML directories that contain hundreds of links to images. These directories do not display the images, but link them. I need an online tool that displays all of these images in a gallery format so that I can quickly identify the images that are relevant to me.

I am sure that there are online tools that do this.

best

Volatility in the Google search algorithm in March 2020

Have you noticed fluctuations in the last search results of your website? I recently came across an article in the SE Roundtable that mentioned some real-time examples.

Here are some comments from Webmasterworld:

A SERP tracker (SEMrush) shows unpredictability in Google today. It is shockingly difficult to dissect right now if I am in position 1 a second and position 1 a second later. I consider it the "1 and no miracle". But I will say on busy days that Google cannot send any transition data. In my least lengthy periods of Google traffic, this is where I'm on my way to seeing how guests make a purchase for the first time.

Recently, two of my locales crashed from a "no traffic" bluff as if they had been removed from the list, but despite what appears, another site that was dead for a considerable amount of time (the same specialty) suddenly and suddenly changing today I no longer recognize what to think.

(tagsToTranslate) Webmaster Forum (t) Internet Marketing (t) Search Engine Optimization (t) Web Design (t) SEO (t) ppc (t) Affiliate Marketing (t) Search Engine Marketing (t) Web Hosting (t) Domain Name ( t) Social media

Performance #: Do you use plain for loops to search for (existing) strings in the string array?

I have defined a few ways to search for a string in a string array (with 82 elements in the example), case-sensitive and case-insensitive.

I am a little surprised that the level for grinding is faster than all other variants.

  1. Sure, there are no controls, but are there any other shortcomings here?
  2. Does Linq not do vectorization behind the scenes?
  3. Can I use these bows without hesitation?
  4. Any other notes?

code

public static void StringArrayContains()
    {
        // Init timing
        var watch = Start();
        watch.Stop();
        watch.Reset();

        // Setup vars
        string query = "big";
        string() stringArray = GetStringArray();
        bool contains = false;
        int times = (int)1e6;

        Console.WriteLine("Case Sensitive Search");

        // Loop with case sensitive equal
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            for (int j = 0; j < stringArray.Length; j++)
            {
                if (string.CompareOrdinal(query, stringArray(j)) == 0)
                {
                    contains = true;
                    break;
                }
            }
        }
        Stop(watch, $"Loop with case sensitive equal", times);

        // Array.Exists + Equals
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            contains = Array.Exists(stringArray, item => string.CompareOrdinal(item, query) == 0);
        }
        Stop(watch, $"Array.Exists + Equals", times);

        // Array.Exists + ==
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            contains = Array.Exists(stringArray, item => item == query);
        }
        Stop(watch, $"Array.Exists + ==", times);

        // Array.IndexOf
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            contains = Array.IndexOf(stringArray, query) > -1;
        }
        Stop(watch, $"Array.IndexOf", times);


        Console.WriteLine("Case Insensitive Search");

        // Loop with case insensitive equal
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            for (int j = 0; j < stringArray.Length; j++)
            {
                if (string.Equals(query, stringArray(j), StringComparison.OrdinalIgnoreCase))
                {
                    contains = true;
                    break;
                }
            }
        }
        Stop(watch, $"Loop with case insensitive equal", times);

        // Array.Exists + EqualsIgnoreCase
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            contains = Array.Exists(stringArray, item => string.Equals(item, query, StringComparison.OrdinalIgnoreCase));
        }
        Stop(watch, $"Array.Exists + EqualsIgnoreCase", times);

        // Linq Contains: OrdinalIgnoreCase
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            contains = stringArray.Contains(query, StringComparer.OrdinalIgnoreCase);
        }
        Stop(watch, $"Linq Contains: OrdinalIgnoreCase", times);

        // Linq Contains: InvariantCultureIgnoreCase
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            contains = stringArray.Contains(query, StringComparer.InvariantCultureIgnoreCase);
        }
        Stop(watch, $"Linq Contains: InvariantCultureIgnoreCase", times);

        // Linq Contains: CurrentCultureIgnoreCase
        watch.Start();
        for (int i = 0; i < times; i++)
        {
            contains = stringArray.Contains(query, StringComparer.CurrentCultureIgnoreCase);
        }
        Stop(watch, $"Linq Contains: CurrentCultureIgnoreCase", times);


        if (!contains)
            throw new Exception();
    }

Result

Case Sensitive Search
                   Loop with case sensitive equal   took    323 ms to execute 1,000,000 times (0.3 us per exec).
                            Array.Exists + Equals   took    445 ms to execute 1,000,000 times (0.4 us per exec).
                                Array.Exists + ==   took    461 ms to execute 1,000,000 times (0.5 us per exec).
                                    Array.IndexOf   took    511 ms to execute 1,000,000 times (0.5 us per exec).

Case Insensitive Search
                 Loop with case insensitive equal   took    408 ms to execute 1,000,000 times (0.4 us per exec).
                  Array.Exists + EqualsIgnoreCase   took    543 ms to execute 1,000,000 times (0.5 us per exec).
                 Linq Contains: OrdinalIgnoreCase   took    827 ms to execute 1,000,000 times (0.8 us per exec).
        Linq Contains: InvariantCultureIgnoreCase   took  6,220 ms to execute 1,000,000 times (6.2 us per exec).
          Linq Contains: CurrentCultureIgnoreCase   took  6,249 ms to execute 1,000,000 times (6.2 us per exec).

connected – strategy for determining the minimum expected costs in a series diagram with the edge probability pi and the search costs ci

Every edge in a series diagram $ e_i $ exists with probability $ p_i $. And if you want to investigate the existence of edges $ e_i $, It will cost you $ c_i $. I want to test connectivity between source $ s $ and goal $ d $ with the minimum expected cost.

I have found that the expected cost can be calculated below if the edge detection sequence is $ e_1, e_2, cdots e_n $::

$$ E (cost) = c_1 + p_1 * (c_2 + p_2 * (c_3 + p_3 * ( cdots (c_ {n-1} + p_ {n-1} * c_n) cdots))) $$

So is there a strategy or an algorithm to find out the minimum expected costs and the edge detection sequence?

Enter the image description here