CodeIgniter Forums

Full Version: CI forum search results code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]megabyte[/eluser]
I search for "user authentication" and get the url

http://ellislab.com/forums/search_result...b4f9df535/


I have used base64 encode and decode but wonder if anyone knows how CI creates theres.

I haven't run any tests but ti seems no matter what you search for the encoded search streing is always pr close tothe same length

El Forum

[eluser]davidbehler[/eluser]
I don't know for sure, but if I had to guess I would say they do it like this:

When you perform a search, they add an entry to a table in their database where they save the search term you used, the list of results (id only I would say) and the timestamp when the search was performed. What you see in the URL is a unique key that's created for every search (possibly the primary key in the search table) using some kind of hashing..md5(search_term.timestamp) or whatever.

Further guessing leads to the assumption, that the search table works like some kind of cache...meaning that if there's someone performing the same search only minutes after you did there will be no new entry in the search table but the results from your search will be returned.

I don't know if that's really how they do it, but that's what my search library does Smile

El Forum

[eluser]Dam1an[/eluser]
I assume its just a unique identifier to a snapshot of the search results at that time
So we can now follow the above link, and see the results for 'user authentication' at the time you done the search, and the results may well be differant from now?

El Forum

[eluser]Wuushu[/eluser]
I'm guessing as soon as a search is made for "user authentication" the following happens:

1) Check against database if a search_history exists for "user authentication" and is not older than X.
2) If it does exist, get the unique key, redirect to results page with unique id in url, there you get result for the unique id from database, unsearialize, display in results view.
3) If it does NOT exist or has timed out, perform search query against database
4) Retrieve database results, serialize them, insert unique-id (random), serialized data, timestamp..
5) redirect to results view with unique id in url and move back to 2)


That's just a wild guess Smile

El Forum

[eluser]TheFuzzy0ne[/eluser]
I believe the database query itself is hashed, and the results are cached to a file.

The hash is then used to link the cached result file to the database entry so when you run a search with the same hash, the data from the cached result file will be used. The cached queries only seem to last a few hours, however.

I'm guessing here too. It just seems like the simplest idea to me, and I'm quite sure that's how EE is built with simplicity in mind.

El Forum

[eluser]johnwbaxter[/eluser]
You should go and ask someone in the http://www.ellislab.com/forums as there are more people there that actually have bought a license and also possibly the forum module too. They would be more likely to know as they would be able to look at the code!

El Forum

[eluser]tekhneek[/eluser]
Is it being http://us.php.net/base64_encode/http://u...e64_decode 'd?

This is interesting.