/ December 18, 2005
3.04 friendly

Do not follow the search-tracker.mod file if your using 3.04 follow this.

There were no major changes I just want credit for taking the time to change one variable, and updating the instructions a little.

Code:
############################################################## ## MOD Title: Internal Search Tracker ## MOD Author: Casey Wilson < at@ap0s7le.com > http://www.ap0s7le.com ## MOD Description: Enables the ability to track internal searches. ## MOD Version: 1.0.0 ## ## Installation Level: Intermediate ## Installation Time: 15 Minutes ## Files To Edit: ## /admin/init.php ## /include/functions.php ## /include/tables.php ## /index.php ## ## Included Files: ## statistics.php ## statistics.tpl ## m_statistics.gif ## ############################################################## ## Author Notes: ## This MOD has been updated to 3.04. ## YMMV, if you have any issues feel free to email me. ## Paid services are also available. ############################################################## ## MOD History: ## ## 2006-5-17 – updated for 3.04 ## ## 2005-12-17 – Version 1.0.0 ## ## – Initial release. ## ############################################################## ## Before Adding This MOD To Your Directory, You Should Back Up All Files Related To This MOD ############################################################## ## # #—–[ SQL ]—————————————— # Where ‘PLD_’ is your table prefix CREATE TABLE `PLD_SEARCHES` ( `ID` int(11) NOT NULL auto_increment, `QUERY` varchar(255) NOT NULL default ”, `NUM` int(11) NOT NULL default ‘0’, `TIME` timestamp(14) NOT NULL, PRIMARY KEY (`ID`) ) TYPE=MyISAM; # #—–[ COPY ]—————————————— # copy statistics.php to /admin/statistics.php copy statistics.tpl to /templates/admin/statistics.tpl copy m_statistics.gif to /admin/images/m_statistics.gif # #—–[ OPEN ]—————————————— # /admin/init.php # #—–[ FIND ]—————————————— # ), ‘message’ => array(‘label’ => _L(‘Edit Email Templates’), ‘url’ => ’email_message.php’), ‘payment’ => array(‘label’ => _L(‘Payments’), ‘url’ => ‘conf_payment.php’, ‘disabled’ => PAY_ENABLE!==’1′), ‘profile’ => _L(‘Profile’), ‘users’ => _L(‘Edit Users’), ) ), # #—–[ AFTER, ADD ]—————————————— # ‘statistics’ => _L(‘Statistics’), # #—–[ OPEN ]—————————————— # include/functions.php # #—–[ FIND ]—————————————— # ?> # #—–[ BEFORE, ADD ]—————————————— # function track_searches($db, $query) { global $tables; $sql = “SELECT COUNT(*) FROM {$tables[‘searches’][‘name’]} WHERE QUERY = ” . $db->qstr($query) . “”; if ($db->GetOne($sql) > 0) { $db->Execute(“UPDATE {$tables[‘searches’][‘name’]} SET NUM=NUM+1 WHERE QUERY = ” . $db->qstr($query) . “”); } else { $db->Execute(“INSERT INTO {$tables[‘searches’][‘name’]} VALUES(NULL, ” .$db->qstr($query) . “, 1, NULL)”) or die (mysql_error()); } } # #—–[ OPEN ]—————————————— # /include/tables.php # #—–[ FIND ]—————————————— # $tables[‘user_permission’] = array( ‘name’ => TABLE_PREFIX.’USER_PERMISSION’, ‘fields’ => array( ‘ID’ => ‘I KEY AUTO’, ‘USER_ID’ => ‘I NOTNULL’, ‘CATEGORY_ID’ => ‘I NOTNULL’, ) ); # #—–[ AFTER, ADD ]—————————————— # $tables[‘searches’] = array( ‘name’ => TABLE_PREFIX.’SEARCHES’, ‘fields’ => array( ‘ID’ => ‘I KEY AUTO’, ‘QUERY’ => ‘C(255) NOTNULL’, ‘NUM’ => ‘I NOTNULL’, ‘TIME’ => ‘T’, ) ); # #—–[ OPEN ]—————————————— # /index.php # #—–[ FIND ]—————————————— # elseif (isset ($_REQUEST[‘search’])) // Search results { require_once ‘search.php’; # #—–[ AFTER, ADD ]—————————————— # track_searches($db, $_REQUEST[‘search’]); # #—–[ SAVE/CLOSE ALL FILES ]—————————————— # # EoM
__________________