Skip to content

Instantly share code, notes, and snippets.

View horsley's full-sized avatar

Horsley Lee horsley

View GitHub Profile
@horsley
horsley / dns.php
Created January 25, 2013 09:18
Simple PHP code act as a dig tool to find dns records
<?php
$result = array();
$result_html = '';
if (isset($_POST['domain']) && !empty($_POST['domain'])) {
$domain_regex = '/[a-z\d][a-z\-\d\.]+[a-z\d]/i';
if (preg_match($domain_regex, $_POST['domain'])) {
if ($url = parse_url($_POST['domain'])) { //compatible when user post an url instead of a domain
if (isset($url['host'])) {
$result = dns_get_record($url['host'], DNS_A + DNS_AAAA + DNS_CNAME);
} else if (isset($url['path'])) {
@horsley
horsley / Translation.class.php
Created January 5, 2013 12:46
simple translation class, use json to store terms pair
<?php
/**
* Created by JetBrains PhpStorm.
* User: horsley
* Date: 12-12-16
* Time: 下午10:19
* To change this template use File | Settings | File Templates.
*/
if (!defined("TRAN_DICT_PATH")) define("TRAN_DICT_PATH", dirname(dirname(__FILE__)) . '/data/translations.json');
@horsley
horsley / lnmp_conf_patch.php
Created December 30, 2012 09:17
lnmp的设置补丁以适应awstats日志统计, 在服务器上chmod +x 之后即可以运行,修改的文件均会被备份
#!/usr/bin/php
<?php
/**
* lnmp的设置补丁以适应awstats日志统计
* @author: horsley <imhorsley@qq.com>
*
* 可用于lnmp和lnmpa,已在0.8和0.9版本上面测试过,默认状态的日志格式有误,少了双引号
*/
error_reporting(E_ALL);
//虚拟主机脚本
@horsley
horsley / template.class.php
Created October 29, 2012 16:28
PHP Simple Template Engine
<?php
//模板文件路径定义
if (!defined('TPL_ROOT_PATH')) define('TPL_ROOT_PATH', dirname(__FILE__).'/tpl');
class Template {
private $_data = array();
private $_tpl_name;
function __construct($tpl_name = '') {
@horsley
horsley / PHPFetionEx.php
Created October 18, 2012 05:54
PHP Fetion Sms Sender
<?php
/**
* PHP飞信发送类-增强版
*
* 本项目基于quanhengzhuang在google code上面的项目php-fetion
* 基于php-fetion版本1.2.1
*
* @author horsley <i@a-li.me>
* @version 1.1.0
*/