二蛋 发布的文章

SeaCMS自带API资源发布插件说明

  • 资源发布API是指将自己站内资源发布出来,做出资源站,供其他站长采集数据。
  • 站长可以在后台控制是否开启资源发布API插件。
  • 资源库API访问地址是:http://您的域名/zyapi.php 整合办法请接着阅读下面内容。
  • 支持发布的信息:影片名称,影片图片地址,影片连载状态,影片语言,影片地区,影片年份,影片备注,影片别名,影片豆瓣评分,影片时光网评分,影片imdb评分,影片上映电视台,影片版本,备用备注信息,影片演员,影片导演,影片简介,总集数,影片时长,影片集数,剧情分类,播放地址,下载地址等。

===海洋cms资源站接入办法===

  1. 修改文件:admin/api.php
  2. 在如下代码区域添加接口地址:

    <!-- 第三方资源站接入开始 -->
    
    您的内容  您的内容  您的内容
    
    <!-- 第三方资源站接入结束 -->
  3. 接口地址参数如下:

    <font face="微软雅黑">视频列表: 
    <a href="admin_reslib.php?ac=list&rid=2dan.cc&url=https://www.2dan.cc/api.php">资源站名称</a>
    采集当天: <a href="admin_reslib.php?ac=day&rid=2dan.cc&url=https://www.2dan.cc/api.php">采集当天</a>
    采集本周: <a href="admin_reslib.php?ac=week&rid=2dan.cc&url=https://www.2dan.cc/api.php">采集本周</a>
    采集所有: <a href="admin_reslib.php?ac=all&rid=2dan.cc&url=https://www.2dan.cc/api.php">采集所有</a>
    </font>

    ac参数:day week all type
    rid参数:rid参数和绑定分类相关,请不要和其它资源库重复,推荐使用资源站域名 如:seacms.net。
    api域名:请将https://www.2dan.cc/api.php换成资源库实际API地址。

- 阅读剩余部分 -

使用HTML5的Placeholder属性给输入框增加背景文字提示效果

背景文字提示效果是输入框常用的功能,但大部分是使用JavaScript实现的:

value="请输入影片名称或主演名称..." onBlur="if(this.value=='') this.value='请输入影片名称或主演名称...';" onFocus="if(this.value=='请输入影片名称或主演名称...') this.value='';"

HTML5提供了新的实现方式,只需要在文本框的标记上添加placeholder属性,然后在属性值里输入你需要的提示信息即可。
语法:

<input placeholder=”提示信息...”>

示例:

<form>
<input type="text" placeholder="你的姓名..." name="lname">
<input type="password" placeholder="你的密码..." name="pass">
<input type="submit" value="提交">
</form>

用在评论框时,可能需要换行,但Placeholder默认不支持换行,这里以JS实现:

$(function() {
    var placeholder = '第一行文本提示\n第二行文本提示\n第三行文本提示';
    $('textarea').val(placeholder);
    $('textarea').css({"line-height":"20px","color":"#A9A9A9"});
    $('textarea').focus(function() {
        if ($(this).val() == placeholder) {
            $(this).val('');
        }
    });
    $('textarea').blur(function() {
        if ($(this).val() == '') {
            $(this).val(placeholder);
        }
    });
});

免费SSL安全证书Let's Encrypt安装使用及Nginx配置

letsencrypt.png
Let's Encrypt CA 项目由非赢利组织 Internet Security Research Group (ISRG) 运营,由Mozilla、思科、Akamai、IdenTrust、EFF 和密歇根大学等组织发起,向网站自动签发和管理免费SSL证书,以加速互联网从 HTTP 向 HTTPS 过渡。

Let's Encrypt 官方网站:https://letsencrypt.org/
Let's Encrypt 项目主页:https://github.com/letsencrypt/letsencrypt

1、安装Let's Encrypt脚本依赖环境

