SOPA 黑屏组件
2012 年 1 月 24 日星期二,美国参议院将对网络审查法案进行投票。虽然这是一项美国法律,但它对整个网络产生了深远的影响。Reddit 等网站表示,他们将在 1 月 18 日上午 8 点到晚上 8 点之间关闭网站。这个组件可以让您加入这一事业。在 1 月 18 日,您的网站将显示一个可定制的页面。搜索引擎排名不会受到影响,因为插件发送了一个 503 状态。
2012 年 1 月 24 日星期二,美国参议院将对网络审查法案进行投票。
虽然这是一项美国法律,但它对整个网络产生了深远的影响。Reddit 等网站表示,他们将在 1 月 18 日上午 8 点到晚上 8 点之间关闭网站。
这个组件可以让您加入这一事业。在 1 月 18 日,您的网站将显示一个可定制的页面。
搜索引擎排名不会受到影响,因为插件发送了一个 503 状态。
这并不完全是 "Cake-y" 的 - 我尝试过先使用插件,然后考虑用组件创建一个错误页面,但我希望人们可以下载一个文件,然后在需要时使用它。
欢迎提出建议…
<?php
class SopaBlackoutComponent extends Object {
var $sopa_blackout_page_title = 'Supporting anti-SOPA Blackout day'; // title and h1 content
var $sopa_blackout_include_video = true; // embed the video from americancensorship.org on your site?
var $sopa_blackout_include_form = true; // include the form from americancensorship.org on your site?
var $sopa_blackout_message = '<p>On the Tuesday 24th January 2012, the US Senate will vote on the <a href="https://en.wikipedia.org/wiki/Stop_Online_Piracy_Act" target="_blank">internet censorship bill</a>.<br /><br />Whilst it is an American law, it has far reaching repurcusions for the web as a whole.<br /><br />There are many companies against SOPA, such as <a href="https://www.mattcutts.com/blog/internet-censorship-sopa/" target="_blank">Google</a>, <a href="https://blog.reddit.com/2012/01/stopped-they-must-be-on-this-all.html" target="_blank">Reddit</a>, <a href="https://news.cnet.com/8301-31921_3-57342914-281/silicon-valley-execs-blast-sopa-in-open-letter/" target="_blank">Facebook, Twitter, Wikipedia</a>, and today I am lending my weight to the argument by taking my site down for the day.<br /><br />If you think SOPA doesn\'t affect you, please think again. Watch the video below, or use the form below to force politicians to take notice.<br /><br />Thank you</p>';
var $sopa_blackout_date = '2012-01-18'; // SOPA Blackout Day - 18th January 2012
var $sopa_blackout_timestart = 8; // Starting at 8am or 08:00:00
var $sopa_blackout_timeend = 20; // Ending at 8pm or 20:00:00
var $sopa_blackout_timezone = null; // recommended timezones would be America/New_York or America/Los_Angeles
//called before Controller::beforeFilter()
function initialize(&$controller, $settings = array()) {
// saving the controller reference for later use
$this->controller =& $controller;
}
//called after Controller::beforeRender()
function beforeRender(&$controller) {
if($this->sopablackout_checkdate()){
$message = '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>'.$this->sopa_blackout_page_title.'</title>
<style>
body, html {background-color:#000000; color:#ffffff;font-family:"Trebuchet MS", Myriad, Arial;}
div.sopablackout_padding {padding:24px;}
#container {width:1000px; margin:40px auto;}
p, div.sopablackout_padding { font-size:14px; line-height:140%;}
</style>
</head>
<body>
<div id="container">
<h1>'.$this->sopa_blackout_page_title.'</h1>
<div class="sopablackout_padding">
'.$this->sopa_blackout_message.'
</div>';
if($this->sopa_blackout_include_video===true){
$message .='
<div class="sopablackout_padding">
<iframe src="https://player.vimeo.com/video/31100268" width="600" height="338" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>';
}
if($this->sopa_blackout_include_form===true){
$message .='
<div class="sopablackout_padding">
<iframe src="https://americancensorship.org/callwidget" width="588" height="625" border="0"></iframe>
</div>';
}
$message .='
</div>
</body>
</html>';
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Retry-After: ' . HOUR);
echo $message;
exit();
}
}
function sopablackout_checkdate(){
$toreturn = false;
if(date('Y-m-d')==$this->sopa_blackout_date){
if($this->sopa_blackout_timezone){
date_default_timezone_set($this->sopa_blackout_timezone);
}
if(date('H')>=$this->sopa_blackout_timestart && date('H')<$this->sopa_blackout_timeend){
$toreturn = true;
}
}
return $toreturn;
}
}
?>