Skip to content

Instantly share code, notes, and snippets.

View suconghou's full-sized avatar

suconghou suconghou

View GitHub Profile
<?php
function get_http_raw()
{
$raw='';
$raw.=$_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL']."\r\n";
foreach($_SERVER as $key => $value)
{
if(substr($key,0,5)==='HTTP_')
{
$key=substr($key,5);
@suconghou
suconghou / array_column.php
Last active January 11, 2016 08:54
低版本PHP兼容函数库
<?php
// 5 >= 5.5.0 才有该函数
if(!function_exists('array_column'))
{
function array_column($input,$columnKey=null,$indexKey=null)
{
if($columnKey&&!$indexKey)
{
@suconghou
suconghou / common.js
Created January 12, 2016 04:00
Javascript辅助函数
// 格式化秒数到时间格式
Number.prototype.formatTime=function(){
// 计算
var h=0,i=0,s=parseInt(this);
if(s>60){
i=parseInt(s/60);
s=parseInt(s%60);
if(i > 60) {
h=parseInt(i/60);
i = parseInt(i%60);
@suconghou
suconghou / ocp.php
Created June 23, 2016 07:02
opcache gui
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok, n1xim, pennedav, kabel)
Version: 0.2.0
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.2.0 0000-00-00 Updated page layout/styles and restructure code to be more MVC-like (kabel)
implemented HTTP Basic authentication (pennedav)
@suconghou
suconghou / music.php
Created June 23, 2016 07:04
some php files
<?php
/**
* 网易音乐
* @version 0.1
*/
class M163
{
const api='http://music.163.com';
private static $headers=array('User-Agent'=>'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36','Accept'=>'*/*');
@suconghou
suconghou / http.go
Created September 29, 2016 15:44
go http file server
package main
import (
"flag"
"fmt"
"net/http"
"os"
"path"
"strconv"
)
@suconghou
suconghou / generate_docker_cert.sh
Last active June 17, 2022 07:26
some shell script
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
set -e
set -x
@suconghou
suconghou / report.sh
Last active April 23, 2017 10:57
get server status
#!/bin/bash
# config
apiUrl="http://127.0.0.1:9090"
# 内网IP
if hash ip 2>/dev/null; then
@suconghou
suconghou / tree.php
Last active April 23, 2017 09:37
2个无限级分类
<?php
public static function data($items)
{
$items=array_column($items,null,'id');
$tree = [];
foreach($items as $item)
{
if(isset($items[$item['pid']]))
{
$items[$item['pid']]['child'][] = &$items[$item['id']];
@suconghou
suconghou / fetch.php
Created July 11, 2017 05:30
fetch domain resource use given host
<?php
$opts = stream_context_create(array(
'http'=> array(
'method' => 'GET',
'header'=> "Host: www.oschina.net\r\nUser-Agent: my file_get_contents use host\r\n",
)
));
$url = "http://125.39.6.163/news/86646/lftp-4-8-0";
echo file_get_contents($url, null, $opts);