Skip to content

Instantly share code, notes, and snippets.

@forthxu
forthxu / http.php
Created February 13, 2015 09:38
PHP开http服务
<?php
trait http{
private $max_read = 8192;
private $software = 'Kws/1.0 (By King)';
private $charset = 'utf-8';
private $headers = [
'_http'=>'HTTP/1.1 %d %s',
'_type'=>'Content-type:%s',
@forthxu
forthxu / http.php
Created February 13, 2015 09:41
PHP开http服务
<?php
trait http{
private $max_read = 8192;
private $software = 'Kws/1.0 (By King)';
private $charset = 'utf-8';
private $headers = [
'_http'=>'HTTP/1.1 %d %s',
'_type'=>'Content-type:%s',
@forthxu
forthxu / YafTemplate.php
Created February 13, 2015 09:42
yaf基础模板类
<?php
namespace Util;
class YafTemplate implements \Yaf\View_Interface{
private $style = ''; //当前生效的风格,用于缓存目录
private $mConfig = array(
'path' => '', //模板目录,绝对地址即在当前地址上加模块目录,
'suffix' => 'html', //模板后缀
'divide' => '/', //模板分割符,控制器和方法中间的分割符,
@forthxu
forthxu / README.md
Last active August 29, 2015 14:17 — forked from chuangbo/README.md

替换上你的Email,密码,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_email=xxx&login_password=xxx"

获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_email=xxx&amp;login_password=xxx&amp;domain_id=xxx"

@forthxu
forthxu / swoole.php
Created April 8, 2015 10:07
swoole IDE开发工具开发提示
<?php
//src https://github.com/Gsinhi/swoole-ide
/**
* 当前Swoole的版本号
*/
define('SWOOLE_VERSION', SWOOLE_VERSION);
/**
* 使用Base模式,业务代码在Reactor中直接执行
*/
@forthxu
forthxu / is_idcard.php
Created June 11, 2015 06:09
函数主要用于国内身份证号码的验证,支持15位与最新的18位身份证号码。
function is_idcard( $id )
{
$id = strtoupper($id);
$regx = "/(^\d{15}$)|(^\d{17}([0-9]|X)$)/";
$arr_split = array();
if(!preg_match($regx, $id))
{
return FALSE;
}
if(15==strlen($id)) //检查15位
@forthxu
forthxu / githook.php
Last active August 29, 2015 14:27
git hook部署
<?php
// nohup /usr/local/php55/bin/php -S 0.0.0.0:82 -t /www/sync/ >> /www/sync/githook.log 2>&1 &
// http://hostname:82/githook.php?token=xfs
$valid_token = 'xfs';
$valid_ip = array('127.0.0.1');
$client_token = $_GET['token'];
$client_ip = $_SERVER['REMOTE_ADDR'];
$fs = fopen('./githook.log', 'a');
fwrite($fs, "\n".'Request on ['.date("Y-m-d H:i:s").'] from ['.$client_ip.']'.PHP_EOL);
if ($client_token !== $valid_token)
@forthxu
forthxu / gitbranch.php
Created August 14, 2015 10:22
git自助切换项目分支
<?php
// http://hostname:82/gitbranch.php
$root_path = '/workspace/www/';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="">
<meta name="description" content="">
@forthxu
forthxu / post-receive.sh
Last active September 14, 2015 03:52 — forked from icyleaf/post-receive.sh
git autodeploy script when it matches the string "[deploy]"
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author icyleaf <icyleaf.cn@gmail.com>
# @link http://icyleaf.com
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below
@forthxu
forthxu / php thread example.php
Last active October 23, 2015 09:52
php thread example
<?php
//example 使用多线程处理任务
// http://netkiller.github.io/journal/thread.php.html 比较全部的php多线程学习
class vote extends Thread {
public $res = '';
public $url = array();
public $name = '';
public $runing = false;