//布局:
{{this.page.layout}}
//id:文件名称和文件夹名称转换为css友好标识符
<body class="page-{{this.page.id}}">
//标题
<h1>{{this.page.title}}</h1>
//描述
<p>{{ this.page.description }}</p>
//meta_title
<title>{{ this.page.meta_title }}</title>
//meta_description
<meta name="description" content="{{ this.page.meta_description }}">
//隐:隐藏的页面只能由登录的后端用户访问。
{% if this.page.hidden %}
<p>Note to other admins: We are currently working on this page.</p>
{% endif %}
//您可以通过this.param它访问当前的URL参数,并返回一个PHP数组
//访问页面参数
//如何访问tab页面中的URL参数。
url = "/account/:tab"
==
{% if this.param.tab == 'details' %}
<p>Here are all your details</p>
{% elseif this.param.tab == 'history' %}
<p>You are viewing a blast from the past</p>
{% endif %}
//如果参数名称也是一个变量,那么可以使用数组语法
url = "/account/:post_id"
==
{% set name = 'post_id' %}
<p>The post ID is: {{ this.param[name] }}</p>
{% placeholder name %}
{% put name %}
<p>Place this text in the name placeholder</p>
{% endput %}
{% placeholder sidebar default %}
<p><a href="/contacts">Contact us</a></p>
{% endplaceholder %}
{% put sidebar %}
<p><a href="/services">Services</a></p>
{% default %}
{% endput %}
//检测占位符是否存在
{% if placeholder('sidemenu') %}
<!-- Markup for a page with a sidebar -->
<div class="row">
<div class="col-md-3">
{% placeholder sidemenu %}
</div>
<div class="col-md-9">
{% page %}
</div>
</div>
{% else %}
<!-- Markup for a page without a sidebar -->
{% page %}
{% endif %}
//自定义属性
{% placeholder ordering title="Ordering information" type="text" %}
{% placeholder ordering default title="Ordering information" type="text" %}
There is no ordering information for this product.
{% endplaceholder %}
//介绍
plugins/
acme/
blog/
models/
user/ <=== Model config directory
columns.yaml <=== Model config files
fields.yaml <==^
User.php <=== Model class
Plugin.php
//定义模型
namespace Acme\Blog\Models;
use Model;
class Post extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = ‘acme_blog_posts‘;
}
//支持的属性
class User extends Model
{
protected $primaryKey = ‘id‘;
public $exists = false;
protected $dates = [‘last_seen_at‘];
public $timestamps = true;
protected $jsonable = [‘permissions‘];
protected $guarded = [‘*‘];
}
//首要的关键
class Post extends Model
{
/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = ‘id‘;
}
//时间戳
class Post extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
}
//如果您需要自定义时间戳的格式,请设置$dateFormat模型上的属性。此属性确定日期属性如何存储在数据库中,以及当模型序列化为数组或JSON时的格式:
class Post extends Model
{
/**
* The storage format of the model‘s date columns.
*
* @var string
*/
protected $dateFormat = ‘U‘;
}
//值存储为JSON
class Post extends Model
{
/**
* @var array Attribute names to encode and decode using JSON.
*/
protected $jsonable = [‘data‘];
}
//访问列值
foreach ($flights as $flight) {
echo $flight->name;
}
//添加附加约束
$flights = Flight::where(‘active‘, 1)
->orderBy(‘name‘, ‘desc‘)
->take(10)
->get();
//集合
foreach ($flights as $flight) {
echo $flight->name;
}
//分块结果
Flight::chunk(200, function ($flights) {
foreach ($flights as $flight) {
//
}
});
//检索单个模型
// Retrieve a model by its primary key
$flight = Flight::find(1);
// Retrieve the first model matching the query constraints
$flight = Flight::where(‘active‘, 1)->first();
//找不到例外
$model = Flight::findOrFail(1);
$model = Flight::where(‘legs‘, ‘>‘, 100)->firstOrFail();
Route::get(‘/api/flights/{id}‘, function ($id) {
return Flight::findOrFail($id);
});
//检索聚合
$count = Flight::where(‘active‘, 1)->count();
$max = Flight::where(‘active‘, 1)->max(‘price‘);
//基本插入
$flight = new Flight;
$flight->name = ‘Sydney to Canberra‘;
$flight->save();
//基本更新
$flight = Flight::find(1);
$flight->name = ‘Darwin to Adelaide‘;
$flight->save();
//还可以针对与给定查询匹配的任意数量的模型执行更新。在这个例子中,所有的航班active,有一个destination的San Diego将被标记为延迟:
Flight::where(‘is_active‘, true)
->where(‘destination‘, ‘Perth‘)
->update([‘delayed‘ => true]);
//质量分配
class Flight extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [‘name‘];
}
//一旦我们赋予了属性质量分配,我们可以使用该create方法在数据库中插入新的记录。该create方法返回保存的模型实例:
$flight = Flight::create([‘name‘ => ‘Flight 10‘]);
//其他创作方法
$flight = Flight::make([‘name‘ => ‘Flight 10‘]);
// Functionally the same as...
$flight = new Flight;
$flight->fill([‘name‘ => ‘Flight 10‘]);
// Retrieve the flight by the attributes, otherwise create it
$flight = Flight::firstOrCreate([‘name‘ => ‘Flight 10‘]);
// Retrieve the flight by the attributes, or instantiate a new instance
$flight = Flight::firstOrNew([‘name‘ => ‘Flight 10‘]);
//删除模型
$flight = Flight::find(1);
$flight->delete();
//按键删除现有的模型
Flight::destroy(1);
Flight::destroy([1, 2, 3]);
Flight::destroy(1, 2, 3);
//通过查询删除模型
$deletedRows = Flight::where(‘active‘, 0)->delete();
//查询范围
class User extends Model
{
/**
* Scope a query to only include popular users.
*/
public function scopePopular($query)
{
return $query->where(‘votes‘, ‘>‘, 100);
}
/**
* Scope a query to only include active users.
*/
public function scopeActive($query)
{
return $query->where(‘is_active‘, 1);
}
}
//利用查询范围
$users = User::popular()->active()->orderBy(‘created_at‘)->get();
//动态范围
class User extends Model
{
/**
* Scope a query to only include users of a given type.
*/
public function scopeApplyType($query, $type)
{
return $query->where(‘type‘, $type);
}
}
//现在您可以在调用范围时传递参数:
$users = User::applyType(‘admin‘)->get();
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
#,广西河池市宜州市,2018-08-01,10:18:13, 输入 service iptables restart Redirecting to /bin/systemctl restart iptables.service Failed to restart iptables.service: Unit not found. 被完美解决!!!
#,广西河池市宜州市,2018-08-01,10:18:26, “ 查看 firewall-cmd --zone= public --query-port=80/tcp ” 这个语句输入后报错 “ usage: see firewall-cmd man page firewall-cmd: error: unrecognized arguments: public ” 将语句修改为 “ firewall-cmd --query-port=80/tcp ” 后可以使用
#,广西河池市宜州市,2018-08-01,10:18:44, Failed to start iptables.service: Unit not found. 这个错误也可以解决...
#457
#458
#459
老板发工资给我,不是因为我为公司做事,而是因为我为了这份工作,没能为自己做事。
不是因为公司得到了什么,而是因为我失去了什么。
所以公司给我的那份工资,严格来说不是工资,是赔偿。
其中分别就是,你出粮给我,我要多谢你。
你赔偿给我,你要加多一句“对不起”。
——黄子华
雇佣关系而已,我时刻提醒自己
第1次你给我发错(多)了,我原谅你。
第2次你又发错(少)了,怎么能继续原谅你?
一个很老的笑话
15830371000
#460
#461
//进入nginx目录 cd nginx看到如下显示nginx.conf syntax is ok
nginx.conf test is successful
说明配置文件正确
wget -O wordpress.zip http://www.linuxde.net/download.aspx?id=1080 Centos出现-bash: unzip: command not found的解决办法 利用unzip命令解压缩的时候,出现-bash: unzip: command not found的错误。 unzip——命令没有找到,其原因肯定是没有安装unzip。 利用一句命令就可以解决了。 命令是: yum install -y unzip zip 安装成功后就可以使用unzip命令Linux下ftp服务可以通过搭建vsftpd服务来实现
执行 systemctl start vsftpd.service 启动vsftp服务,然后可以通过命令: systemctl status vsftpd.service 查看ftp服务的运行状态
systemctl stop vsftpd.serviceFTP是一种文件传输协议,一般是为了方便数据共享的。包括一个FTP服务器和多个FTP客户端。FTP客户端通过FTP协议在服务器上下载资源。
SFTP协议是在FTP的基础上对数据进行加密,使得传输的数据相对来说更安全。但是这种安全是以牺牲效率为代价的。
SFTP的传输效率比FTP要低。
#462
#463
#464
#465
变量:
{{variable}} {{isAjax?'Yes':'No'}} {{'Your name:' ~ name}}标签:
{%tag%} {%if stormCloudComing%} Stay inside {else %} Gooutside and play {%endif%} {%set activePage='blog'%}过滤器:
{{‘string’|filter}} {{price |currency('USD')}} {{'October Glory'|upper|replace({'October':'Morning'})}}功能:
{{function()}} {{dump(variable)}}this.page:
//布局: {{this.page.layout}} //id:文件名称和文件夹名称转换为css友好标识符 <body class="page-{{this.page.id}}"> //标题 <h1>{{this.page.title}}</h1> //描述 <p>{{ this.page.description }}</p> //meta_title <title>{{ this.page.meta_title }}</title> //meta_description <meta name="description" content="{{ this.page.meta_description }}"> //隐:隐藏的页面只能由登录的后端用户访问。 {% if this.page.hidden %} <p>Note to other admins: We are currently working on this page.</p> {% endif %}this.layout:
//属性:您可以通过访问当前的布局对象,this.layout并返回该对象Cms\Classes\Layout //ID: <body class="layout-{{ this.layout.id }}"> //描述 <meta name="description" content="{{ this.layout.description }}"> this.theme: //属性 :this.theme将提供直接访问表单字段值,由任何主题定制定义。它本身也具有以下特性 //ID <body class="theme-{{ this.theme.id }}"> //配置 <meta name="description" content="{{ this.theme.config.description }}">this.param:
//您可以通过this.param它访问当前的URL参数,并返回一个PHP数组 //访问页面参数 //如何访问tab页面中的URL参数。 url = "/account/:tab" == {% if this.param.tab == 'details' %} <p>Here are all your details</p> {% elseif this.param.tab == 'history' %} <p>You are viewing a blast from the past</p> {% endif %} //如果参数名称也是一个变量,那么可以使用数组语法 url = "/account/:post_id" == {% set name = 'post_id' %} <p>The post ID is: {{ this.param[name] }}</p>this.environment
//您可以通过访问当前环境对象,this.environment并返回引用当前环境配置的字符串 //如果网站在测试环境中运行,以下示例将显示横幅: {% if this.environment == 'test' %} <div class="banner">Test Environment</div> {% endif %}{%partial%}
{% partial "footer" %} {% partial "sidebar/menu" %} {% set tabName = "profile" %} {% partial tabName %} % partial "blog-posts" posts=posts %} {% partial "location" city="Vancouver" country="Canada" %} <p>Country: {{ country }}, city: {{ city }}.</p>{%content%}
{% content "contacts.htm" %} {% content "sidebar/content.htm" %} {% content "readme.txt" %} {% content "changelog.md" %} {% put sidebar %} {% content 'sidebar-content.htm' %} {% endput %} {% content "welcome.htm" name=user.name %} {% content "location.htm" city="Vancouver" country="Canada" %} <p>Country: {country}, city: {city}.</p> {% content "welcome.htm" likes=[ {name:'Dogs'}, {name:'Fishing'}, {name:'Golf'} ] %} <ul> {likes} <li>{name}</li> {/likes} </ul>{%占位符%}
{% placeholder name %} {% put name %} <p>Place this text in the name placeholder</p> {% endput %} {% placeholder sidebar default %} <p><a href="/contacts">Contact us</a></p> {% endplaceholder %} {% put sidebar %} <p><a href="/services">Services</a></p> {% default %} {% endput %} //检测占位符是否存在 {% if placeholder('sidemenu') %} <!-- Markup for a page with a sidebar --> <div class="row"> <div class="col-md-3"> {% placeholder sidemenu %} </div> <div class="col-md-9"> {% page %} </div> </div> {% else %} <!-- Markup for a page without a sidebar --> {% page %} {% endif %} //自定义属性 {% placeholder ordering title="Ordering information" type="text" %} {% placeholder ordering default title="Ordering information" type="text" %} There is no ordering information for this product. {% endplaceholder %}#466
<style> .west-01 { position: absolute; width: 200px; height: 180px; left: 50%; margin-left: -398px; top: 352px; background-image: url(https://out.img.pan.lizhenqiu.com/FqDMTm_8I03UBd6Lx-cY9FaIB99m); background-repeat: no-repeat; -webkit-animation: play01 1.4s steps(8) infinite; -moz-animation: play01 1.4s steps(8) infinite; -ms-animation: play01 1.4s steps(8) infinite; animation: play01 1.4s steps(8) infinite } @-webkit-keyframes play01 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @-moz-keyframes play01 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @-o-keyframes play01 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @-ms-keyframes play01 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @keyframes play01 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } .west-02 { position: absolute; width: 200px; height: 180px; left: 50%; margin-left: -198px; top: 356px; background-image: url(https://out.img.pan.lizhenqiu.com/Fjr4nM2HtaFF-XM-oabkVJBL-U1z); background-repeat: no-repeat; -webkit-animation: play02 1.4s steps(8) infinite; -moz-animation: play02 1.4s steps(8) infinite; -ms-animation: play02 1.4s steps(8) infinite; animation: play02 1.4s steps(8) infinite } @-webkit-keyframes play02 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @-moz-keyframes play02 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @-o-keyframes play02 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @-ms-keyframes play02 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } @keyframes play02 { 0% { background-position: 0 0 } 100% { background-position: -1600px 0 } } .west-03 { position: absolute; width: 170px; height: 240px; left: 50%; margin-left: -11px; top: 326px; background-image: url(https://out.img.pan.lizhenqiu.com/Ft1ZQTkZbB535lBwZ4vjVhWU5ol6); background-repeat: no-repeat; -webkit-animation: play03 1.4s steps(8) infinite; -moz-animation: play03 1.4s steps(8) infinite; -ms-animation: play03 1.4s steps(8) infinite; animation: play03 1.4s steps(8) infinite } @-webkit-keyframes play03 { 0% { background-position: 0 0 } 100% { background-position: -1360px 0 } } @-moz-keyframes play03 { 0% { background-position: 0 0 } 100% { background-position: -1360px 0 } } @-o-keyframes play03 { 0% { background-position: 0 0 } 100% { background-position: -1360px 0 } } @-ms-keyframes play03 { 0% { background-position: 0 0 } 100% { background-position: -1360px 0 } } @keyframes play03 { 0% { background-position: 0 0 } 100% { background-position: -1360px 0 } } .west-04 { position: absolute; width: 210px; height: 200px; left: 50%; margin-left: 198px; top: 372px; background-image: url(https://out.img.pan.lizhenqiu.com/FjTycCEEtOfP7JYjlvAybcZVFYqh); background-repeat: no-repeat; -webkit-animation: play04 1.4s steps(8) infinite; -moz-animation: play04 1.4s steps(8) infinite; -ms-animation: play04 1.4s steps(8) infinite; animation: play04 1.4s steps(8) infinite } @-webkit-keyframes play04 { 0% { background-position: 0 0 } 100% { background-position: -1680px 0 } } @-moz-keyframes play04 { 0% { background-position: 0 0 } 100% { background-position: -1680px 0 } } @-o-keyframes play04 { 0% { background-position: 0 0 } 100% { background-position: -1680px 0 } } @-ms-keyframes play04 { 0% { background-position: 0 0 } 100% { background-position: -1680px 0 } } @keyframes play04 { 0% { background-position: 0 0 } 100% { background-position: -1680px 0 } } </style> <div class="west-01"></div> <div class="west-02"></div> <div class="west-03"></div> <div class="west-04"></div>#467
一、背景 在各操作系统下,文本文件所使用的换行符是不一样的。UNIX/Linux 使用的是 0x0A(LF),早期的 Mac OS 使用的是0x0D(CR),后来的 OS X 在更换内核后与 UNIX 保持一致了。但 DOS/Windows 一直使用 0x0D0A(CRLF)作为换行符。Git提供了一个“换行符自动转换”功能。这个功能默认处于“自动模式”,当你在签出文件时,它试图将 UNIX 换行符(LF)替换为 Windows 的换行符(CRLF);当你在提交文件时,它又试图将 CRLF 替换为 LF。Git 的“换行符自动转换”功能听起来似乎很智能、很贴心,因为它试图一方面保持仓库内文件的一致性(UNIX 风格),一方面又保证本地文件的兼容性(Windows 风格)。但遗憾的是,这个功能是有 bug 的,而且在短期内都不太可能会修正。 二、解决方案 1.Git设置 git config --global core.autocrlf false git config --global core.safecrlf true 含义: AutoCRLF #提交时转换为LF,检出时转换为CRLF git config --global core.autocrlf true #提交时转换为LF,检出时不转换 git config --global core.autocrlf input #提交检出均不转换 git config --global core.autocrlf false SafeCRLF #拒绝提交包含混合换行符的文件 git config --global core.safecrlf true #允许提交包含混合换行符的文件 git config --global core.safecrlf false #提交包含混合换行符的文件时给出警告 git config --global core.safecrlf warn 2.IDE设置使用UNIX换行符 IDEA的设置File -> Settings Editor -> Code Style Line separator (for new lines) ,选择:Unix and OS X (\n) 对已使用Windows换行符的文件,可以使用Sublime Text打开, View->Line Endings,选Unix,保存;crlf 和 lf 是文本换行的不同方式:
crlf: "\r\n", windows系统的换行方式
lf: "\n", Linux系统的换行方式
他们之间的不同经常会导致不同会导致使用不同系统的同事之间的代码冲突问题。
在你使用git拉取代码的时候,git会自动将代码当中与你当前系统不同的换行方式转化成你当前系统的换行方式,从而造成这种冲突。
window系统解决办法:
1. 修改git全局配置,禁止git自动将lf转换成crlf, 命令:
git config --global core.autocrlf false
2. 修改编辑器的用户配置,例如vscode
"files.eol": "\n", // 文件换行使用lf方式
#468
//运行select查询 $users = Db::select(‘select * from users where active = ?‘, [1]); 传递给该select方法的第一个参数是原始SQL查询,而第二个参数是需要绑定到查询的任何参数绑定。通常,这些是where子句约束的值。参数绑定提供了针对SQL注入的保护。 该select方法将始终返回一个array结果。数组中的每个结果将是一个PHP stdClass对象,允许您访问结果的值: foreach ($users as $user) { echo $user->name; } //使用命名绑定 $results = Db::select(‘select * from users where id = :id‘, [‘id‘ => 1]); //运行一个insert语句 要执行一个insert语句,你可以使用insert在Db立面上的方法。像这样select,这个方法将原始SQL查询作为第一个参数,绑定作为第二个参数: Db::insert(‘insert into users (id, name) values (?, ?)‘, [1, ‘Joe‘]); //运行更新语句 该update方法应用于更新数据库中的现有记录。该语句受影响的行数将由方法返回: $affected = Db::update(‘update users set votes = 100 where name = ?‘, [‘John‘]); //运行delete语句 该delete方法应用于从数据库中删除记录。喜欢update,将返回删除的行数: $deleted = Db::delete(‘delete from users‘); //运行一般声明 某些数据库语句不应返回任何值。对于这些类型的操作,您可以使用立面上的statement方法Db Db::statement(‘drop table users‘); //多个数据库连接 当使用多个连接时,您可以通过立面上的connection方法访问每个连接Db。在name传递给connection方法应该对应于您列出的其中一个连接config/database.php组态文件中 $users = Db::connection(‘foo‘)->select(...); $pdo = Db::connection()->getPdo(); //数据库事务 Db::transaction(function () { Db::table(‘users‘)->update([‘votes‘ => 1]); Db::table(‘posts‘)->delete(); }); //手动使用交易 如果您想手动开始事务并完全控制回滚和提交,您可以使用立面上的beginTransaction方法Db: Db::beginTransaction(); 您可以通过以下rollBack方法回滚事务: Db::rollBack(); 最后,您可以通过以下commit方法提交事务: Db::commit(); //数据库事件 如果要接收应用程序执行的每个SQL查询,可以使用该listen方法。此方法对于记录查询或调试很有用。 Db::listen(function($sql, $bindings, $time) { // }); //查询记录 启用查询日志记录时,将记录所有已为当前请求运行的查询的内存。调用该enableQueryLog方法启用此功能 Db::connection()->enableQueryLog(); 要获取执行查询的数组,可以使用以下getQueryLog方法: $queries = Db::getQueryLog(); 然而,在某些情况下,例如当插入大量行时,这可能导致应用程序使用多余的内存。要禁用日志,您可以使用以下disableQueryLog方法: Db::connection()->disableQueryLog();检索结果
//从表中检索所有行--get来看一下表中的所有记录 $users = Db::table(‘users‘)->get(); //通过访问列作为对象的属性来访问每列的值: foreach ($users as $user) { echo $user->name; } //从表中检索单个行/列 $user = Db::table(‘users‘)->where(‘name‘, ‘John‘)->first(); echo $user->name; //如果您甚至不需要整行,您可以使用该value方法从记录中提取单个值。此方法将直接返回列的值: $email = Db::table(‘users‘)->where(‘name‘, ‘John‘)->value(‘email‘); //分块结果从一张桌子 Db::table(‘users‘)->chunk(100, function($users) { foreach ($users as $user) { // } }); //您可以通过以下方式返回false来阻止进一步处理的块Closure: Db::table(‘users‘)->chunk(100, function($users) { // Process the records... return false; }); //检索列值列表 //如果要检索包含单列值的数组,则可以使用该lists方法 $titles = Db::table(‘roles‘)->lists(‘title‘); foreach ($titles as $title) { echo $title; } //您还可以为返回的数组指定自定义键列: $roles = Db::table(‘roles‘)->lists(‘title‘, ‘name‘); foreach ($roles as $name => $title) { echo $title; } //骨料 $users = Db::table(‘users‘)->count(); $price = Db::table(‘orders‘)->max(‘price‘); $price = Db::table(‘orders‘) ->where(‘is_finalized‘, 1) ->avg(‘price‘); //选择 $users = Db::table(‘users‘)->select(‘name‘, ‘email as user_email‘)->get(); //该distinct方法允许您强制查询返回不同的结果: $users = Db::table(‘users‘)->distinct()->get(); $query = Db::table(‘users‘)->select(‘name‘); $users = $query->addSelect(‘age‘)->get(); //原始表达式 $users = Db::table(‘users‘) ->select(Db::raw(‘count(*) as user_count, status‘)) ->where(‘status‘, ‘<>‘, 1) ->groupBy(‘status‘) ->get(); //加盟 $users = Db::table(‘users‘) ->join(‘contacts‘, ‘users.id‘, ‘=‘, ‘contacts.user_id‘) ->join(‘orders‘, ‘users.id‘, ‘=‘, ‘orders.user_id‘) ->select(‘users.*‘, ‘contacts.phone‘, ‘orders.price‘) ->get(); $users = Db::table(‘users‘) ->leftJoin(‘posts‘, ‘users.id‘, ‘=‘, ‘posts.user_id‘) ->get(); Db::table(‘users‘) ->join(‘contacts‘, function ($join) { $join->on(‘users.id‘, ‘=‘, ‘contacts.user_id‘)->orOn(...); }) ->get(); Db::table(‘users‘) ->join(‘contacts‘, function ($join) { $join->on(‘users.id‘, ‘=‘, ‘contacts.user_id‘) ->where(‘contacts.user_id‘, ‘>‘, 5); }) ->get(); //where子句 $users = Db::table(‘users‘)->where(‘votes‘, ‘=‘, 100)->get(); $users = Db::table(‘users‘)->where(‘votes‘, 100)->get(); $users = Db::table(‘users‘) ->where(‘votes‘, ‘>=‘, 100) ->get(); $users = Db::table(‘users‘) ->where(‘votes‘, ‘<>‘, 100) ->get(); $users = Db::table(‘users‘) ->where(‘name‘, ‘like‘, ‘T%‘) ->get(); //“或”声明 $users = Db::table(‘users‘) ->where(‘votes‘, ‘>‘, 100) ->orWhere(‘name‘, ‘John‘) ->get(); //“之间”之间的陈述 $users = Db::table(‘users‘) ->whereBetween(‘votes‘, [1, 100])->get(); $users = Db::table(‘users‘) ->whereNotBetween(‘votes‘, [1, 100]) ->get(); //“在哪里”声明 $users = Db::table(‘users‘) ->whereIn(‘id‘, [1, 2, 3]) ->get(); $users = Db::table(‘users‘) ->whereNotIn(‘id‘, [1, 2, 3]) ->get(); //“null”语句 $users = Db::table(‘users‘) ->whereNull(‘updated_at‘) ->get(); $users = Db::table(‘users‘) ->whereNotNull(‘updated_at‘) ->get(); //排序 $users = Db::table(‘users‘) ->orderBy(‘name‘, ‘desc‘) ->get(); //分组 $users = Db::table(‘users‘) ->groupBy(‘account_id‘) ->having(‘account_id‘, ‘>‘, 100) ->get(); //该havingRaw方法可用于将原始字符串设置为having子句的值。例如,我们可以找到销售额超过$ 2,500的所有部门: $users = Db::table(‘orders‘) ->select(‘department‘, Db::raw(‘SUM(price) as total_sales‘)) ->groupBy(‘department‘) ->havingRaw(‘SUM(price) > 2500‘) ->get(); //限制和抵消 //要限制从查询返回的结果数,或者在查询(OFFSET)中跳过给定数量的结果,可以使用skip和take方法: $users = Db::table(‘users‘)->skip(10)->take(5)->get(); //插入 Db::table(‘users‘)->insert( [‘email‘ => ‘john@example.com‘, ‘votes‘ => 0] ); Db::table(‘users‘)->insert([ [‘email‘ => ‘taylor@example.com‘, ‘votes‘ => 0], [‘email‘ => ‘dayle@example.com‘, ‘votes‘ => 0] ]); //自动递增ID $id = Db::table(‘users‘)->insertGetId( [‘email‘ => ‘john@example.com‘, ‘votes‘ => 0] ); //更新 Db::table(‘users‘) ->where(‘id‘, 1) ->update([‘votes‘ => 1]); //递增/递减 Db::table(‘users‘)->increment(‘votes‘); Db::table(‘users‘)->increment(‘votes‘, 5); Db::table(‘users‘)->decrement(‘votes‘); Db::table(‘users‘)->decrement(‘votes‘, 5); Db::table(‘users‘)->increment(‘votes‘, 1, [‘name‘ => ‘John‘]); //删除 Db::table(‘users‘)->delete(); Db::table(‘users‘)->where(‘votes‘, ‘<‘, 100)->delete(); Db::table(‘users‘)->truncate(); //悲观锁定 Db::table(‘users‘)->where(‘votes‘, ‘>‘, 100)->sharedLock()->get(); Db::table(‘users‘)->where(‘votes‘, ‘>‘, 100)->lockForUpdate()->get(); //缓存查询 //持久缓存 $users = Db::table(‘users‘)->remember(10)->get(); //内存缓存 Db::table(‘users‘)->get(); // Result from database Db::table(‘users‘)->get(); // Result from database Model::all(); // Result from database Model::all(); // Result from in-memory cache //您可以使用enableDuplicateCache或disableDuplicateCache方法启用或禁用重复缓存 Db::table(‘users‘)->enableDuplicateCache()->get(); //如果查询存储在缓存中,则当使用insert,update,delete或truncate语句时,它将自动被清除。但是您可以使用该flushDuplicateCache方法手动清除缓存 Db::table(‘users‘)->enableDuplicateCache()->get();models:
//介绍 plugins/ acme/ blog/ models/ user/ <=== Model config directory columns.yaml <=== Model config files fields.yaml <==^ User.php <=== Model class Plugin.php //定义模型 namespace Acme\Blog\Models; use Model; class Post extends Model { /** * The table associated with the model. * * @var string */ protected $table = ‘acme_blog_posts‘; } //支持的属性 class User extends Model { protected $primaryKey = ‘id‘; public $exists = false; protected $dates = [‘last_seen_at‘]; public $timestamps = true; protected $jsonable = [‘permissions‘]; protected $guarded = [‘*‘]; } //首要的关键 class Post extends Model { /** * The primary key for the model. * * @var string */ protected $primaryKey = ‘id‘; } //时间戳 class Post extends Model { /** * Indicates if the model should be timestamped. * * @var bool */ public $timestamps = false; } //如果您需要自定义时间戳的格式,请设置$dateFormat模型上的属性。此属性确定日期属性如何存储在数据库中,以及当模型序列化为数组或JSON时的格式: class Post extends Model { /** * The storage format of the model‘s date columns. * * @var string */ protected $dateFormat = ‘U‘; } //值存储为JSON class Post extends Model { /** * @var array Attribute names to encode and decode using JSON. */ protected $jsonable = [‘data‘]; } //访问列值 foreach ($flights as $flight) { echo $flight->name; } //添加附加约束 $flights = Flight::where(‘active‘, 1) ->orderBy(‘name‘, ‘desc‘) ->take(10) ->get(); //集合 foreach ($flights as $flight) { echo $flight->name; } //分块结果 Flight::chunk(200, function ($flights) { foreach ($flights as $flight) { // } }); //检索单个模型 // Retrieve a model by its primary key $flight = Flight::find(1); // Retrieve the first model matching the query constraints $flight = Flight::where(‘active‘, 1)->first(); //找不到例外 $model = Flight::findOrFail(1); $model = Flight::where(‘legs‘, ‘>‘, 100)->firstOrFail(); Route::get(‘/api/flights/{id}‘, function ($id) { return Flight::findOrFail($id); }); //检索聚合 $count = Flight::where(‘active‘, 1)->count(); $max = Flight::where(‘active‘, 1)->max(‘price‘); //基本插入 $flight = new Flight; $flight->name = ‘Sydney to Canberra‘; $flight->save(); //基本更新 $flight = Flight::find(1); $flight->name = ‘Darwin to Adelaide‘; $flight->save(); //还可以针对与给定查询匹配的任意数量的模型执行更新。在这个例子中,所有的航班active,有一个destination的San Diego将被标记为延迟: Flight::where(‘is_active‘, true) ->where(‘destination‘, ‘Perth‘) ->update([‘delayed‘ => true]); //质量分配 class Flight extends Model { /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [‘name‘]; } //一旦我们赋予了属性质量分配,我们可以使用该create方法在数据库中插入新的记录。该create方法返回保存的模型实例: $flight = Flight::create([‘name‘ => ‘Flight 10‘]); //其他创作方法 $flight = Flight::make([‘name‘ => ‘Flight 10‘]); // Functionally the same as... $flight = new Flight; $flight->fill([‘name‘ => ‘Flight 10‘]); // Retrieve the flight by the attributes, otherwise create it $flight = Flight::firstOrCreate([‘name‘ => ‘Flight 10‘]); // Retrieve the flight by the attributes, or instantiate a new instance $flight = Flight::firstOrNew([‘name‘ => ‘Flight 10‘]); //删除模型 $flight = Flight::find(1); $flight->delete(); //按键删除现有的模型 Flight::destroy(1); Flight::destroy([1, 2, 3]); Flight::destroy(1, 2, 3); //通过查询删除模型 $deletedRows = Flight::where(‘active‘, 0)->delete(); //查询范围 class User extends Model { /** * Scope a query to only include popular users. */ public function scopePopular($query) { return $query->where(‘votes‘, ‘>‘, 100); } /** * Scope a query to only include active users. */ public function scopeActive($query) { return $query->where(‘is_active‘, 1); } } //利用查询范围 $users = User::popular()->active()->orderBy(‘created_at‘)->get(); //动态范围 class User extends Model { /** * Scope a query to only include users of a given type. */ public function scopeApplyType($query, $type) { return $query->where(‘type‘, $type); } } //现在您可以在调用范围时传递参数: $users = User::applyType(‘admin‘)->get();#469
nginx可以include任何文件,而不仅仅是.htaccess
在 nginx/nginx.conf的server{}中引入 .htaccess 文件:
include /vhosts/quany.info/.htaccess;#470
如图,将向上裁剪,底部图片内容不变,顶部图片被裁剪
#471
#472
CentOS7中执行
service iptables start/stop
会报错Failed to start iptables.service: Unit iptables.service failed to load: No such file or directory.
在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理,
如果要添加范围例外端口 如 1000-2000
语法命令如下:启用区域端口和协议组合
firewall-cmd [--zone=<zone>] --add-port=<port>[-<port>]/<protocol> [--timeout=<seconds>]
此举将启用端口和协议的组合。端口可以是一个单独的端口 <port> 或者是一个端口范围 <port>-<port> 。协议可以是 tcp 或 udp。
实际命令如下:
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone=public --query-port=80/tcp
删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent
当然你可以还原传统的管理方式。
执行一下命令:
systemctl stop firewalld
systemctl mask firewalld
并且安装iptables-services:
yum install iptables-services
设置开机启动:
systemctl enable iptables
systemctl stop iptables
systemctl start iptables
systemctl restart iptables
systemctl reload iptables
保存设置:
service iptables save
OK,再试一下应该就好使了
开放某个端口 在/etc/sysconfig/iptables里添加
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
输入 service iptables restart
Redirecting to /bin/systemctl restart iptables.service
Failed to restart iptables.service: Unit not found.
被完美解决!!!
“ 查看 firewall-cmd --zone= public --query-port=80/tcp ” 这个语句输入后报错 “ usage: see firewall-cmd man page firewall-cmd: error: unrecognized arguments: public ” 将语句修改为 “ firewall-cmd --query-port=80/tcp ” 后可以使用
#473
1.1 Nginx如果未开启SSL模块,配置Https时提示错误
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:37原因也很简单,nginx缺少http_ssl_module模块,编译安装的时候带上--with-http_ssl_module配置就行了,但是现在的情况是我的nginx已经安装过了,怎么添加模块,其实也很简单,往下看: 做个说明:我的nginx的安装目录是/usr/local/nginx这个目录,我的源码包在/usr/local/src/nginx-1.6.2目录
1.2 Nginx开启SSL模块
切换到源码包:
cd /usr/local/src/nginx-1.11.3查看nginx原有的模块
/usr/local/nginx/sbin/nginx -V在configure arguments:后面显示的原有的configure参数如下:
--prefix=/usr/local/nginx --with-http_stub_status_module那么我们的新配置信息就应该这样写:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module运行上面的命令即可,等配置完
配置完成后,运行命令
make这里不要进行make install,否则就是覆盖安装
然后备份原有已安装好的nginx
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak然后将刚刚编译好的nginx覆盖掉原有的nginx(这个时候nginx要停止状态)
cp ./objs/nginx /usr/local/nginx/sbin/然后启动nginx,仍可以通过命令查看是否已经加入成功
/usr/local/nginx/sbin/nginx -VNginx 配置Http和Https共存
server { listen 80 default backlog=2048; listen 443 ssl; server_name wosign.com; root /var/www/html; ssl_certificate /usr/local/Tengine/sslcrt/ wosign.com.crt; ssl_certificate_key /usr/local/Tengine/sslcrt/ wosign.com .Key; }把ssl on;这行去掉,ssl写在443端口后面。这样http和https的链接都可以用
Nginx 配置SSL安全证书重启避免输入密码
可以用私钥来做这件事。生成一个解密的key文件,替代原来key文件。
openssl rsa -in server.key -out server.key.unsecureNginx SSL性能调优
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m;Nginx 配置Http跳转Https
server { listen 80; server_name www.域名.com; rewrite ^(.*) https://$server_name$1 permanent; } server { listen 443; server_name www.域名.com; root /home/www; ssl on; ssl_certificate /etc/nginx/certs/server.crt; ssl_certificate_key /etc/nginx/certs/server.key; }#474
查看了所运行的端口
>
netstat -anp解决办法:
进入防火墙配置文件看看了
vim /etc/sysconfig/iptables
// 看看有没有443的文件,没有的话在改文件中添加下面这行
>-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
再次注意,
>-A INPUT -j REJECT –reject-with icmp-host-prohibited
添加的新的那句需要在这句的前面,否则443端口也有问题
原因是这条规则的作用是拒绝所有-j REJECT 在iptables帮助文档里面有一下说明This is used to send back an error packet in response to the matched packet
就是表明拒绝你,并返回一个错误连接信息。请求没到nginx那,肯定没有状态码返回,同时你的浏览器返回的只能是无法连接。
如果返回404,403等等,那说明是nginx的配置等因素;
/usr/local/nginx/sbin/nginx -s reload nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid" 解决方法: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 使用nginx -c的参数指定nginx.conf文件的位置 [root@localhost nginx]# cd logs/ [root@localhost logs]# ll 总用量 12 -rw-r--r-- 1 root root 1246 12月 9 18:10 access.log -rw-r--r-- 1 root root 516 12月 10 15:39 error.log -rw-r--r-- 1 root root 5 12月 10 15:38 nginx.pid 看nginx.pid文件已经有了#475
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>HTML5实现图形挤压变形效果DEMO演示</title> <style> /*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}body { background: #000; } .zone { width: 800px; height: 600px; background: #000; margin: auto; -webkit-filter: blur(15px) saturate(800%); filter: blur(15px) saturate(800%); cursor: none; } .zone .blob { width: 90px; height: 67.5px; margin: 20px 20px; background: red; float: left; border-radius: 100%; -webkit-transform: translateZ(0); transform: translateZ(0); } .zone .repulse { width: 90px; height: 67.5px; background: lightblue; display: block; position: absolute; border-radius: 100%; -webkit-filter: saturate(600%); filter: saturate(600%); } </style> </head> <body> <div class="zone"> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <div class="blob"></div> <span class="repulse"></span> </div> <script src='https://lizhenqiu.com/templates/default/jquery.min.js'></script> <script>$(document).on('mousemove', function(e){ $('.repulse').css({ left: e.pageX, top: e.pageY }); });</script> </body> </html>