Posted in site bugs
5968
4:04 am, July 10, 2021
 

weird search results being recorded

i noticed some weird search results being recorded like this:

the search function should only be recording a result if it finds a result, so this should not be added unless it can actually find this text, which i doubt it. 

Some annoying robot is adding this i think. 

page: search.page.php

PHP

if($search_value > "") {
    $page_content .= $class->list_all(
        $start = $start_val,
        $max = $page_step,
        "search", 
        $template_file_name,
        $search_term = $search_value
    );
}

i think the issue is with the search link text being added from the url. it does not validate if the text exists on the page before adding it, so need a check on there before adding it. 

e.g: https://kruxor.com/view/code/DPkzR/weird-search-results-being-recorded/search_text:::weird%20search%20results%20being%20recorded 

I have only allowed the characters on searches, so this should fix the random text issues now.

PHP

$search_text = preg_replace("/[^A-Za-z0-9 ]/", '', $search_text);

see if this solves the problem

View Statistics
This Week
97
This Month
585
This Year
675

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
“If you just sit and observe, you will see how restless your mind is. If you try to calm it, it only makes it worse, but over time it does calm, and when it does, there’s room to hear more subtle things. You see so much more than you could see before. It’s a discipline; you have to practice it.”
Steve Jobs
Random CSS Property

caret-color

The caret-color CSS property sets the color of the insertion caret, the visible marker where the next character typed will be inserted. This is sometimes referred to as the text input cursor. The caret appears in elements such as <input> or those with the contenteditable attribute. The caret is typically a thin vertical line that flashes to help make it more noticeable. By default, it is black, but its color can be altered with this property.
caret-color css reference