移到通用导出

parent a7396818
Showing with 3615 additions and 252 deletions
......@@ -5,28 +5,28 @@ APP_URL=http://localhost
//CMS MYSQL配置
DB_CONNECTION=mysql
DB_HOST=192.168.1.232
DB_HOST=192.168.2.232
DB_PORT=3306
DB_DATABASE=ichuntcms
DB_USERNAME=ichuntcms
DB_PASSWORD=ichuntcms#zsyM
//云芯数据库
DB_HOST_PUR=192.168.1.232
DB_HOST_PUR=192.168.2.232
DB_DATABASE_PUR=liexin_wms
DB_USERNAME_PUR=liexin_wms
DB_PASSWORD_PUR=liexin_wms#zsyM
DB_PORT_PUR=3306
//财务数据库
DB_HOST_FINANCE=192.168.1.232
DB_HOST_FINANCE=192.168.2.232
DB_DATABASE_FINANCE=liexin_finance
DB_USERNAME_FINANCE=liexin_finance
DB_PASSWORD_FINANCE=liexin_finance#zsyM
DB_PORT_FINANCE=3306
//云芯数据库
DB_HOST_YUNXIN=192.168.1.232
DB_HOST_YUNXIN=192.168.2.232
DB_DATABASE_YUNXIN=liexin_yunxin
DB_USERNAME_YUNXIN=liexin_yunxin
DB_PASSWORD_YUNXIN=liexin_yunxin#zsyM
......
......@@ -10,6 +10,7 @@ use App\Jobs\JopExportPutawayList;
use App\Model\CommonModel;
use App\Model\ExportModel;
use App\Model\GoodsAuditModel;
use App\Model\Server\ServerExportModel;
use App\Model\Server\ServerFinanceModel;
use App\Model\Server\ServerFoostoneModel;
use App\Model\Server\ServerMicModel;
......@@ -78,11 +79,7 @@ class ApiController extends Controller
//退货列表导出
private function ApiAbnormalListExport($request, $id){
$data= $request->input();
$data['is_consign'] = 1; //供应商代发
$id = (new UploadLogModel())->addLog($request->account_id,2,$data);
if(!$id) return Export(20003,'任务推送失败');
dispatch(new JopExportAbnormlList($id));
Export(0,$id);
(new ServerExportModel())->abnormalExport($data,$request->account_id,$request->mobile);
}
//入库列表
private function ApiPutawayList($request, $id){
......@@ -148,14 +145,11 @@ class ApiController extends Controller
dispatch(new JopExportGoodsList($id));
Export(0,$id);
}
//联营商品导出
//联营商品导出(改成后台导出)
private function ApiGoodsComListExport($request, $id){
$data= $request->input();
$data['supplier_com_code'] = $request->supplier_com_code;
$id = (new UploadLogModel())->addLog($request->account_id,5,$data,$request->mobile);
if(!$id) return Export(20003,'任务推送失败');
dispatch(new JopExportGoodsComList($id));
Export(0,$id);
(new ServerExportModel())->GoodsComExport($data,$request->account_id,$request->mobile);
}
//查询自营品牌
private function GetBrand($request){
......@@ -171,15 +165,13 @@ class ApiController extends Controller
}
//导出结果查询
private function ApiExportResult($request){
$loginfo = (new UploadLogModel())->where(['create_uid'=>$request->account_id,"id"=>$request->input("id")])->first();
$status = @$loginfo['status'];
if($status == 2){ //成功
Export(0,$loginfo['file_path']);
}elseif ($status == 3){ //失败
Export(1,"没有数据");
}else{
Export(2,"没完成");
}
$input['create_uid2'] = $request->account_id; //用户id
$id = $request->input("id");
if(!$id) Export(2,"没完成");
$input['id'] =$request->input("id"); //导出任务id
$client = new \Hprose\Http\Client("http://export.liexin.com/getDownPath",false);
echo $client->getDownPath(\GuzzleHttp\json_encode($input));
}
//商品列表
private function ApiSkuList($request){
......
......@@ -14,6 +14,7 @@ use App\Jobs\UploadAbnormal;
use App\Jobs\UploadDelivery;
use App\Jobs\UploadItems;
use App\Model\ConsignSaleModel;
use App\Model\ExportModel;
use App\Model\PackingModel;
use App\Model\PreSaleOrderModel;
use App\Model\PurchaseDeliveryItemsModel;
......@@ -135,5 +136,74 @@ class HandleController extends Controller
print_r($a);
}
private function e(){
#联营列表导出
$input['supplier_com_code'] = 'L0000008'; //用户id
$input['is_scroll'] = 1; //状态
$input['limit'] = 500; //状态
// $s = ExportModel::ApiAbnormalListExport($input);
// print_r($s);
// die();
$data = [
"type"=> 2, # 类型 1:模板调用 2: api回调
"source_items_id"=>5, #来源明细id,必填
"file_name"=> "联营列表导出",
"excel_suf" => "csv", #导出文件格式 csv,xls
"header"=> [ #导出头部
"商品ID","SKU型号","商品类别","供应商","制造商","渠道标签","内部编号","库存","状态","是否过期","更新时间"
],
"query_param"=>$input, #查询参数
"callbackurl"=> "http://yunxin.liexin.com/server/goodsComList", #rpc回调网址
"callbackfuc"=>"goodsComListServer", #rpc回调函数
"create_uid"=> 0, #创建人id
"create_uid2"=> 1, #前台创建人id
"create_name"=>111
];
$client = new \Hprose\Http\Client("http://yunxin.liexin.com/server/goodsComList",false);
$d = $client->goodsComListServer(\GuzzleHttp\json_encode($input));
print_r($d);
die();
#导出异常列表
// $input['is_consign'] = 1; //供应商代发
$input['create_uid2'] = 1; //用户id
$input['status'] = '-10,2'; //状态
// $s = ExportModel::ApiAbnormalListExport($input);
// print_r($s);
// die();
$data = [
"type"=> 2, # 类型 1:模板调用 2: api回调
"source_items_id"=>4, #来源明细id,必填
"file_name"=> "退货列表导出",
"excel_suf" => "csv", #导出文件格式 csv,xls
"header"=> [ #导出头部
'退货单号','创建单时间','金额','状态','币种','商品编码','型号','品牌','封装','包装方式','MPQ','数量','单价'
],
"query_param"=>$input, #查询参数
"callbackurl"=> "http://yunxin.liexin.com/server/exportAbnormlList", #rpc回调网址
"callbackfuc"=>"exportAbnormlList", #rpc回调函数
"create_uid"=> 0, #创建人id
"create_uid2"=> 1, #前台创建人id
"create_name"=>111
];
$client = new \Hprose\Http\Client("http://yunxin.liexin.com/server/AbnormalList",false);
$d = $client->AbnormalListExport(\GuzzleHttp\json_encode($input));
print_r($d);
die();
}
private function de(){
// $input['is_consign'] = 1; //供应商代发
$input['create_uid2'] = 1; //用户id
$input['id'] =139; //状态
$client = new \Hprose\Http\Client("http://export.liexin.com/getDownPath",false);
$d = $client->getDownPath(\GuzzleHttp\json_encode($input));
print_r($d);
die();
}
}
<?php
namespace App\Http\Controllers;
use App\Model\ExportModel;
use Illuminate\Http\Request;
use App\Http\Requests;
use DB;
use Hprose;
class ServerController extends Controller
{
public function Entrance(Request $request, $id)
{
set_time_limit(0);
$this->$id($request, $id);
}
/*
* 异常列表导出
*/
public function exportAbnormlList(){
$server=new Hprose\Http\Service();
$server->addMethod('exportAbnormlListServer',$this);
$server->handle();
}
//异常列表导出服务
public function exportAbnormlListServer($info){
$res= ExportModel::ApiAbnormalListExport(json_decode($info,true));
return $res;
}
/*
* 联营数据导出
*/
public function goodsComList(){
$server=new Hprose\Http\Service();
$server->addMethod('goodsComListServer',$this);
$server->handle();
}
//异常列表导出服务
public function goodsComListServer($info){
$res= ExportModel::GoodsComListExport(json_decode($info,true));
return $res;
}
}
<?php
namespace App\Http\Controllers;
use App\Model\ConsignSaleModel;
use App\Model\PurchaseModel;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Model\ActivityModel;
use App\Model\ActivityModuleModel;
class WebApiController extends Controller
{
public function Entrance(Request $request, $id ){
$sign=Validate($request->input());
if($sign!==true){
$this->Export(10001,'签名错误',$sign);
}
$this->$id($request, $id);
}
private function Export($errcode=0,$errmsg='成功',$data=''){
ErrorLog($errcode,$errcode,$errmsg);
if(is_array($errcode)){
echo json_encode(['errcode'=>$errcode[0],'errmsg'=>$errcode[1],'data'=>!empty($errcode[2])?$errcode[2]:'']);
exit();
}else{
echo json_encode(['errcode'=>$errcode,'errmsg'=>$errmsg,'data'=>$data]);
exit();
}
}
private function ActivityInfo($request, $id){
$Model=new ActivityModel();
$data=$Model->WebApiActivityInfo();
$this->Export($data);
}
}
<?php
namespace App\Http\Controllers;
use App\Model\ConsignSaleModel;
use App\Model\PreSaleOrderModel;
use App\Model\PurchaseItemsModel;
use App\Model\PurchaseModel;
use App\Model\PutawayItemsModel;
use App\Model\PutawayModel;
use App\Model\Server\WmsToPurModel;
use App\Model\SupplierReceiptModel;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class WmsApiController extends Controller
{
public function Entrance(Request $request, $id ){
$this->$id($request, $id);
}
private function Export($errcode=0,$errmsg='成功',$data='',$total=''){
//ErrorLog($errcode,$errcode,$errmsg);
if(is_array($errcode)){
if(!empty($errcode['errcode'])){
echo json_encode(['errcode'=>$errcode['errcode'],'errmsg'=>$errcode['errmsg'],'data'=>!empty($errcode['data'])?$errcode['data']:'','total'=>!empty($errcode['total'])?$errcode['total']:''],JSON_UNESCAPED_UNICODE);
}else{
echo json_encode(['errcode'=>$errcode[0],'errmsg'=>$errcode[1],'data'=>!empty($errcode[2])?$errcode[2]:'','total'=>!empty($errcode[3])?$errcode[3]:''],JSON_UNESCAPED_UNICODE);
}
}else{
echo json_encode(['errcode'=>$errcode,'errmsg'=>$errmsg,'data'=>$data,'total'=>$total],JSON_UNESCAPED_UNICODE);
}
exit();
}
private function ExportLayui($errcode=0,$errmsg=0,$data=[],$count=0,$other=''){
if(is_array($errcode)){
echo json_encode(['code'=>$errcode[0],'msg'=>$errcode[1],'data'=>$errcode[2],'count'=>$errcode[3],'other'=>!empty($errcode[4]) ? $errcode[4] : '']);
}else{
echo json_encode(['code'=>$errcode,'msg'=>$errmsg,'data'=>$data,'count'=>$count,'other'=>$other]);
}
exit();
}
private function WebApiPutaway($request){
$PutawayModel=new PutawayModel();
$this->Export($PutawayModel->WebApiPutaway($request->Wmsdata));
}
private function WebApiRevokePay($request){
$PurModel=new PurchaseModel();
$this->Export($PurModel->WebApiRevokePay($request->Wmsdata));
}
/*
* 寄售接口
*/
private function WebApiConsignSale($request){
$this->Export((new ConsignSaleModel())->main($request->Wmsdata));
}
/*
* 超售批量插入订单数据
*/
private function WebApiPreSaleOrderAdd($request){
$this->Export((new PreSaleOrderModel())->bultInsert($request->Wmsdata));
}
/*
* 超售批量update订单数据
*/
private function WebApiPreSaleOrderUpdate($request){
$this->Export((new PreSaleOrderModel())->updateStatus($request->Wmsdata));
}
/*
* 获取单个供应商银行信息
* @param int limit 每页多少条
* @param int p 第几页
* @param int currency 币种
* @param int supplier_id 供应商ID
*/
private function WebApiSupplierReceiptList($request){
$this->ExportLayui((new SupplierReceiptModel())->getList(0,$request->Wmsdata));
}
/*
* 账期回写请款状态(部分请款,完全请款)
*/
private function WebApiPeriodPayStatus($request){
$PurModel=new PurchaseModel();
$this->Export($PurModel->PeriodPayStatus($request->Wmsdata));
}
/*
* wms出库(库内异常退货)推送信息到采购
*/
private function WebApiAbnormalStockReturn($request){
$res = (new WmsToPurModel())->WebApiAbnormalStockReturn($request->Wmsdata);
$this->Export($res);
}
/*
* 批量获取单个sku送货在途
* @param $sku_arr =[10197,10198,10199] 需要查询的sku_id数组
* @return [10197:50,10198:30,10199:50] 返回查询后的送货在途数据
*/
private function WebApiRunningNumber($request){
$res = (new PurchaseItemsModel())->RunningNumber($request->Wmsdata);
$this->Export($res);
}
}
......@@ -37,9 +37,9 @@ class CheckLogin
if (strpos($nowUrl,'/web/login') !== false){ //如果已经登录,跳到登录页
return $userInfoArr['supplier_id'] >0 ? redirect('/web/GoodsList' ) : redirect('/web/GoodsComList' );
}
foreach ($userInfoKey as $k=>$v){
Redis::expire($v,7200); //延长登录时间
}
// foreach ($userInfoKey as $k=>$v){
// Redis::expire($v,7200); //延长登录时间
// }
$request->mobile = $userInfoArr['mobile'];
$request->account_id = $userInfoArr['account_id']; //自营id
$request->supplier_id = $userInfoArr['supplier_id'];
......
......@@ -1238,4 +1238,8 @@ function G($start,$end='',$dec=4)
{
$_info[$start] = microtime(TRUE);
}
}
//列表返回2,非断点返回
function ExportLayuiReturn($arr){
return json_encode(['code'=>@$arr[0],'msg'=>@$arr[1],'data'=>@$arr[2],'count'=>@$arr[3],'other'=>!empty(@$arr[4]) ? @$arr[4] : ''],JSON_UNESCAPED_UNICODE);
}
\ No newline at end of file
......@@ -11,4 +11,6 @@ Route::match(['get', 'post'],'/hd/{key}', 'HandleController@Entrance')
Route::group(['middleware' => 'pure'], function () {
Route::match(['get', 'post'],'/pure/{key}', 'PureController@info');
});
\ No newline at end of file
});
Route::match(['get', 'post'],'/server/{key}', 'ServerController@Entrance'); //对外提供导出回调接口
\ No newline at end of file
......@@ -54,6 +54,8 @@ class OperationLogMap{
'ptw_cancelorder_return'=>'采购取消订单通知仓库-返回结果',
'skulower_price_get'=>'获取sku最低价-请求数据',
'skulower_price_success'=>'获取sku最低价-返回结果',
'export_post'=>'通用导出-发送',
'export_res'=>'通用导出-结果',
];
}
......
......@@ -2,7 +2,10 @@
namespace App\Model;
use App\Map\GoodsMap;
use App\Model\Server\ServerEsModel;
use App\Model\Server\ServerFoostoneModel;
use App\Model\Server\ServerMicModel;
use Request;
use DB;
use App\Model\Server\ServerPurModel;
......@@ -11,38 +14,20 @@ use App\Model\Server\ServerFinanceModel;
//导出模型
class ExportModel
{
//订单列表导出
static function ApiOrderListExport($request){
$input = $request->input();
$input['type'] = 2; //导出类型
$res = (new ServerPurModel($request->appid,$request->key))->OrderList($input,2);
if (!count($res['data']) ){
exit("没有数据");
}
$out = [];
foreach ($res['data'] as $k=>$v){
array_push($out,[
'order_sn'=>$v['order_sn'],
'picking_amount'=>$v['picking_amount'],
'currency'=>$v['currency'],
'pay_type'=>$v['pay_type'],
'status'=>$v['status'],
'create_time'=>$v['create_time'],
]);
}
export_csv($out,['订单号','订单金额','币种','结算方式','状态','创建时间'],'订单列表导出'.time().'.csv');
}
/*
* 退货列表导出
* 导出内容:退货单号,创建单时间,金额,状态,商家商品编码,型号,品牌,封装,包装方式,MPQ,数量,单价,收货数量
*/
static function ApiAbnormalListExport($request){
$input = $request->input();
$input['type'] = 2; //导出类型
$res = (new ServerPurModel($request->appid,$request->key))->AbnormalDetail($input,2);
* 退货列表导出
* 对外提供导出接口
*/
static function AbnormalListExport($input){
if (!@$input['create_uid2']) return [1002,'用户id不得为空'];
$account = (new SupplierAccountModel())->select("appid","key")->where("id",$input['create_uid2'])->first();
if(!$account) return [1001,'不存在此用户id'];
$res = (new ServerPurModel($account->appid,$account->key))->AbnormalDetail($input,2);
if (!count($res['data']) ){
exit("没有数据");
return $res;
}
$out = [];
foreach ($res['data'] as $k=>$v){
......@@ -54,7 +39,7 @@ class ExportModel
'currency'=>$v['currency'],
'supplier_goods_id'=>$v['supplier_goods_id'],
'goods_name'=>$v['goods_name'],
'supplier_brand_name'=>$v['supplier_brand_name'],
'brand_name'=>$v['brand_name'],
'encap'=>$v['encap'],
'packing_id'=>$v['packing_id'],
'mpq'=>$v['mpq'],
......@@ -62,30 +47,66 @@ class ExportModel
'initial_price'=>$v['initial_price'],
]);
}
export_csv($out,['退货单号','创建单时间','金额','状态','币种','商品编码','型号','品牌','封装','包装方式','MPQ','数量','单价'],'退货列表导出'.time().'.csv');
$res['data'] = $out;
return $res;
}
//对账单列表导出
static function ApiReconcilePurListExport($request){
$input = $request->input();
$input['type'] = 2; //导出类型
$res = (new ServerFinanceModel($request->appid,$request->key))->reconcilePurList($input,2);
if ($res['code'] > 0 ){
exit("没有数据");
/*
* 联营数据导出
*/
static function GoodsComListExport($query){
#查询es数据
$ServerEsModel = new ServerEsModel();
$ServerMicModel = new ServerMicModel();
$s = [
'is_scroll'=>$query['is_scroll'], //游标
'offset'=>$query['limit'],
'supplier_id'=>17,
'canal/condition'=>$query['supplier_com_code'],
];
if (@$query['goods_id']) $s['goods_id/condition'] = $query['goods_id'];
if(array_key_exists('goods_status',$query)) $s['goods_status/condition'] = $query['goods_status'];
if (@$query['brand_id']) $s['brand_id/condition'] = $query['brand_id'];
if (@$query['goods_name']) $s['goods_name/condition'] = $query['goods_name'];
$searchArr = $ServerEsModel->searchSku($s);
$total = @$searchArr['data']['total'];
if (@$searchArr['error_code'] > 0 || !count($total) ){
return [1001,'没有数据'];
}
#查询基石数据
$micData = [
'goods_id'=>$searchArr['data']['goods_id'] //商品id数组
];
$res = $ServerMicModel->synchronization($micData,2);
if ($res['code'] > 0){
return [1002,'没有数据'];
}
$out = [];
foreach ($res['data'] as $k=>$v){
array_push($out,[
'reconcile_pur_sn'=>$v['reconcile_pur_sn'],
'amount'=>$v['amount'],
'currency'=>$v['currency'],
'day_num'=>$v['day_num'],
'finish_time'=>$v['finish_time'],
'create_time'=>$v['create_time'],
'checking_time'=>$v['checking_time'],
'status'=>$v['status'],
]);
foreach ($res['data'] as $k=>&$v){
if(!$v) continue;
$temp = [
'goods_id'=>$k."\t",
'goods_name'=>@$v['goods_name'],
'goods_type_name'=> @GoodsMap::$goods_type[$v['goods_type']],
'supplier_name'=>@$v['supplier_name'],
'brand_name'=>@$v['brand_name'],
'canal'=>@$v['canal'],
'encoded'=>@$v['encoded'],
'stock'=>@$v['stock'],
'goods_status_name'=>@GoodsMap::$status[$v['goods_status']],
'expire'=>@GoodsMap::$expire[$v['status']],
'update_time'=>timeToDate($v['update_time']),
];
array_push($out,$temp); //推入
}
export_csv($out,['对账单号','账单金额','结算币种','结算方式','结算时间','创建时间','对账时间','状态'],'对账列表导出'.time().'.csv');
$res['count'] = $total;
$res['data'] = $out;
$res['scroll_id'] = $searchArr['data']['scroll_id']; #游标回传
return $res;
}
......
<?php
namespace App\Model\Server;
use App\Model\OperationLogModel;
use Request;
use DB;
//通用导出模型
class ServerExportModel
{
private $yunxinUrl ; //云芯网址
private $ExportUrl ; //导出网址
const IS_DEBUG = 0; //是否调试
public function __construct()
{
$this->ExportUrl = config('website.URL_EXPORT');
$this->yunxinUrl = config('website.URL_YUNXIN');
}
public function push($data){
OperationLogModel::log(["operation_type"=>"1","relevance_type"=>'export_post',"content"=>$data,"extend1"=>""]); //日志
$client = new \Hprose\Http\Client($this->ExportUrl."/insertExport",false);
$res = $client->insertExport(json_encode($data));
if (self::IS_DEBUG){
print_r($this->ExportUrl."/insertExport");
print_r("<br/>");
print_r($data);
print_r("<br/>");
print_r($res);
print_r("<br/>");
die();
}
OperationLogModel::log(["operation_type"=>"1","relevance_type"=>'export_res',"content"=>$data,"extend1"=>$res]); //日志
return $res;
}
/*
* 导出异常列表推送任务
*/
public function abnormalExport($input,$create_uid,$create_name){
// $input['is_consign'] = 1; //供应商代发
$input['create_uid2'] = $create_uid; //用户id
$data = [
"type"=> 2, # 类型 1:模板调用 2: api回调
"source_items_id"=>4, #来源明细id,必填
"file_name"=> "退货列表导出",
"excel_suf" => "csv", #导出文件格式 csv,xls
"header"=> [ #导出头部
'退货单号','创建单时间','金额','状态','币种','商品编码','型号','品牌','封装','包装方式','MPQ','数量','单价'
],
"query_param"=>$input, #查询参数
"callbackurl"=> $this->yunxinUrl."/server/exportAbnormlList", #rpc回调网址
"callbackfuc"=>"exportAbnormlListServer", #rpc回调函数
"create_uid"=> 0, #创建人id
"create_uid2"=> $create_uid, #前台创建人id
"create_name"=>$create_name
];
echo self::push($data);
}
/*
* 联营列表推送任务
*/
public function GoodsComExport($input,$create_uid,$create_name){
$input['is_scroll'] = 1; //状态
$data = [
"type"=> 2, # 类型 1:模板调用 2: api回调
"source_items_id"=>5, #来源明细id,必填
"file_name"=> "联营列表导出",
"excel_suf" => "csv", #导出文件格式 csv,xls
"header"=> [ #导出头部
"商品ID","SKU型号","商品类别","供应商","制造商","渠道标签","内部编号","库存","状态","是否过期","更新时间"
],
"query_param"=>$input, #查询参数
"callbackurl"=> "http://yunxin.liexin.com/server/goodsComList", #rpc回调网址
"callbackfuc"=>"goodsComListServer", #rpc回调函数
"create_uid"=> 0,
"create_uid2"=> $create_uid, #前台创建人id
"create_name"=>$create_name
];
echo self::push($data);
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ class ServerPurModel
const IS_DEBUG = 0; //是否调试
public function __construct($appid,$key,$domain="")
{
$this->_url = getHostUrl('pur_domain',$domain);
$this->_url = config('website.URL_PUR');
$this->appid = $appid;
$this->key = $key;
}
......
......@@ -73,7 +73,7 @@ class SupplierAccountModel extends Model
#登录信息写入缓存
$key = md5($account_name.$code.time());
$expire = 7200;//过期两个小时
$expire = 3600*24;//过期24个小时
$res = Redis::setex('yunxin_login_'.$key."_supplier_accountid_".$account_id, $expire, utf8JsonEncode($info));
if ($res != 'OK'){
throw new Exception('写入缓存失败',1004);
......
......@@ -12,8 +12,8 @@
"maatwebsite/excel": "~2.0.0",
"vladimir-yuldashev/laravel-queue-rabbitmq": "5.2",
"artisaninweb/laravel-soap": "0.2.*",
"gregwar/captcha": "^1.1"
"gregwar/captcha": "^1.1",
"hprose/hprose": "^2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
......
<?php
#不与线上环境同步
return [
"URL_ICHUNT" =>"https://www.ichunt.com",
"URL_EXPORT" =>"http://export.liexin.com",
"URL_ICHUNT" =>"https://www.ichunt.com",
"URL_YUNXIN" => "http://yunxin.liexin.com",
"URL_FINANCE" => "http://finance.liexin.com",
"URL_FOOTSTONE" => "http://foostone.liexin.com",
......@@ -9,7 +11,7 @@ return [
"URL_ES"=>"http://soso12.ichunt.com",//测试Es地址
// "URL_ES"=>"http://szso.ichunt.com",//测试Es地址
//"URL_ES"=>"http://soso12.ichunt.com/search/Es/searchSku",//Es地址
"URL_MIC_FOOTSTONE"=>"http://192.168.1.232:60004",//基石微服务
"URL_MIC_FOOTSTONE"=>"http://192.168.2.232:60004",//基石微服务
'UploadKey'=>'fh6y5t4rr351d2c3bryi',//Es密钥
"domain" => "liexin.com", //根域名
......
......@@ -62,7 +62,11 @@ function ajax_push2(url,data){
*/
function common_export(url,data) {
var res = ajax_push(url,data)
if(res.code > 0) {
if(!res) {
alert_err("网络错误,请重试")
return false;
}
if(res.err_code > 0) {
alert_err(res.msg)
return false;
}
......@@ -72,18 +76,18 @@ function common_export(url,data) {
,shade: 0.6
,style: 'background: rgba(216,100,125,0.9); color:#fff; border:none;',
});
var logid = res.msg //导出id
var logid = res.other //导出id
var t2 = window.setInterval(function () {
var res = ajax_push2('/api/ApiExportResult',{"id":logid})
if(res.code == 0){
if(res.err_code == 0){
layer.closeAll();
window.location.href = res.msg
window.location.href = res.err_msg
window.clearInterval(t2)
}
if(res.code == 1){
if(res.err_code == 1){
layer.closeAll();
window.clearInterval(t2)
alert_err(res.msg)
alert_err(res.err_msg)
}
},3000);
}
......
......@@ -16,6 +16,7 @@ return array(
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'e7223560d890eab89cda23685e711e2c' => $vendorDir . '/psy/psysh/src/Psy/functions.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'd7f4f7522f962c095f835c50e6136087' => $vendorDir . '/hprose/hprose/src/init.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
);
......@@ -36,6 +36,7 @@ return array(
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
'Illuminate\\' => array($vendorDir . '/laravel/framework/src/Illuminate'),
'Hprose\\' => array($vendorDir . '/hprose/hprose/src/Hprose'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
......
The MIT License (MIT)
Copyright (c) 2008-2018 http://hprose.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<p align="center"><img src="http://hprose.com/banner.@2x.png" alt="Hprose" title="Hprose" width="650" height="200" /></p>
<a href="https://promisesaplus.com/">
<img src="https://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo" title="Promises/A+ 1.1 compliant" align="right" />
</a>
# Hprose for PHP
[![Build Status](https://travis-ci.org/hprose/hprose-php.svg?branch=master)](https://travis-ci.org/hprose/hprose-php)
[![Join the chat at https://gitter.im/hprose/hprose-php](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/hprose/hprose-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Supported PHP versions: 5.3 .. 7.1](https://img.shields.io/badge/php-5.3~7.1-blue.svg)
[![Packagist](https://img.shields.io/packagist/v/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![Packagist Download](https://img.shields.io/packagist/dm/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![License](https://img.shields.io/packagist/l/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
## Introduction
*Hprose* is a High Performance Remote Object Service Engine.
It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.
*Hprose* supports many programming languages, for example:
* AAuto Quicker
* ActionScript
* ASP
* C++
* Dart
* Delphi/Free Pascal
* dotNET(C#, Visual Basic...)
* Golang
* Java
* JavaScript
* Node.js
* Objective-C
* Perl
* PHP
* Python
* Ruby
* ...
Through *Hprose*, You can conveniently and efficiently intercommunicate between those programming languages.
This project is the implementation of Hprose for PHP.
Hprose 2.0 for PHP Documents: https://github.com/hprose/hprose-php/wiki
<p align="center"><img src="http://hprose.com/banner.@2x.png" alt="Hprose" title="Hprose" width="650" height="200" /></p>
<a href="https://promisesaplus.com/">
<img src="https://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo" title="Promises/A+ 1.1 compliant" align="right" />
</a>
# Hprose for PHP
[![Build Status](https://travis-ci.org/hprose/hprose-php.svg?branch=master)](https://travis-ci.org/hprose/hprose-php)
[![Join the chat at https://gitter.im/hprose/hprose-php](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/hprose/hprose-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Supported PHP versions: 5.3 .. 7.1](https://img.shields.io/badge/php-5.3~7.1-blue.svg)
[![Packagist](https://img.shields.io/packagist/v/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![Packagist Download](https://img.shields.io/packagist/dm/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![License](https://img.shields.io/packagist/l/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
## 简介
*Hprose* 是高性能远程对象服务引擎(High Performance Remote Object Service Engine)的缩写。
它是一个先进的轻量级的跨语言跨平台面向对象的高性能远程动态通讯中间件。它不仅简单易用,而且功能强大。你只需要稍许的时间去学习,就能用它轻松构建跨语言跨平台的分布式应用系统了。
*Hprose* 支持众多编程语言,例如:
* AAuto Quicker
* ActionScript
* ASP
* C++
* Dart
* Delphi/Free Pascal
* dotNET(C#, Visual Basic...)
* Golang
* Java
* JavaScript
* Node.js
* Objective-C
* Perl
* PHP
* Python
* Ruby
* ...
通过 *Hprose*,你就可以在这些语言之间方便高效的实现互通了。
本项目是 Hprose 的 PHP 语言版本实现。
Hprose 2.0 for PHP 文档: https://github.com/hprose/hprose-php/wiki
{
"name": "hprose/hprose",
"type": "library",
"description": "It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.",
"keywords": [
"hprose",
"phprpc",
"rpc",
"webservice",
"websocket",
"http",
"ajax",
"json",
"jsonrpc",
"xmlrpc",
"cross-language",
"cross-platform",
"cross-domain",
"html5",
"serialize",
"serialization",
"protocol",
"web",
"service",
"framework",
"library",
"game",
"communication",
"middleware",
"webapi",
"socket",
"tcp",
"async",
"unix",
"future"
],
"homepage": "http://hprose.com/",
"license": "MIT",
"authors": [
{
"name": "Ma Bingyao",
"email": "andot@hprose.com",
"homepage": "http://hprose.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"suggest": {
"ext-hprose": "Faster serialize and unserialize hprose extension."
},
"require-dev": {
"phpunit/phpunit": ">=4.0.0"
},
"autoload": {
"files": [
"src/init.php"
],
"psr-4": {
"Hprose\\": "src/Hprose"
}
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose.php *
* *
* hprose for php 5.3+ *
* *
* LastModified: Jul 10, 2017 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
require_once __DIR__ . '/init.php';
// Autoload for non-composer applications
spl_autoload_register(function ($className) {
if ((strlen($className) > 7) && (strtolower(substr($className, 0, 7)) === "hprose\\")) {
$file = __DIR__ . DIRECTORY_SEPARATOR . str_replace("\\", DIRECTORY_SEPARATOR, $className) . ".php";
if (is_file($file)) {
include $file;
return true;
}
}
return false;
});
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/BytesIO.php *
* *
* hprose BytesIO class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class BytesIO {
protected $buffer;
protected $length;
protected $pos = 0;
protected $mark = -1;
public function __construct($string = '') {
$this->buffer = $string;
$this->length = strlen($string);
}
public function close() {
$this->buffer = '';
$this->pos = 0;
$this->mark = -1;
$this->length = 0;
}
public function length() {
return $this->length;
}
public function getc() {
if ($this->pos < $this->length) {
return $this->buffer[$this->pos++];
}
return '';
}
public function read($n) {
$s = substr($this->buffer, $this->pos, $n);
$this->skip($n);
return $s;
}
public function readfull() {
$s = substr($this->buffer, $this->pos);
$this->pos = $this->length;
return $s;
}
public function readuntil($tag) {
$pos = strpos($this->buffer, $tag, $this->pos);
if ($pos !== false) {
$s = substr($this->buffer, $this->pos, $pos - $this->pos);
$this->pos = $pos + strlen($tag);
}
else {
$s = substr($this->buffer, $this->pos);
$this->pos = $this->length;
}
return $s;
}
public function readString($n) {
$pos = $this->pos;
$buffer = $this->buffer;
for ($i = 0; $i < $n; ++$i) {
switch (ord($buffer[$pos]) >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7: {
// 0xxx xxxx
++$pos;
break;
}
case 12:
case 13: {
// 110x xxxx 10xx xxxx
$pos += 2;
break;
}
case 14: {
// 1110 xxxx 10xx xxxx 10xx xxxx
$pos += 3;
break;
}
case 15: {
// 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
$pos += 4;
++$i;
if ($i >= $n) {
throw new Exception('bad utf-8 encoding');
}
break;
}
default: {
throw new Exception('bad utf-8 encoding');
}
}
}
return $this->read($pos - $this->pos);
}
public function mark() {
$this->mark = $this->pos;
}
public function unmark() {
$this->mark = -1;
}
public function reset() {
if ($this->mark != -1) {
$this->pos = $this->mark;
}
}
public function skip($n) {
$this->pos += $n;
}
public function eof() {
return ($this->pos >= $this->length);
}
public function write($str, $n = -1) {
if ($n == -1) {
$this->buffer .= $str;
$n = strlen($str);
}
else {
$this->buffer .= substr($str, 0, $n);
}
$this->length += $n;
}
public function load($filename) {
$str = file_get_contents($filename);
if ($str === false) return false;
$this->buffer = $str;
$this->pos = 0;
$this->mark = -1;
$this->length = strlen($str);
return true;
}
public function save($filename) {
return file_put_contents($filename, $this->buffer);
}
public function toString() {
return $this->buffer;
}
public function __toString() {
return $this->buffer;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/ClassManager.php *
* *
* hprose class manager class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class ClassManager {
private static $classCache1 = array();
private static $classCache2 = array();
public static function register($class, $alias) {
self::$classCache1[$alias] = $class;
self::$classCache2[$class] = $alias;
}
public static function getClassAlias($class) {
if (isset(self::$classCache2[$class])) {
return self::$classCache2[$class];
}
$alias = str_replace('\\', '_', $class);
self::register($class, $alias);
return $alias;
}
public static function getClass($alias) {
if (isset(self::$classCache1[$alias])) {
return self::$classCache1[$alias];
}
if (!class_exists($alias)) {
$class = str_replace('_', '\\', $alias);
if (class_exists($class)) {
self::register($class, $alias);
return $class;
}
return 'stdClass';
}
return $alias;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Completer.php *
* *
* hprose Completer class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Completer {
private $future;
public function __construct() {
$this->future = new Future();
}
public function future() {
return $this->future;
}
public function complete($result) {
$this->future->resolve($result);
}
public function completeError($error) {
$this->future->reject($error);
}
public function isCompleted() {
return $this->future->state !== Future::PENDING;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Deferred.php *
* *
* hprose Deferred class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Deferred {
public $promise;
public function __construct() {
$this->promise = new Future();
}
public function resolve($value) {
$this->promise->resolve($value);
}
public function reject($reason) {
$this->promise->reject($reason);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/FakeReaderRefer.php *
* *
* hprose FakeReaderRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class FakeReaderRefer implements ReaderRefer {
public function set($val) {}
public function read($index) {
throw new Exception("Unexpected serialize tag '" .
Tags::TagRef .
"' in stream");
}
public function reset() {}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/FakeWriterRefer.php *
* *
* hprose FakeWriterRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class FakeWriterRefer implements WriterRefer {
public function set($val) {}
public function write(BytesIO $stream, $val) { return false; }
public function reset() {}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter.php *
* *
* hprose filter interface for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
interface Filter {
public function inputFilter($data, stdClass $context);
public function outputFilter($data, stdClass $context);
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/JSONRPC/ClientFilter.php *
* *
* json rpc client filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\JSONRPC;
use stdClass;
use Exception;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ClientFilter implements Filter {
private static $id = 1;
private $version;
public function __construct() {
$this->version = "2.0";
}
public function getVersion() {
return $this->version;
}
public function setVersion($version) {
if ($version === "1.0" || $version === "1.1" || $version === "2.0") {
$this->version = $version;
}
else {
throw new Exception("version must be 1.0, 1.1 or 2.0 in string format.");
}
}
public function inputFilter($data, stdClass $context) {
$response = json_decode($data);
if (!isset($response->result)) {
$response->result = null;
}
if (!isset($response->error)) {
$response->error = null;
}
$stream = new BytesIO();
$writer = new Writer($stream, true);
if ($response->error) {
$stream->write(Tags::TagError);
$writer->writeString($response->error->message);
}
else {
$stream->write(Tags::TagResult);
$writer->serialize($response->result);
}
$stream->write(Tags::TagEnd);
return $stream->toString();
}
public function outputFilter($data, stdClass $context) {
$request = new stdClass();
if ($this->version === "1.1") {
$request->version = "1.1";
}
else if ($this->version === "2.0") {
$request->jsonrpc = "2.0";
}
$stream = new BytesIO($data);
$reader = new Reader($stream);
$tag = $stream->getc();
if ($tag === Tags::TagCall) {
$request->method = $reader->readString();
$tag = $stream->getc();
if ($tag == Tags::TagList) {
$reader->reset();
$request->params = $reader->readListWithoutTag();
}
}
else {
throw new Exception("Error Processing Request", 1);
}
$request->id = self::$id++;
return json_encode($request);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/JSONRPC/ServiceFilter.php *
* *
* json rpc service filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\JSONRPC;
use stdClass;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ServiceFilter implements Filter {
function inputFilter($data, stdClass $context) {
if ($data !== "" && ($data{0} === '[' || $data{0} === '{')) {
try {
$requests = json_decode($data);
}
catch (Exception $e) {
return $data;
}
if ($data{0} === '{') {
$requests = array($requests);
}
else if (count($requests) === 0) {
return $data;
}
$stream = new BytesIO();
$writer = new Writer($stream, true);
$context->userdata->jsonrpc = array();
foreach ($requests as $request) {
$jsonrpc = new stdClass();
if (isset($request->id)) {
$jsonrpc->id = $request->id;
}
else {
$jsonrpc->id = null;
}
if (isset($request->version)) {
$jsonrpc->version = $request->version;
}
else if (isset($request->jsonrpc)) {
$jsonrpc->version = $request->jsonrpc;
}
else {
$jsonrpc->version = '1.0';
}
$context->userdata->jsonrpc[] = $jsonrpc;
if (isset($request->method)) {
$stream->write(Tags::TagCall);
$writer->writeString($request->method);
if (isset($request->params) &&
count($request->params) > 0) {
$writer->writeArray($request->params);
}
}
else {
unset($context->userdata->jsonrpc);
return $data;
}
}
$stream->write(Tags::TagEnd);
$data = $stream->toString();
unset($stream);
unset($writer);
}
return $data;
}
function outputFilter($data, stdClass $context) {
if (isset($context->userdata->jsonrpc)) {
$responses = array();
$stream = new BytesIO($data);
$reader = new Reader($stream);
$tag = $stream->getc();
foreach ($context->userdata->jsonrpc as $jsonrpc) {
$response = new stdClass();
$response->id = $jsonrpc->id;
$version = $jsonrpc->version;
if ($version !== '2.0') {
if ($version === '1.1') {
$response->version = '1.1';
}
$response->result = null;
$response->error = null;
}
else {
$response->jsonrpc = '2.0';
}
if ($tag !== Tags::TagEnd) {
$reader->reset();
if ($tag === Tags::TagResult) {
$response->result = $reader->unserialize();
}
else if ($tag === Tags::TagError) {
$lasterror = error_get_last();
$response->error = new stdClass();
$response->error->code = $lasterror['type'];
$response->error->message = $reader->unserialize();
}
$tag = $stream->getc();
}
else {
$response->result = null;
}
if ($response->id !== null) {
$responses[] = $response;
}
}
if (count($context->userdata->jsonrpc) === 1) {
if (count($responses) === 1) {
return json_encode($responses[0]);
}
return '';
}
return json_encode($responses);
}
return $data;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/XMLRPC/ClientFilter.php *
* *
* xml-rpc client filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\XMLRPC;
use stdClass;
use Exception;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ClientFilter implements Filter {
public function inputFilter($data, stdClass $context) {
$result = xmlrpc_decode($data, "UTF-8");
$stream = new BytesIO();
$writer = new Writer($stream, true);
if (isset($result['faultString'])) {
$stream->write(Tags::TagError);
$writer->writeString($result['faultString']);
}
else {
$stream->write(Tags::TagResult);
$writer->serialize($result);
}
$stream->write(Tags::TagEnd);
return $stream->toString();
}
public function outputFilter($data, stdClass $context) {
$method = null;
$params = array();
$stream = new BytesIO($data);
$reader = new Reader($stream);
$tag = $stream->getc();
if ($tag === Tags::TagCall) {
$method = $reader->readString();
$tag = $stream->getc();
if ($tag ==Tags::TagList) {
$reader->reset();
$params = $reader->readListWithoutTag();
}
}
else {
throw new Exception("Error Processing Request", 1);
}
return xmlrpc_encode_request($method, $params);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/XMLRPC/ServiceFilter.php *
* *
* xml-rpc service filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\XMLRPC;
use stdClass;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ServiceFilter implements Filter {
public function inputFilter($data, stdClass $context) {
if ($data !== "" && $data{0} === '<') {
$context->userdata->format = "xmlrpc";
$method = null;
$params = xmlrpc_decode_request($data, $method, "UTF-8");
$stream = new BytesIO();
$writer = new Writer($stream, true);
if (isset($method)) {
$stream->write(Tags::TagCall);
$writer->writeString($method);
if (isset($params)) {
$writer->writeArray($params);
}
}
$stream->write(Tags::TagEnd);
$data = $stream->toString();
}
return $data;
}
public function outputFilter($data, stdClass $context) {
if (isset($context->userdata->format) && $context->userdata->format === "xmlrpc") {
$result = null;
if ($data !== "") {
$stream = new BytesIO($data);
$reader = new Reader($stream);
while (($tag = $stream->getc()) !== Tags::TagEnd) {
$reader->reset();
switch ($tag) {
case Tags::TagResult:
$result = $reader->unserialize();
break;
case Tags::TagError:
$lasterror = error_get_last();
$result = array(
"faultCode" => $lasterror["type"],
"faultString" => $reader->unserialize()
);
break;
case Tags::TagFunctions:
$result = $reader->unserialize();
break;
default:
return xmlrpc_encode($result);
}
}
}
$data = xmlrpc_encode($result);
}
return $data;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Formatter.php *
* *
* hprose formatter class for php 5.3+ *
* *
* LastModified: Jul 16, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Formatter {
public static function serialize($var, $simple = false) {
$stream = new BytesIO();
$writer = new Writer($stream, $simple);
$writer->serialize($var);
$data = $stream->toString();
$stream->close();
return $data;
}
public static function unserialize($data, $simple = false) {
$stream = new BytesIO($data);
$reader = new Reader($stream, $simple);
$result = $reader->unserialize();
$stream->close();
return $result;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future/CallableWrapper.php *
* *
* Future CallableWrapper for php 5.3+ *
* *
* LastModified: Mar 7, 2017 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Future;
class CallableWrapper extends Wrapper {
public function __invoke() {
$obj = $this->obj;
return all(func_get_args())->then(function($args) use ($obj) {
if (HaveGenerator) {
return co(call_user_func_array($obj, $args));
}
return call_user_func_array($obj, $args);
});
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future/UncatchableException.php *
* *
* UncatchableException for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Future;
use Exception;
class UncatchableException extends Exception {}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future/Wrapper.php *
* *
* Future Wrapper for php 5.3+ *
* *
* LastModified: Mar 7, 2017 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Future;
class Wrapper {
protected $obj;
public function __construct($obj) {
$this->obj = $obj;
}
public function __call($name, array $arguments) {
$method = array($this->obj, $name);
return all($arguments)->then(function($args) use ($method, $name) {
if (HaveGenerator) {
return co(call_user_func_array($method, $args));
}
return call_user_func_array($method, $args);
});
}
public function __get($name) {
return $this->obj->$name;
}
public function __set($name, $value) {
$this->obj->$name = $value;
}
public function __isset($name) {
return isset($this->obj->$name);
}
public function __unset($name) {
unset($this->obj->$name);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/HandlerManager.php *
* *
* hprose HandlerManager class for php 5.3+ *
* *
* LastModified: Feb 26, 2018 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
use Closure;
abstract class HandlerManager {
private $invokeHandlers = array();
private $beforeFilterHandlers = array();
private $afterFilterHandlers = array();
protected $defaultInvokeHandler;
protected $defaultBeforeFilterHandler;
protected $defaultAfterFilterHandler;
protected $invokeHandler;
protected $beforeFilterHandler;
protected $afterFilterHandler;
public function __construct() {
$self = $this;
$this->defaultInvokeHandler = function(/*string*/ $name, array &$args, stdClass $context) use ($self) {
try {
$result = $self->invokeHandler($name, $args, $context);
if (HaveGenerator) {
return Future\co($result);
}
else {
return Future\toFuture($result);
}
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
};
$this->defaultBeforeFilterHandler = function(/*string*/ $request, stdClass $context) use ($self) {
try {
$result = $self->beforeFilterHandler($request, $context);
if (HaveGenerator) {
return Future\co($result);
}
else {
return Future\toFuture($result);
}
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
};
$this->defaultAfterFilterHandler = function(/*string*/ $request, stdClass $context) use ($self) {
try {
$result = $self->afterFilterHandler($request, $context);
if (HaveGenerator) {
return Future\co($result);
}
else {
return Future\toFuture($result);
}
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
};
$this->invokeHandler = $this->defaultInvokeHandler;
$this->beforeFilterHandler = $this->defaultBeforeFilterHandler;
$this->afterFilterHandler = $this->defaultAfterFilterHandler;
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ abstract function invokeHandler(/*string*/ $name, array &$args, stdClass $context);
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ abstract function beforeFilterHandler(/*string*/ $request, stdClass $context);
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ abstract function afterFilterHandler(/*string*/ $request, stdClass $context);
protected function getNextInvokeHandler(Closure $next, /*callable*/ $handler) {
return function(/*string*/ $name, array &$args, stdClass $context) use ($next, $handler) {
try {
$array = array($name, &$args, $context, $next);
$result = call_user_func_array($handler, $array);
if (HaveGenerator) {
return Future\co($result);
}
else {
return Future\toFuture($result);
}
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
};
}
protected function getNextFilterHandler(Closure $next, /*callable*/ $handler) {
return function(/*string*/ $request, stdClass $context) use ($next, $handler) {
try {
$result = call_user_func($handler, $request, $context, $next);
if (HaveGenerator) {
return Future\co($result);
}
else {
return Future\toFuture($result);
}
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
};
}
public function addInvokeHandler(/*callable*/ $handler) {
if ($handler == null) return null;
$this->invokeHandlers[] = $handler;
$next = $this->defaultInvokeHandler;
for ($i = count($this->invokeHandlers) - 1; $i >= 0; --$i) {
$next = $this->getNextInvokeHandler($next, $this->invokeHandlers[$i]);
}
$this->invokeHandler = $next;
return $this;
}
public function addBeforeFilterHandler(/*callable*/ $handler) {
if ($handler == null) return;
$this->beforeFilterHandlers[] = $handler;
$next = $this->defaultBeforeFilterHandler;
for ($i = count($this->beforeFilterHandlers) - 1; $i >= 0; --$i) {
$next = $this->getNextFilterHandler($next, $this->beforeFilterHandlers[$i]);
}
$this->beforeFilterHandler = $next;
return $this;
}
public function addAfterFilterHandler(/*callable*/ $handler) {
if ($handler == null) return null;
$this->afterFilterHandlers[] = $handler;
$next = $this->defaultAfterFilterHandler;
for ($i = count($this->afterFilterHandlers) - 1; $i >= 0; --$i) {
$next = $this->getNextFilterHandler($next, $this->afterFilterHandlers[$i]);
}
$this->afterFilterHandler = $next;
return $this;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Http/Server.php *
* *
* hprose http server class for php 5.3+ *
* *
* LastModified: Jul 17, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Http;
class Server extends Service {
public function start() {
$this->handle();
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Http/Service.php *
* *
* hprose http service class for php 5.3+ *
* *
* LastModified: Jul 23, 2018 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Http;
use stdClass;
use Hprose\Future;
class Service extends \Hprose\Service {
const ORIGIN = 'HTTP_ORIGIN';
public $onSendHeader = null;
public $crossDomain = false;
public $p3p = false;
public $get = true;
private $origins = array();
public function header($name, $value, $context) {
header("$name: $value");
}
public function getAttribute($name, $context) {
return $_SERVER[$name];
}
public function hasAttribute($name, $context) {
return isset($_SERVER[$name]);
}
protected function readRequest($context) {
return file_get_contents("php://input");
}
protected function createContext($request, $response) {
$context = new stdClass();
$context->server = $this;
$context->request = $request;
$context->response = $response;
$context->userdata = new stdClass();
return $context;
}
public function writeResponse($data, $context) {
echo $data;
}
public function isGet($context) {
return isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] === 'GET');
}
public function isPost($context) {
return isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] === 'POST');
}
private function sendHeader($context) {
if ($this->onSendHeader !== null) {
$sendHeader = $this->onSendHeader;
call_user_func($sendHeader, $context);
}
$this->header('Content-Type', 'text/plain', $context);
if ($this->p3p) {
$this->header('P3P', 'CP="CAO DSP COR CUR ADM DEV TAI PSA PSD ' .
'IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi ' .
'UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV ' .
'INT DEM CNT STA POL HEA PRE GOV"', $context);
}
if ($this->crossDomain) {
if ($this->hasAttribute(static::ORIGIN, $context) &&
$this->getAttribute(static::ORIGIN, $context) != "null") {
$origin = $this->getAttribute(static::ORIGIN, $context);
if (count($this->origins) === 0 ||
isset($this->origins[strtolower($origin)])) {
$this->header('Access-Control-Allow-Origin', $origin, $context);
$this->header('Access-Control-Allow-Credentials', 'true', $context);
}
}
else {
$this->header('Access-Control-Allow-Origin', '*', $context);
}
}
}
public function isCrossDomainEnabled() {
return $this->crossDomain;
}
public function setCrossDomainEnabled($enable = true) {
$this->crossDomain = $enable;
}
public function isP3PEnabled() {
return $this->p3p;
}
public function setP3PEnabled($enable = true) {
$this->p3p = $enable;
}
public function isGetEnabled() {
return $this->get;
}
public function setGetEnabled($enable = true) {
$this->get = $enable;
}
public function addAccessControlAllowOrigin($origin) {
$count = strlen($origin);
if (($count > 0) && ($origin{$count - 1} === "/")) {
$origin = substr($origin, 0, -1);
}
$this->origins[strtolower($origin)] = true;
}
public function removeAccessControlAllowOrigin($origin) {
$count = strlen($origin);
if (($count > 0) && ($origin{$count - 1} === "/")) {
$origin = substr($origin, 0, -1);
}
unset($this->origins[strtolower($origin)]);
}
public function handle($request = null, $response = null) {
$context = $this->createContext($request, $response);
$self = $this;
$this->userFatalErrorHandler = function($error) use ($self, $context) {
$self->writeResponse($self->endError($error, $context), $context);
};
$this->sendHeader($context);
$result = '';
if ($this->isGet($context)) {
if ($this->get) {
$result = $this->doFunctionList();
}
}
elseif ($this->isPost($context)) {
ob_start();
ob_implicit_flush(0);
$result = $this->defaultHandle($this->readRequest($context), $context);
$message = @ob_get_contents();
@ob_end_clean();
if ($message)$this->errorLog($message);
}
else {
$result = $this->doFunctionList();
}
if (Future\isFuture($result)) {
$result->then(function($result) use ($self, $context) {
$self->header('Content-Length', strlen($result), $context);
$self->writeResponse($result, $context);
});
}
else {
$this->header('Content-Length', strlen($result), $context);
$this->writeResponse($result, $context);
}
return $context->response;
}
protected function errorLog($err) {
error_log($err);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/InvokeSettings.php *
* *
* hprose InvokeSettings class for php 5.3+ *
* *
* LastModified: Jul 27, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use ArrayAccess;
class InvokeSettings implements ArrayAccess {
public $settings;
public function __construct(array $settings = array()) {
if ($settings !== null) {
$this->settings = $settings;
}
else {
$this->settings = array();
}
}
public function __set($name, $value) {
$this->settings[$name] = $value;
}
public function __get($name) {
return isset($this->settings[$name]) ? $this->settings[$name] : null;
}
public function __isset($name) {
return isset($this->settings[$name]);
}
public function __unset($name) {
unset($this->settings[$name]);
}
public function offsetSet($offset, $value) {
$this->settings[$offset] = $value;
}
public function offsetGet($offset) {
return isset($this->settings[$offset]) ? $this->settings[$offset] : null;
}
public function offsetExists($offset) {
return isset($this->settings[$offset]);
}
public function offsetUnset($offset) {
unset($this->settings[$offset]);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Promise.php *
* *
* Promise for php 5.3+ *
* *
* LastModified: Dec 5, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Promise extends Future {
public function __construct($executor = null) {
parent::__construct();
if (is_callable($executor)) {
$self = $this;
call_user_func($executor,
function($value = NULL) use ($self) {
$self->resolve($value);
},
function($reason) use ($self) {
$self->reject($reason);
}
);
}
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Promise/functions.php *
* *
* some helper functions for php 5.3+ *
* *
* LastModified: Dec 5, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Promise;
use Hprose\Future;
function isPromise($obj) {
return $obj instanceof Future;
}
function error($e) {
return Future\error($e);
}
function value($v) {
return Future\value($v);
}
function resolve($value) {
return value($value);
}
function reject($reason) {
return error($reason);
}
function sync($computation) {
return Future\sync($computation);
}
function promise($executor) {
return new Promise($executor);
}
function all($array) {
return Future\all($array);
}
function join() {
return all(func_get_args());
}
function race($array) {
return Future\race($array);
}
function any($array) {
return Future\any($array);
}
function settle($array) {
return Future\settle($array);
}
function run($handler/*, arg1, arg2, ... */) {
$args = array_slice(func_get_args(), 1);
return all($args)->then(
function($args) use ($handler) {
return call_user_func_array($handler, $args);
}
);
}
function wrap($handler) {
return Future\wrap($handler);
}
function each($array, $callback) {
return Future\each($array, $callback);
}
function every($array, $callback) {
return Future\every($array, $callback);
}
function some($array, $callback) {
return Future\some($array, $callback);
}
function filter($array, $callback, $preserveKeys = false) {
return Future\filter($array, $callback, $preserveKeys);
}
function map($array, $callback) {
return Future\map($array, $callback);
}
function reduce($array, $callback, $initial = NULL) {
return Future\reduce($array, $callback, $initial);
}
function search($array, $searchElement, $strict = false) {
return Future\search($array, $searchElement, $strict);
}
function includes($array, $searchElement, $strict = false) {
return Future\includes($array, $searchElement, $strict);
}
function diff(/*$array1, $array2, ...*/) {
return call_user_func_array("\\Hprose\\Future\\diff", func_get_args());
}
function udiff(/*$array1, $array2, $...*/) {
return call_user_func_array("\\Hprose\\Future\\udiff", func_get_args());
}
function toPromise($obj) {
return Future\toPromise($obj);
}
function promisify($fn) {
return Future\promisify($fn);
}
if (class_exists("\\Generator")) {
function co(/*$generator, arg1, arg2...*/) {
return call_user_func_array("\\Hprose\\Future\\co", func_get_args());
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Proxy.php *
* *
* hprose Proxy class for php 5.3+ *
* *
* LastModified: Jul 27, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Closure;
use ArrayAccess;
class Proxy implements ArrayAccess {
private $client;
private $namespace;
private $methodCache = array();
private $settings = array();
public function __construct(Client $client, $namespace = '') {
$this->client = $client;
$this->namespace = $namespace;
}
public function __invoke() {
$args = func_get_args();
$name = substr($this->namespace, 0, -1);
$settings = new InvokeSettings($this->settings);
$n = count($args);
if ($n > 0) {
if ($args[$n - 1] instanceof Closure) {
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback, $settings);
}
else if ($args[$n - 1] instanceof InvokeSettings) {
$settings->settings = array_merge($settings->settings, array_pop($args)->settings);
if (($n > 1) && ($args[$n - 2] instanceof Closure)) {
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback, $settings);
}
return $this->client->invoke($name, $args, $settings);
}
else if (($n > 1) && is_array($args[$n - 1]) &&
($args[$n - 2] instanceof Closure)) {
$settings->settings = array_merge($settings->settings, array_pop($args));
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback, $settings);
}
}
return $this->client->invoke($name, $args, $settings);
}
public function __call($name, array $args) {
if (isset($this->methodCache[$name])) {
$method = $this->methodCache[$name];
return call_user_func_array($method, $args);
}
$name = $this->namespace . $name;
$n = count($args);
if ($n > 0) {
if ($args[$n - 1] instanceof Closure) {
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback);
}
else if ($args[$n - 1] instanceof InvokeSettings) {
if (($n > 1) && ($args[$n - 2] instanceof Closure)) {
$settings = array_pop($args);
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback, $settings);
}
$settings = array_pop($args);
return $this->client->invoke($name, $args, $settings);
}
else if (($n > 1) && is_array($args[$n - 1]) &&
($args[$n - 2] instanceof Closure)) {
$settings = new InvokeSettings(array_pop($args));
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback, $settings);
}
}
return $this->client->invoke($name, $args);
}
public function __get($name) {
if (isset($this->methodCache[$name])) {
return $this->methodCache[$name];
}
$method = new Proxy($this->client, $this->namespace . $name . '_');
$this->methodCache[$name] = $method;
return $method;
}
public function offsetSet($name, $value) {
$this->settings[$name] = $value;
}
public function offsetGet($name) {
return isset($this->settings[$name]) ? $this->settings[$name] : null;
}
public function offsetExists($name) {
return isset($this->settings[$name]);
}
public function offsetUnset($name) {
unset($this->settings[$name]);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/RawReader.php *
* *
* hprose raw reader class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class RawReader {
public $stream;
public function __construct(BytesIO $stream) {
$this->stream = $stream;
}
public function unexpectedTag($tag, $expectTags = '') {
if ($tag && $expectTags) {
return new Exception("Tag '" . $expectTags . "' expected, but '" . $tag . "' found in stream");
}
else if ($tag) {
return new Exception("Unexpected serialize tag '" . $tag . "' in stream");
}
else {
return new Exception('No byte found in stream');
}
}
public function readRaw() {
$ostream = new BytesIO();
$this->privateReadRaw($ostream);
return $ostream;
}
private function privateReadRaw(BytesIO $ostream, $tag = '') {
if ($tag == '') {
$tag = $this->stream->getc();
}
$ostream->write($tag);
switch ($tag) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case Tags::TagNull:
case Tags::TagEmpty:
case Tags::TagTrue:
case Tags::TagFalse:
case Tags::TagNaN:
break;
case Tags::TagInfinity:
$ostream->write($this->stream->getc());
break;
case Tags::TagInteger:
case Tags::TagLong:
case Tags::TagDouble:
case Tags::TagRef:
$this->readNumberRaw($ostream);
break;
case Tags::TagDate:
case Tags::TagTime:
$this->readDateTimeRaw($ostream);
break;
case Tags::TagUTF8Char:
$this->readUTF8CharRaw($ostream);
break;
case Tags::TagBytes:
$this->readBytesRaw($ostream);
break;
case Tags::TagString:
$this->readStringRaw($ostream);
break;
case Tags::TagGuid:
$this->readGuidRaw($ostream);
break;
case Tags::TagList:
case Tags::TagMap:
case Tags::TagObject:
$this->readComplexRaw($ostream);
break;
case Tags::TagClass:
$this->readComplexRaw($ostream);
$this->privateReadRaw($ostream);
break;
case Tags::TagError:
$this->privateReadRaw($ostream);
break;
default: throw $this->unexpectedTag($tag);
}
}
private function readNumberRaw(BytesIO $ostream) {
$s = $this->stream->readuntil(Tags::TagSemicolon) .
Tags::TagSemicolon;
$ostream->write($s);
}
private function readDateTimeRaw(BytesIO $ostream) {
$s = '';
do {
$tag = $this->stream->getc();
$s .= $tag;
} while ($tag != Tags::TagSemicolon &&
$tag != Tags::TagUTC);
$ostream->write($s);
}
private function readUTF8CharRaw(BytesIO $ostream) {
$ostream->write($this->stream->readString(1));
}
private function readBytesRaw(BytesIO $ostream) {
$len = $this->stream->readuntil(Tags::TagQuote);
$s = $len . Tags::TagQuote . $this->stream->read((int)$len) . Tags::TagQuote;
$this->stream->skip(1);
$ostream->write($s);
}
private function readStringRaw(BytesIO $ostream) {
$len = $this->stream->readuntil(Tags::TagQuote);
$s = $len . Tags::TagQuote . $this->stream->readString((int)$len) . Tags::TagQuote;
$this->stream->skip(1);
$ostream->write($s);
}
private function readGuidRaw(BytesIO $ostream) {
$ostream->write($this->stream->read(38));
}
private function readComplexRaw(BytesIO $ostream) {
$s = $this->stream->readuntil(Tags::TagOpenbrace) .
Tags::TagOpenbrace;
$ostream->write($s);
while (($tag = $this->stream->getc()) != Tags::TagClosebrace) {
$this->privateReadRaw($ostream, $tag);
}
$ostream->write($tag);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/ReaderRefer.php *
* *
* hprose reader reference interface for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
interface ReaderRefer {
public function set($val);
public function read($index);
public function reset();
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/RealReaderRefer.php *
* *
* hprose RealReaderRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class RealReaderRefer implements ReaderRefer {
private $ref;
public function __construct() {
$this->reset();
}
public function set($val) {
$this->ref[] = $val;
}
public function read($index) {
return $this->ref[$index];
}
public function reset() {
$this->ref = array();
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/RealWriterRefer.php *
* *
* hprose RealWriterRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use SplObjectStorage;
class RealWriterRefer implements WriterRefer {
private $oref;
private $sref = array();
private $refcount = 0;
public function __construct() {
$this->oref = new SplObjectStorage();
}
private function writeRef(BytesIO $stream, $index) {
$stream->write(Tags::TagRef . $index . Tags::TagSemicolon);
return true;
}
public function set($val) {
if (is_string($val)) {
$this->sref[$val] = $this->refcount;
}
elseif (is_object($val)) {
$this->oref->attach($val, $this->refcount);
}
$this->refcount++;
}
public function write(BytesIO $stream, $val) {
if (is_string($val) && isset($this->sref[$val])) {
return $this->writeRef($stream, $this->sref[$val]);
}
elseif (is_object($val) && isset($this->oref[$val])) {
return $this->writeRef($stream, $this->oref[$val]);
}
return false;
}
public function reset() {
$this->oref = new \SplObjectStorage();
$this->sref = array();
$this->refcount = 0;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/ResultMode.php *
* *
* hprose ResultMode enum for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class ResultMode {
const Normal = 0;
const Serialized = 1;
const Raw = 2;
const RawWithEndTag = 3;
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/Client.php *
* *
* hprose socket client class for php 5.3+ *
* *
* LastModified: Aug 6, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
use stdClass;
use Exception;
class Client extends \Hprose\Client {
private $hdtrans;
private $fdtrans;
public $fullDuplex = false;
public $readBuffer = 8192;
public $writeBuffer = 8192;
public $maxPoolSize = 10;
public $noDelay = true;
public $keepAlive = true;
public $options = null;
public function __construct($uris = null, $async = true) {
parent::__construct($uris, $async);
$this->hdtrans = new HalfDuplexTransporter($this, $async);
$this->fdtrans = new FullDuplexTransporter($this, $async);
}
public function __destruct() {
try {
$this->loop();
}
catch (\Exception $e) {
}
}
public function isFullDuplex() {
return $this->fullDuplex;
}
public function setFullDuplex($fullDuplex) {
$this->fullDuplex = $fullDuplex;
}
public function getReadBuffer() {
return $this->readBuffer;
}
public function setReadBuffer($size) {
$this->readBuffer = $size;
}
public function getWriteBuffer() {
return $this->writeBuffer;
}
public function setWriteBuffer($size) {
$this->writeBuffer = $size;
}
public function getMaxPoolSize() {
return $this->maxPoolSize;
}
public function setMaxPoolSize($maxPoolSize) {
if ($maxPoolSize < 1) throw new Exception("maxPoolSize must be great than 0");
$this->maxPoolSize = $maxPoolSize;
}
public function setNoDelay($value) {
$this->noDelay = $value;
}
public function isNoDelay() {
return $this->noDelay;
}
public function setKeepAlive($value) {
$this->keepAlive = $value;
}
public function isKeepAlive() {
return $this->keepAlive;
}
protected function sendAndReceive($request, stdClass $context) {
if ($this->fullDuplex) {
return $this->fdtrans->sendAndReceive($request, $context);
}
return $this->hdtrans->sendAndReceive($request, $context);
}
public function getOptions() {
return $this->options;
}
public function setOptions(array $options) {
$this->options = $options;
}
public function set($key, $value) {
$this->options[$key] = $value;
return $this;
}
public function loop() {
if ($this->fullDuplex) {
$this->fdtrans->loop();
}
else {
$this->hdtrans->loop();
}
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/DataBuffer.php *
* *
* hprose socket DataBuffer class for php 5.3+ *
* *
* LastModified: Jul 12, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
class DataBuffer {
public $index;
public $buffer;
public $length;
public $id;
public function __construct($index, $buffer, $length, $id = null) {
$this->index = $index;
$this->buffer = $buffer;
$this->length = $length;
$this->id = $id;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/FullDuplexTransporter.php *
* *
* hprose socket FullDuplexTransporter class for php 5.3+ *
* *
* LastModified: Jul 24, 2018 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
class FullDuplexTransporter extends Transporter {
private static $id = 0;
private static $idinited = false;
private function getId() {
if (self::$idinited === false) {
self::$idinited = true;
$min = intval(date('i'), 10);
$sec = intval(date('s'), 10);
$msec = microtime(true);
$msec -= floor($msec);
self::$id = floor(($min * 60 + $sec + $msec) * 1000) * 1024;
}
return self::$id++;
}
protected function appendHeader($request, $id = null) {
if ($id === null) {
$id = $this->getId();
}
return pack("NN", strlen($request) | 0x80000000, $id) . $request;
}
protected function createRequest($index, $request) {
$id = $this->getId();
$buffer = $this->appendHeader($request, $id);
return new DataBuffer($index, $buffer, strlen($buffer), $id);
}
protected function afterWrite($request, $stream, $o) {
$response = new DataBuffer($request->index, '', 0, $request->id);
$stream_id = (integer)$stream;
unset($o->requests[$stream_id]);
if (empty($o->queue[$stream_id])) {
$o->queue[$stream_id] = array();
$o->readpool[] = $stream;
}
$o->queue[$stream_id][$request->id] = $response;
}
protected function asyncReadError($o, $stream, $index = -1) {
$stream_id = (integer)$stream;
foreach ($o->queue[$stream_id] as $response) {
$index = $response->index;
$o->results[$index]->reject($this->getLastError('response read error'));
$this->free($o, $index);
}
unset($o->queue[$stream_id]);
unset($o->responses[$stream_id]);
@fclose($stream);
$this->removeStream($stream, $o->readpool);
$this->removeStream($stream, $o->writepool);
}
private function getHeaderInfo($stream) {
$header = $this->readHeader($stream, 8);
if ($header === false) return false;
list(, $length, $id) = unpack('N*', $header);
$length &= 0x7FFFFFFF;
return array($length, $id);
}
protected function getBodyLength($stream) {
$headerInfo = $this->getHeaderInfo($stream);
if ($headerInfo === false) return false;
return $headerInfo[0];
}
protected function getResponse($stream, $o) {
$stream_id = (integer)$stream;
if (isset($o->responses[$stream_id])) {
$response = $o->responses[$stream_id];
}
else {
$headerInfo = $this->getHeaderInfo($stream);
if ($headerInfo === false) return false;
$id = $headerInfo[1];
if (isset($o->queue[$stream_id][$id])) {
$response = $o->queue[$stream_id][$id];
}
else {
$response = new DataBuffer(-1, '', 0, $id);
}
$response->length = $headerInfo[0];
$o->responses[$stream_id] = $response;
}
return $response;
}
protected function afterRead($stream, $o, $response) {
$stream_id = (integer)$stream;
if (isset($o->queue[$stream_id][$response->id])) {
unset($o->queue[$stream_id][$response->id]);
}
if (empty($o->queue[$stream_id])) {
$this->removeStream($stream, $o->readpool);
}
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/HalfDuplexTransporter.php *
* *
* hprose socket HalfDuplexTransporter class for php 5.3+ *
* *
* LastModified: Feb 24, 2018 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
class HalfDuplexTransporter extends Transporter {
protected function appendHeader($request) {
return pack("N", strlen($request)) . $request;
}
protected function createRequest($index, $request) {
$buffer = $this->appendHeader($request);
return new DataBuffer($index, $buffer, strlen($buffer));
}
protected function afterWrite($request, $stream, $o) {
$stream_id = (integer)$stream;
$o->responses[$stream_id] = new DataBuffer($request->index, '', 0);
$o->readpool[] = $stream;
unset($o->requests[$stream_id]);
$this->removeStream($stream, $o->writepool);
}
protected function asyncReadError($o, $stream, $index) {
if (isset($o->results[$index])) {
$o->results[$index]
->reject($this->getLastError('response read error'));
$this->free($o, $index);
}
unset($o->responses[(integer)$stream]);
@fclose($stream);
$this->removeStream($stream, $o->readpool);
}
protected function getBodyLength($stream) {
$header = $this->readHeader($stream, 4);
if ($header === false) return false;
list(, $length) = unpack('N', $header);
return $length;
}
protected function getResponse($stream, $o) {
$stream_id = (integer)$stream;
$response = $o->responses[$stream_id];
if ($response->length === 0) {
$length = $this->getBodyLength($stream);
$response->length = $length;
}
return $response;
}
protected function afterRead($stream, $o, $response) {
if ($o->current < $o->count) {
$o->writepool[] = $stream;
}
$this->removeStream($stream, $o->readpool);
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/Server.php *
* *
* hprose socket server library for php 5.3+ *
* *
* LastModified: Jan 14, 2018 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
use Exception;
class Server extends Service {
public $settings = array();
public $noDelay = true;
public $keepAlive = true;
public $uris = array();
public function __construct($uri) {
parent::__construct();
$this->uris[] = $uri;
}
public function setNoDelay($value) {
$this->noDelay = $value;
}
public function isNoDelay() {
return $this->noDelay;
}
public function setKeepAlive($value) {
$this->keepAlive = $value;
}
public function isKeepAlive() {
return $this->keepAlive;
}
public function set($settings) {
$this->settings = array_replace($this->settings, $settings);
}
public function addListener($uri) {
$this->uris[] = $uri;
}
private function createSocketServer($uri) {
$scheme = parse_url($uri, PHP_URL_SCHEME);
if ($scheme == 'unix') {
$uri = 'unix://' . parse_url($uri, PHP_URL_PATH);
}
$errno = 0;
$errstr = '';
$context = stream_context_create($this->settings);
$server = stream_socket_server($uri, $errno, $errstr,
STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context);
if (function_exists('socket_import_stream')) {
if (($scheme === 'tcp') || ($scheme === 'unix')) {
$socket = socket_import_stream($server);
socket_set_option($socket, SOL_SOCKET, SO_KEEPALIVE, (int)$this->keepAlive);
if ($scheme === 'tcp') {
socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int)$this->noDelay);
}
}
}
if ($server === false) {
throw new Exception($errstr, $errno);
}
return $server;
}
public function start() {
$servers = array();
foreach ($this->uris as $uri) {
$servers[] = $this->createSocketServer($uri);
}
$this->handle($servers);
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/Timer.php *
* *
* hprose socket Timer class for php 5.3+ *
* *
* LastModified: Aug 10, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
class Timer {
private $server;
public function __construct($server) {
$this->server = $server;
}
public function setTimeout($callback, $delay) {
return $this->server->after($delay, $callback);
}
public function clearTimeout($timerid) {
return $this->server->clear($timerid);
}
public function setImmediate($callback) {
$this->server->defer($callback);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Tags.php *
* *
* hprose tags enum for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Tags {
/* Serialize Tags */
const TagInteger = 'i';
const TagLong = 'l';
const TagDouble = 'd';
const TagNull = 'n';
const TagEmpty = 'e';
const TagTrue = 't';
const TagFalse = 'f';
const TagNaN = 'N';
const TagInfinity = 'I';
const TagDate = 'D';
const TagTime = 'T';
const TagUTC = 'Z';
const TagBytes = 'b';
const TagUTF8Char = 'u';
const TagString = 's';
const TagGuid = 'g';
const TagList = 'a';
const TagMap = 'm';
const TagClass = 'c';
const TagObject = 'o';
const TagRef = 'r';
/* Serialize Marks */
const TagPos = '+';
const TagNeg = '-';
const TagSemicolon = ';';
const TagOpenbrace = '{';
const TagClosebrace = '}';
const TagQuote = '"';
const TagPoint = '.';
/* Protocol Tags */
const TagFunctions = 'F';
const TagCall = 'C';
const TagResult = 'R';
const TagArgument = 'A';
const TagError = 'E';
const TagEnd = 'z';
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/TimeoutException.php *
* *
* hprose TimeoutException for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class TimeoutException extends Exception {}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/WriterRefer.php *
* *
* hprose writer reference interface for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
interface WriterRefer {
public function set($val);
public function write(BytesIO $stream, $val);
public function reset();
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/functions.php *
* *
* some helper functions for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
function deferred() {
return new Deferred();
}
define('HaveGenerator', class_exists("\\Generator", false));
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Throwable.php *
* *
* Throwable for php 7- *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
if (!interface_exists("Throwable")) {
interface Throwable {
public function getMessage();
public function getCode();
public function getFile();
public function getLine();
public function getTrace();
public function getTraceAsString();
public function getPrevious();
public function __toString();
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* TypeError.php *
* *
* TypeError for php 7- *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
if (!class_exists('TypeError')) {
class TypeError extends Exception {}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* functions.php *
* *
* hprose functions for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
if (!function_exists('hprose_serialize')) {
function hprose_serialize($var, $simple = false) {
return \Hprose\Formatter::serialize($var, $simple);
}
}
if (!function_exists('hprose_unserialize')) {
function hprose_unserialize($data, $simple = false) {
return \Hprose\Formatter::unserialize($data, $simple);
}
}
<?php
require_once __DIR__ . '/Throwable.php';
require_once __DIR__ . '/TypeError.php';
require_once __DIR__ . '/Hprose/functions.php';
require_once __DIR__ . '/Hprose/Future/functions.php';
require_once __DIR__ . '/Hprose/Promise/functions.php';
require_once __DIR__ . '/functions.php';
// Deprecated
// Compatible with older versions only
// You'd better not use these classes.
spl_autoload_register(function ($className) {
$oldVersionAliases = array(
// 'hproseasync' => array('Hprose\\Async', 'HproseAsync'), // Hprose\Async not found
'hprosecompleter' => array('Hprose\\Completer', 'HproseCompleter'),
'hprosefuture' => array('Hprose\\Future', 'HproseFuture'),
'hprosetags' => array('Hprose\\Tags', 'HproseTags'),
'hprosebytesio' => array('Hprose\\BytesIO', 'HproseBytesIO'),
'hproseclassmanager' => array('Hprose\\ClassManager', 'HproseClassManager'),
'hproserawreader' => array('Hprose\\RawReader', 'HproseRawReader'),
'hprosereader' => array('Hprose\\Reader', 'HproseReader'),
'hprosewriter' => array('Hprose\\Writer', 'HproseWriter'),
'hproseformatter' => array('Hprose\\Formatter', 'HproseFormatter'),
'hproseresultmode' => array('Hprose\\ResultMode', 'HproseResultMode'),
'hprosefilter' => array('Hprose\\Filter', 'HproseFilter'),
'hproseclient' => array('Hprose\\Client', 'HproseClient'),
'hproseservice' => array('Hprose\\Service', 'HproseService'),
'hprosehttpclient' => array('Hprose\\Http\\Client', 'HproseHttpClient'),
'hprosehttpservice' => array('Hprose\\Http\\Service', 'HproseHttpService'),
'hprosehttpserver' => array('Hprose\\Http\\Server', 'HproseHttpServer'),
'hprosesocketclient' => array('Hprose\\Socket\\Client', 'HproseSocketClient'),
'hprosesocketservice' => array('Hprose\\Socket\\Service', 'HproseSocketService'),
'hprosesocketserver' => array('Hprose\\Socket\\Server', 'HproseSocketServer'),
'hprosejsonrpcclientfilter' => array('Hprose\\Filter\\JSONRPC\\ClientFilter', 'HproseJSONRPCClientFilter'),
'hprosejsonrpcservicefilter' => array('Hprose\\Filter\\JSONRPC\\ServiceFilter', 'HproseJSONRPCServiceFilter'),
'hprosexmlrpcclientfilter' => array('Hprose\\Filter\\XMLRPC\\ClientFilter', 'HproseXMLRPCClientFilter'),
'hprosexmlrpcservicefilter' => array('Hprose\\Filter\\XMLRPC\\ServiceFilter', 'HproseXMLRPCServiceFilter'),
);
if (isset($oldVersionAliases[$key = strtolower($className)])) {
list($original, $alias) = $oldVersionAliases[$key];
class_alias($original, $alias);
return true;
}
return false;
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment