小编Bor*_*rsn的帖子

Nginx 允许通过域但不允许通过 IP

这是我的配置:

server {
    listen 80;
    listen [::]:80;
    server_name  domain.tld www.domain.tld;
    return 301 https://erp.uni.mk$request_uri;
}
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name  domain.tld;
    ssl_certificate "/etc/nginx/ssl/ca_full.crt";
    ssl_certificate_key "/etc/nginx/ssl/private.key";
    ...
}
Run Code Online (Sandbox Code Playgroud)

我想要实现的是阻止通过 IP 的访问。并且只允许通过域。

我见过一些使用正则表达式的解决方案,但我同时使用 IPv4 和 IPv6。而且它不应该影响性能。

有什么建议如何解决这个问题吗?

nginx

5
推荐指数
1
解决办法
8241
查看次数

即使监听器未触发,也会调整大小

在调整大小时,甚至不会触发侦听器。

class MainContainer extends React.Component {
  constructor(props) {
    super(props);
    this.containerRef = React.createRef();
    this.state = {};
  }

  componentDidMount() {
    this.containerRef.current.addEventListener("resize", this.handleResize);
  }

  componentWillUnmount() {
    this.containerRef.current.removeEventListener("resize", this.handleResize);
  }

  handleResize() {
    console.log("handleResize");
  }

  render() {
      return (
        <React.Fragment>
          <Container ref={this.containerRef}>
            <Body />
          </Container>
          <ShadowTop show={this.state.top} />
        </React.Fragment>
      );
  }

}
Run Code Online (Sandbox Code Playgroud)

--

