Anyone using a WordPress theme with a search.php (e.g WordPress Default) might be interested in this... I wanted to see what my visitors were searching for, so I worked out a simple way to write their queries to a txt file. Just whack this in your search.php file (in your theme directory), put it under the <?php get_header(); ?> line: <?php $mydate = date('d F Y H:i:s -'); $mydata = "$mydate $s\n"; $x = fopen("saved_searches.txt", "a"); fwrite($x, $mydata); fclose($x); ?> Code (markup): You'll need to create the initial empty saved_seaches.txt file in your WP directory, and chmod it to 777 (I think). And or course you'll have to be hosting your own WP installation. If all goes to plan you should end up with a txt file full of this sort of garbage: 18 July 2006 02:17:35 - katamari 18 July 2006 02:50:36 - banana 18 July 2006 02:50:52 - egg 18 July 2006 02:51:34 - egg2 18 July 2006 02:52:35 - test Any php nerds know if doing this has any security implications?
If it is in an unprotected directory and chmod'd to 777, anyone will be able to view it. I would at the least put the file in a protected directory.
All the plugins I looked at did way too many other things I didn't need or want. Other than people being able to view the txt file if it's not in a protected dir (which isn't a big deal) - what are the safety issues in what I'm doing?
That is the safety issue. But beyond that, your method is more cumbersome and the plugin I mentioned willl give you not only search terms but the referrer information as well, nicely summarized. If you're happy with it, I'm not trying to put you down for that. Just pointing out for others that there are existing packages out there (including but not limioted to bsuite) that will do what your mod does and won't need to be redone with updates to Wordpress such as the upcoming version 2.04). It's always nice to have choice.