欢迎来到 艾瑞可erik 的魔法世界 🧙‍♂️

给我一个需求,还你一个项目——别管它是什么。这就是全栈。

📚 291 篇文章 🏷️ 504 个标签 📂 90 个分类

🔥 最新文章

9个超酷的jQuery倒计时插件和教程

作者: 帕兰 倒计时功能在很多项目中都会使用到,比如维修页面、团购网站和下载限时网站等等。通过使用jQuery倒计时插件,你可以简化你的工作量,却同样创造出超酷的jQuery倒计时功能。本文为你介绍10款jQuery倒计时插件。

1. jQuery Countdown

这个jQuery插件可以让你设置一个div或span元素来显示倒计时,它拥有一堆的选项可以实现你的各种需求。

Demo

9 Super Cool jQuery Countdown Plugins and Tutorials

Author: 帕兰 Countdown functionality is used in many projects, such as maintenance pages, group-buying sites, and download time-limited sites, and so on. By using jQuery countdown plugins, you can simplify your workload while still creating super cool jQuery countdown functionality. This article introduces 10 jQuery countdown plugins for you.

1. jQuery Countdown

This jQuery plugin lets you set up a div or span element to display a countdown, and it has a bunch of options that can fulfill your various needs.

Demo

21个实用便利的PHP代码

作者: 帕兰

1. PHP可阅读随机字符串

此代码将创建一个可阅读的字符串,使其更接近词典中的单词,实用且具有密码验证功能。

/**************
*@length - length of random string (must be a multiple of 2)
**************/
function readable_random_string($length = 6){
    $conso=array("b","c","d","f","g","h","j","k","l",
    "m","n","p","r","s","t","v","w","x","y","z");
    $vocal=array("a","e","i","o","u");
    $password="";
    srand ((double)microtime()*1000000);
    $max = $length/2;
    for($i=1; $i<=$max; $i++)
    {
    $password.=$conso[rand(0,19)];
    $password.=$vocal[rand(0,4)];
    }
    return $password;
}

21 Handy and Practical PHP Code Snippets

Author: Paran

1. PHP readable random string

This code creates a readable string that is closer to words found in a dictionary, which is practical and also works for password verification.

/**************
*@length - length of random string (must be a multiple of 2)
**************/
function readable_random_string($length = 6){
    $conso=array("b","c","d","f","g","h","j","k","l",
    "m","n","p","r","s","t","v","w","x","y","z");
    $vocal=array("a","e","i","o","u");
    $password="";
    srand ((double)microtime()*1000000);
    $max = $length/2;
    for($i=1; $i<=$max; $i++)
    {
    $password.=$conso[rand(0,19)];
    $password.=$vocal[rand(0,4)];
    }
    return $password;
}

9个PHP库简介和下载

作者: 帕兰 9个非常有用的PHP类库,相信一定可以为你的WEB开发提供更好和更为快速的方法。

1. ReCAPTCHA

The reCAPTCHA 库让你可以为网站创建高级的 CAPTCHA 系统,这个系统其实是用来生成验证信息的,甚至包括语音验证。当然还有 reCAPTCHA 服务可以使用,其提供易用的免费 API,值得在你的网站试试。 下载 ReCAPTCHA | 获得 API Key | 文档

A Brief Introduction to 9 PHP Libraries, Plus Downloads

Author: 帕兰 9 extremely useful PHP libraries that will surely give you better and faster ways to do WEB development.

1. ReCAPTCHA

The reCAPTCHA library lets you create an advanced CAPTCHA system for your site. This system is actually used to generate verification information, including voice verification. Of course, the reCAPTCHA service is also available, offering an easy-to-use free API that is worth trying on your website. Download ReCAPTCHA | Get an API Key | Documentation

目前还是玩物——可穿戴式设备报告解析

by maomaobear

目前还是玩物——可穿戴式设备报告解析

日前,腾讯对穿戴式设备做了一个调查,样本数量达到了 24877 个,而且做了配比处理,可信度颇高。数据显示了一些很有意思的现象,我们来看一下。

一、穿戴式设备雷声大雨点小

