如何实现独立页面加密访问
如何实现独立页面加密访问
<?php
/**
* 加密模板
*
* @package custom
*/
; ?>
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<div class="col-mb-12 col-8" id="main" role="main">
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<h1 class="post-title" itemprop="name headline"><a itemtype="url" href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h1>
<div class="post-content" itemprop="articleBody">
<?php
$password = "1234"; // 这里是密码
$p = "";
if(isset($_COOKIE["isview"]) and $_COOKIE["isview"] == $password){
$isview = true;
}else{
if(isset($_POST["pwd"])){
if($_POST["pwd"] == $password){
setcookie("isview",$_POST["pwd"],time()+3600*3);
$isview = true;
}else{
$p = (empty($_POST["pwd"])) ? "对不起,您输入的密码错误!" : "对不起,您输入的密码错误!";
}
}else{
$isview = false;
$p = "请输入密码访问:";
}
}
if(@$isview){ ?>
<?php $this->content(); ?><?php }else{ ?>
<form class="protected" action="?yes" method="post"><p class="word"><?php echo $p; ?></p>
<p>
<input type="password" class="text" name="pwd" />
<input type="submit" class="submit" value="提交" />
</p>
</form> <?php
} ?>
</div>
</article>
<?php $this->need('comments.php'); ?>
</div><!-- end #main-->
<?php $this->need('sidebar.php'); ?>
<?php $this->need('footer.php'); ?>
最后更新于 2020-05-28 22:18:11 并被添加「加密 typecho 独立页面」标签,已有 1844 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处