You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.4 KiB

<?php
// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_networkcondition_info()
{
return [
'name' => tr('Network condition'),
'documentation' => 'PluginNetworkCondition',
'description' => tr('Display content based on the user\'s IP address'),
'prefs' => ['wikiplugin_networkcondition'],
'iconname' => 'computer',
'introduced' => 11,
'body' => tr('Content to display conditionally.'),
'params' => [
'ipv4list' => [
'required' => false,
'name' => tra('IPv4 List'),
'description' => tra("Comma-separated list of IPv4 addresses to match against the visitor's address."),
'since' => '11.0',
'default' => '',
'filter' => 'text',
'separator' => ',',
],
],
];
}
function wikiplugin_networkcondition($data, $params)
{
global $tikilib;
$ip = $tikilib->get_ip_address();
if (! empty($params['ipv4list'])) {
$list = $params['ipv4list'];
if (! is_array($list)) {
$list = explode(',', $params['ipv4list']);
}
if (! in_array($ip, $list)) {
return '';
}
}
return $data;
}