-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
328 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
<?php | ||
if (!defined('__TYPECHO_ROOT_DIR__')) exit; | ||
/** | ||
* Hello World | ||
* | ||
* @package AllsitePasswd | ||
* @author 小类 | ||
* @version 1.0.0 | ||
* @link http://leiyanhui.com/typecho_AllsitePasswd_Plugin | ||
*/ | ||
class AllsitePasswd_Plugin implements Typecho_Plugin_Interface | ||
{ | ||
/** | ||
* 激活插件方法,如果激活失败,直接抛出异常 | ||
* | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function activate() | ||
{ | ||
Typecho_Plugin::factory('admin/menu.php')->navBar = array('AllsitePasswd_Plugin', 'render'); | ||
|
||
|
||
|
||
Typecho_Plugin::factory('Widget_Archive')->headerOptions =array('AllsitePasswd_Plugin', 'main_fun'); | ||
|
||
|
||
|
||
} | ||
|
||
public static function main_fun() | ||
{ | ||
|
||
$Str_Msg_PSWERR=""; | ||
//检查密码 处理 cookies | ||
if ( isset($_POST['index_passwd']) ){ | ||
|
||
if ( trim($_POST['index_passwd'])== Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->str_Pword ){ | ||
|
||
setcookie("index_passwd",trim($_POST['index_passwd']),time()+3600*1); | ||
|
||
echo '<meta http-equiv="refresh" content="0;url='.$_SERVER["REQUEST_URI"].'"> '; | ||
}else{ | ||
$Str_Msg_PSWERR="密码错误,请重新输入"; | ||
} | ||
} | ||
|
||
if(empty($_COOKIE["index_passwd"])){ | ||
?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head><meta charset="UTF-8"> | ||
<title> | ||
<?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->str_word)?> | ||
</title> | ||
<style> | ||
/*点击按钮样式*/ | ||
.dianji { | ||
width: 100px; | ||
height: 55px; | ||
padding: 15px 35px; | ||
color: #fff; | ||
background: #A0DAD0; | ||
border-radius: 0 2px 2px 0; | ||
box-shadow: none; | ||
border: 0; | ||
text-shadow: none; | ||
} | ||
/*输入框样式*/ | ||
.shurukuang { | ||
width: 189px; | ||
height: 50px; | ||
float: none; | ||
border-radius: 2px 0 0 2px; | ||
padding: 0 0 0 10px; | ||
border-color: #A0DAD0; | ||
outline: none; | ||
} | ||
/*提示文字样式*/ | ||
.wenzi{ | ||
font-size: 21px!important; | ||
display: table; | ||
margin: 10px auto 50px; | ||
color: #ff6d6d; | ||
} | ||
/*居中*/ | ||
.juzhong{ | ||
display: table; | ||
margin: 100px auto 50px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="juzhong" > | ||
<img class="juzhong" src=" <?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->url_pic)?>" /> | ||
<p class="wenzi"> <?php echo Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->str_word?></p> | ||
<br><span style="color:red"><?php echo $Str_Msg_PSWERR;?></span> | ||
<form action="<?php echo $_SERVER["REQUEST_URI"];?>" method="post" > | ||
<input type="password" class="shurukuang" name="index_passwd" placeholder="<?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->placeholder)?>" /> | ||
<input type="submit" class="dianji" value="<?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->Submit)?>"> | ||
</form> | ||
</div> | ||
</body> | ||
</html> | ||
<?php | ||
//停止输出其他内容 | ||
exit(); | ||
|
||
}else{ | ||
//密码存在 什么都不做 | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
/** | ||
* 禁用插件方法,如果禁用失败,直接抛出异常 | ||
* | ||
* @static | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function deactivate(){} | ||
|
||
/** | ||
* 获取插件配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form 配置面板 | ||
* @return void | ||
*/ | ||
public static function config(Typecho_Widget_Helper_Form $form) | ||
{ | ||
/** 分类名称 */ | ||
$str_word = new Typecho_Widget_Helper_Form_Element_Text('str_word', NULL, '网站已经启用全站加密,请输入密码访问', _t('提示文字')); | ||
$form->addInput($str_word); | ||
|
||
|
||
$placeholder = new Typecho_Widget_Helper_Form_Element_Text('placeholder', NULL, '输入密码查看精彩内容', _t('输入框提示')); | ||
$form->addInput($placeholder); | ||
|
||
|
||
$Submit = new Typecho_Widget_Helper_Form_Element_Text('Submit', NULL, '提交', _t('Submit按钮提示')); | ||
$form->addInput($Submit); | ||
|
||
$url_pic = new Typecho_Widget_Helper_Form_Element_Text('url_pic', NULL, 'http://typecho.org/usr/themes/bluecode/img/typecho-logo.svg', _t('提示图片')); | ||
$form->addInput($url_pic); | ||
|
||
$str_Pword = new Typecho_Widget_Helper_Form_Element_Text('str_Pword', NULL, '123456',_t('设置全站访问密码')); | ||
$form->addInput($str_Pword); | ||
|
||
$enable_in_html = new Typecho_Widget_Helper_Form_Element_Radio('enable_in_html', array ('0' => '加密后内容依旧可以在html和搜索引擎中可见', '1' => '彻底隐藏数据'), '0', '是否完全隐藏内容:', ''); | ||
$form->addInput($enable_in_html); | ||
} | ||
|
||
/** | ||
* 个人用户的配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form | ||
* @return void | ||
*/ | ||
public static function personalConfig(Typecho_Widget_Helper_Form $form){} | ||
|
||
/** | ||
* 插件实现方法 | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public static function render() | ||
{ | ||
echo '<a href="options-plugin.php?config=AllsitePasswd">全站密码</a>'; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
if (!defined('__TYPECHO_ROOT_DIR__')) exit; | ||
/** | ||
* Hello World | ||
* | ||
* @package AllsitePasswd | ||
* @author 小类 | ||
* @version 1.0.0 | ||
* @link http://leiyanhui.com/typecho_AllsitePasswd_Plugin | ||
*/ | ||
class AllsitePasswd_Plugin implements Typecho_Plugin_Interface | ||
{ | ||
/** | ||
* 激活插件方法,如果激活失败,直接抛出异常 | ||
* | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function activate() | ||
{ | ||
Typecho_Plugin::factory('admin/menu.php')->navBar = array('AllsitePasswd_Plugin', 'render'); | ||
|
||
|
||
|
||
Typecho_Plugin::factory('Widget_Archive')->headerOptions =array('AllsitePasswd_Plugin', 'main_fun'); | ||
|
||
|
||
|
||
} | ||
|
||
public static function main_fun() | ||
{ | ||
|
||
$Str_Msg_PSWERR=""; | ||
//检查密码 处理 cookies | ||
if ( isset($_POST['index_passwd']) ){ | ||
|
||
if ( trim($_POST['index_passwd'])== Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->str_Pword ){ | ||
|
||
setcookie("index_passwd",trim($_POST['index_passwd']),time()+3600*24*7); | ||
|
||
echo '<meta http-equiv="refresh" content="0;url='.$_SERVER["REQUEST_URI"].'"> '; | ||
}else{ | ||
$Str_Msg_PSWERR="密码错误,请重新输入"; | ||
} | ||
} | ||
|
||
if(empty($_COOKIE["index_passwd"])){ | ||
?> | ||
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"> | ||
<title><?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->str_word)?></title> | ||
<style>html {padding: 50px 10px;font-size: 16px;line-height: 1.4;color: #666;background: #F6F6F3;-webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%;}html,input { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }body {max-width: 500px;_width: 500px;padding: 30px 20px;margin: 0 auto;background: #FFF;}ul {padding: 0 0 0 40px;}.container {max-width: 380px;_width: 380px;margin: 0 auto;}</style> | ||
</head><body> | ||
<div class="container"> | ||
<img src=" <?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->url_pic)?>" /> | ||
<br> | ||
<?php echo Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->str_word?> | ||
<br><span style="color:red"><?php echo $Str_Msg_PSWERR;?></span><br> | ||
|
||
<form action="<?php echo $_SERVER["REQUEST_URI"];?>" method="post" > | ||
<input type="password" name="index_passwd" placeholder="<?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->placeholder)?>" /> | ||
|
||
<input type="submit" value="<?php echo htmlspecialchars(Typecho_Widget::widget('Widget_Options')->plugin('AllsitePasswd')->Submit)?>"> | ||
</form> | ||
</div> | ||
</body></html> | ||
<?php | ||
//停止输出其他内容 | ||
exit(); | ||
|
||
}else{ | ||
//密码存在 什么都不做 | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
/** | ||
* 禁用插件方法,如果禁用失败,直接抛出异常 | ||
* | ||
* @static | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function deactivate(){} | ||
|
||
/** | ||
* 获取插件配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form 配置面板 | ||
* @return void | ||
*/ | ||
public static function config(Typecho_Widget_Helper_Form $form) | ||
{ | ||
/** 分类名称 */ | ||
$str_word = new Typecho_Widget_Helper_Form_Element_Text('str_word', NULL, '网站已经启用全站加密,请输入密码访问', _t('提示文字')); | ||
$form->addInput($str_word); | ||
|
||
|
||
$placeholder = new Typecho_Widget_Helper_Form_Element_Text('placeholder', NULL, '输入密码查看精彩内容', _t('输入框提示')); | ||
$form->addInput($placeholder); | ||
|
||
|
||
$Submit = new Typecho_Widget_Helper_Form_Element_Text('Submit', NULL, '提交', _t('Submit按钮提示')); | ||
$form->addInput($Submit); | ||
|
||
$url_pic = new Typecho_Widget_Helper_Form_Element_Text('url_pic', NULL, 'http://typecho.org/usr/themes/bluecode/img/typecho-logo.svg', _t('提示图片')); | ||
$form->addInput($url_pic); | ||
|
||
$str_Pword = new Typecho_Widget_Helper_Form_Element_Text('str_Pword', NULL, '123456',_t('设置全站访问密码')); | ||
$form->addInput($str_Pword); | ||
|
||
//$enable_in_html = new Typecho_Widget_Helper_Form_Element_Radio('enable_in_html', array ('0' => '加密后内容依旧可以在html和搜索引擎中可见', '1' => '彻底隐藏数据'), '0', '是否完全隐藏内容:', ''); | ||
// $form->addInput($enable_in_html); | ||
} | ||
|
||
/** | ||
* 个人用户的配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form | ||
* @return void | ||
*/ | ||
public static function personalConfig(Typecho_Widget_Helper_Form $form){} | ||
|
||
/** | ||
* 插件实现方法 | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public static function render() | ||
{ | ||
echo '<a href="options-plugin.php?config=AllsitePasswd">全站密码</a>'; | ||
} | ||
|
||
|
||
|
||
} |