Skip to content

Instantly share code, notes, and snippets.

@luxixing
luxixing / audition.php
Last active December 19, 2015 18:19
面试题答案
1 打印前一天时间
<?php
echo date("Y-m-d H:i:s", strtotime("-1 days"));
?>
2 过滤html代码
如果此题单纯值的html代码,则 htmlspecialchars($str),处理输入存储
如果包含用户输入过滤,则sql语句防注入,过滤关键词,使用pdo的时候prepare sql语句 ' 转义
还有和谐社会的关键词过滤(这个非技术而属于政治了)
php 原生 Filler 族函数能做相当一部分工作,可在此基础上扩展一个过滤类
<?php
// No, Thanks. Direct file access forbidden.
! defined( 'ABSPATH' ) AND exit;
// INIT
add_action( 'after_setup_theme', array( 'unavailable_post_status', 'init' ) );
class unavailable_post_status extends wp_custom_post_status
{
/**
@luxixing
luxixing / php-configure.sh
Created June 23, 2013 02:27
php编译选项 报错一般就是扩展依赖的库不存在,查找并且安装即可
./configure\
--with-config-file-path=/usr/local\
--with-config-file-path=/usr/local/etc/php\
--enable-fpm\
--with-fpm-user=php-fpm\
--with-fpm-group=php-fpm\
--enable-mysqlnd\
--with-mysqli\
--with-pdo-mysql\
--with-mysql=mysqlnd\
@luxixing
luxixing / cmd.sh
Created June 22, 2013 15:31
一些常用sh命令收集
#将本地生成的公匙写入到远端服务器的验证文件中,实现无密码登录
cat ~/.ssh/id_rsa.pub | ssh user@host "cat - >> ~/.ssh/authorized_keys"
#生成ssh密匙命令在当前用户家目录
ssh-keygen
#显示系统有多少用户
cat /etc/passwd | cut -d: -f1
#ssh登陆之后执行一个命令
ssh -t root@10.1.1.169 "cd /data ; bash"
@luxixing
luxixing / php-pdo-helper.php
Last active April 23, 2019 20:40
PHP-PDO Class
<?php
/**
* 轻量级pdo操作封装函数
* @author xixing.lu@outlook.com
* @version 2013-04-16
* @todo 根据实际情况继续优化或者添加功能
*/
namespace dataservice\helper;
class PDOHelper