Skip to content

Instantly share code, notes, and snippets.

@eddy8
eddy8 / wp_magic_quotes.php
Created May 9, 2013 02:31
PHP:wp functions - wp_magic_quotes
<?php
/**
* Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
*
* Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
* or $_ENV are needed, use those superglobals directly.
*
* @access private
* @since 3.0.0
*/
@eddy8
eddy8 / html_escape.php
Created May 10, 2013 06:00
PHP:html escape
<?php
function html_escape($var)
{
if (is_array($var))
{
return array_map('html_escape', $var);
}
else
{
return htmlspecialchars($var, ENT_QUOTES);
@eddy8
eddy8 / hex2bin.php
Created June 5, 2013 01:57
16进制串转字符串
<?php
if(!function_exists('hex2bin')) {
/**
* 16进制串转字符串
* @param {string} $h 16进制串
* @return {string} 对应字符串,参数有误返回NULL
*/
function hex2bin($h){
if (!is_string($h)) return null;
$r='';
@eddy8
eddy8 / time_of_a_week_ago.php
Last active December 19, 2015 09:19
获取一周前的时间
<?php
function a_week_ago(){
$today = getdate();
$start_time = mktime(0,0,0,$today['mon'],$today['mday']-7,$today['year']);
$end_time = time();
}
<?php
$x = function($bar, $foo="9") {
echo $foo, $bar, "\n";
};
class MissingArgumentException extends Exception {
}
function call_user_func_named_array($method, $arr){
@eddy8
eddy8 / ping.php
Created October 16, 2013 02:41
php ping
<?php
/**
*@param $domain string IP address or URL
*/
function pingDomain($domain){
$data = parse_url($domain);
if (isset($data['host'])) {
$domain = $data['host'];
}else{
$domain = $data['path'];
@eddy8
eddy8 / url_exist.php
Last active August 29, 2015 14:00
check url exist
<?php
/**
* 判断URL是否存在/可访问
* @param string $url url
* @return bool 存在返回true。不存在返回false
*/
function url_exist($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
@eddy8
eddy8 / dec2bin.php
Created April 29, 2014 03:10
dec to bin
<?php
/**
* 不用内置函数自己实现十进制转二进制
* @param integer $num 十进制数
* @return string 二进制字符串
*/
function my_dec2bin($num){
if(!is_integer($num)){
return '';
}
@eddy8
eddy8 / webservice.frm
Created May 23, 2014 08:09
vb6 use java webservice with post and soap
Private Sub Command1_Click()
Dim strSoapAction As String
Dim strUrl As String
Dim strxml As String
Dim returnMsg As String
strUrl = "http://xxx.com/xxx"
strSoapAction = "http://yyy.com/zzz"
<?php
ignore_user_abort(true);
set_time_limit(0); // disable the time limit for this script
$path = "/absolute_path_to_your_files/"; // change the path to fit your websites document structure
$dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\].]|[\.]{2,})", '', $_GET['download_file']); // simple file name validation
$dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); // Remove (more) invalid characters
$fullPath = $path.$dl_file;