作者: Jefsky

  • 开启win10滑动关机

    n
    %windir%\System32\SlideToShutDown.exe
    n
  • http怎么做自动跳转https

    n

    Apache 版本

    nnnn

    整站跳转,则在网站的配置文件的标签内:

    nnnn
    RewriteEngine onnnRewriteCond %{SERVER_PORT} !^443nnRewriteRule ^(.*)? https://%{SERVER_NAME}/$1 [L,R=301]n
    nnnn

    对某个目录做https强制跳转:

    nnnn
       RewriteEngine onn
    nnnn

    对某个网页进行https跳转,可以使用redirect 301来做跳转!redirect 301 /你的网页 https://你的主机+网页

    nnnn

    Nginx版本

    nnnn

    配置80端口的文件里面,写入以下内容

    nnnn
               server {nn    listen       80;nn    server_name  localhost;nn    rewrite ^(.*)https://host$1 permanent;    nn    }nnn
    nnnn

    IIS 版本

    nnnn

    IIs中实现Http自动转换到Https方法介绍 (403跳转对SEO有一定影响)

    nnnn

    1、根据IIS版本备份以下文件:
    IIS6.0 路径:C:WINDOWSHelpiisHelpcommon403-4.htm

    nnnn

    IIS7.0以上 路径:C:inetpubcusterrzh-CN403.htm

    nnnn

    2、把以下内容全部拷贝替换(403-4或403)里面所有内容,保存即可

    nnnn
    <script type="text/javascript">nnvar url = window.location.href;nn                if (url.indexOf("https") < 0) {nn                    url = url.replace("http:", "https:");nn                    window.location.replace(url);nn                }nn</script>nn
    nnnn

    注释:IIS6中,站点属性-》目录安全性-》编辑中把“要求安全通道(SSL)”勾选上即可。
    IIS7、8中,SSL设置-》把“要求SSL”勾选即可。

    nnnn

    TOMCAT 版本

    nnnn

    1、在conf目录下的server.xml文件中找到以下配置,修改redirectPort参数值为”443″,默认是“8443”.

    nnnn

    2、在conf目录下的web.xml文件内容……中增加以下配置。

    nnnn
    <web-app>nn.........nn<security-constraint>nn    <web-resource-collection >        nn   <web-resource-name >SSL</web-resource-name>     nn   <url-pattern>/*</url-pattern>nn       </web-resource-collection>    nn       <user-data-constraint>nn<transport-guarantee>CONFIDENTIAL</transport-guarantee>nn       </user-data-constraint>nn</security-constraint>nn</web-app>nn
    nnnn

    单独页面通用代码段

    nnnn

    在需要强制为https的页面上加入以下代码进行处理http–>https

    nnnn
    <script type="text/javascript">nn        var url = window.location.href;nn        if (url.indexOf("https") < 0) {nn        url = url.replace("http:", "https:");nn        window.location.replace(url);nn        }nn</script>n
    nnnn

    PHP页面跳转

    nnnn
    if (_SERVER["HTTPS"] <> "on") nn{ nnxredir="https://"._SERVER["SERVER_NAME"]._SERVER["REQUEST_URI"]; nnheader("Location: ".$xredir); nn}nn
    n
  • 终于解决typecho自带编辑器的不方便了

    n

    关于typecho自带的markdown解析引擎可以使用parsedown插件替换: kokororin / typecho-plugin-parsedown

    nnnn

    启用该插件后,无需任何设置,自动替换前台文章解析,支持解析表格和html代码。

    nnnn

    关于编辑器,这里推荐ue ueditor for typecho 2018

    nnnn

    安装方式1:在线安装

    nnnn

    使用ueditor.install.php在服务器上下载和安装

    nnnn

    访问https://github.com/chanshengzhi/ueditor-for-typecho/releases

    nnnn

    下载最新版本的安装脚本(ueditor.install.php)

    nnnn

    上传到ueditor.install.php到/usr/plugins文件夹下

    nnnn

    访问yourdomain.com/usr/plugins/ueditor.install.php进行安装

    nnnn

    安装成功后进入typecho插件管理界面启用即可.

    nnnn

    安装方式2:下载安装

    nnnn

    访问https://github.com/chanshengzhi/ueditor-for-typecho/releases,下载所需版本的压缩包,解压后上传其中的ueditor文件夹到/usr/plugins文件夹下, 进入typecho插件管理界面启用即可

    nnnn

    typecho parsedown 解析markdown插件
    使用parsedown替换typecho自带的markdown解析库。启用前请将目录名重命名为parsedown。

    n
  • 增加hosts记录

    n
    @echo offnnset /p url=请输入域名地址:nnset /p ip=请输入IP地址:nnset hosts=%systemroot%\System32\drivers\etc\hostsnnattrib -h -s -r "%hosts%"nn(echo %ip%    %url%)>>"%hosts%"nnattrib +h +r +s "%hosts%"nnipconfig /flushdnsnnpause
    n
  • console花式log

    n

    console.log利用占位符格式化打印
    %c表示css样式

    nnnn
        console.log('%c hello jefsky', 'color: yellow;font-size: 24px;font-weight: bold;text-decoration: underline;');n
    nnnn

    %d 或 %i表示整型

    nnnn
        console.log('%d', 123);nn    console.log('%i', 123);n
    nnnn

    %f表示浮点型

    nnnn
         console.log('%f', 123.321);n
    nnnn

    %o表示DOM元素

    nnnn
        console.log('%o', document.body);n
    nnnn

    %O表示javascript对象

    nnnn
        console.log('%O', new Date());n
    nnnn

    console对象的其他属性

    nnnn

    assert: ƒ assert()

    nnnn

    clear: ƒ clear()

    nnnn

    context: ƒ context()

    nnnn

    count: ƒ count()

    nnnn

    countReset: ƒ countReset()

    nnnn

    debug: ƒ debug()

    nnnn

    dir: ƒ dir()

    nnnn

    dirxml: ƒ dirxml()

    nnnn

    error: ƒ error()

    nnnn

    group: ƒ group()

    nnnn

    groupCollapsed: ƒ groupCollapsed()

    nnnn

    groupEnd: ƒ groupEnd()

    nnnn

    info: ƒ info()

    nnnn

    log: ƒ log()

    nnnn

    memory: (…)

    nnnn

    profile: ƒ profile()

    nnnn

    profileEnd: ƒ profileEnd()

    nnnn

    table: ƒ table()

    nnnn

    time: ƒ time()

    nnnn

    timeEnd: ƒ timeEnd()

    nnnn

    timeLog: ƒ timeLog()

    nnnn

    timeStamp: ƒ timeStamp()

    nnnn

    trace: ƒ trace()

    nnnn

    warn: ƒ warn()

    nnnn

    有兴趣的可以在你的浏览器console中尝试一下

    n
  • tp5.0 PHP8.0报错Method ReflectionParameter::getClass() is deprecated

    n

    $class = $param->getClass();
    //更换为
    $class = $param->getType();

    n
  • 宝塔部署时,出现“open_basedir restriction in effect”错误

    n

    错误信息:
    Warning: require(): open_basedir restriction in effect.
    Warning: require(XXXXXXXXXXX): failed to open stream: Operation not permitted in XXXX

    nnnn

    解决方案:
    更改宝塔网站配置:去掉勾选防跨站攻击(open_basedir);

    n
  • ubuntu18.04安装了phpmyadmin之后,root账户不能登录

    ubuntu18.04安装了phpmyadmin之后,root账户不能登录,但在终端中sudo mysql -u root -p仍然可以用root登录。

    nn

    显示ERROR 1698: Access denied for user ‘root’@’localhost’

    nn

    用phpmyadmin账户登录以后,看不到其他数据库,没有权限

    nn

    解决方法一:

    nn

    创建一个新用户并授予所需的权限。

    nn

    MySQL赋予用户权限的命令的格式为:
    grant 权限 on 数据库对象 to 用户 identified by “密码”

    nn

    1、连接数据库

    nn

    sudo mysql -u root -p

    nn

    2、创建一个赋予权限的账户(例如 root_sql)

    nn

    CREATE USER 'root_sql'@'localhost' IDENTIFIED BY 'yourpasswd';nGRANT ALL PRIVILEGES ON *.* TO 'root_sql'@'localhost' WITH GRANT OPTION;nFLUSH PRIVILEGES;

    nn

    3、更新phpMyAdmin配置

    nn

    打开文件/etc/dbconfig-common/phpmyadmin.conf,修改你的配置文件内容

    nn

    # dbc_dbuser: database usern#       the name of the user who we will use to connect to the database.ndbc_dbuser='root_sql'n n# dbc_dbpass: database user passwordn#       the password to use with the above username when connectingn#       to a database, if one is requiredndbc_dbpass='yourpasswd'

    nn

    解决方法二:

    nn

    给phpmyadmin账户赋予所有权限,那么你只要执行

    nn

    GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' IDENTIFIED BY 'yourpasswd';nFLUSH PRIVILEGES;
  • javascript中何时this何时that

    n

    this是Javascript中的一个关键字。

    nnnn

    当函数运行时,会自动生成的一个内部对象,this代表的就是当前对象,只能在当前函数内部使用,注意这里很重要是当前函数内部!!!因为很多时候会函数中有函数,这个时候,我们就需要把外部函数对象this复制一份了,所以就有了var that=this,that就在里面的函数中用外面的函数对象,这样就不会出现报错说没有什么对象或者变量了。

    nnnn
    $(‘#div.clickme').click(function(){nn    //此时,this就是#div.clickme这个对象nn    var that = this;    //复制,把this对象复制到thatnn    $(‘#.loop').each(function(){nn    //此时,this就成了each遍历到的.loop对象nn    //that是外面的那个#div.clickme对象nn    });nn});n
    n
  • Typecho访客阅读数统计

    n
    在当前主题function.php中加上n/*n * 无插件阅读数n*/nfunction get_post_view(archive)n{ncid = archive->cid;ndb = Typecho_Db::get();nprefix =db->getPrefix();nif (!array_key_exists('views', db->fetchRow(db->select()->from('table.contents')))) {n    db->query('ALTER TABLE `' .prefix . 'contents` ADD `views` INT(10) DEFAULT 0;');n    echo 0;n    return;n}nrow =db->fetchRow(db->select('views')->from('table.contents')->where('cid = ?',cid));nif (archive->is('single')) {ndb->query(db->update('table.contents')->rows(array('views' => (int)row['views'] + 1))->where('cid = ?', cid));n}nechorow['views'];n   }n前台调用n<?php get_post_view($this) ?>
    n