Difference between revisions of "Extension:SearchLog.php"
(Make a start) |
(log file stuff) |
||
Line 7: | Line 7: | ||
define('SEARCHLOG_VERSION','0.0.1, 2007-05-17'); | define('SEARCHLOG_VERSION','0.0.1, 2007-05-17'); | ||
− | + | ||
+ | $wgSearchLogFile = dirname(__FILE__)."/search.log"; | ||
+ | $wgExtensionFunctions[] = 'wfSetupSearchLog'; | ||
+ | |||
$wgExtensionCredits['other'][] = array( | $wgExtensionCredits['other'][] = array( | ||
'name' => 'SearchLog', | 'name' => 'SearchLog', | ||
Line 16: | Line 19: | ||
); | ); | ||
− | # If a search has been posted, log the info | + | function wfSetupSearchLog() { |
− | if (isset($_REQUEST['search'])) { | + | global $wgSearchLogFile,$wgUser; |
− | + | ||
− | + | # If a search has been posted, log the info | |
− | + | if (isset($_REQUEST['search'])) { | |
− | } | + | if (isset($_REQUEST['go'])) $type = 'go'; |
− | + | else if (isset($_REQUEST['go'])) $type = 'fulltext'; | |
+ | else $type = 'other'; | ||
+ | |||
+ | # Log the data to the file | ||
+ | if ($fh = fopen($wgSearchLogFile,'a')) { | ||
+ | fwrite($fh, | ||
+ | } | ||
+ | } | ||
+ | } | ||
?> | ?> |
Revision as of 22:08, 17 May 2007
<?php
- Extension:SearchLog
{{#Security:*|dev}}{{#Security:view|*}}Template:Php
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: User:NadCategory:Extensions created with Template:Extension
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('SEARCHLOG_VERSION','0.0.1, 2007-05-17');
$wgSearchLogFile = dirname(__FILE__)."/search.log"; $wgExtensionFunctions[] = 'wfSetupSearchLog';
$wgExtensionCredits['other'][] = array( 'name' => 'SearchLog', 'author' => 'User:Nad', 'description' => 'An example extension made with Extension:SearchLog', 'url' => 'http://www.organicdesign.co.nz/Extension:Example', 'version' => SEARCHLOG_VERSION );
function wfSetupSearchLog() { global $wgSearchLogFile,$wgUser;
# If a search has been posted, log the info if (isset($_REQUEST['search'])) { if (isset($_REQUEST['go'])) $type = 'go'; else if (isset($_REQUEST['go'])) $type = 'fulltext'; else $type = 'other';
# Log the data to the file if ($fh = fopen($wgSearchLogFile,'a')) { fwrite($fh, } } } ?>