foreach方法,forech(function(currentValue,index,arr),thisValue)

function(currentValue, index, arr)
fn是必需的。 数组中每个元素需要调用的函数。

函数参数:
参数 描述
currentValue 必需。当前元素
index 可选。当前元素的索引值。
arr 可选。当前元素所属的数组对象。
thisValue 可选。传递给函数的值一般用 “this” 值。
如果这个参数为空, “undefined” 会传递给 “this” 值

tips:
onclick=”number.foreach(myfunction)”
var numbers = [4,9,16,25]

php-7.2编译出错记录

openssl安装文件找不到:

evp.h找不到时

先export PKG-CONFIG-PATH=”/usr/lib64/pkgconfig”

再./configure ……..

 

php7.2是enable-gd,enable-zip

php7.4更改为with-gd with-zip,囧

php迭代示例

<code>

<?php
echo “<pre>”;
$area = array(
array(‘id’=>113,’area’=>’亚运村’,’pid’=>11),
array(‘id’=>115,’area’=>’奥运村’,’pid’=>11),
array(‘id’=>1,’area’=>’北京’,’pid’=>0),
array(‘id’=>2,’area’=>’广西’,’pid’=>0),
array(‘id’=>3,’area’=>’广东’,’pid’=>0),
array(‘id’=>4,’area’=>’福建’,’pid’=>0),
array(‘id’=>11,’area’=>’朝阳区’,’pid’=>1),
array(‘id’=>12,’area’=>’海淀区’,’pid’=>1),
array(‘id’=>21,’area’=>’南宁市’,’pid’=>2),
array(‘id’=>45,’area’=>’福州市’,’pid’=>4),
array(‘id’=>234,’area’=>’武鸣县’,’pid’=>21)
);

function familytree($arr,$id){
static $list = array();
foreach($arr as $v){
if($v[‘id’]==$id){

familytree($arr,$v[‘pid’]);
$list[] = $v;
}
}
return $list;
}
print_r(familytree($area,113));
?>

</code>

include工作原理php

PHP的inlcude,require,include_once,require_oncej
在include包含文件并执行这个文件时,是先退出php模式并在html模式下解析此文件。

这也是为什么html文件中如果要插入php一定要定义好php标签。

the_content方法不显示内容的问题

查了很多,有的人说是the_content方法被重写,有的人通过改写
我发现我的问题是修改模板的时候,选择了的single导致的,如图
点了自定义模板后,主页设置里面选择了一个静态页面导致。

重放攻击,md5(‘test’,’test’,随机数)

单独的随机数不能避免重放攻击,随机数一般会和签名加密技术,后台验证技术混合以提高破解和重放难度。
重放攻击(Replay Attacks)又称重播攻击、回放攻击或新鲜性攻击(Freshness Attacks),是指攻击者发送一个目的主机已接收过的包,来达到欺骗系统的目的,主要用于身份认证过程,破坏认证的正确性。
从重放攻击的定义上我们可以看到,重放攻击提交给服务器的数据是曾经有效的,如何防止这种数据,对特定信息给与一个特定的随机数,并且这个随机数保存在服务器内,在验证了用户信息前,首先会对随机数进行验证,如果发现提交的随机数和服务器保存的不同则,该条信息无效通过这种方法来防止重放攻击。
常用的防御重放攻击,不会直接暴露随机数,一般随机数会用在MD5,HASH(数字签名)上,比如在对有效值进行MD5加密时添加随机数,如用户名为test,密码为test的MD5加密过程可能为MD5(“test”,”test”,随机数),这样在直接传输时不会暴露出随机值,黑客在提交重放攻击时系统发现MD5签名和系统签名计算后不同则,可被认定为重放攻击。
当然矛和盾是一种存在的,有可能该值刚好又一次的分配给了该用户,可能会重放攻击成功,但这个概率在科学计算上可以被视为0,而且随着随机数的位数的提高,概率会不断降低。

