Skip to content

Instantly share code, notes, and snippets.

@yuktse
yuktse / curl_connect_ssl_in_windows.md
Created March 6, 2014 09:40
windows 用 curl 连 ssl/https 失败的原因

通常是由于windows系统不能验证对方网站的CA(数字证书)

可以加这条语句解决:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不要验证SSL
@yuktse
yuktse / detect_city_via_ip.php
Created March 6, 2014 09:37
通过IP查城市
<?
function detect_city($ip) {
$default = 'UNKNOWN';
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost')
$ip = '8.8.8.8';
$curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';
@yuktse
yuktse / multi_curl.php
Created March 6, 2014 09:34
multi curl and single curl
<?
set_time_limit(0);
include 'runtime.php';
/**
* 使用多个子连接读同时读取多个连接
*/
function multiCurl($urls)
{
// 构建 $multi_handle
@yuktse
yuktse / qeephp_multi_db_connection
Created March 6, 2014 08:45
qeephp model连接不同DB,及不同服务器的DB
1. 首先是同服务器的不同DB
在模型的__define() 里面增加
'table_config' => array(
'schema' => 'dbname',
),
2. 其次是不同服务器的DB
@yuktse
yuktse / ExcelOutput
Created March 6, 2014 08:41
EXCEL导出XML格式文件,要注意的地方。
EXCEL导出XML结构:如果用于程序,如果打不开,出错的地方可能在于
1. Row index。删了,并补上空白行<Row />
2. <Table> 中的 ExpandedRowCount, ExpandedColumnCount。删了
3. WorksheetOptions标签里的内容,可能会导致WPS出错
4. 没有使用htmlspecialchars函数转换特别字符,WPS会出错
5. 数字类型的格填入了文字
6. 注意换行符"\r\n"之类要换成"&#10;"
@yuktse
yuktse / ExcelOutput_Html.php
Created March 6, 2014 04:30
以HTML形式输出EXCEL文件
<?
/**
* @sample
* [code]
* $excel = new ExcelOutput();
* $excel->start();
*
* // ... page content in html format comes here
*
* $e->save();
@yuktse
yuktse / ExcelOutput_Html.php
Created March 6, 2014 04:23
以HTML形式输出EXCEL文件
/**
* @sample
* [code]
* $excel = new ExcelOutput();
* $excel->start();
*
* // ... page content in html format comes here
*
* $e->save();
* [/code]
@yuktse
yuktse / vjia_soap_request.php
Created March 5, 2014 08:21
vjia_soap_request
function _request($service, $method, $param = array()){
// sys config, values comes from win.vjia.com
$auth['Uname'] = 'username';
$auth['Password'] = 'password';
// method config
// $wsdl_uri = "http://sws2.vjia.com/swsmsTest/{$service}.asmx?wsdl"; // sandbox
$wsdl_uri = "http://sws2.vjia.com/swsms/{$service}.asmx?wsdl"; // production
$client = new SoapClient($wsdl_uri, array('trace'=>true, 'exceptions'=>true, 'style'=>SOAP_DOCUMENT, 'encoding'=>'UTF-8', 'soap_version'=>SOAP_1_1));
@yuktse
yuktse / joinPath.php
Created March 4, 2014 03:21
join path function
functin joinPath($a, $b){
return rtrim($a, '/\ ') . DIRECTORY_SEPARATOR . ltrim($b, '/\ ');
}
@yuktse
yuktse / Helper_Devel.php
Created February 25, 2014 09:58
Helper codes in development
<?php
function dump($var, $label = null){
if($label) echo "<b>$label</b>";
echo '<pre>';
print_r($var);
echo '</pre>';
}
class Runtime
{