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

weird search results being recorded

<p>i noticed some weird search results being recorded like this:</p>
<p><img src="https://i.imgur.com/012elP0.png" /></p>
<p>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.&nbsp;</p>
<p>Some annoying robot is adding this i think.&nbsp;</p>
<p>page: search.page.php</p>
<h4>PHP</h4>
<pre><code class="php hljs">if($searchvalue &gt; "") {<br />&nbsp; &nbsp; $pagecontent .= $class-&gt;listall(<br />&nbsp; &nbsp; &nbsp; &nbsp; $start = $startval,<br />&nbsp; &nbsp; &nbsp; &nbsp; $max = $pagestep,<br />&nbsp; &nbsp; &nbsp; &nbsp; "search",&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; $templatefilename,<br />&nbsp; &nbsp; &nbsp; &nbsp; $searchterm = $searchvalue<br />&nbsp; &nbsp; );<br />}</code></pre>
<p>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.&nbsp;</p>
<p>e.g: <a href="https://kruxor.com/view/code/DPkzR/weird-search-results-being-recorded/search
text:::weird%20search%20results%20being%20recorded">https://kruxor.com/view/code/DPkzR/weird-search-results-being-recorded/searchtext:::weird%20search%20results%20being%20recorded</a>&nbsp;</p>
<p>I have only allowed the characters on searches, so this should fix the random text issues now.</p>
<h4>PHP</h4>
<pre><code class="php hljs">$search
text = pregreplace("/[^A-Za-z0-9 ]/", '', $searchtext);</code></pre>
<p>see if this solves the problem</p>

View Statistics
This Week
168
This Month
979
This Year
317

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...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

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
For a long time it had seemed to me that life was about to begin - real life. But there was always some obstacle in the way, something to be gotten through first, some unfinished business, time still to be served, or a debt to be paid. Then life would begin. At last it dawned on me that these obstacles were my life.
Alfred D. Souza
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.