数据现实,在互联网群体中,知道穿戴式设备的人还是很多的,但是肯使用的只有 2.9% 了,这个比例还是比较低的。一方面说明这个市场的潜力还很大,另外一方面,说明现在的穿戴式设备还没有找到人们的需求痛点,能用到的人太少。

Still Just a Toy for Now — An Analysis of the Wearable Device Report

by maomaobear

Still Just a Toy for Now — An Analysis of the Wearable Device Report

A while ago Tencent did a survey on wearable devices, with a sample size of 24,877 and with weighting applied, so its credibility is quite high. The data revealed some very interesting phenomena. Let’s take a look.

1. Wearable devices: much thunder, little rain

The data shows that among the internet population, a great many people know about wearable devices, but only 2.9% are willing to use one, which is a fairly low proportion. On the one hand this shows that the market still has great potential; on the other hand, it shows that today’s wearable devices have not yet found people’s real pain points, and too few people can actually make use of them.

PHP “Unserialize()”安全漏洞

来源:Linux社区 作者:Linux 受影响系统: PHP PHP < 5.4.36 描述: CVE(CAN) ID: CVE-2014-8142 PHP是广泛使用的通用目的脚本语言,特别适合于Web开发,可嵌入到HTML中。 PHP 5.4.36之前版本,”process_nested_data()”函数在实现上存在释放后重利用漏洞,攻击者通过向”unserialize()” 函数传递构造的输入,利用此漏洞可破坏内存;”var_push_dtor()”函数在实现上存在空指针间接引用漏洞,攻击者通过 向”unserialize()”函数传递构造的输入,利用此漏洞可造成崩溃。成功利用这些漏洞可造成任意代码执行。 <来源:Stefan Esser 链接:http://secunia.com/advisories/61236/ > 建议: 厂商补丁: PHP —- 目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载: PHP: http://php.net/ChangeLog-5.php#5.4.36 https://bugs.php.net/bug.php?id=68594 Charlie Eriksen: https://bugs.php.net/bug.php?id=68545 CentOS 6.3 安装LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm 在部署LNMP的时候遇到Nginx启动失败的2个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm Ubuntu安装Nginx php5-fpm MySQL(LNMP环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm

PHP "Unserialize()" Security Vulnerability

Source: Linux Community Author: Linux Affected systems: PHP PHP < 5.4.36 Description: CVE(CAN) ID: CVE-2014-8142 PHP is a widely used general-purpose scripting language, especially well suited to web development, and can be embedded in HTML. In versions of PHP before 5.4.36, the “process_nested_data()” function has a use-after-free vulnerability in its implementation; an attacker can exploit it by passing crafted input to the “unserialize()” function to corrupt memory. The “var_push_dtor()” function has a null pointer dereference vulnerability in its implementation; an attacker can exploit it by passing crafted input to the “unserialize()” function to cause a crash. Successful exploitation of these vulnerabilities can result in arbitrary code execution. <Source: Stefan Esser Link: http://secunia.com/advisories/61236/ > Recommendation: Vendor patch: PHP —- The vendor has already released an upgrade patch to fix this security issue; please download it from the vendor’s homepage: PHP: http://php.net/ChangeLog-5.php#5.4.36 https://bugs.php.net/bug.php?id=68594 Charlie Eriksen: https://bugs.php.net/bug.php?id=68545 CentOS 6.3 installing LNMP (PHP 5.4, MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm Two problems with Nginx failing to start when deploying LNMP http://www.linuxidc.com/Linux/2013-03/81120.htm Ubuntu installing Nginx, php5-fpm, MySQL (setting up an LNMP environment) http://www.linuxidc.com/Linux/2012-10/72458.htm

为MySQL设置查询超时

作者: Laruence 昨天有人在群里问, MySQL是否可以设置读写超时(非连接超时), 如果可以就可以避免一条SQL执行过慢, 导致PHP超时错误. 这个, 其实可以有. 只不过稍微要麻烦点. 首先, 在libmysql中, 是提供了MYSQL_OPT_READ_TIMEOUT设置项的, 并且libmysql中提供了设置相关设置项的API, mysql_options:

Setting a query timeout for MySQL