mysql-5.7在centos7中按systemd启动,手册中说明

The following discussion covers these topics:

Overview of systemd

Configuring MySQL Using systemd

Configuring Multiple MySQL Instances Using systemd

Migrating from mysqld_safe to systemd

Overview of systemd

systemd provides automatic server startup and shutdown. It also enables manual server management using the systemctl command. For example:

systemctl {start|stop|restart|status} mysqld
Alternatively, use the service command (with the arguments reversed), which is compatible with System V systems:

service mysqld {start|stop|restart|status}
For the systemctl or service commands, if the MySQL service name is not mysqld, use the appropriate name (for example, mysql on SLES systems).

Support for systemd includes these files:

mysqld.service: systemd service unit configuration, with details about the mysqld service.

mysqld@.service: Like mysqld.service, but used for managing multiple MySQL instances.

mysqld.tmpfiles.d: File containing information to support the tmpfiles feature. This file is installed under the name mysql.conf.

mysqld_pre_systemd: Support script for the unit file. This script assists in creating the error log file only if its location matches the pattern /var/log/mysql*.log. In other cases, the error log directory must be writable or the error log must be present and writable for the user running the mysqld process.

On platforms for which systemd support is installed, scripts such as mysqld_safe and the System V initialization script are not installed because they are unnecessary. For example, mysqld_safe can handle server restarts, but systemd provides the same capability, and does so in a manner consistent with management of other services rather than using an application-specific program.

As of MySQL 5.7.13, on platforms for which systemd support is installed, systemd has the capability of managing multiple MySQL instances. For details, see Configuring Multiple MySQL Instances Using systemd. Consequently, mysqld_multi and mysqld_multi.server are not installed because they are unnecessary.

Configuring MySQL Using systemd

To add or change systemd options for MySQL, these methods are available:

Use a localized systemd configuration file.

Arrange for systemd to set environment variables for the MySQL server process.

Set the MYSQLD_OPTS systemd variable.

To use a localized systemd configuration file, create the /etc/systemd/system/mysqld.service.d directory if it does not exist. In that directory, create a file that contains a [Service] section listing the desired settings. For example:

[Service]
LimitNOFILE=max_open_files
PIDFile=/path/to/pid/file
Nice=nice_level
LimitCore=core_file_limit
Environment=”LD_PRELOAD=/path/to/malloc/library”
Environment=”TZ=time_zone_setting”
The discussion here uses override.conf as the name of this file. Newer versions of systemd support the following command, which opens an editor and permits you to edit the file:

systemctl edit mysqld
Whenever you create or change override.conf, reload the systemd configuration, then tell systemd to restart the MySQL service:

systemctl daemon-reload
systemctl restart mysqld
Support for configuration using override.conf was added in MySQL 5.7.7.

With systemd, the override.conf configuration method must be used for certain parameters, rather than settings in a [mysqld_safe] or [mysqld] group in a MySQL option file:

For some parameters, override.conf must be used because systemd itself must know their values and it cannot read MySQL option files to get them.

Parameters that specify values otherwise settable only using options known to mysqld_safe must be specified using systemd because there is no corresponding mysqld parameter.

For additional information about using systemd rather than mysqld_safe, see Migrating from mysqld_safe to systemd.

You can set the following parameters in override.conf:

To specify the process ID file:

As of MySQL 5.7.10: Use override.conf and change both PIDFile and ExecStart to name the PID file path name. Any setting of the process ID file in MySQL option files will be ignored.

Before MySQL 5.7.10: Use PIDFile in override.conf rather than the –pid-file option for mysqld_safe or mysqld. systemd must know the PID file location so that it can restart or stop the server. If the PID file value is specified in a MySQL option file, the value must match the PIDFile value or MySQL startup may fail.

To set the number of file descriptors available to the MySQL server, use LimitNOFILE in override.conf rather than the –open-files-limit option for mysqld_safe or mysqld.