export const Container = styled.div`
  @media (max-width: 760px) {
    position: absolute;
  }

  margin-top: ${({ theme }) => theme.header.height.percent}%;
  margin-top: -webkit-calc(${({ theme }) => theme.header.height.pixel}px);
  margin-top: -moz-calc(${({ theme }) => theme.header.height.pixel}px);
  margin-top: calc(${({ …
Run Code Online (Sandbox Code Playgroud)

javascript addeventlistener reactjs styled-components

4
推荐指数
1
解决办法
2501
查看次数

使用 LEFT JOINS 进行 MySQL 更新

这是我的查询:

UPDATE 
    `product_pricing` 

SET `formula_id`= '2'

WHERE 1
Run Code Online (Sandbox Code Playgroud)
SELECT

product_pricing.id,
product_pricing.formula_id,
product_pricing.vat_calculated,

products_ids.id,
products_ids.link_id,

product_attributes.fty_id,
product_attributes.size_id,

product_sizes.size_id,
product_sizes.wheel

FROM product_pricing 

LEFT JOIN products_ids ON product_pricing.id = products_ids.id
LEFT JOIN product_attributes ON products_ids.link_id = product_attributes.fty_id
LEFT JOIN product_sizes ON product_attributes.size_id = product_sizes.size_id

WHERE

product_sizes.wheel = '13'
Run Code Online (Sandbox Code Playgroud)

如何将 SELECT 查询与更新查询结合起来?

我只需要更新具有此信息的产品product_sizes.wheel = '13',但要获取此信息,我需要一些左连接。

mysql sql

3
推荐指数
1
解决办法
1万
查看次数

使用来自 shell 变量的 JSON 内容运行 curl 命令

我有下面的脚本...

而且我似乎无法让变量起作用

#!/bin/bash

info = 'Help...?'    
object='{"attachments": [{"title": "ti1","text": $info }]}'    
curl -X POST -H 'Content-type: application/json' --data '$object' https://hooks.slack.com/services/xxxx

exit 0
Run Code Online (Sandbox Code Playgroud)

即使--data '$object'没有$info……也无法工作,因为 Slack API 无法读取我的请求。

我该如何解决?

linux bash shell

2
推荐指数
1
解决办法
9545
查看次数

PHP的inet_pton()转换IPv4和IPv6

当我使用时inet_pton(),FE80:0000:0000:0000:0202:B3FF:FE1E:8329我得到??????)任何东西.

所以我添加bin2hex()fe800000000000000202b3fffe1e8329更好地完成了.

但是,我期待一个16而不是32的字符串.

而且从那里变得更加不一致.

转换时,8.8.8.8我得到080808088的字符串.


有没有办法在一切都相同的长度上实现某种一致性,还是应该按原样将其添加到数据库中?

我正在寻找一种有效/快速的方法来实现这一目标,这将导致一个更小的字符串,这将占用我的数据库更少的空间,而不会浪费太多的资源.

php

2
推荐指数
1
解决办法
255
查看次数

不满足特征绑定 `chrono::DateTime&lt;Utc&gt;: FromSql&lt;diesel::sql_types::Nullable&lt;diesel::sql_types::Timestamptz&gt;, Pg&gt;`

我陷入了这个错误,不知道如何修复它。

有什么想法我做错了什么吗?

错误:

 Compiling actix-test v0.1.0 (/Users/b/o/d/Rust/actix-test)
error[E0277]: the trait bound `chrono::DateTime<Utc>: FromSql<diesel::sql_types::Nullable<diesel::sql_types::Timestamptz>, Pg>` is not satisfied
    --> src/app/e/api/products/properties.rs:16:61
     |
16   |     let query_result = web::block(move || properties::table.load::<Property>(&*con).unwrap()).await;
     |                                                             ^^^^ the trait `FromSql<diesel::sql_types::Nullable<diesel::sql_types::Timestamptz>, Pg>` is not implemented for `chrono::DateTime<Utc>`
     |
     = help: the following implementations were found:
               <chrono::DateTime<Utc> as FromSql<diesel::sql_types::Timestamptz, Pg>>
     = note: required because of the requirements on the impl of `Queryable<diesel::sql_types::Nullable<diesel::sql_types::Timestamptz>, Pg>` for `chrono::DateTime<Utc>`
     = note: 2 redundant requirements hidden
     = note: required because of the requirements on …
Run Code Online (Sandbox Code Playgroud)

postgresql rust rust-cargo rust-diesel

2
推荐指数
1
解决办法
2011
查看次数

延长动画持续时间 - CSS3

我有以下动画.我想要做的是当动画到达时50%我希望它在那里停留8秒钟.

如果我改变animation-duration: 3s;8s它是痛苦的缓慢.

而且transition-duration: 0.5s;似乎没有任何影响.

我也尝试过添加animation-duration: 5s;,50% {}但也没有做任何事情.


有关如何实现这一目标的任何建议?

html body div#size_cont div#dirt_specs {

        -webkit-animation-name: dirt-specs1-anim;
        -moz-animation-name: dirt-specs1-anim;
        -o-animation-name: dirt-specs1-anim;
        animation-name: dirt-specs1-anim;

        -webkit-animation-timing-function: ease-in-out;
        -moz-animation-timing-function: ease-in-out;
        -o-animation-timing-function: ease-in-out;
        animation-timing-function: ease-in-out;

        -webkit-animation-iteration-count: infinite;
        -moz-animation-iteration-count: infinite;
        -o-animation-iteration-count: infinite;
        animation-iteration-count: infinite;

        -webkit-transition-duration: 0.5s;
        -moz-transition-duration: 0.5s;
        -o-transition-duration: 0.5s;
        transition-duration: 0.5s;

        -webkit-animation-duration: 3s;
        -moz-animation-duration: 3s;
        -o-animation-duration: 3s;
        animation-duration: 3s;


        transform: scale(1.4,1.4);
        opacity: 0;
    }

    @-webkit-keyframes dirt-specs1-anim {       
        50% { 
            transform: scale(1.2,1.2);
            opacity: 0.5; …
Run Code Online (Sandbox Code Playgroud)

html css animation css3

1
推荐指数
1
解决办法
255
查看次数

css:disabled ::不工作后

似乎无法让以下选择器工作.

难道我做错了什么?

   html body div#main_container form#account_info input[type=text]:disabled::after, input[type=email]:disabled::after {
     content: "dfjnsfnj";
     position: absolute; float: none; clear: both; display: block;
     top: 0; left: 0;
     width: 100px; height: 100px; margin: 0; padding: 0;

     font-family: "Open Sans", sans-serif; font-weight: 600; font-size: 25px; line-height: 25px; text-align: left;
     letter-spacing: -3px;
     color: #3d5a71;
     background-color: red;
   }
Run Code Online (Sandbox Code Playgroud)

css

0
推荐指数
1
解决办法
1585
查看次数

php Mac地址检查格式

我从 url 获取用户的 mac。我要做的是匹配以查看地址是否真实。因为我将针对数据库运行它,如果格式不正确,我不想运行它。

这是我到目前为止:

if (isset($_GET['mac'])) { 
    if (strlen($_GET['mac']) == 18) { 
        $get_mac_filtered = preg_replace('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', '',$_GET['mac']);
            if (preg_match('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', $_GET['mac']) == $get_mac_filtered) {
                echo 'Got a mac match! '.$get_mac_filtered;
            }else {
                echo 'Sorry !=';
            }
}else {die();} }
Run Code Online (Sandbox Code Playgroud)

我猜问题出在这里,(preg_match('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', $_GET['mac']) == $get_mac_filtered)因为它又回来了else

php

0
推荐指数
1
解决办法
5957
查看次数

向DateTime(PHP)添加'x'小时,'x'分钟和'x'秒

我有一定的时间戳,想要添加一个'x' hours,'x' minutes'x' seconds为它.

我试过这样的:

date_default_timezone_set('UTC'); 
$now = DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''));
$now = $now->setTimezone(new DateTimeZone('Europe/London'))->format('Y-m-d H:i:s.u');

echo '<br> Localized: '.$now;

echo '<br> Time1: '.date("Y-m-d H:i:s", strtotime('+3 hours +5 minutes +4 seconds', $now));

echo '<br> Time2: '.date("Y-m-d H:i:s", strtotime('+0 hours +5 minutes +4 seconds', $now));
Run Code Online (Sandbox Code Playgroud)
Localized: 2018-06-12 10:51:32.166452

Time1: 1970-01-01 03:38:42
Time2: 1970-01-01 00:38:42
Run Code Online (Sandbox Code Playgroud)

但结果是不正确的......我在这里做错了什么?

php

0
推荐指数
1
解决办法
68
查看次数

jQuery将屏幕加载到纯JavaScript中

我有这个加载屏幕脚本,我想在项目中实现.

但是它需要jQuery.由于页面中没有任何元素需要jQuery,我想节省一些空间并避免添加它.

有什么办法可以用纯JavaScript提供完全相同的功能吗?

HTML:

<body onload="hide_preloader();">    
<div class="preloader"> <div class="loader"></div> </div>
</body>
Run Code Online (Sandbox Code Playgroud)

jQuery的:

jQuery(window).load(function() { rotate = 0; $(".preloader").fadeOut(250); });
Run Code Online (Sandbox Code Playgroud)

谢谢

html javascript css jquery css-transitions

-1
推荐指数
1
解决办法
1669
查看次数

php $变量在IF语句之外不起作用

else {
    if ($_COOKIE['HotspotLanguage'] == 'ENG') { 
        $url_lang_code = '?lang=eng'; 
        header('Location: '.$url_captive_portal.$url_lang_code.'');
    } elseif ($_COOKIE['HotspotLanguage'] == 'ALB') { 
        $url_lang_code = '?lang=alb'; 
        header('Location: '.$url_captive_portal.$url_lang_code.''); 
    } elseif ($_COOKIE['HotspotLanguage'] == 'MKD') { 
        $url_lang_code = '?lang=mkd'; 
        header('Location: '.$url_captive_portal.$url_lang_code.'');
    }
}
Run Code Online (Sandbox Code Playgroud)

从上面的代码中可以看出,我已经定义了一个变量$url_lang_code; 但是,我的变量在if声明之外不起作用.

URL被重写,这是有效的.但是,如果我使用$url_lang_codeif语句之外的某个地方,它就不起作用......

难道我做错了什么?

php cookies if-statement

-1
推荐指数
1
解决办法
107
查看次数

PHP:子类无法访问MySQL对象

使用该函数,chief我尝试启动一个将由多个类/函数全局使用的mysql连接.

当我将这个类扩展到session类时$db,子类无法访问mysql对象.

class chief {

    protected $db;

    public function __construct() {

        $this->db=new stdClass();

        $this->db=new mysqli('', '', '', '');
    }

}

class session extends chief {
    public function __construct($address=null) {

        var_dump($this->db);
    }
}
Run Code Online (Sandbox Code Playgroud)

打印结果:

chief Object
(
    [db:protected] => mysqli Object
        (
            [affected_rows] => 0
            [client_info] => mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387 $
            [client_version] => 50012
            [connect_errno] => 0
            [connect_error] => 
            [errno] => 0
            [error] => 
            [error_list] => Array
                (
                )

            [field_count] => …
Run Code Online (Sandbox Code Playgroud)

php mysql class

-1
推荐指数
1
解决办法
53
查看次数