Author: Laruence Yesterday someone asked in a group chat whether MySQL can set a read/write timeout (not a connection timeout), because if it could, you could avoid a single slow SQL query causing a PHP timeout error. Well, it turns out you can. It’s just a bit more trouble. First of all, libmysql does provide the MYSQL_OPT_READ_TIMEOUT setting, and libmysql provides an API for setting the relevant options, mysql_options:

Nginx 1.5.2 + PHP 5.5.1 + MySQL 5.6.10 在 CentOS 下的编译安装

by 张宴 ]

  最近配置了几台Web服务器,将安装笔记贴出来吧。没时间像以前那样,将文章写的那样系统了,请见谅。详细配置,可以看以前的旧文章:http://blog.zyan.cc/nginx_php_v6 1、安装Nginx:

1
mkdir -p /Data/tgz cd /Data/tgz yum install wget yum install pcre yum install openssl* yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make yum -y install gd gd2 gd-devel gd2-devel /usr/sbin/groupadd www /usr/sbin/useradd -g www www ulimit -SHn 65535 wget [ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz](ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz) tar zxvf pcre-8.32.tar.gz cd pcre-8.32 ./configure --prefix=/Data/apps/pcre make && make install cd ../wget [http://nginx.org/download/nginx-1.5.2.tar.gz](http://nginx.org/download/nginx-1.5.2.tar.gz) tar zxvf nginx-1.5.2.tar.gz cd nginx-1.5.2 ./configure --user=www --group=www --prefix=/Data/apps/nginx --with-http\_stub\_status\_module --with-http\_ssl\_module --with-pcre=/Data/tgz/pcre-8.32 --with-http\_realip\_module --with-http\_image\_filter\_module make make install cd ../

Compiling and Installing Nginx 1.5.2 + PHP 5.5.1 + MySQL 5.6.10 on CentOS

by 张宴 ]

I recently set up a few web servers, so let me post my install notes here. I haven’t had time to write things up as systematically as I used to — please bear with me. For the detailed configuration, see my older article: http://blog.zyan.cc/nginx_php_v6 1. Install Nginx:

1
mkdir -p /Data/tgz cd /Data/tgz yum install wget yum install pcre yum install openssl* yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make yum -y install gd gd2 gd-devel gd2-devel /usr/sbin/groupadd www /usr/sbin/useradd -g www www ulimit -SHn 65535 wget [ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz](ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz) tar zxvf pcre-8.32.tar.gz cd pcre-8.32 ./configure --prefix=/Data/apps/pcre make && make install cd ../wget [http://nginx.org/download/nginx-1.5.2.tar.gz](http://nginx.org/download/nginx-1.5.2.tar.gz) tar zxvf nginx-1.5.2.tar.gz cd nginx-1.5.2 ./configure --user=www --group=www --prefix=/Data/apps/nginx --with-http\_stub\_status\_module --with-http\_ssl\_module --with-pcre=/Data/tgz/pcre-8.32 --with-http\_realip\_module --with-http\_image\_filter\_module make make install cd ../

上传进度支持(Upload progress in sessions)

文件上传进度反馈, 这个需求在当前是越来越普遍, 比如大附件邮件. 在PHP5.4以前, 我们可以通过APC提供的功能来实现. 或者使用PECL扩展uploadprogress来实现. 虽然说, 它们能很好的解决现在的问题, 但是也有很明显的不足:

  • 1. 他们都需要额外安装(我们并没有打算把APC加入PHP5.4)
  • 2. 它们都使用本地机制来存储这些信息, APC使用共享内存, 而uploadprogress使用文件系统(不考虑NFS), 这在多台前端机的时候会造成麻烦.

Upload progress in sessions

File upload progress feedback is a requirement that has become more and more common, for example large email attachments. Before PHP 5.4, we could implement it through the functionality provided by APC. Or we could use the PECL extension uploadprogress. Although they can solve the problem well, they also have obvious shortcomings:

  • 1. They both require extra installation (we had no intention of adding APC to PHP 5.4)
  • 2. They both use a local mechanism to store this information: APC uses shared memory, while uploadprogress uses the filesystem (not counting NFS). This causes trouble when there are multiple front-end machines.

再一次, 不要使用(include/require)_once

最近关于apc.include_once_override的去留, 我们做了几次讨论, 这个APC的配置项一直一来就没有被很好的实现过. 在这里, 我想和大家在此分享下, 这个问题的原因, 以及对我们的一些启示. 关于使用include还是include_once(以下,都包含require_once), 这个讨论很长了, 结论也一直有, 就是尽量使用include, 而不是include_once, 以前最多的理由的是, include_once需要查询一遍已加载的文件列表, 确认是否存在, 然后再加载. 诚然, 这个理由是对的, 不过, 我今天要说的, 是另外一个的原因. 我们知道, PHP去判断一个文件是否被加载, 是需要得到这个文件的opened_path的, 意思是说, 比如:

1
2
3
4
<?php
set\_include\_path("/tmp/:/tmp2/");
include_once("2.php");
?>

Once Again: Do Not Use (include/require)_once

Recently we had several discussions about whether apc.include_once_override should stay or go. This APC configuration option has never really been implemented well. Here I would like to share with you the reason behind this problem, and what it teaches us. The discussion about whether to use include or include_once (which below also covers require_once) has gone on for a long time, and the conclusion has always been the same: use include as much as possible rather than include_once. The most common reason given in the past was that include_once has to scan the list of already-loaded files to confirm whether the file exists before loading it. That reason is indeed correct, but what I want to talk about today is a different one. As we know, for PHP to determine whether a file has been loaded, it needs to obtain the file’s opened_path, which means, for example:

1
2
3
4
<?php
set\_include\_path("/tmp/:/tmp2/");
include_once("2.php");
?>

PHP 真正多线程的使用

by 张宴 PHP 5.3 以上版本,使用pthreads PHP扩展,可以使PHP真正地支持多线程。多线程在处理重复性的循环任务,能够大大缩短程序执行时间。 我之前的文章中说过,大多数网站的性能瓶颈不在PHP服务器上,因为它可以简单地通过横向增加服务器或CPU核数来轻松应对(对于各种云主机,增加 VPS或CPU核数就更方便了,直接以备份镜像增加VPS,连操作系统、环境都不用安装配置),而是在于MySQL数据库。如果用 MySQL 数据库,一条联合查询的SQL,也许就可以处理完业务逻辑,但是,遇到大量并发请求,就歇菜了。如果用 NoSQL 数据库,也许需要十次查询,才能处理完同样地业务逻辑,但每次查询都比 MySQL 要快,十次循环NoSQL查询也许比一次MySQL联合查询更快,应对几万次/秒的查询完全没问题。如果加上PHP多线程,通过十个线程同时查询 NoSQL,返回结果汇总输出,速度就要更快了。我们实际的APP产品中,调用一个通过用户喜好实时推荐商品的PHP接口,PHP需要对BigSea NoSQL数据库发起500~1000次查询,来实时算出用户的个性喜好商品数据,PHP多线程的作用非常明显。

Using Real Multithreading in PHP

by 张宴 With PHP 5.3 and above, using the pthreads PHP extension lets PHP truly support multithreading. When handling repetitive loop tasks, multithreading can greatly shorten program execution time. As I said in a previous article of mine, the performance bottleneck of most websites is not the PHP server, because that can be easily handled by simply scaling out with more servers or more CPU cores (for the various cloud hosts, adding VPS instances or CPU cores is even more convenient — you just add a VPS from a backup image, and you don’t even have to install or configure an operating system or environment). The bottleneck is the MySQL database. If you use a MySQL database, a single join query in SQL might be enough to handle the business logic, but when you run into a large number of concurrent requests, it falls apart. If you use a NoSQL database, you might need ten queries to handle the same business logic, but each query is faster than MySQL — ten NoSQL queries in a loop may well be faster than one MySQL join query, and handling tens of thousands of queries per second is no problem at all. Add PHP multithreading on top, querying NoSQL with ten threads at the same time and aggregating the returned results for output, and it gets even faster. In our actual APP product, calling a single PHP interface that recommends products in real time based on user preferences requires PHP to issue 500~1000 queries to the BigSea NoSQL database in order to compute the user’s personalized preferred product data in real time — the effect of PHP multithreading is very obvious here.