To set the maximum core file size, use LimitCore in override.conf rather than the –core-file-size option for mysqld_safe.

To set the scheduling priority for the MySQL server, use Nice in override.conf rather than the –nice option for mysqld_safe.

Some MySQL parameters are configured using environment variables:

LD_PRELOAD: Set this variable if the MySQL server should use a specific memory-allocation library.

TZ: Set this variable to specify the default time zone for the server.

There are multiple ways to specify the value of environment values that should be in effect for the MySQL server process managed by systemd:

Use Environment lines in the override.conf file. For the syntax, see the example in the preceding discussion that describes how to use this file.

Specify the values in the /etc/sysconfig/mysql file (create the file if it does not exist). Assign values using the following syntax:

LD_PRELOAD=/path/to/malloc/library
TZ=time_zone_setting
After modifying /etc/sysconfig/mysql, restart the server to make the changes effective:

systemctl restart mysqld
To specify options for mysqld without modifying systemd configuration files directly, set or unset the MYSQLD_OPTS systemd variable. For example:

systemctl set-environment MYSQLD_OPTS=”–general_log=1″
systemctl unset-environment MYSQLD_OPTS
After modifying the systemd environment, restart the server to make the changes effective:

systemctl restart mysqld
MYSQLD_OPTS can also be set in the /etc/sysconfig/mysql file.

Configuring Multiple MySQL Instances Using systemd

As of MySQL 5.7.13, on platforms for which systemd support is installed, systemd has the capability of managing multiple MySQL instances. Consequently, mysqld_multi and mysqld_multi.server are not installed because they are unnecessary.

To use multiple-instance capability, modify my.cnf to include configuration of key options for each instance. For example, to manage two instances named replica01 and replica02, add something like this to the file:

[mysqld@replica01]
datadir=/var/lib/mysql-replica01
socket=/var/lib/mysql-replica01/mysql.sock
port=3307
log-error=/var/log/mysqld-replica01.log

[mysqld@replica02]
datadir=/var/lib/mysql-replica02
socket=/var/lib/mysql-replica02/mysql.sock
port=3308
log-error=/var/log/mysqld-replica02.log
The replica names shown here use @ as the delimiter because that is the only delimiter supported by systemd.

Instances then are managed by normal systemd commands, such as:

systemctl start mysqld@replica01
systemctl start mysqld@replica02
To enable instances to run at boot time, do this:

systemctl enable mysqld@replica01
systemctl enable mysqld@replica02
Use of wildcards is also supported. For example, this command displays the status of all replica instances:

systemctl status ‘mysqld@replica*’
For management of multiple MySQL instances on the same machine, systemd automatically uses a different unit file (mysqld@.service rather than mysqld.service). In that unit file, %I and %i reference the parameter passed in after the @ marker and are used to manage the specific instance. For a command such as this:

systemctl start mysqld@mysql1
systemd starts the server using a command such as this:

mysqld –defaults-group-suffix=@%I …
The result is that the [server], [mysqld], and [mysqld@mysql1] option groups are read and used for that instance of the service.

Migrating from mysqld_safe to systemd

Because mysqld_safe is not installed when systemd is used, options previously specified for that program (for example, in an [mysqld_safe] option group) must be specified another way:

Some mysqld_safe options are also understood by mysqld and can be moved from the [mysqld_safe] option group to the [mysqld] group. This does not include –pid-file or –open-files-limit. To specify those options, use the override.conf systemd file, described previously.

For some mysqld_safe options, there are similar mysqld options. For example, the mysqld_safe option for enabling syslog logging is –syslog. For mysqld, enable the log_syslog system variable instead. For details, see Section 6.4.2, “The Error Log”.

mysqld_safe options not understood by mysqld can be specified in override.conf or environment variables. For example, with mysqld_safe, if the server should use a specific memory allocation library, this is specified using the –malloc-lib option. For installations that manage the server with systemd, arrange to set the LD_PRELOAD environment variable instead, as described previously.