moritz-sauer-13/silverstripe-agegate 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moritz-sauer-13/silverstripe-agegate

最新稳定版本:1.0.1

Composer 安装命令:

composer require moritz-sauer-13/silverstripe-agegate

包简介

Adds age-gate for verifying visitor's eligibility to view restricted content

README 文档

README

This is a Fork of https://github.com/RevStrat/silverstripe-agegate to Support SS5

SilverStripe AgeGate

This module provides an age-gate function, with support for the IPStack API or GeoLite2 database. Please provide your own GeoLite2 database in the data folder.

Important Notice

This plugin is no longer maintained. If you wish to take over maintenance, please reach out and I'll be happy to transfer.

Installation

composer require revstrat/silverstripe-agegate

Usage

Place <% include AgeGate %> just inside your opening <body> tag.

Normal template inheritance allows for customization of the age gate appearance.

Configure the desired GeoIP service by setting the following in your app's yml file:

RevStrat\AgeGate\PageControllerExtension:
  geoip_source: "RevStrat\\AgeGate\\IPStack"

Where RevStrat\\AgeGate\\IPStack is the namespaced class that will handle GeoIP lookups. To create your own, simply implement the GeoIPServiceInterface interface and update geoip_source to your fully namespaced class.

The IPStack interface makes use of two environment variables:

The IPSTACK_ENDPOINT key points to the endpoint URL and is parsed with sprintf. Update this to a compatible service (such as Nekudo) or change the protocol (paid accounts on IPStack can use https for lookups). The IPSTACK_ACCESS_KEY should be set to your access key.

Once everything is configured, be sure to run /dev/build?flush=all.

Configure age restriction by country under Settings > Age Gate Control.

Overiding the form

Implement these methods on your PageController. These methods are an example of how one might use two buttons on the age gate.

public function updateGetShowAgeGate(&$ageGateActive, &$sufficientAge) {
        
    }

    public function updateAgeGateForm(&$fields, &$actions, $minimumAge) {
    	$fields->removeByName('OfAge');
    	$actions = new FieldList(
    		FormAction::create('passAgeGate')->setTitle("Yes I'm over $minimumAge"),
    		FormAction::create('failAgeGate')->setTitle("I'm not $minimumAge yet")
    	);
    }

    public function passAgeGate($data, Form $form) {
    	$data['OfAge'] = true;
    	return $this->doAgeGate($data, $form);
    }

    public function failAgeGate($data, Form $form) {
    	$data["OfAge"] = false;
    	return $this->doAgeGate($data, $form);
    }

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2025-11-20