summaryrefslogtreecommitdiff
path: root/plugins/data.agentinfo.php
blob: 9d0778410688e3f7db10cc94ea10f0b2fb41755d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php

namespace Bitweaver\Liberty;

use Bitweaver\KernelTools;

/**
 * @version  $Revision$
 * @package  liberty
 * @subpackage plugins_data
 */
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See below for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
// |
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Author (TikiWiki): Damian Parker <damosoft@users.sourceforge.net>
// | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
// | by: StarRider <starrrider@users.sourceforge.net>
// +----------------------------------------------------------------------+
// $Id$

/**
 * definitions
 */
define( 'PLUGIN_GUID_DATAAGENTINFO', 'dataagentinfo' );
global $gLibertySystem;
$pluginParams = [
	'tag' => 'AGENTINFO',
	'auto_activate' => false,
	'requires_pair' => false,
	'load_function' => '\data_agentinfo',
	'title' => 'AgentInfo',
	'help_page' => 'DataPluginAgentInfo',
	'description' => KernelTools::tra("This plugin will display the viewer's IP address, the Browser they are using, or the info about the site's Server software."),
	'help_function' => '\data_agentinfo_help',
	'syntax' => "{AGENTINFO info= }",
	'plugin_type' => DATA_PLUGIN,
];
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAAGENTINFO, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAAGENTINFO );

/**
 * Help Function
 */
function data_agentinfo_help() {
	$help =
		'<table class="data help">'
			.'<tr>'
				.'<th>' . KernelTools::tra( "Key" ) . '</th>'
				.'<th>' . KernelTools::tra( "Type" ) . '</th>'
				.'<th>' . KernelTools::tra( "Comments" ) . '</th>'
			.'</tr>'
			.'<tr class="odd">'
				.'<td>info</td>'
				.'<td>' . KernelTools::tra( "string") . '<br />' . KernelTools::tra("(optional)") . '</td>'
				.'<td>' . KernelTools::tra( "Show information about the Browser being used.") . '<br />'
				.'<strong>ip</strong>: ' . KernelTools::tra( "To get the client\'s IP address (default)" ) . '<br />'
				.'<strong>browser</strong>: ' . KernelTools::tra( "To get the clients Browser infromation." ) . '<br />'
				.'<strong>server</strong>: ' . KernelTools::tra( "To get the site\'s server software" ) . '</td>'
			.'</tr>'
		.'</table>'
		. KernelTools::tra("Example: ") . "{AGENTINFO info='browser'}";
	return $help;
}

// Load Function
function data_agentinfo($data, $params) {
	$info = 'IP';
	extract ($params, EXTR_SKIP);
	switch (strtoupper ($info)) {
		case 'SVRSW': // To maintain Pre-Clyde Parameters
		case 'SERVER':
			  $ret = $_SERVER["SERVER_SOFTWARE"];
			  return $ret;
		case 'BROWSER':
			  $ret = $_SERVER["HTTP_USER_AGENT"];
			  return $ret;
		default:
			  $ret = $_SERVER["REMOTE_ADDR"];
			  return $ret;
	}

}