# CentOS 6
yum install centos-release-SCL && yum update
yum install python27
scl enable python27 bash
yum install python27-python-devel python27-python-setuptools python27-python-tools python27-python-virtualenv
yum install augeas-libs dialog gcc libffi-devel openssl-devel python-devel
yum install python-argparse

# CentOS 7
yum install -y git python27
yum install -y augeas-libs dialog gcc libffi-devel openssl-devel python-devel
yum install python-argparse

2、获取Let's Encrypt并生成SSL证书

yum install git-core
git clone https://github.com/letsencrypt/letsencrypt.git
cd letsencrypt
./letsencrypt-auto certonly --email [email protected] -d www.2dan.cc --webroot -w /home/html --agree-tos

如果多个域名可以加多个-d 域名

- 阅读剩余部分 -

利用Nginx的accesskey和secure_link模块实现防盗链

之前文章Nginx搭建flv mp4流媒体服务器中介绍了通过referer判断实现简单的防盗链,弊端是来源容易被伪造。今天介绍一下更高级的防盗链策略。

软件版本:
nginx-1.22.1
nginx-accesskey-2.0.3

增加编译参数 --with-http_secure_link_module --add-module=/root/nginx-accesskey-2.0.3 并重新编译 nginx

./configure --prefix=/usr/local/nginx --add-module=../nginx_mod_h264_streaming-2.2.7 --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --user=www --group=www --with-http_flv_module --with-http_stub_status_module --with-threads --with-http_ssl_module --with-http_secure_link_module --add-module=/root/nginx-accesskey-2.0.3 --with-openssl-opt='enable-tls1_3 enable-weak-ssl-ciphers' --with-http_v2_module --with-http_mp4_module --with-cc-opt='-O3'
make && make install

完整的配置文件示例:

user www www;

worker_processes auto;

error_log  /usr/local/nginx/logs/error.log  crit;

pid /usr/local/nginx/logs/nginx.pid;

events {
    use epoll;
    worker_connections 65535;
}

http {
    include mime.types;
    default_type application/octet-stream;
    
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 150m;
    tcp_nopush on;
    tcp_nodelay on;
    
    sendfile on;
    
    keepalive_timeout 65;
    limit_conn_zone $binary_remote_addr zone=perip:10m; #容器共使用10M的内存来应对IP传输开销
    
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    gzip_proxied        expired no-cache no-store private auth;
    gzip_disable        "MSIE [1-6]\.";
    
    server {
        listen 80;
        listen 443 ssl http2 fastopen=3 reuseport;
        server_name 2dan.cc; 
        root /home/html;
        limit_conn perip 3; #限制每个IP同一时间只能发起3个连接
        limit_rate_after 10m; #在视频文件下载10M以后开始限速
        limit_rate 100k; #速度限制为100K
        charset utf-8;
        
        ssl on;
        ssl_certificate      2dan.cc_bundle.crt;
        ssl_certificate_key  2dan.cc.key;
        ssl_session_timeout  5m;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
        ssl_prefer_server_ciphers on;
        error_page 497 https://$host$uri; #http重定向到https 

        location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
        
        location ~ \.(mp4|m3u8)$ {
                 mp4;
                 valid_referers none blocked *.2dan.cc; #防盗链授权
            if ($invalid_referer) {
                  return 403;
            }
            if (!-e $request_filename) {rewrite ^/(.*)/(.*)/(.*)/(.*) /$4?key=$1&st=$2&e=$3 last;}
            accesskey on;
            accesskey_hashmethod md5;
            accesskey_arg "key";
            accesskey_signature "mypass$REMOTE_ADDR";
            secure_link $arg_st,$arg_e;
            secure_link_md5 mypass$arg_e;
            if ( $secure_link = "" ) {
                return 402;
            }
            if ( $secure_link = "0" ) {
                return 405;
            }
        }
        access_log off;
    }
}

结合PHP实现自动跳转到真实链接地址

- 阅读剩余部分 -