mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Add ability to customize robot user agents
This commit is contained in:
parent
72651ed095
commit
82213ce11a
5 changed files with 28 additions and 0 deletions
|
|
@ -115,6 +115,7 @@ return array(
|
||||||
'classes' => array(),
|
'classes' => array(),
|
||||||
),
|
),
|
||||||
'security' => array(
|
'security' => array(
|
||||||
|
'robot_user_agents' => array(),
|
||||||
'check_csrf_token' => false,
|
'check_csrf_token' => false,
|
||||||
'nofollow' => false,
|
'nofollow' => false,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,16 @@ class UA
|
||||||
return self::$_robot_cache[$ua] = true;
|
return self::$_robot_cache[$ua] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the custom user-agent list.
|
||||||
|
$customlist = Config::get('security.robot_user_agents') ?: array();
|
||||||
|
foreach ($customlist as $item)
|
||||||
|
{
|
||||||
|
if (strpos($ua, $item) !== false)
|
||||||
|
{
|
||||||
|
return self::$_robot_cache[$ua] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we're here, it's probably not a robot.
|
// If we're here, it's probably not a robot.
|
||||||
return self::$_robot_cache[$ua] = false;
|
return self::$_robot_cache[$ua] = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -652,6 +652,13 @@ class adminAdminController extends admin
|
||||||
natcasesort($classes);
|
natcasesort($classes);
|
||||||
Rhymix\Framework\Config::set('mediafilter.classes', array_values($classes));
|
Rhymix\Framework\Config::set('mediafilter.classes', array_values($classes));
|
||||||
|
|
||||||
|
// Robot user agents
|
||||||
|
$robot_user_agents = $vars->robot_user_agents;
|
||||||
|
$robot_user_agents = array_filter(array_map('trim', preg_split('/[\r\n]/', $robot_user_agents)), function($item) {
|
||||||
|
return $item !== '';
|
||||||
|
});
|
||||||
|
Rhymix\Framework\Config::set('security.robot_user_agents', array_values($robot_user_agents));
|
||||||
|
|
||||||
// Remove old embed filter
|
// Remove old embed filter
|
||||||
$config = Rhymix\Framework\Config::getAll();
|
$config = Rhymix\Framework\Config::getAll();
|
||||||
unset($config['embedfilter']);
|
unset($config['embedfilter']);
|
||||||
|
|
|
||||||
|
|
@ -438,6 +438,10 @@ class adminAdminView extends admin
|
||||||
context::set('mediafilter_object', implode(PHP_EOL, Rhymix\Framework\Filters\MediaFilter::getObjectWhitelist()));
|
context::set('mediafilter_object', implode(PHP_EOL, Rhymix\Framework\Filters\MediaFilter::getObjectWhitelist()));
|
||||||
context::set('mediafilter_classes', implode(PHP_EOL, Rhymix\Framework\Config::get('mediafilter.classes') ?: array()));
|
context::set('mediafilter_classes', implode(PHP_EOL, Rhymix\Framework\Config::get('mediafilter.classes') ?: array()));
|
||||||
|
|
||||||
|
// Load robot user agents.
|
||||||
|
$robot_user_agents = Rhymix\Framework\Config::get('security.robot_user_agents') ?: array();
|
||||||
|
Context::set('robot_user_agents', implode(PHP_EOL, $robot_user_agents));
|
||||||
|
|
||||||
// Admin IP access control
|
// Admin IP access control
|
||||||
$allowed_ip = Rhymix\Framework\Config::get('admin.allow');
|
$allowed_ip = Rhymix\Framework\Config::get('admin.allow');
|
||||||
Context::set('admin_allowed_ip', implode(PHP_EOL, $allowed_ip));
|
Context::set('admin_allowed_ip', implode(PHP_EOL, $allowed_ip));
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,12 @@
|
||||||
<textarea name="mediafilter_classes" id="mediafilter_classes" rows="4" style="width:100%;">{$mediafilter_classes}</textarea>
|
<textarea name="mediafilter_classes" id="mediafilter_classes" rows="4" style="width:100%;">{$mediafilter_classes}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="x_control-group">
|
||||||
|
<label class="x_control-label" for="robot_user_agents">Robot User Agents</label>
|
||||||
|
<div class="x_controls" style="margin-right:14px">
|
||||||
|
<textarea name="robot_user_agents" id="robot_user_agents" rows="4" style="width:100%;">{$robot_user_agents}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="x_control-group">
|
<div class="x_control-group">
|
||||||
<label class="x_control-label" for="admin_allowed_ip">{$lang->admin_ip_allow}</label>
|
<label class="x_control-label" for="admin_allowed_ip">{$lang->admin_ip_allow}</label>
|
||||||
<div class="x_controls">
|
<div class="x_controls">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue